Memory Write Problem!?!
Jun 26, 2013 at 1:02am UTC
Hi, Im having a problem, the code dont give me a problem but this allway happen "Cannot open process." how do i fix it? im running Windows 7 64bit im code on Dev-C++
tnx in 4hand ^^
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
#include <stdio.h>
#include <windows.h>
int main()
{
int newValue = 500;
HWND hWnd = FindWindow(0, "Kalkylatorn" );
if (hWnd == 0) {
fprintf(stderr, "Cannot find window." );
} else {
DWORD pId;
GetWindowThreadProcessId(hWnd, &pId);
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
if (!hProc) {
fprintf(stderr, "Cannot open process." );
} else {
int isSuccessful = WriteProcessMemory(hProc, (LPVOID)0x000AFCC4, &newValue, (DWORD)sizeof (newValue), NULL);
if (isSuccessful > 0) {
puts("Process memory written." );
} else {
fprintf(stderr, "Cannot write process memory." );
}
CloseHandle(hProc);
}
}
getchar();
return 0;
}
Jun 26, 2013 at 6:55am UTC
Topic archived. No new replies allowed.