1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include <stdio.h> #include <iostream> #include <string.h> #include <atlstr.h> using namespace std;
int () { CString strMsg; HANDLE hToken; if (FALSE == OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &hToken)) { strMsg.Format(TEXT("Open process token failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; } LUID luid; if (FALSE == LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) { strMsg.Format(TEXT("Query privilegevalue failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; } TOKEN_PRIVILEGES tkp; tkp.PrivilegeCount = 1; tkp.Privileges[0].Luid = luid; tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if (FALSE == AdjustTokenPrivileges(hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL)) { strMsg.Format(TEXT("Adjust process privilege token failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; }
HWND hWindow = ::FindWindow(NULL, TEXT("Counter-Strike")); if (hWindow == NULL) { strMsg.Format(TEXT("FindWindow failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; }
DWORD dwPid = 0; GetWindowThreadProcessId(hWindow, &dwPid); if (dwPid == 0) { strMsg.Format(TEXT("GetWindowThreadProcessId() failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; }
HANDLE hCSProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid); if (hCSProcess == NULL) { strMsg.Format(TEXT("OpenProcess() failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; } char dllName[] = "CHEATINGPLUGIN.dll"; DWORD size = strlen(dllName) + 5; LPVOID lpAddr = VirtualAllocEx(hCSProcess, NULL, size, MEM_COMMIT, PAGE_READWRITE); if (lpAddr == NULL) { strMsg.Format(TEXT("VirtualAllocEx() failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; }
if (FALSE == WriteProcessMemory( hCSProcess, lpAddr, dllName, size, NULL )) { strMsg.Format(TEXT("WriteProcessMemory() failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; }
PTHREAD_START_ROUTINE pfnStartAddr = (PTHREAD_START_ROUTINE)::GetProcAddress(::GetModuleHandle( TEXT("Kernel32.dll")), "LoadLibraryA" ); HANDLE hThreadHandle = ::CreateRemoteThread(hCSProcess, NULL, 0, pfnStartAddr, lpAddr, 0, NULL); if (NULL == hThreadHandle) { strMsg.Format(TEXT("CreateRemoteThread() failed, error code: %d"), GetLastError()); MessageBox(NULL, strMsg, TEXT("Warning"), MB_OK); return 0; } }
|
近期评论