代码摘录于网络,这组宏用得非常巧妙,感谢原作者~~~
#include <Windows.h> HMODULE g_hMSIMG32 = NULL; #define MSIMG32_DEF_IMPORT(x, y) g_fp##x = GetProcAddress(g_hMSIMG32, y); #define MSIMG32_BUILD_STUB(x) __declspec(naked) void x ( void ) { \ __asm pushad \ __asm call MSIMG32InitializeImports \ __asm popad \ __asm jmp g_fp##x## \ } FARPROC g_fpvSetDdrawflag; FARPROC g_fpAlphaBlend; FARPROC g_fpDllInitialize; FARPROC g_fpGradientFill; FARPROC g_fpTransparentBlt; void MSIMG32InitializeImports( void ) { if( g_hMSIMG32 == NULL ) { char szBuffer[MAX_PATH] = {0}; GetSystemDirectory(szBuffer, sizeof(szBuffer)); strcat(szBuffer, "\\msimg32.dll"); g_hMSIMG32 = LoadLibrary(szBuffer); MSIMG32_DEF_IMPORT(vSetDdrawflag, "vSetDdrawflag"); MSIMG32_DEF_IMPORT(AlphaBlend, "AlphaBlend"); MSIMG32_DEF_IMPORT(DllInitialize, "DllInitialize"); MSIMG32_DEF_IMPORT(GradientFill, "GradientFill"); MSIMG32_DEF_IMPORT(TransparentBlt, "TransparentBlt"); } } MSIMG32_BUILD_STUB(vSetDdrawflag) MSIMG32_BUILD_STUB(AlphaBlend) MSIMG32_BUILD_STUB(DllInitialize) MSIMG32_BUILD_STUB(GradientFill) MSIMG32_BUILD_STUB(TransparentBlt) ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// BOOL __stdcall DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved ) { if( dwReason == DLL_PROCESS_ATTACH ) { DisableThreadLibraryCalls(hModule); } else if( dwReason == DLL_PROCESS_DETACH ) { } return TRUE; }
已有1位网友发表了看法:
发表评论