Skip to content

Commit

Permalink
Quieten some debug output in CAPE.c & Trace.c, fix compiler warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kevoreilly committed Dec 2, 2022
1 parent a4c6cde commit 5a447f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CAPE/CAPE.c
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,9 @@ BOOL IsAddressAccessible(PVOID Address)

if (!VirtualQuery(Address, &MemInfo, sizeof(MEMORY_BASIC_INFORMATION)))
{
#ifdef DEBUG_COMMENTS
ErrorOutput("IsAddressAccessible: unable to query memory address 0x%p", Address);
#endif
return 0;
}

Expand Down Expand Up @@ -1278,7 +1280,8 @@ PCHAR ScanForExport(PVOID Address, SIZE_T ScanMax)

for (unsigned int j = 0; j < ExportDirectory->NumberOfFunctions; j++)
{
if ((PUCHAR)Address - (PUCHAR)ImageBase > AddressOfFunctions[AddressOfNameOrdinals[j]] && (PUCHAR)Address - (PUCHAR)ImageBase - AddressOfFunctions[AddressOfNameOrdinals[j]] <= (int)ScanMax)
if ((PUCHAR)Address - (PUCHAR)ImageBase > (int)AddressOfFunctions[AddressOfNameOrdinals[j]]
&& (PUCHAR)Address - (PUCHAR)ImageBase - AddressOfFunctions[AddressOfNameOrdinals[j]] <= (int)ScanMax)
return (PCHAR)ImageBase + AddressOfNames[j];
}

Expand Down
8 changes: 6 additions & 2 deletions CAPE/Trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ SIZE_T StrTest(PCHAR StrCandidate, PCHAR OutputBuffer, SIZE_T BufferSize)
SIZE_T Count;
if (!ReadProcessMemory(GetCurrentProcess(), StrCandidate, OutputBuffer, BufferSize, &Count))
{
DebugOutput("StrTest: ReadProcessMemory bombed on 0x%p", StrCandidate);
#ifdef DEBUG_COMMENTS
DebugOutput("StrTest: ReadProcessMemory failed on string candidate at 0x%p", StrCandidate);
#endif
return 0;
}
PCHAR Character = (PCHAR)OutputBuffer;
Expand Down Expand Up @@ -135,7 +137,9 @@ SIZE_T StrTestW(PWCHAR StrCandidate, PWCHAR OutputBuffer, SIZE_T BufferSize)
SIZE_T Count;
if (!ReadProcessMemory(GetCurrentProcess(), StrCandidate, OutputBuffer, BufferSize, &Count))
{
DebugOutput("StrTestW: ReadProcessMemory bombed on 0x%p", StrCandidate);
#ifdef DEBUG_COMMENTS
DebugOutput("StrTestW: ReadProcessMemory failed on string candidate at 0x%p", StrCandidate);
#endif
return 0;
}
PWCHAR Character = (PWCHAR)OutputBuffer;
Expand Down

0 comments on commit 5a447f0

Please sign in to comment.