#include #include bool injectDllIntoProcess( DWORD dwPid, LPCSTR pcDllName ) { HANDLE hProcess; DWORD dwWritten; LPVOID pStringInRemoteProcess; hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, dwPid); if(!hProcess) return false; pStringInRemoteProcess = VirtualAllocEx( hProcess, 0, strlen(pcDllName)+1, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE ); WriteProcessMemory( hProcess, pStringInRemoteProcess, pcDllName, strlen(pcDllName)+1, &dwWritten ); if( dwWritten != strlen(pcDllName)+1 ) return false; CreateRemoteThread(hProcess, 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress( GetModuleHandleA("kernel32.dll") , "LoadLibraryA"), pStringInRemoteProcess, 0, 0); return true; } int main(int argc, char* argv[]) { DWORD dwPid = 0; printf("GWLP DLL Injector by ExJam\n"); if (argc < 2) { printf("Usage: InjectPacketDump \n" \ "\tAlternatively, just drop the DLL on to this executable.\n\n" \ "I'm about to exit...\n"); // So you have time to read the message... Sleep(4000); exit( -1 ); } printf("Waiting for Guild Wars..."); while( dwPid == 0 ) { Sleep(100); GetWindowThreadProcessId( FindWindowA( "ArenaNet_Dx_Window_Class", 0 ), &dwPid ); if(dwPid==NULL) { GetWindowThreadProcessId( FindWindowA( "ArenaNet_Dialog_Class", 0 ), &dwPid ); } } if(!injectDllIntoProcess( dwPid, argv[1] )) { MessageBoxA( NULL, "Could not inject dll into process!", "Error", 0 ); exit( -1 ); } return 0; }