diff --git a/src/tcpgecko/hardware_breakpoints.h b/src/tcpgecko/hardware_breakpoints.h index c910781..ae2a677 100644 --- a/src/tcpgecko/hardware_breakpoints.h +++ b/src/tcpgecko/hardware_breakpoints.h @@ -184,7 +184,7 @@ void setDataBreakpoint(int address, bool read, bool write) { // log_print("Setting DABR...\n"); OSSetDABR(1, address, read, write); // log_print("DABR set\n"); - int enabled = OSIsInterruptEnabled(); + // int enabled = OSIsInterruptEnabled(); // log_printf("Interrupts enabled: %i\n", enabled); } diff --git a/src/tcpgecko/kernel.h b/src/tcpgecko/kernel.h index bc11df6..080d3d4 100644 --- a/src/tcpgecko/kernel.h +++ b/src/tcpgecko/kernel.h @@ -99,7 +99,6 @@ int kernelMemoryCompare(const char *sourceBuffer, } bool loopEntered = false; - while (kern_read(sourceBuffer) == kern_read(destinationBuffer)) { loopEntered = true; sourceBuffer = (char *) sourceBuffer + KERNEL_MEMORY_COMPARE_STEP_SIZE; diff --git a/src/tcpgecko/tcp_gecko.cpp b/src/tcpgecko/tcp_gecko.cpp index 9deaa88..94e7bce 100644 --- a/src/tcpgecko/tcp_gecko.cpp +++ b/src/tcpgecko/tcp_gecko.cpp @@ -1252,12 +1252,14 @@ static int processCommands(struct pygecko_bss_t *bss, int clientfd) { int comparisonResult; if (kernelRead) { - comparisonResult = kernelMemoryCompare((char *) currentAddress, searchBytes, searchBytesCount); + comparisonResult = kernelMemoryCompare((char *) currentAddress, + searchBytes, searchBytesCount); } else { - comparisonResult = memcmp((void *) currentAddress, searchBytes, searchBytesCount); + comparisonResult = memoryCompare((void *) currentAddress, + searchBytes, (size_t) searchBytesCount); } if (comparisonResult == 0) { - // Search bytes have been found + // Search bytes have been found, add the addresses to the return buffer ((int *) buffer)[1 + searchBytesOccurrences] = currentAddress; searchBytesOccurrences++; @@ -1579,4 +1581,4 @@ void startTCPGecko() { OSResumeThread(thread); log_print("TCP Gecko started...\n"); -} +} \ No newline at end of file diff --git a/src/tcpgecko/utilities.h b/src/tcpgecko/utilities.h index 912f010..6984d42 100644 --- a/src/tcpgecko/utilities.h +++ b/src/tcpgecko/utilities.h @@ -4,6 +4,7 @@ #include "../dynamic_libs/os_functions.h" #include "../utils/logger.h" #include "kernel.h" +#include /* size_t */ void writeCode(u32 address, u32 instruction) { u32 *pointer = (u32 *) (address + 0xA0000000); @@ -20,4 +21,15 @@ void patchFunction(char *function, char *patchBytes, unsigned int patchBytesSize log_print("Successfully patched!\n"); } +int memoryCompare(const void *s1, const void *s2, size_t n) { + const unsigned char *p1 = static_cast(s1); + const unsigned char *p2 = static_cast(s2); + while (n--) + if (*p1 != *p2) + return *p1 - *p2; + else + p1++, p2++; + return 0; +} + #endif \ No newline at end of file diff --git a/tcpgecko.elf b/tcpgecko.elf index 0e6eb67..a2adbc9 100644 Binary files a/tcpgecko.elf and b/tcpgecko.elf differ