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

pscid.c

Go to the documentation of this file.
00001 00002 /*++ 00003 00004 Copyright (c) 1989 Microsoft Corporation 00005 00006 Module Name: 00007 00008 pscid.c 00009 00010 Abstract: 00011 00012 This module implements the Client ID related services. 00013 00014 00015 Author: 00016 00017 Mark Lucovsky (markl) 25-Apr-1989 00018 Jim Kelly (JimK) 2-August-1990 00019 00020 Revision History: 00021 00022 --*/ 00023 00024 #include "psp.h" 00025 00026 NTSTATUS 00027 PsLookupProcessThreadByCid( 00028 IN PCLIENT_ID Cid, 00029 OUT PEPROCESS *Process OPTIONAL, 00030 OUT PETHREAD *Thread 00031 ) 00032 00033 /*++ 00034 00035 Routine Description: 00036 00037 This function accepts The Client ID of a thread, and returns a 00038 referenced pointer to the thread, and possibly a referenced pointer 00039 to the process. 00040 00041 Arguments: 00042 00043 Cid - Specifies the Client ID of the thread. 00044 00045 Process - If specified, returns a referenced pointer to the process 00046 specified in the Cid. 00047 00048 Thread - Returns a referenced pointer to the thread specified in the 00049 Cid. 00050 00051 Return Value: 00052 00053 STATUS_SUCCESS - A process and thread were located based on the contents 00054 of the Cid. 00055 00056 STATUS_INVALID_CID - The specified Cid is invalid. 00057 00058 --*/ 00059 00060 { 00061 00062 PHANDLE_TABLE_ENTRY CidEntry; 00063 PETHREAD lThread; 00064 NTSTATUS Status; 00065 00066 CidEntry = ExMapHandleToPointer(PspCidTable, Cid->UniqueThread); 00067 Status = STATUS_INVALID_CID; 00068 if (CidEntry != NULL) { 00069 lThread = (PETHREAD)CidEntry->Object; 00070 if ((lThread != (PETHREAD)PSP_INVALID_ID) && 00071 ( 00072 lThread->Tcb.Header.Type == ThreadObject && 00073 lThread->Cid.UniqueProcess == Cid->UniqueProcess && 00074 lThread->GrantedAccess 00075 ) ) { 00076 if (ARGUMENT_PRESENT(Process)) { 00077 *Process = THREAD_TO_PROCESS(lThread); 00078 ObReferenceObject(*Process); 00079 } 00080 00081 ObReferenceObject(lThread); 00082 *Thread = lThread; 00083 Status = STATUS_SUCCESS; 00084 } 00085 00086 ExUnlockHandleTableEntry(PspCidTable, CidEntry); 00087 } 00088 00089 return Status; 00090 } 00091 00092 00093 NTSTATUS 00094 PsLookupProcessByProcessId( 00095 IN HANDLE ProcessId, 00096 OUT PEPROCESS *Process 00097 ) 00098 00099 /*++ 00100 00101 Routine Description: 00102 00103 This function accepts the process id of a process and returns a 00104 referenced pointer to the process. 00105 00106 Arguments: 00107 00108 ProcessId - Specifies the Process ID of the process. 00109 00110 Process - Returns a referenced pointer to the process specified by the 00111 process id. 00112 00113 Return Value: 00114 00115 STATUS_SUCCESS - A process was located based on the contents of 00116 the process id. 00117 00118 STATUS_INVALID_PARAMETER - The process was not found. 00119 00120 --*/ 00121 00122 { 00123 00124 PHANDLE_TABLE_ENTRY CidEntry; 00125 PEPROCESS lProcess; 00126 NTSTATUS Status; 00127 00128 CidEntry = ExMapHandleToPointer(PspCidTable, ProcessId); 00129 Status = STATUS_INVALID_PARAMETER; 00130 if (CidEntry != NULL) { 00131 lProcess = (PEPROCESS)CidEntry->Object; 00132 if (lProcess != (PEPROCESS)PSP_INVALID_ID && lProcess->Pcb.Header.Type == ProcessObject && lProcess->GrantedAccess ) { 00133 ObReferenceObject(lProcess); 00134 *Process = lProcess; 00135 Status = STATUS_SUCCESS; 00136 } 00137 00138 ExUnlockHandleTableEntry(PspCidTable, CidEntry); 00139 } 00140 00141 return Status; 00142 } 00143 00144 00145 NTSTATUS 00146 PsLookupThreadByThreadId( 00147 IN HANDLE ThreadId, 00148 OUT PETHREAD *Thread 00149 ) 00150 00151 /*++ 00152 00153 Routine Description: 00154 00155 This function accepts the thread id of a thread and returns a 00156 referenced pointer to the thread. 00157 00158 Arguments: 00159 00160 ThreadId - Specifies the Thread ID of the thread. 00161 00162 Thread - Returns a referenced pointer to the thread specified by the 00163 thread id. 00164 00165 Return Value: 00166 00167 STATUS_SUCCESS - A thread was located based on the contents of 00168 the thread id. 00169 00170 STATUS_INVALID_PARAMETER - The thread was not found. 00171 00172 --*/ 00173 00174 { 00175 00176 PHANDLE_TABLE_ENTRY CidEntry; 00177 PETHREAD lThread; 00178 NTSTATUS Status; 00179 00180 CidEntry = ExMapHandleToPointer(PspCidTable, ThreadId); 00181 Status = STATUS_INVALID_PARAMETER; 00182 if (CidEntry != NULL) { 00183 lThread = (PETHREAD)CidEntry->Object; 00184 if (lThread != (PETHREAD)PSP_INVALID_ID && lThread->Tcb.Header.Type == ThreadObject && lThread->GrantedAccess ) { 00185 00186 ObReferenceObject(lThread); 00187 *Thread = lThread; 00188 Status = STATUS_SUCCESS; 00189 } 00190 00191 ExUnlockHandleTableEntry(PspCidTable, CidEntry); 00192 } 00193 00194 return Status; 00195 }

Generated on Sat May 15 19:41:31 2004 for test by doxygen 1.3.7