mirror of
https://github.com/GameHackingBook/GameHackingCode
synced 2026-06-08 11:08:54 +00:00
Various fixes
This commit is contained in:
@@ -97,6 +97,8 @@ DWORD WINAPI exampleThread(LPVOID lpParam)
|
||||
auto window = FindWindowA(NULL, "Chapter10 Input Example");
|
||||
typeStringWithSendMessage(window, "Typing using SendMessage()!\rEffectively the same, but more powerful :-)\r\r");
|
||||
|
||||
std::cout << std::endl << std::endl << "DONE! you can close this now!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ public:
|
||||
}
|
||||
void updateScore(int endx, int endy)
|
||||
{
|
||||
this->score = g + heuristic(endx, endy) * TILE_COST;
|
||||
auto h = this->heuristic(endx, endy) * TILE_COST;
|
||||
this->score = g + h;
|
||||
}
|
||||
AStarNodePtr getCopy()
|
||||
{
|
||||
|
||||
@@ -123,19 +123,31 @@ DWORD getMyBaseAddressFS()
|
||||
return newBase;
|
||||
}
|
||||
|
||||
DWORD getRemoteBaseAddress(HANDLE Process)
|
||||
DWORD getRemoteBaseAddress(HANDLE process)
|
||||
{
|
||||
LPVOID TIB;
|
||||
__asm
|
||||
{
|
||||
MOV EAX, DWORD PTR FS:[0x18]
|
||||
ADD EAX, 0x30
|
||||
MOV TIB, EAX
|
||||
}
|
||||
// read 0x30 bytes past _the_game's_ TIB to get the PEB
|
||||
DWORD PEB = readMemoryAPI<DWORD>(Process, TIB);
|
||||
// read 0x8 bytes past _the_game's_ PEB to get the base
|
||||
return readMemoryAPI<DWORD>(Process, (LPVOID)(PEB + 0x08));
|
||||
|
||||
DWORD newBase;
|
||||
// get the address of kernel32.dll
|
||||
HMODULE k32 = GetModuleHandleA("kernel32.dll");
|
||||
|
||||
// get the address of GetModuleHandle()
|
||||
LPVOID funcAdr = GetProcAddress(k32, "GetModuleHandleA");
|
||||
|
||||
if (!funcAdr)
|
||||
funcAdr = GetProcAddress(k32, "GetModuleHandleW");
|
||||
// create the thread
|
||||
HANDLE thread = CreateRemoteThread(process, NULL, NULL, (LPTHREAD_START_ROUTINE)funcAdr, NULL, NULL, NULL);
|
||||
|
||||
// let the thread finish
|
||||
WaitForSingleObject(thread, INFINITE);
|
||||
|
||||
// get the exit code
|
||||
GetExitCodeThread(thread, &newBase);
|
||||
|
||||
// clean up the thread handle
|
||||
CloseHandle(thread);
|
||||
|
||||
return newBase;
|
||||
}
|
||||
|
||||
void printMyBaseAddresses(HANDLE Process)
|
||||
|
||||
@@ -17,7 +17,7 @@ ExecutableModule::~ExecutableModule(void)
|
||||
DWORD ExecutableModule::findPattern(const char* pattern, unsigned int patternLength, unsigned int occurance)
|
||||
{
|
||||
unsigned int ocur = 0;
|
||||
for (DWORD adr = this->base; adr < this->base + this->size - patternLength; adr++)
|
||||
for (DWORD adr = this->base; adr <= this->base + this->size - patternLength; adr++)
|
||||
{
|
||||
|
||||
if (memcmp((LPVOID)pattern, (LPVOID)adr, patternLength) == 0)
|
||||
|
||||
Reference in New Issue
Block a user