File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments