的包裝DLL運行完美 - 這裏是如何工作的:
假設,在library.dll
出口int somefunct(int i, void* o)
- 現在你創建你自己的DLL,喜歡的東西
#include <windows.h>
//Declare this for every function prototype
typedef int (*int_f_int_pvoid)(int,void*);
//Declare this for every function
int_f_int_pvoid lib_somefunct
//this snipplet goes into dllmain
...
HINSTANCE hlibdll = LoadLibrary("X:\PATH\TO\renamed_library.dll");
//For every function
lib_somefunct=(int_f_int_pvoid)GetProcAddress(hlibdll,"somefunct");
...
//Again for every function
int somefunct(int i, void* o)
{
//Log the function call and parameters
//...
//Call library.dll
int result=lib_somefunct(i, o);
//Log the result
//...
return result;
}
個
導出功能,命名結果DLL library.dll
重命名原來的以renamed_library.dll
現在的目標EXE將加載(你)library.dll
,這反過來將加載後(原件,但改名)renamed_library.dll
- 每當目標程序調用一個函數,它將運行你的登錄代碼。
警告:您的traget EXE可能是多線程的,因此請準備好線程安全的日誌記錄機制。
我已成功使用此方法調試一個奇怪的MAPI問題。
Google for「dll wrapper generator」。一年前在Perl中,但不記得名字。我確定還有其他人。 – dgnorton