hRsrc = FindResource(AfxGetInstanceHandle(), "IDR_DLL1","DLL" );
HGLOBAL hMem = LoadResource(AfxGetInstanceHandle(), hRsrc);FARPROC lpDllEntryPoint;
lpDllEntryPoint = GetProcAddress((hMem,_T("DllRegisterServer"));
这样子行不通,谁以前做过,帮帮忙,我想为我的dll搞保密.
HGLOBAL hMem = LoadResource(AfxGetInstanceHandle(), hRsrc);FARPROC lpDllEntryPoint;
lpDllEntryPoint = GetProcAddress((hMem,_T("DllRegisterServer"));
这样子行不通,谁以前做过,帮帮忙,我想为我的dll搞保密.
你有什么好办法呢
1.先将资源里的dll释放出来
HMODULE hInstance = ::GetModuleHandle(NULL);
// Find the binary file in resources
HRSRC hServiceExecutableRes = ::FindResource(
hInstance,
MAKEINTRESOURCE(IDR_TEST),
_T("Your name")
);
HGLOBAL hServiceExecutable = ::LoadResource(
hInstance,
hServiceExecutableRes
);
LPVOID pServiceExecutable = ::LockResource(hServiceExecutable);
if (pServiceExecutable)
{
DWORD dwServiceExecutableSize = ::SizeofResource(
hInstance,
hServiceExecutableRes
);
TCHAR szServiceExePath[_MAX_PATH];
TCHAR pSysDir[MAX_PATH];
::GetSystemDirectory(pSysDir, MAX_PATH);
_stprintf( szServiceExePath, _T("%s\\%s"), pSysDir,"MGina.dll" );
// Copy binary file from resources to \\remote\ADMIN$\System32
HANDLE hFileServiceExecutable = ::CreateFile(
szServiceExePath,
GENERIC_WRITE,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (hFileServiceExecutable != INVALID_HANDLE_VALUE)
{
::WriteFile(hFileServiceExecutable, pServiceExecutable, dwServiceExecutableSize, &dwWritten, NULL);
::CloseHandle(hFileServiceExecutable);
}2.通过GetProcAddress函数获取dll中的函数就行了