[CMAKE]
[reactos.git] / dll / ntdll / rtl / libsupp.c
index 5237098..4239183 100644 (file)
@@ -486,3 +486,36 @@ done:
     *ret = resdirptr;
     return STATUS_SUCCESS;
 }
+
+/*
+ * @implemented
+ */
+PVOID NTAPI
+RtlPcToFileHeader(IN PVOID PcValue,
+                  PVOID* BaseOfImage)
+{
+    PLIST_ENTRY ModuleListHead;
+    PLIST_ENTRY Entry;
+    PLDR_DATA_TABLE_ENTRY Module;
+    PVOID ImageBase = NULL;
+
+    RtlEnterCriticalSection (NtCurrentPeb()->LoaderLock);
+    ModuleListHead = &NtCurrentPeb()->Ldr->InLoadOrderModuleList;
+    Entry = ModuleListHead->Flink;
+    while (Entry != ModuleListHead)
+    {
+        Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
+
+        if ((ULONG_PTR)PcValue >= (ULONG_PTR)Module->DllBase &&
+                (ULONG_PTR)PcValue < (ULONG_PTR)Module->DllBase + Module->SizeOfImage)
+        {
+            ImageBase = Module->DllBase;
+            break;
+        }
+        Entry = Entry->Flink;
+    }
+    RtlLeaveCriticalSection (NtCurrentPeb()->LoaderLock);
+
+    *BaseOfImage = ImageBase;
+    return ImageBase;
+}