Author: ion
Date: Mon Oct 23 00:52:13 2006
New Revision: 24613
URL: http://svn.reactos.org/svn/reactos?rev=24613&view=rev
Log:
- Implement KeThawAllThreads based on KeFreezeAllThreads.
- Fix a bug in KeFreezeAllThreads which was causing us never to actually parse the next flink.
- Fix a bug in KeFreezeAllThreads which was causing us never to leave the critical region we entered at the beginning.
Modified:
trunk/reactos/ntoskrnl/include/internal/ke.h
trunk/reactos/ntoskrnl/ke/thrdobj.c
Modified: trunk/reactos/ntoskrnl/include/internal/ke.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/ke.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/ke.h Mon Oct 23 00:52:13 2006
@@ -528,6 +528,12 @@
VOID
NTAPI
+KeThawAllThreads(
+ VOID
+);
+
+VOID
+NTAPI
KeFreezeAllThreads(
VOID
);
Modified: trunk/reactos/ntoskrnl/ke/thrdobj.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/thrdobj.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ke/thrdobj.c (original)
+++ trunk/reactos/ntoskrnl/ke/thrdobj.c Mon Oct 23 00:52:13 2006
@@ -304,11 +304,17 @@
/* Release the APC lock */
KiReleaseApcLockFromDpcLevel(&ApcLock);
+
+ /* Move to the next thread */
+ NextEntry = NextEntry->Flink;
}
/* Release the process lock and exit the dispatcher */
KiReleaseProcessLock(&LockHandle);
KiExitDispatcher(LockHandle.OldIrql);
+
+ /* Leave the critical region */
+ KeLeaveCriticalRegion();
}
ULONG
@@ -573,6 +579,71 @@
return PreviousCount;
}
+VOID
+NTAPI
+KeThawAllThreads(VOID)
+{
+ KLOCK_QUEUE_HANDLE LockHandle, ApcLock;
+ PKTHREAD Current, CurrentThread = KeGetCurrentThread();
+ PKPROCESS Process = CurrentThread->ApcState.Process;
+ PLIST_ENTRY ListHead, NextEntry;
+ LONG OldCount;
+ ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
+
+ /* Lock the process */
+ KiAcquireProcessLock(Process, &LockHandle);
+
+ /* Enter a critical region */
+ KeEnterCriticalRegion();
+
+ /* Loop the Process's Threads */
+ ListHead = &Process->ThreadListHead;
+ NextEntry = ListHead->Flink;
+ while (NextEntry != ListHead)
+ {
+ /* Get the current thread */
+ Current = CONTAINING_RECORD(NextEntry, KTHREAD, ThreadListEntry);
+
+ /* Lock it */
+ KiAcquireApcLockAtDpcLevel(Current, &ApcLock);
+
+ /* Make sure we are frozen */
+ OldCount = Current->FreezeCount;
+ if (OldCount)
+ {
+ /* Decrease the freeze count */
+ Current->FreezeCount--;
+
+ /* Check if both counts are zero now */
+ if (!(Current->SuspendCount) && (!Current->FreezeCount))
+ {
+ /* Lock the dispatcher */
+ KiAcquireDispatcherLockAtDpcLevel();
+
+ /* Signal the suspend semaphore and wake it */
+ Current->SuspendSemaphore.Header.SignalState++;
+ KiWaitTest(&Current->SuspendSemaphore, 1);
+
+ /* Unlock the dispatcher */
+ KiReleaseDispatcherLockFromDpcLevel();
+ }
+ }
+
+ /* Release the APC lock */
+ KiReleaseApcLockFromDpcLevel(&ApcLock);
+
+ /* Go to the next one */
+ NextEntry = NextEntry->Flink;
+ }
+
+ /* Release the process lock and exit the dispatcher */
+ KiReleaseProcessLock(&LockHandle);
+ KiExitDispatcher(LockHandle.OldIrql);
+
+ /* Leave the critical region */
+ KeLeaveCriticalRegion();
+}
+
BOOLEAN
NTAPI
KeTestAlertThread(IN KPROCESSOR_MODE AlertMode)
Author: ion
Date: Sun Oct 22 23:53:10 2006
New Revision: 24609
URL: http://svn.reactos.org/svn/reactos?rev=24609&view=rev
Log:
- Implement DbgkPostFakeModuleMessages.
- Stub MmGetFileNameForAddress but write documentation on how to implement it (thanks to Filip Navara). For now it always returns ntdll.dll as a testhack.
Modified:
trunk/reactos/ntoskrnl/dbgk/debug.c
trunk/reactos/ntoskrnl/include/internal/mm.h
trunk/reactos/ntoskrnl/mm/section.c
Modified: trunk/reactos/ntoskrnl/dbgk/debug.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/dbgk/debug.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/dbgk/debug.c (original)
+++ trunk/reactos/ntoskrnl/dbgk/debug.c Sun Oct 22 23:53:10 2006
@@ -464,8 +464,103 @@
IN PETHREAD Thread,
IN PDEBUG_OBJECT DebugObject)
{
- /* FIXME: TODO */
- return STATUS_UNSUCCESSFUL;
+ PPEB Peb = Process->Peb;
+ PPEB_LDR_DATA LdrData;
+ PLDR_DATA_TABLE_ENTRY LdrEntry;
+ PLIST_ENTRY ListHead, NextEntry;
+ DBGKM_MSG ApiMessage;
+ PDBGKM_LOAD_DLL LoadDll = &ApiMessage.LoadDll;
+ ULONG i;
+ PIMAGE_NT_HEADERS NtHeader;
+ UNICODE_STRING ModuleName;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ IO_STATUS_BLOCK IoStatusBlock;
+ NTSTATUS Status;
+ PAGED_CODE();
+
+ /* Quit if there's no PEB */
+ if (!Peb) return STATUS_SUCCESS;
+
+ /* Get the Loader Data List */
+ LdrData = Peb->Ldr;
+ ListHead = &LdrData->InLoadOrderModuleList;
+ NextEntry = ListHead->Flink;
+
+ /* Loop the modules */
+ i = 0;
+ while ((NextEntry != ListHead) && (i < 500))
+ {
+ /* Get the entry */
+ LdrEntry = CONTAINING_RECORD(NextEntry,
+ LDR_DATA_TABLE_ENTRY,
+ InLoadOrderLinks);
+
+ /* Setup the API Message */
+ RtlZeroMemory(&ApiMessage, sizeof(DBGKM_MSG));
+ ApiMessage.ApiNumber = DbgKmLoadDllApi;
+
+ /* Set base and clear the name */
+ LoadDll->BaseOfDll = LdrEntry->DllBase;
+ LoadDll->NamePointer = NULL;
+
+ /* Get the NT Headers */
+ NtHeader = RtlImageNtHeader(LoadDll->BaseOfDll);
+ if (NtHeader)
+ {
+ /* Save debug data */
+ LoadDll->DebugInfoFileOffset = NtHeader->FileHeader.
+ PointerToSymbolTable;
+ LoadDll->DebugInfoSize = NtHeader->FileHeader.NumberOfSymbols;
+ }
+
+ /* Get the name of the DLL */
+ Status = MmGetFileNameForAddress(NtHeader, &ModuleName);
+ if (NT_SUCCESS(Status))
+ {
+ /* Setup the object attributes */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &ModuleName,
+ OBJ_FORCE_ACCESS_CHECK |
+ OBJ_KERNEL_HANDLE |
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ /* Open the file to get a handle to it */
+ Status = ZwOpenFile(&LoadDll->FileHandle,
+ GENERIC_READ | SYNCHRONIZE,
+ &ObjectAttributes,
+ &IoStatusBlock,
+ FILE_SHARE_READ |
+ FILE_SHARE_WRITE |
+ FILE_SHARE_DELETE,
+ FILE_SYNCHRONOUS_IO_NONALERT);
+ if (!NT_SUCCESS(Status)) LoadDll->FileHandle = NULL;
+
+ /* Free the name now */
+ ExFreePool(ModuleName.Buffer);
+ }
+
+ /* Send the fake module load message */
+ Status = DbgkpQueueMessage(Process,
+ Thread,
+ &ApiMessage,
+ 2,
+ DebugObject);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Message send failed, close the file handle if we had one */
+ if (LoadDll->FileHandle) ObCloseHandle(LoadDll->FileHandle,
+ KernelMode);
+ }
+
+ /* Go to the next module */
+ NextEntry = NextEntry->Flink;
+ i++;
+ }
+
+ /* Return success */
+ return STATUS_SUCCESS;
}
NTSTATUS
Modified: trunk/reactos/ntoskrnl/include/internal/mm.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/mm.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/mm.h Sun Oct 22 23:53:10 2006
@@ -1315,6 +1315,12 @@
MmGetFileObjectForSection(
IN PROS_SECTION_OBJECT Section
);
+NTSTATUS
+NTAPI
+MmGetFileNameForAddress(
+ IN PVOID Address,
+ OUT PUNICODE_STRING ModuleName
+);
PVOID
NTAPI
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c (original)
+++ trunk/reactos/ntoskrnl/mm/section.c Sun Oct 22 23:53:10 2006
@@ -106,9 +106,26 @@
return Section->FileObject; // Section->ControlArea->FileObject on NT
}
-
-
-
+NTSTATUS
+NTAPI
+MmGetFileNameForAddress(IN PVOID Address,
+ OUT PUNICODE_STRING ModuleName)
+{
+ /*
+ * FIXME: TODO.
+ * Filip says to get the MADDRESS_SPACE from EPROCESS,
+ * then use the MmMarea routines to locate the Marea that
+ * corresponds to the address. Then make sure it's a section
+ * view type (MEMORY_AREA_SECTION_VIEW) and use the marea's
+ * per-type union to get the .u.SectionView.Section pointer to
+ * the SECTION_OBJECT. Then we can use MmGetFileObjectForSection
+ * to get the FILE_OBJECT, from which we can then query the name
+ * to get the full filename (much like we do for creating the
+ * SeAuditName in EPROCESS.
+ */
+ RtlCreateUnicodeString(ModuleName, L"C:\\ReactOS\\system32\\ntdll.dll");
+ return STATUS_SUCCESS;
+}
/* Note: Mmsp prefix denotes "Memory Manager Section Private". */
Author: janderwald
Date: Sun Oct 22 23:11:24 2006
New Revision: 24607
URL: http://svn.reactos.org/svn/reactos?rev=24607&view=rev
Log:
- set breakpoint before FreeConsole to have a bigger chance of output :)
Modified:
trunk/reactos/base/setup/usetup/usetup.c
Modified: trunk/reactos/base/setup/usetup/usetup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/usetup.c…
==============================================================================
--- trunk/reactos/base/setup/usetup/usetup.c (original)
+++ trunk/reactos/base/setup/usetup/usetup.c Sun Oct 22 23:11:24 2006
@@ -3669,13 +3669,12 @@
}
}
- /* Reboot */
- FreeConsole();
-
/// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
/// DO NOT REMOVE!!!
DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE");
+ /* Reboot */
+ FreeConsole();
NtShutdownSystem(ShutdownReboot);
NtTerminateProcess(NtCurrentProcess(), 0);
}
Author: janderwald
Date: Sun Oct 22 22:52:01 2006
New Revision: 24606
URL: http://svn.reactos.org/svn/reactos?rev=24606&view=rev
Log:
- add an checkpoint for the system regression tool
Modified:
trunk/reactos/base/setup/usetup/usetup.c
Modified: trunk/reactos/base/setup/usetup/usetup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/usetup.c…
==============================================================================
--- trunk/reactos/base/setup/usetup/usetup.c (original)
+++ trunk/reactos/base/setup/usetup/usetup.c Sun Oct 22 22:52:01 2006
@@ -3671,6 +3671,11 @@
/* Reboot */
FreeConsole();
+
+ /// THE FOLLOWING DPRINT IS FOR THE SYSTEM REGRESSION TOOL
+ /// DO NOT REMOVE!!!
+ DPRINT1("SYSREG_CHECKPOINT:USETUP_COMPLETE");
+
NtShutdownSystem(ShutdownReboot);
NtTerminateProcess(NtCurrentProcess(), 0);
}