乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      如何把DLL嵌入到exe文件中?? embed DLL in MFC C++ EXE

       quasiceo 2014-01-13

      Is it possible to embed an external CLI/C++ DLL into a MFC EXE as a embedded resource or something like that? My application currently connects to DLL sitting right beside it that has some basic functions like connect to database, pull information from DB, etc..

      I use LoadLibrary to use the DLL functions. Then I secure my EXE with themida and pack the EXE and DLL together. The problem is though to pack the DLL and EXE I have to disable file patching in themida which is a very strong feature. I have to disable it because when I pack my EXE it needs to modify the file a bit, and then themida thinks it has been cracked or something and does not allow the application to work.

      So is there a way to embed this DLL into my EXE? The DLL is not compatible with themida sadly which is why it is a separate file.


      add comment

      2 Answers

      1) Add a Resource Script file in the executable project.

      IDR_DLL_BIN        BINARY  MOVEABLE PURE   “..\\debug\\myextern.dll

      2) Compile RC file to RES file using the Resource Compiler:

      rc.exe /fo Release/mydll.res “.\mydll.rc 

      If you are using Visual Studio, it will build the RES file and will also bind it with executable.

      3) Find and load the resource from the executable:

      bool ExtractResource(const HINSTANCE hInstance, WORD resourceID, LPCTSTR szFilename)
      {
        bool bSuccess = false; 
        try
        {
            // Find and load the resource
            HRSRC hResource = FindResource(hInstance, MAKEINTRESOURCE(resourceID), _T(“BINARY”));
            HGLOBAL hFileResource = LoadResource(hInstance, hResource);
      
            // Open and map this to a disk file
            LPVOID lpFile = LockResource(hFileResource);
            DWORD dwSize = SizeofResource(hInstance, hResource);            
      
            // Open the file and filemap
            HANDLE hFile = CreateFile(szFilename, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
            HANDLE hFileMap = CreateFileMapping(hFile, NULL, PAGE_READWRITE, 0, dwSize, NULL);            
            LPVOID lpAddress = MapViewOfFile(hFileMap, FILE_MAP_WRITE, 0, 0, 0);            
      
            // Write the file
            CopyMemory(lpAddress, lpFile, dwSize);            
      
            // Un-map the file and close the handles
            UnmapViewOfFile(lpAddress);
            CloseHandle(hFileMap);
            CloseHandle(hFile);
         }
         catch(…)
         {
              // Whatever
         } 
         return bSuccess;
      
       }
      share|improve this answer


      將所用到的dll和exe打包成一個(gè)exe,比如enigma virtual box之類

        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多