Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

dbgkp.h File Reference

#include "ntos.h"
#include "wdbgexts.h"
#include "ntdbg.h"
#include <zwapi.h>
#include <string.h>

Go to the source code of this file.

Defines

#define NOEXTAPI

Functions

NTSTATUS DbgkpSendApiMessage (IN OUT PDBGKM_APIMSG ApiMsg, IN PVOID Port, IN BOOLEAN SuspendProcess)
VOID DbgkpSuspendProcess (IN BOOLEAN CreateDeleteLockHeld)
VOID DbgkpResumeProcess (IN BOOLEAN CreateDeleteLockHeld)
HANDLE DbgkpSectionHandleToFileHandle (IN HANDLE SectionHandle)


Define Documentation

#define NOEXTAPI
 

Definition at line 34 of file dbgkp.h.


Function Documentation

VOID DbgkpResumeProcess IN BOOLEAN  CreateDeleteLockHeld  ) 
 

Definition at line 86 of file dbgkproc.c.

References KernelMode, KeThawAllThreads(), PAGED_CODE, PsGetCurrentProcess, PsLockProcess(), PsLockWaitForever, and PsUnlockProcess().

Referenced by DbgkExitThread(), and DbgkpSendApiMessage().

00092 : 00093 00094 This function causes all threads in the calling process except for 00095 the calling thread to resume. 00096 00097 Arguments: 00098 00099 CreateDeleteLockHeld - Supplies a flag that specifies whether or not 00100 the caller is holding the process create delete lock. If the 00101 caller holds the lock, than this function will not aquire the 00102 lock before suspending the process. 00103 00104 Return Value: 00105 00106 None. 00107 00108 --*/ 00109 00110 { 00111 00112 PEPROCESS Process; 00113 00114 PAGED_CODE(); 00115 00116 Process = PsGetCurrentProcess(); 00117 // 00118 // Thaw the execution of all threads in the current process, but 00119 // the calling thread. 00120 // 00121 00122 if ( !CreateDeleteLockHeld ) { 00123 PsLockProcess(Process,KernelMode,PsLockWaitForever); 00124 } 00125 00126 KeThawAllThreads(); 00127 00128 if ( !CreateDeleteLockHeld ) { 00129 PsUnlockProcess(Process); 00130 } 00131 00132 return; 00133 }

HANDLE DbgkpSectionHandleToFileHandle IN HANDLE  SectionHandle  ) 
 

Definition at line 136 of file dbgkproc.c.

References ExFreePool(), FileName, Handle, MmGetFileNameForSection(), NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, RtlAnsiStringToUnicodeString(), RtlFreeUnicodeString(), Status, TRUE, and ZwOpenFile().

Referenced by DbgkCreateThread(), and DbgkMapViewOfSection().

00142 : 00143 00144 This function Opens a handle to the file associated with the processes 00145 section. The file is opened such that it can be dupped all the way to 00146 the UI where the UI can either map the file or read the file to get 00147 the debug info. 00148 00149 Arguments: 00150 00151 SectionHandle - Supplies a handle to the section whose associated file 00152 is to be opened. 00153 00154 Return Value: 00155 00156 NULL - The file could not be opened. 00157 00158 NON-NULL - Returns a handle to the file associated with the specified 00159 section. 00160 00161 --*/ 00162 00163 { 00164 NTSTATUS Status; 00165 ANSI_STRING FileName; 00166 UNICODE_STRING UnicodeFileName; 00167 OBJECT_ATTRIBUTES Obja; 00168 IO_STATUS_BLOCK IoStatusBlock; 00169 HANDLE Handle; 00170 00171 PAGED_CODE(); 00172 00173 Status = MmGetFileNameForSection(SectionHandle, (PSTRING)&FileName); 00174 if ( !NT_SUCCESS(Status) ) { 00175 return NULL; 00176 } 00177 00178 Status = RtlAnsiStringToUnicodeString(&UnicodeFileName,&FileName,TRUE); 00179 ExFreePool(FileName.Buffer); 00180 if ( !NT_SUCCESS(Status) ) { 00181 return NULL; 00182 } 00183 00184 InitializeObjectAttributes( 00185 &Obja, 00186 &UnicodeFileName, 00187 OBJ_CASE_INSENSITIVE, 00188 NULL, 00189 NULL 00190 ); 00191 00192 Status = ZwOpenFile( 00193 &Handle, 00194 (ACCESS_MASK)(GENERIC_READ | SYNCHRONIZE), 00195 &Obja, 00196 &IoStatusBlock, 00197 FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, 00198 FILE_SYNCHRONOUS_IO_NONALERT 00199 ); 00200 RtlFreeUnicodeString(&UnicodeFileName); 00201 if ( !NT_SUCCESS(Status) ) { 00202 return NULL; 00203 } 00204 else { 00205 return Handle; 00206 } 00207 }

NTSTATUS DbgkpSendApiMessage IN OUT PDBGKM_APIMSG  ApiMsg,
IN PVOID  Port,
IN BOOLEAN  SuspendProcess
 

Definition at line 31 of file dbgkport.c.

References DbgkpResumeProcess(), DbgkpSuspendProcess(), FALSE, LpcRequestWaitReplyPort(), NT_SUCCESS, NTSTATUS(), NULL, PAGED_CODE, PsGetCurrentProcess, and TRUE.

Referenced by DbgkCreateThread(), DbgkExitProcess(), DbgkExitThread(), DbgkForwardException(), DbgkMapViewOfSection(), and DbgkUnMapViewOfSection().

00039 : 00040 00041 This function sends the specified API message over the specified 00042 port. It is the callers responsibility to format the API message 00043 prior to calling this function. 00044 00045 If the SuspendProcess flag is supplied, then all threads in the 00046 calling process are first suspended. Upon receipt of the reply 00047 message, the threads are resumed. 00048 00049 Arguments: 00050 00051 ApiMsg - Supplies the API message to send. 00052 00053 Port - Supplies the address of a port to send the api message. 00054 00055 SuspendProcess - A flag that if set to true, causes all of the 00056 threads in the process to be suspended prior to the call, 00057 and resumed upon receipt of a reply. 00058 00059 Return Value: 00060 00061 TBD 00062 00063 --*/ 00064 00065 { 00066 NTSTATUS st; 00067 ULONG_PTR MessageBuffer[PORT_MAXIMUM_MESSAGE_LENGTH/sizeof(ULONG_PTR)]; 00068 00069 PAGED_CODE(); 00070 00071 if ( SuspendProcess ) { 00072 DbgkpSuspendProcess(FALSE); 00073 } 00074 00075 ApiMsg->ReturnedStatus = STATUS_PENDING; 00076 00077 PsGetCurrentProcess()->CreateProcessReported = TRUE; 00078 00079 st = LpcRequestWaitReplyPort( 00080 Port, 00081 (PPORT_MESSAGE) ApiMsg, 00082 (PPORT_MESSAGE) &MessageBuffer[0] 00083 ); 00084 00085 ZwFlushInstructionCache(NtCurrentProcess(), NULL, 0); 00086 if ( NT_SUCCESS(st) ) { 00087 RtlMoveMemory(ApiMsg,MessageBuffer,sizeof(*ApiMsg)); 00088 } 00089 if ( SuspendProcess ) { 00090 DbgkpResumeProcess(FALSE); 00091 } 00092 00093 return st; 00094 }

VOID DbgkpSuspendProcess IN BOOLEAN  CreateDeleteLockHeld  ) 
 

Definition at line 36 of file dbgkproc.c.

References KeFreezeAllThreads(), KernelMode, PAGED_CODE, PsGetCurrentProcess, PsLockProcess(), PsLockWaitForever, and PsUnlockProcess().

Referenced by DbgkExitThread(), and DbgkpSendApiMessage().

00042 : 00043 00044 This function causes all threads in the calling process except for 00045 the calling thread to suspend. 00046 00047 Arguments: 00048 00049 CreateDeleteLockHeld - Supplies a flag that specifies whether or not 00050 the caller is holding the process create delete lock. If the 00051 caller holds the lock, than this function will not aquire the 00052 lock before suspending the process. 00053 00054 Return Value: 00055 00056 None. 00057 00058 --*/ 00059 00060 { 00061 PEPROCESS Process; 00062 00063 PAGED_CODE(); 00064 00065 Process = PsGetCurrentProcess(); 00066 00067 // 00068 // Freeze the execution of all threads in the current process, but 00069 // the calling thread. 00070 // 00071 if ( !CreateDeleteLockHeld ) { 00072 PsLockProcess(Process,KernelMode,PsLockWaitForever); 00073 } 00074 00075 KeFreezeAllThreads(); 00076 00077 if ( !CreateDeleteLockHeld ) { 00078 PsUnlockProcess(Process); 00079 } 00080 00081 00082 return; 00083 }


Generated on Sat May 15 19:43:23 2004 for test by doxygen 1.3.7