-
-
[求助][求助]DLL中释放资源失败?看代码
-
发表于:
2011-3-21 13:18
5364
-
bool FreeExeResource(char StPath[200])
{
DWORD dwWritten = 0;
HMODULE hInstance = ::GetModuleHandle(NULL);
HRSRC hSvcExecutableRes = ::FindResource(hInstance, MAKEINTRESOURCE(103), "BIN" );
HGLOBAL hSvcExecutable = ::LoadResource(hInstance, hSvcExecutableRes);
LPVOID pSvcExecutable = ::LockResource(hSvcExecutable);
if(pSvcExecutable == NULL)
return FALSE;
DWORD dwSvcExecutableSize = ::SizeofResource(hInstance, hSvcExecutableRes);
HANDLE hFileSvcExecutable = CreateFile(StPath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hFileSvcExecutable == INVALID_HANDLE_VALUE)
return FALSE;
WriteFile(hFileSvcExecutable, pSvcExecutable, dwSvcExecutableSize, &dwWritten, NULL);
CloseHandle(hFileSvcExecutable);
return dwWritten == dwSvcExecutableSize;
}
以上代码在dll中释放不了资源。。 求救啊
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)