NTSTATUS CsrNewThread( VOID ) /*++ Routine Description: This function is called by each new thread (except the first thread in a process.) It's function is to call the subsystem to notify it that a new thread is starting. Arguments: None. Return Value: Status Code from either client or server --*/ { return NtRegisterThreadTerminatePort( CsrPortHandle ); }
NTSTATUS DbgUiConnectToDbg( VOID ) /*++ Routine Description: This routine makes a connection between the caller and the DbgUi port in the Dbg subsystem. In addition to returning a handle to a port object, a handle to a state change semaphore is returned. This semaphore is used in DbgUiWaitStateChange APIs. Arguments: None. Return Value: TBD. --*/ { NTSTATUS st; UNICODE_STRING PortName; ULONG ConnectionInformationLength; SECURITY_QUALITY_OF_SERVICE DynamicQos; // // if app is already connected, don't reconnect // st = STATUS_SUCCESS; if ( !DbgUiApiPort ) { // // Set up the security quality of service parameters to use over the // port. Use the most efficient (least overhead) - which is dynamic // rather than static tracking. // DynamicQos.ImpersonationLevel = SecurityImpersonation; DynamicQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING; DynamicQos.EffectiveOnly = TRUE; RtlInitUnicodeString(&PortName,L"\\DbgUiApiPort"); ConnectionInformationLength = sizeof(DbgStateChangeSemaphore); st = NtConnectPort( &DbgUiApiPort, &PortName, &DynamicQos, NULL, NULL, NULL, (PVOID)&DbgStateChangeSemaphore, &ConnectionInformationLength ); if ( NT_SUCCESS(st) ) { NtRegisterThreadTerminatePort(DbgUiApiPort); } else { DbgUiApiPort = NULL; } } return st; }