mirror of
https://github.com/reactos/reactos.git
synced 2025-01-21 02:53:30 +08:00
- Write DLL Being mapped into NtTib->ArbitraryUserPointer so that the debugger can pick it up.
- Fix bugs in DbgkWakeTarget, DbgkCreateThread, DbgkMapViewOfSection and call from NtMapViewOfSection. svn path=/trunk/; revision=25010
This commit is contained in:
parent
898809f6cb
commit
94912681e1
@ -280,8 +280,9 @@ DbgUiConvertStateChangeStructure(IN PDBGUI_WAIT_STATE_CHANGE WaitStateChange,
|
||||
{
|
||||
/* Save the image name from the TIB */
|
||||
DebugEvent->u.LoadDll.lpImageName =
|
||||
&((PTEB)ThreadBasicInfo.TebBaseAddress)->
|
||||
((PTEB)ThreadBasicInfo.TebBaseAddress)->
|
||||
Tib.ArbitraryUserPointer;
|
||||
DPRINT1("Image name: %p\n", DebugEvent->u.LoadDll.lpImageName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1986,6 +1986,7 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
||||
PVOID ImageBase;
|
||||
PIMAGE_NT_HEADERS NtHeaders;
|
||||
BOOLEAN MappedAsDataFile;
|
||||
PVOID ArbitraryUserPointer;
|
||||
|
||||
if (Module == NULL)
|
||||
{
|
||||
@ -2027,6 +2028,9 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
||||
/* Map the dll into the process */
|
||||
ViewSize = 0;
|
||||
ImageBase = 0;
|
||||
ArbitraryUserPointer = NtCurrentTeb()->Tib.ArbitraryUserPointer;
|
||||
NtCurrentTeb()->Tib.ArbitraryUserPointer = FullDosName.Buffer;
|
||||
DPRINT1("POI. DAT: %p %S\n", NtCurrentTeb()->Tib.ArbitraryUserPointer, FullDosName.Buffer);
|
||||
Status = NtMapViewOfSection(SectionHandle,
|
||||
NtCurrentProcess(),
|
||||
&ImageBase,
|
||||
@ -2037,6 +2041,8 @@ LdrpLoadModule(IN PWSTR SearchPath OPTIONAL,
|
||||
0,
|
||||
MEM_COMMIT,
|
||||
PAGE_READONLY);
|
||||
NtCurrentTeb()->Tib.ArbitraryUserPointer = ArbitraryUserPointer;
|
||||
DPRINT1("Poi gone!\n");
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("map view of section failed (Status 0x%08lx)\n", Status);
|
||||
|
@ -12,6 +12,8 @@
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
extern ULONG DbgkpTraceLevel;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
HANDLE
|
||||
@ -236,9 +238,11 @@ DbgkCreateThread(PVOID StartAddress)
|
||||
if (Teb)
|
||||
{
|
||||
/* Copy the system library name and link to it */
|
||||
#if 0
|
||||
wcsncpy(Teb->StaticUnicodeBuffer,
|
||||
L"ntdll.dll",
|
||||
sizeof(Teb->StaticUnicodeBuffer));
|
||||
sizeof(Teb->StaticUnicodeBuffer) / sizeof(WCHAR));
|
||||
#endif
|
||||
Teb->Tib.ArbitraryUserPointer = Teb->StaticUnicodeBuffer;
|
||||
|
||||
/* Return it in the debug event as well */
|
||||
@ -369,7 +373,7 @@ DbgkExitThread(IN NTSTATUS ExitStatus)
|
||||
|
||||
VOID
|
||||
NTAPI
|
||||
DbgkMapViewOfSection(IN HANDLE SectionHandle,
|
||||
DbgkMapViewOfSection(IN PVOID Section,
|
||||
IN PVOID BaseAddress,
|
||||
IN ULONG SectionOffset,
|
||||
IN ULONG_PTR ViewSize)
|
||||
@ -380,6 +384,8 @@ DbgkMapViewOfSection(IN HANDLE SectionHandle,
|
||||
PETHREAD Thread = PsGetCurrentThread();
|
||||
PIMAGE_NT_HEADERS NtHeader;
|
||||
PAGED_CODE();
|
||||
DBGKTRACE(DBGK_PROCESS_DEBUG,
|
||||
"Section: %p. Base: %p\n", Section, BaseAddress);
|
||||
|
||||
/* Check if this thread is hidden, doesn't have a debug port, or died */
|
||||
if ((Thread->HideFromDebugger) ||
|
||||
@ -392,7 +398,7 @@ DbgkMapViewOfSection(IN HANDLE SectionHandle,
|
||||
}
|
||||
|
||||
/* Setup the parameters */
|
||||
LoadDll->FileHandle = DbgkpSectionToFileHandle(SectionHandle);
|
||||
LoadDll->FileHandle = DbgkpSectionToFileHandle(Section);
|
||||
LoadDll->BaseOfDll = BaseAddress;
|
||||
LoadDll->DebugInfoFileOffset = 0;
|
||||
LoadDll->DebugInfoSize = 0;
|
||||
|
@ -329,7 +329,7 @@ DbgkForwardException(IN PEXCEPTION_RECORD ExceptionRecord,
|
||||
PAGED_CODE();
|
||||
DBGKTRACE(DBGK_EXCEPTION_DEBUG,
|
||||
"ExceptionRecord: %p Port: %p\n", ExceptionRecord, DebugPort);
|
||||
KEBUGCHECK(0);
|
||||
while (TRUE);
|
||||
|
||||
/* Setup the API Message */
|
||||
ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 |
|
||||
@ -442,13 +442,13 @@ DbgkpWakeTarget(IN PDEBUG_EVENT DebugEvent)
|
||||
/* Check if we have to wake up the event */
|
||||
if (DebugEvent->Flags & 2)
|
||||
{
|
||||
/* Signal the continue event */
|
||||
KeSetEvent(&DebugEvent->ContinueEvent, IO_NO_INCREMENT, FALSE);
|
||||
/* Otherwise, free the debug event */
|
||||
DbgkpFreeDebugEvent(DebugEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, free the debug event */
|
||||
DbgkpFreeDebugEvent(DebugEvent);
|
||||
/* Signal the continue event */
|
||||
KeSetEvent(&DebugEvent->ContinueEvent, IO_NO_INCREMENT, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ DbgkExitThread(
|
||||
VOID
|
||||
NTAPI
|
||||
DbgkMapViewOfSection(
|
||||
IN HANDLE SectionHandle,
|
||||
IN PVOID Section,
|
||||
IN PVOID BaseAddress,
|
||||
IN ULONG SectionOffset,
|
||||
IN ULONG_PTR ViewSize
|
||||
|
@ -3777,7 +3777,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||
(Status != STATUS_IMAGE_NOT_AT_BASE))
|
||||
{
|
||||
/* Notify the debugger */
|
||||
DbgkMapViewOfSection(SectionHandle,
|
||||
DbgkMapViewOfSection(Section,
|
||||
SafeBaseAddress,
|
||||
SafeSectionOffset.LowPart,
|
||||
SafeViewSize);
|
||||
|
Loading…
Reference in New Issue
Block a user