diff --git a/Chapter10_ResponsiveHacks/main-responsiveHacks.cpp b/Chapter10_ResponsiveHacks/main-responsiveHacks.cpp index 48415a9..1068ab5 100644 --- a/Chapter10_ResponsiveHacks/main-responsiveHacks.cpp +++ b/Chapter10_ResponsiveHacks/main-responsiveHacks.cpp @@ -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; } diff --git a/Chapter11_SearchAlgorithms/Chapter11_SearchAlgorithms.cpp b/Chapter11_SearchAlgorithms/Chapter11_SearchAlgorithms.cpp index 78c4d7b..3d32bfb 100644 --- a/Chapter11_SearchAlgorithms/Chapter11_SearchAlgorithms.cpp +++ b/Chapter11_SearchAlgorithms/Chapter11_SearchAlgorithms.cpp @@ -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() { diff --git a/Chapter6_AccessingMemory/main-accessingMemory.cpp b/Chapter6_AccessingMemory/main-accessingMemory.cpp index 1400837..4e226b4 100644 --- a/Chapter6_AccessingMemory/main-accessingMemory.cpp +++ b/Chapter6_AccessingMemory/main-accessingMemory.cpp @@ -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(Process, TIB); - // read 0x8 bytes past _the_game's_ PEB to get the base - return readMemoryAPI(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) diff --git a/Chapter8_AdobeAirHook/ExecutableModule.cpp b/Chapter8_AdobeAirHook/ExecutableModule.cpp index fe12033..e91e652 100644 --- a/Chapter8_AdobeAirHook/ExecutableModule.cpp +++ b/Chapter8_AdobeAirHook/ExecutableModule.cpp @@ -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)