33,311
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
int iChoice; // Store users choice.
DWORD dwProcId; // Store Star Sonata Process ID
HWND hStarSonata; //
HANDLE hProcess; // Handle to Star Sonata process
// Always do error checking, even if it takes a few seconds more to type!
if ((hStarSonata = FindWindow(NULL, "Star Sonata")) == NULL) { // Try to find the Star Sonata window.
printf("Cannot find Star Sonata window!"); // We couldn't find it
exit(1); // So let the user know and exit.
}
if (! GetWindowThreadProcessId(hStarSonata, &dwProcId)) { // Try to get the Process ID for use in OpenProcess
printf("Cannot retrieve process Id!"); // Let them know we cant get it
exit(1); // Exit...
}
// Now we are going to get a process handle to the game
if ((hProcess = OpenProcess(PROCESS_VM_WRITE, FALSE, dwProcId)) == NULL) { // Call OpenProcess to get VM Write access
printf("Cannot open process!"); // Failed to open process. Wrong priviliges?
exit(1);
}
printf("Star Sonata Speed Hack (Noz3001)\n\n(1)Enable Speed Hack\t(2)Disable Speed Hack\t(3)Quit\n\n"); // Show Options
while(iChoice != 3) { // Whilst option is not 3
printf("NOZ> _\b");
scanf("%i", &iChoice); // Get next option
switch(iChoice) {
case 1:
// Enable speed hack
if (! WriteProcessMemory(hProcess, (void*)0x00463de0, 0x75, 1, NULL)) { // Try to write 0x75 (jne) to 0x00463de0 (my address)
printf("Failed to write to memory!\n");
}
printf("Speed hack enabled.\n");
break;
case 2:
// Disable speed hack
if (! WriteProcessMemory(hProcess, (void*)0x00463de0, 0x74, 1, NULL)) { // 0x74 is (je). The original opcode.
printf("Failed to write to memory!\n");
}
printf("Speed hack disabled.\n");
break;
case 3:
printf("Leaving...\n");
continue;
default:
printf("No such option!\n");
break;
}
}
CloseHandle(hProcess);
exit(0);
}
提示:Failed to write to memory
我用GetLastError获取的结果是998
为什么??