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
|
#include <windows.h>
#include <stdlib.h>
#include <iostream>
using namespace std;
//TOKEN_ALL_ACCESS
//TOKEN_ADJUST_PRIVILEGES
DWORD Reset = 0;
void enableDebugPrivileges()
{
HANDLE cHandle = GetCurrentProcess();
HANDLE tHandle;
SetLastError(Reset);
BOOL bret = OpenProcessToken(cHandle, TOKEN_ALL_ACCESS, &tHandle);
cout<<"In OpenProcessToken, Error: "<<GetLastError()<<endl;
LUID luid;
SetLastError(Reset);
bret = LookupPrivilegeValue(NULL, "SeDebugPrivilege", &luid);
cout<<"In LookupPrivilegeValue, Error: "<<GetLastError()<<endl;
TOKEN_PRIVILEGES NewState;
TOKEN_PRIVILEGES PreviousState;
DWORD ReturnLength;
NewState.PrivilegeCount = 1;
NewState.Privileges[0].Luid = luid;
NewState.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
SetLastError(Reset);
AdjustTokenPrivileges(tHandle, false, &NewState, 28, &PreviousState, &ReturnLength);
cout<<"In AdjustTokenPrivileges, Error: "<<GetLastError()<<endl;
return;
}
int main()
{
enableDebugPrivileges();
DWORD pid;
HANDLE hProcess;
LONG address = 0x1F0579C; //Only made for Minesweeper, for now...
int output = 0;
do
{
cout<<"PID: ";
cin>>pid;
SetLastError(Reset);
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
cout<<"In OpenProcess, Error: "<<GetLastError()<<endl;
} while (!hProcess);
SetLastError(Reset);
ReadProcessMemory(hProcess, (LPVOID)address, (LPVOID)&output, sizeof(output), NULL);
cout<<"In ReadProcessMemory, Error: "<<GetLastError()<<endl;
cout<<output<<endl;
system("PAUSE");
return 0;
}
|