- UID
- 2198
注册时间2005-6-29
阅读权限255
最后登录1970-1-1
副坛主
  
该用户从未签到
|
- #include <stdio.h>
- #include <windows.h>
- #include "Shlwapi.h"
- HMODULE g_hMSIMG32 = NULL;
- DWORD __stdcall ThreadProc(LPVOID lpParam){
- return 0;
- }
- BOOL __stdcall DllMain( HMODULE hModule, DWORD dwReason, LPVOID lpReserved )
- {
- if( dwReason == DLL_PROCESS_ATTACH ){
- HANDLE m_hThread=CreateThread(NULL,0,ThreadProc,NULL,0,NULL);
- CloseHandle(m_hThread);
- }
- else if( dwReason == DLL_PROCESS_DETACH ){
- }
- return TRUE;
- }
- #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 ] = "";
- 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)
复制代码
这组宏用的好巧妙 ~
节选自 msimg32+with+TabSiPlus\msimg32 with TabSiPlus\DLLMain.cpp 工程
|
评分
-
查看全部评分
|