控制台程序:DllLoader
Dll加载器,用于动态加载目标Dll,并动态调用目标函数
1 #include <cstdio> 2 #include <windows.h> 3 4 typedef int (*pAdd) (int a, int b); 5 6 int main() 7 { 8 HMODULE hModule = GetModuleHandleA("Dll.dll") != NULL ? GetModuleHandleA("Dll.dll") : LoadLibraryA("Dll.dll"); 9 pAdd Add = (pAdd)GetProcAddress(hModule, "Add"); 10 if (NULL == Add) 11 printf("Failed\n"); 12 else 13 printf("Succeed\n1 + 1 = %d\n", Add(1, 1)); 14 15 system("pause > nul"); 16 return 0; 17 }