- NDK 0.98, now with versionned headers. Too many changes to list, see the TinyKRNL...
[reactos.git] / reactos / ntoskrnl / kdbg / kdb_symbols.c
index 89e58dd..bb8df6d 100644 (file)
@@ -55,6 +55,7 @@ KdbpSymFindUserModule(IN PVOID Address  OPTIONAL,
   PEPROCESS CurrentProcess;
   PPEB Peb = NULL;
   INT Count = 0;
+  INT Length;
 
   CurrentProcess = PsGetCurrentProcess();
   if (CurrentProcess != NULL)
@@ -72,21 +73,18 @@ KdbpSymFindUserModule(IN PVOID Address  OPTIONAL,
   while (current_entry != &Peb->Ldr->InLoadOrderModuleList &&
          current_entry != NULL)
     {
-      current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderModuleList);
-
+      current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
+      Length = min(current->BaseDllName.Length / sizeof(WCHAR), 255);
       if ((Address != NULL && (Address >= (PVOID)current->DllBase &&
                                Address < (PVOID)((char *)current->DllBase + current->SizeOfImage))) ||
-          (Name != NULL && _wcsicmp(current->BaseDllName.Buffer, Name) == 0) ||
+          (Name != NULL && _wcsnicmp(current->BaseDllName.Buffer, Name, Length) == 0) ||
           (Index >= 0 && Count++ == Index))
         {
-         INT Length = current->BaseDllName.Length;
-         if (Length > 255)
-           Length = 255;
          wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
          pInfo->Name[Length] = L'\0';
           pInfo->Base = (ULONG_PTR)current->DllBase;
           pInfo->Size = current->SizeOfImage;
-          pInfo->RosSymInfo = current->RosSymInfo;
+          pInfo->RosSymInfo = current->PatchInformation;
           return TRUE;
         }
       current_entry = current_entry->Flink;
@@ -111,25 +109,25 @@ KdbpSymFindModule(IN PVOID Address  OPTIONAL,
   PLDR_DATA_TABLE_ENTRY current;
   extern LIST_ENTRY ModuleListHead;
   INT Count = 0;
+  INT Length;
 
   current_entry = ModuleListHead.Flink;
 
   while (current_entry != &ModuleListHead)
     {
-      current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderModuleList);
+      current = CONTAINING_RECORD(current_entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
 
+      Length = min(current->BaseDllName.Length / sizeof(WCHAR), 255);
       if ((Address != NULL && (Address >= (PVOID)current->DllBase &&
                                Address < (PVOID)((ULONG_PTR)current->DllBase + current->SizeOfImage))) ||
-          (Name != NULL && _wcsnicmp(current->BaseDllName.Buffer, Name,
-                                     current->BaseDllName.Length / sizeof(WCHAR)) == 0) ||
+          (Name != NULL && _wcsnicmp(current->BaseDllName.Buffer, Name, Length) == 0) ||
           (Index >= 0 && Count++ == Index))
         {
-         wcsncpy(pInfo->Name, current->BaseDllName.Buffer,
-                 min(255, current->BaseDllName.Length / sizeof(WCHAR)));
-         pInfo->Name[255] = L'\0';
+         wcsncpy(pInfo->Name, current->BaseDllName.Buffer, Length);
+         pInfo->Name[Length] = L'\0';
           pInfo->Base = (ULONG_PTR)current->DllBase;
           pInfo->Size = current->SizeOfImage;
-          pInfo->RosSymInfo = current->RosSymInfo;
+          pInfo->RosSymInfo = current->PatchInformation;
           return TRUE;
         }
       current_entry = current_entry->Flink;
@@ -495,7 +493,7 @@ KdbSymLoadUserModuleSymbols(IN PLDR_DATA_TABLE_ENTRY LdrModule)
   UNICODE_STRING KernelName;
   DPRINT("LdrModule %p\n", LdrModule);
 
-  LdrModule->RosSymInfo = NULL;
+  LdrModule->PatchInformation = NULL;
 
   KernelName.MaximumLength = sizeof(Prefix) + LdrModule->FullDllName.Length;
   KernelName.Length = KernelName.MaximumLength - sizeof(WCHAR);
@@ -509,7 +507,7 @@ KdbSymLoadUserModuleSymbols(IN PLDR_DATA_TABLE_ENTRY LdrModule)
          LdrModule->FullDllName.Length);
   KernelName.Buffer[KernelName.Length / sizeof(WCHAR)] = L'\0';
 
-  KdbpSymLoadModuleSymbols(&KernelName, (PROSSYM_INFO*)&LdrModule->RosSymInfo);
+  KdbpSymLoadModuleSymbols(&KernelName, (PROSSYM_INFO*)&LdrModule->PatchInformation);
 
   ExFreePool(KernelName.Buffer);
 }
@@ -529,7 +527,7 @@ KdbSymFreeProcessSymbols(IN PEPROCESS Process)
   CurrentProcess = PsGetCurrentProcess();
   if (CurrentProcess != Process)
   {
-    KeAttachProcess(EPROCESS_TO_KPROCESS(Process));
+    KeAttachProcess(&Process->Pcb);
   }
   Peb = Process->Peb;
   ASSERT(Peb);
@@ -539,9 +537,9 @@ KdbSymFreeProcessSymbols(IN PEPROCESS Process)
   while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList &&
         CurrentEntry != NULL)
     {
-      Current = CONTAINING_RECORD(CurrentEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderModuleList);
+      Current = CONTAINING_RECORD(CurrentEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
 
-      KdbpSymUnloadModuleSymbols(Current->RosSymInfo);
+      KdbpSymUnloadModuleSymbols(Current->PatchInformation);
 
       CurrentEntry = CurrentEntry->Flink;
     }
@@ -561,11 +559,11 @@ KdbSymLoadDriverSymbols(IN PUNICODE_STRING Filename,
                         IN PLDR_DATA_TABLE_ENTRY Module)
 {
   /* Load symbols for the image if available */
-  DPRINT("Loading driver %wZ symbols (driver @ %08x)\n", Filename, Module->Base);
+  DPRINT("Loading driver %wZ symbols (driver @ %08x)\n", Filename, Module->DllBase);
 
-  Module->RosSymInfo = NULL;
+  Module->PatchInformation = NULL;
 
-  KdbpSymLoadModuleSymbols(Filename, (PROSSYM_INFO*)&Module->RosSymInfo);
+  KdbpSymLoadModuleSymbols(Filename, (PROSSYM_INFO*)&Module->PatchInformation);
 }
 
 /*! \brief Unloads symbol info for a driver.
@@ -576,8 +574,8 @@ VOID
 KdbSymUnloadDriverSymbols(IN PLDR_DATA_TABLE_ENTRY ModuleObject)
 {
   /* Unload symbols for module if available */
-  KdbpSymUnloadModuleSymbols(ModuleObject->RosSymInfo);
-  ModuleObject->RosSymInfo = NULL;
+  KdbpSymUnloadModuleSymbols(ModuleObject->PatchInformation);
+  ModuleObject->PatchInformation = NULL;
 }
 
 /*! \brief Called when a symbol file is loaded by the loader?
@@ -619,7 +617,7 @@ KdbSymProcessBootSymbols(IN PCHAR FileName)
   {
      if (! LoadSymbols)
      {
-        ModuleObject->RosSymInfo = NULL;
+        ModuleObject->PatchInformation = NULL;
         return;
      }
 
@@ -633,16 +631,16 @@ KdbSymProcessBootSymbols(IN PCHAR FileName)
      if (i < KeLoaderBlock.ModsCount)
      {
         KeLoaderModules[i].Reserved = 1;
-        if (ModuleObject->RosSymInfo != NULL)
+        if (ModuleObject->PatchInformation != NULL)
         {
-           KdbpSymRemoveCachedFile(ModuleObject->RosSymInfo);
+           KdbpSymRemoveCachedFile(ModuleObject->PatchInformation);
         }
 
         if (IsRaw)
         {
            if (! RosSymCreateFromRaw((PVOID) KeLoaderModules[i].ModStart,
                                      KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart,
-                                     (PROSSYM_INFO*)&ModuleObject->RosSymInfo))
+                                     (PROSSYM_INFO*)&ModuleObject->PatchInformation))
            {
               return;
            }
@@ -651,7 +649,7 @@ KdbSymProcessBootSymbols(IN PCHAR FileName)
         {
            if (! RosSymCreateFromMem((PVOID) KeLoaderModules[i].ModStart,
                                      KeLoaderModules[i].ModEnd - KeLoaderModules[i].ModStart,
-                                     (PROSSYM_INFO*)&ModuleObject->RosSymInfo))
+                                     (PROSSYM_INFO*)&ModuleObject->PatchInformation))
            {
               return;
            }
@@ -660,14 +658,14 @@ KdbSymProcessBootSymbols(IN PCHAR FileName)
         /* add file to cache */
         RtlInitAnsiString(&AnsiString, FileName);
        RtlAnsiStringToUnicodeString(&UnicodeString, &AnsiString, TRUE);
-        KdbpSymAddCachedFile(&UnicodeString, ModuleObject->RosSymInfo);
+        KdbpSymAddCachedFile(&UnicodeString, ModuleObject->PatchInformation);
         RtlFreeUnicodeString(&UnicodeString);
 
         DPRINT("Installed symbols: %s@%08x-%08x %p\n",
               FileName,
               ModuleObject->DllBase,
-              ModuleObject->SizeOfImage + ModuleObject->DllBase,
-              ModuleObject->RosSymInfo);
+              ModuleObject->SizeOfImage + (ULONG)ModuleObject->DllBase,
+              ModuleObject->PatchInformation);
      }
   }
 }
@@ -685,8 +683,8 @@ KdbSymInit(IN PLDR_DATA_TABLE_ENTRY NtoskrnlModuleObject,
   int Found;
   char YesNo;
 
-  NtoskrnlModuleObject->RosSymInfo = NULL;
-  LdrHalModuleObject->RosSymInfo = NULL;
+  NtoskrnlModuleObject->PatchInformation = NULL;
+  LdrHalModuleObject->PatchInformation = NULL;
 
   InitializeListHead(&SymbolFileListHead);
   KeInitializeSpinLock(&SymbolFileListLock);