Skip to content

Commit 290a227

Browse files
committed
Fixed bug in windows specific platform code.
1 parent c65cdfc commit 290a227

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

Dumper/Platform/Private/PlatformWindows.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,10 @@ namespace
128128
const PEB* Peb = GetPEB();
129129
const PEB_LDR_DATA* Ldr = Peb->Ldr;
130130

131-
int NumEntriesLeft = Ldr->Length;
132-
133131
const std::string LowercaseSearchModuleName = Utils::StrToLower(SearchModuleName);
134132

135-
for (const LIST_ENTRY* P = Ldr->InMemoryOrderModuleList.Flink; P && NumEntriesLeft-- > 0; P = P->Flink)
133+
const LIST_ENTRY* FirstEntry = &Ldr->InMemoryOrderModuleList;
134+
for (const LIST_ENTRY* P = Ldr->InMemoryOrderModuleList.Flink; P && P != FirstEntry; P = P->Flink)
136135
{
137136
const LDR_DATA_TABLE_ENTRY* Entry = reinterpret_cast<const LDR_DATA_TABLE_ENTRY*>(P);
138137

@@ -573,13 +572,13 @@ const void* PlatformWindows::GetAddressOfExportedFunction(const char* SearchModu
573572
const WORD* Ordinals = reinterpret_cast<const WORD*>(ModuleBase + ExportTable->AddressOfNameOrdinals);
574573

575574
/* Iterate all names and return the function if the name matches what we're looking for */
576-
for (int i = 0; i < ExportTable->NumberOfFunctions; i++)
575+
for (int i = 0; i < ExportTable->NumberOfNames; i++)
577576
{
578577
const WORD NameIndex = Ordinals[i];
579-
const char* Name = reinterpret_cast<const char*>(ModuleBase + NameOffsets[NameIndex]);
578+
const char* Name = reinterpret_cast<const char*>(ModuleBase + NameOffsets[i]);
580579

581580
if (strcmp(SearchFunctionName, Name) == 0)
582-
return reinterpret_cast<void*>(ModuleBase + FunctionOffsets[i]);
581+
return reinterpret_cast<void*>(ModuleBase + FunctionOffsets[NameIndex]);
583582
}
584583

585584
return nullptr;

0 commit comments

Comments
 (0)