BOOL WINAPI InjectDllWithLoadLibrary(HANDLE hProcess,LPCTSTR lpszDllPath)//; //使用 LoadLibrary的方式注入dll { LPVOID lpNameAddr=VirtualAllocEx(hProcess,NULL,lstrlen(lpszDllPath)+sizeof(TCHAR),MEM_COMMIT,PAGE_EXECUTE_READWRITE); if (lpNameAddr==NULL) { return FALSE; } if (!WriteProcessMemory(hProcess,lpNameAddr,lpszDllPath,lstrlen(lpszDllPath),NULL)) { VirtualFree(lpNameAddr,NULL,MEM_FREE); return FALSE; } LPVOID lpLoadLibraryAddr=(LPVOID)GetModuleHandle(_T(“Kernel32.dll”)); lpLoadLibraryAddr=(LPVOID)GetProcAddress((HMODULE)lpLoadLibraryAddr, #ifdef UNICODE “LoadLibraryW” #else “LoadLibraryA” #endif ); HANDLE hThread=CreateRemoteThread(hProcess,NULL,NULL,(LPTHREAD_START_ROUTINE)lpLoadLibraryAddr,lpNameAddr,NULL,NULL); if (hThread==NULL) { VirtualFree(lpNameAddr,NULL,MEM_FREE); return FALSE; } WaitForSingleObject(hThread,INFINITE); CloseHandle(hThread); VirtualFree(lpNameAddr,NULL,MEM_FREE); return TRUE; }

感谢您的阅读,本文由 smallwhite's Blog 版权所有。如若转载,请注明出处:smallwhite's Blog(https://smallwhite.ml/pub/uncategorized/shi-yong-loadlibrary-yuan-xian-cheng-xiang-jin-cheng-zhu-ru-dll.html
LuaPlus 载入指定库的方法
【小技巧】如何修改 LuaPlus中的 Lua 5.1 的引擎,让Lua支持中文变量名、混合变量名