The undocumented way of NtOpenProcess.
103{
104 NTSTATUS Status = STATUS_SUCCESS;
105 ACCESS_STATE AccessState;
106 CHAR AuxData[0x200] = {0};
107 PEPROCESS ProcessObject =
NULL;
108 HANDLE ProcHandle =
NULL;
109
111 &AccessState,
112 AuxData,
114 (PGENERIC_MAPPING)((PCHAR)*PsProcessType + 52));
115
116 if (!NT_SUCCESS(Status))
117 {
118 return Status;
119 }
120
121 AccessState.PreviouslyGrantedAccess |= AccessState.RemainingDesiredAccess;
122 AccessState.RemainingDesiredAccess = 0;
123
124 Status = PsLookupProcessByProcessId(ProcessId, &ProcessObject);
125
126 if (!NT_SUCCESS(Status))
127 {
129 return Status;
130 }
131 Status = ObOpenObjectByPointer(
132 ProcessObject,
133 0,
134 &AccessState,
135 0,
136 *PsProcessType,
137 AccessMode,
138 &ProcHandle);
139
141
142 ObDereferenceObject(ProcessObject);
143
144 if (NT_SUCCESS(Status))
145 *ProcessHandle = ProcHandle;
146
147 return Status;
148}
PHANDLE ACCESS_MASK DesiredAccess
Definition Hooks.h:130