@@ -146,54 +146,75 @@ ExpDebuggerWorker(
146146 }
147147}
148148
149- /*++
150- * @name NtSystemDebugControl
151- * @implemented
149+ /**
150+ * @brief
151+ * Perform various queries to the kernel debugger.
152152 *
153- * Perform various queries to debugger.
154- * This API is subject to test-case creation to further evaluate its
155- * abilities (if needed to at all)
153+ * @param[in] Command
154+ * A SYSDBG_COMMAND value describing the kernel debugger command to perform.
156155 *
157- * See: http://www.osronline.com/showthread.cfm?link=93915
158- * http://void.ru/files/Ntexapi.h
159- * http://www.codeguru.com/code/legacy/system/ntexapi.zip
160- * http://www.securityfocus.com/bid/9694
156+ * @param[in] InputBuffer
157+ * Pointer to a user-provided input command-specific buffer, whose length
158+ * is given by InputBufferLength.
161159 *
162- * @param ControlCode
163- * Description of the parameter. Wrapped to more lines on ~70th
164- * column.
160+ * @param[in] InputBufferLength
161+ * The size (in bytes) of the buffer pointed by InputBuffer.
165162 *
166- * @param InputBuffer
167- * FILLME
163+ * @param[out] OutputBuffer
164+ * Pointer to a user-provided command-specific output buffer, whose length
165+ * is given by OutputBufferLength.
168166 *
169- * @param InputBufferLength
170- * FILLME
167+ * @param[in] OutputBufferLength
168+ * The size (in bytes) of the buffer pointed by OutputBuffer.
171169 *
172- * @param OutputBuffer
173- * FILLME
170+ * @param[out] ReturnLength
171+ * Optional pointer to a ULONG variable that receives the actual length of
172+ * data written written in the output buffer. It is always zero, except for
173+ * the live dump commands where an actual non-zero length is returned.
174174 *
175- * @param OutputBufferLength
176- * FILLME
175+ * @return
176+ * STATUS_SUCCESS in case of success, or a proper error code otherwise.
177177 *
178- * @param ReturnLength
179- * FILLME
178+ * @remarks
180179 *
181- * @return STATUS_SUCCESS in case of success, proper error code otherwise
180+ * - The caller must have SeDebugPrivilege, otherwise the function fails
181+ * with STATUS_ACCESS_DENIED.
182182 *
183- * @remarks None
183+ * - Only the live dump commands: SysDbgGetTriageDump, and SysDbgGetLiveKernelDump
184+ * (Win8.1+) are available even if the debugger is disabled or absent.
184185 *
185- *--*/
186+ * - The following system-critical commands are not accessible anymore
187+ * for user-mode usage with this API on NT 5.2+ (Windows 2003 SP1 and later)
188+ * systems:
189+ *
190+ * SysDbgQueryVersion,
191+ * SysDbgReadVirtual and SysDbgWriteVirtual,
192+ * SysDbgReadPhysical and SysDbgWritePhysical,
193+ * SysDbgReadControlSpace and SysDbgWriteControlSpace,
194+ * SysDbgReadIoSpace and SysDbgWriteIoSpace,
195+ * SysDbgReadMsr and SysDbgWriteMsr,
196+ * SysDbgReadBusData and SysDbgWriteBusData,
197+ * SysDbgCheckLowMemory.
198+ *
199+ * For these, NtSystemDebugControl() will return STATUS_NOT_IMPLEMENTED.
200+ * They are now available from kernel-mode only with KdSystemDebugControl().
201+ *
202+ * @note
203+ * See: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2339
204+ *
205+ * @see KdSystemDebugControl()
206+ **/
186207NTSTATUS
187208NTAPI
188209NtSystemDebugControl (
189- _In_ SYSDBG_COMMAND ControlCode ,
210+ _In_ SYSDBG_COMMAND Command ,
190211 _In_reads_bytes_ (InputBufferLength ) PVOID InputBuffer ,
191212 _In_ ULONG InputBufferLength ,
192213 _Out_writes_bytes_ (OutputBufferLength ) PVOID OutputBuffer ,
193214 _In_ ULONG OutputBufferLength ,
194215 _Out_opt_ PULONG ReturnLength )
195216{
196- switch (ControlCode )
217+ switch (Command )
197218 {
198219 case SysDbgQueryModuleInformation :
199220 case SysDbgQueryTraceInformation :
@@ -226,10 +247,11 @@ NtSystemDebugControl(
226247 case SysDbgSetPrintBufferSize :
227248 case SysDbgGetKdUmExceptionEnable :
228249 case SysDbgSetKdUmExceptionEnable :
250+
229251 case SysDbgGetKdBlockEnable :
230252 case SysDbgSetKdBlockEnable :
231253 return KdSystemDebugControl (
232- ControlCode ,
254+ Command ,
233255 InputBuffer , InputBufferLength ,
234256 OutputBuffer , OutputBufferLength ,
235257 ReturnLength , KeGetPreviousMode ());
0 commit comments