-
-
Save kirbyUK/9d7d85bfa695cce84c5a620b2a623e3e to your computer and use it in GitHub Desktop.
Extracts loading hints from a running Shrek SuperSlam process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
const LPCTSTR WINDOW_NAME = "Shrek SuperSlam"; | |
const unsigned char* START_ADDRESS = 0x0A6725A0; | |
const unsigned char* END_ADDRESS = 0x0A674D00; | |
struct Hint { | |
char name[16]; | |
char garbage[16]; | |
char hint[128]; | |
}; | |
DWORD GetPid() | |
{ | |
HWND hwnd = FindWindowA(NULL, WINDOW_NAME); | |
DWORD pid = 0; | |
GetWindowThreadProcessId(hwnd, &pid); | |
return pid; | |
} | |
HANDLE GetHandle(DWORD pid) | |
{ | |
return OpenProcess( | |
PROCESS_VM_READ, | |
FALSE, | |
pid | |
); | |
} | |
struct Hint* ReadHint(HANDLE handle, unsigned char** addr) | |
{ | |
int len = 0; | |
struct Hint* hint = (struct Hint*)malloc(sizeof(struct Hint)); | |
char buffer[16] = { | |
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, | |
}; | |
if (ReadProcessMemory(handle, (LPVOID)*addr, hint->name, 16, 0) == FALSE) | |
{ | |
free(hint); | |
printf("Error reading memory!\n"); | |
return NULL; | |
} | |
*addr += 16; | |
if (ReadProcessMemory(handle, (LPVOID)*addr, hint->garbage, 16, 0) == FALSE) | |
{ | |
free(hint); | |
printf("Error reading memory!\n"); | |
return NULL; | |
} | |
*addr += 16; | |
while (buffer[15] != 0x00) | |
{ | |
if (ReadProcessMemory(handle, (LPVOID)*addr, buffer, 16, 0) == FALSE) | |
{ | |
free(hint); | |
printf("Error reading memory!\n"); | |
return NULL; | |
} | |
for (int i = 0; i < 16; i++) | |
hint->hint[i + len] = buffer[i]; | |
*addr += 16; | |
len += 16; | |
} | |
return hint; | |
} | |
int main() | |
{ | |
DWORD pid = GetPid(); | |
if (pid == NULL) | |
{ | |
printf("Couldn't get PID!\n"); | |
return 1; | |
} | |
HANDLE handle = GetHandle(pid); | |
if ((handle == INVALID_HANDLE_VALUE) || (handle == NULL)) | |
{ | |
printf("Couldn't get handle!\n"); | |
return 1; | |
} | |
for (unsigned char* addr = START_ADDRESS; addr < END_ADDRESS; addr) | |
{ | |
struct Hint* hint = ReadHint(handle, &addr); | |
if (hint == NULL) | |
return 1; | |
printf("%s: %s\n", hint->name, hint->hint); | |
free(hint); | |
} | |
CloseHandle(handle); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment