#define NDEBUG
#include <debug.h>
-extern ULONG DbgkpTraceLevel;
-
/* FUNCTIONS *****************************************************************/
HANDLE
VOID
NTAPI
-DbgkCreateThread(PVOID StartAddress)
+DbgkCreateThread(IN PETHREAD Thread,
+ IN PVOID StartAddress)
{
- PETHREAD Thread = PsGetCurrentThread();
PEPROCESS Process = PsGetCurrentProcess();
ULONG ProcessFlags;
IMAGE_INFO ImageInfo;
PTEB Teb;
PAGED_CODE();
+ /* Sanity check */
+ ASSERT(Thread == PsGetCurrentThread());
+
/* Try ORing in the create reported and image notify flags */
- ProcessFlags = InterlockedOr((PLONG)&Process->Flags,
- PSF_CREATE_REPORTED_BIT |
- PSF_IMAGE_NOTIFY_DONE_BIT);
+ ProcessFlags = PspSetProcessFlag(Process,
+ PSF_CREATE_REPORTED_BIT |
+ PSF_IMAGE_NOTIFY_DONE_BIT);
/* Check if we were the first to set them or if another thread raced us */
if (!(ProcessFlags & PSF_IMAGE_NOTIFY_DONE_BIT) && (PsImageNotifyEnabled))
{
/* Otherwise, do it just for the thread */
CreateThread->SubSystemKey = 0;
- CreateThread->StartAddress = NULL;
+ CreateThread->StartAddress = StartAddress;
/* Setup the API Message */
ApiMessage.h.u1.Length = sizeof(DBGKM_MSG) << 16 |
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) ||
- !(Process->DebugPort) ||
- (Thread->DeadThread) ||
- (KeGetPreviousMode() == KernelMode))
+ /* Check if this thread is kernel, hidden or doesn't have a debug port */
+ if ((ExGetPreviousMode() == KernelMode) ||
+ (Thread->HideFromDebugger) ||
+ !(Process->DebugPort))
{
/* Don't notify the debugger */
return;
PETHREAD Thread = PsGetCurrentThread();
PAGED_CODE();
- /* Check if this thread is hidden, doesn't have a debug port, or died */
- if ((Thread->HideFromDebugger) ||
- !(Process->DebugPort) ||
- (Thread->DeadThread) ||
- (KeGetPreviousMode() == KernelMode))
+ /* Check if this thread is kernel, hidden or doesn't have a debug port */
+ if ((ExGetPreviousMode() == KernelMode) ||
+ (Thread->HideFromDebugger) ||
+ !(Process->DebugPort))
{
/* Don't notify the debugger */
return;
/* Send the message */
DbgkpSendApiMessage(&ApiMessage, TRUE);
}
-
-/* EOF */