-1

I'm working with Visual Studio 2012 & 2017 with C++ 11 and Pelles C 9.0 with C++ 11...

When I build a empty program and DLL but they contain lots of unused imports in pe file!

VC++ has 26 imports of KERNEL32 and Pelles has 70 imports of KERNEL32 My project is totally empty!

I need to remove them from linker and compiled file.

I have an DLL is compiled with Pelles C and it only has 4 import that it really use :

    KERNEL32.dll
    VirtualProtect  ord:0 rva2iat: 000012A0
    GetModuleHandleA  ord:0 rva2iat: 000012A8
    Sleep  ord:0 rva2iat: 000012B0
    CreateThread  ord:0 rva2iat: 000012B8

I want to do the same , I don't need any of those 70 imports and functions , How Can I do it ?

4

1 回答 1

0

感谢TimoVJL | 这是解决方案:

#include <windows.h>

#ifdef _WIN64
#pragma comment(linker, "/ENTRY:DllMainCRTStartup")
#else
#pragma comment(linker, "/ENTRY:_DllMainCRTStartup@12")
#endif
BOOL WINAPI DllMainCRTStartup(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
{
    if (dwReason == DLL_PROCESS_ATTACH) g_hmod = hDLL;
    return TRUE;
} 
于 2019-03-25T23:26:35.140 回答