ROATools.cpp
资源名称:ROA3.40.rar [点击查看]
上传用户:tianheyiqi
上传日期:2010-04-16
资源大小:282k
文件大小:3k
源码类别:
外挂编程
开发平台:
Visual C++
- #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define SOLUTION_MAX 5000 #define FULL_LIST_MAX 480000 #define OPEN_LIST_MAX 160000 #define LOOKUPS_MAX 200000 #define SESSION_MAX 10 #define G_NORMAL 1
- #include <windows.h> #include <Tlhelp32.h> #define DLLEXPORT __declspec(dllexport)
- static BOOL bCtrlDown = false;
- static BOOL bAltDown = false;
- static BOOL bShiftDown = false;
- #ifdef __cplusplus extern "C" { #endif #ifdef WIN32 extern DLLEXPORT int WINAPI InjectDLL(DWORD ProcID, LPCTSTR dll); extern DLLEXPORT DWORD WINAPI GetProcByName (char * name); #endif /* WIN32 */ #ifdef __cplusplus } #endif DLLEXPORT int WINAPI InjectDLL(DWORD ProcID, LPCTSTR dll) { HANDLE hProcessToAttach = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ProcID); if (!hProcessToAttach) return 0; LPVOID pAttachProcessMemory = NULL; DWORD dwBytesWritten = 0; char * dllRemove; dllRemove = (char*)malloc(strlen(dll)); memset((LPVOID)dllRemove, 0, strlen(dll)); pAttachProcessMemory = VirtualAllocEx( hProcessToAttach, NULL, strlen(dll), MEM_COMMIT, PAGE_EXECUTE_READWRITE ); if (!pAttachProcessMemory) return 0; WriteProcessMemory( hProcessToAttach, pAttachProcessMemory, (LPVOID)dll, strlen(dll), &dwBytesWritten ); if (!dwBytesWritten) return 0; HANDLE hThread = CreateRemoteThread( hProcessToAttach, NULL, 0, (LPTHREAD_START_ROUTINE)LoadLibraryA, (LPVOID)pAttachProcessMemory, 0, NULL); if (!hThread) return 0; WaitForSingleObject(hThread, INFINITE); WriteProcessMemory( hProcessToAttach, pAttachProcessMemory, (LPVOID)dllRemove, strlen(dll), &dwBytesWritten ); if (!dwBytesWritten) return 0; VirtualFreeEx( hProcessToAttach, pAttachProcessMemory, strlen(dll), MEM_RELEASE); if(hThread) CloseHandle(hThread); return 1; } DLLEXPORT DWORD WINAPI GetProcByName (char * name) { HANDLE toolhelp; PROCESSENTRY32 pe; pe.dwSize = sizeof(PROCESSENTRY32); toolhelp = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (Process32First(toolhelp,&pe)) { do { if (!stricmp(name, pe.szExeFile)) { CloseHandle(toolhelp); return pe.th32ProcessID; } } while (Process32Next(toolhelp,&pe)); } CloseHandle(toolhelp); return 0; } BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID _Reserved) { switch(dwReason) { case DLL_PROCESS_ATTACH:
- bCtrlDown = false;
- bAltDown = false;
- bShiftDown = false; break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; } return true; }
- typedef void (*SENDKEYPROC)(char key, BOOL bCtrl, BOOL bAlt, BOOL bShift);
- LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- if (nCode == HC_ACTION)
- {
- HWND hWnd = FindWindow(NULL, "天外仙境");
- if(::IsWindow(hWnd))
- {
- PostMessage(hWnd, WM_USER+2500, wParam, lParam);
- }
- }
- return CallNextHookEx(0, nCode, wParam, lParam);
- }