hRsrc = FindResource(AfxGetInstanceHandle(), "IDR_DLL1","DLL" ); 
HGLOBAL hMem = LoadResource(AfxGetInstanceHandle(), hRsrc);FARPROC lpDllEntryPoint; 
lpDllEntryPoint = GetProcAddress((hMem,_T("DllRegisterServer"));
这样子行不通,谁以前做过,帮帮忙,我想为我的dll搞保密.

解决方案 »

  1.   

    1 再重新将内存中的 dll 文件重新写回到磁盘上,然后调用2 查找其磁盘偏移,这个没做过
      

  2.   

    DentistryDoctor:
    你有什么好办法呢
      

  3.   

    换种方式,不用DLL,做成static library
      

  4.   

    实现应该简单:
    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中的函数就行了