[REFORMATTING]

- Reindent the dbgbuffer.c code to the ReactOS Standard Indentation.

svn path=/trunk/; revision=54662
This commit is contained in:
Aleksey Bragin 2011-12-16 15:45:09 +00:00
parent ce424af08c
commit b8928d9e26

View file

@ -1,8 +1,8 @@
/* COPYRIGHT: See COPYING in the top level directory /* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
* FILE: lib/rtl/dbgbuffer.c * FILE: lib/rtl/dbgbuffer.c
* PROGRAMER: James Tabor * PROGRAMER: James Tabor
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -14,9 +14,10 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
/* /*
* @unimplemented * @unimplemented
*/ */
PRTL_DEBUG_INFORMATION NTAPI PRTL_DEBUG_INFORMATION
NTAPI
RtlCreateQueryDebugBuffer(IN ULONG Size, RtlCreateQueryDebugBuffer(IN ULONG Size,
IN BOOLEAN EventPair) IN BOOLEAN EventPair)
{ {
@ -24,16 +25,13 @@ RtlCreateQueryDebugBuffer(IN ULONG Size,
PRTL_DEBUG_INFORMATION Buf = NULL; PRTL_DEBUG_INFORMATION Buf = NULL;
SIZE_T ViewSize = 100 * PAGE_SIZE; SIZE_T ViewSize = 100 * PAGE_SIZE;
Status = NtAllocateVirtualMemory( NtCurrentProcess(), Status = NtAllocateVirtualMemory(NtCurrentProcess(),
(PVOID*)&Buf, (PVOID*)&Buf,
0, 0,
&ViewSize, &ViewSize,
MEM_COMMIT, MEM_COMMIT,
PAGE_READWRITE); PAGE_READWRITE);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status)) return NULL;
{
return NULL;
}
Buf->ViewBaseClient = Buf; Buf->ViewBaseClient = Buf;
Buf->ViewSize = (ULONG)ViewSize; Buf->ViewSize = (ULONG)ViewSize;
@ -44,16 +42,17 @@ RtlCreateQueryDebugBuffer(IN ULONG Size,
} }
/* /*
* @unimplemented * @unimplemented
*/ */
NTSTATUS NTAPI NTSTATUS
NTAPI
RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION Buf) RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION Buf)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
if (NULL != Buf) if (NULL != Buf)
{ {
Status = NtFreeVirtualMemory( NtCurrentProcess(), Status = NtFreeVirtualMemory(NtCurrentProcess(),
(PVOID)Buf, (PVOID)Buf,
(PSIZE_T)&Buf->ViewSize, /* FIXME: not portable! */ (PSIZE_T)&Buf->ViewSize, /* FIXME: not portable! */
MEM_RELEASE); MEM_RELEASE);
@ -66,10 +65,11 @@ RtlDestroyQueryDebugBuffer(IN PRTL_DEBUG_INFORMATION Buf)
} }
/* /*
* Based on lib/epsapi/enum/modules.c by KJK::Hyperion. * Based on lib/epsapi/enum/modules.c by KJK::Hyperion.
* *
*/ */
NTSTATUS NTAPI NTSTATUS
NTAPI
RtlpQueryRemoteProcessModules(HANDLE ProcessHandle, RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
IN PRTL_PROCESS_MODULES Modules OPTIONAL, IN PRTL_PROCESS_MODULES Modules OPTIONAL,
IN ULONG Size OPTIONAL, IN ULONG Size OPTIONAL,
@ -90,7 +90,7 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
DPRINT("RtlpQueryRemoteProcessModules Start\n"); DPRINT("RtlpQueryRemoteProcessModules Start\n");
/* query the process basic information (includes the PEB address) */ /* query the process basic information (includes the PEB address) */
Status = NtQueryInformationProcess ( ProcessHandle, Status = NtQueryInformationProcess(ProcessHandle,
ProcessBasicInformation, ProcessBasicInformation,
&pbiInfo, &pbiInfo,
sizeof(PROCESS_BASIC_INFORMATION), sizeof(PROCESS_BASIC_INFORMATION),
@ -115,11 +115,11 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
} }
/* get the address of the PE Loader data */ /* get the address of the PE Loader data */
Status = NtReadVirtualMemory ( ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
&(pbiInfo.PebBaseAddress->Ldr), &(pbiInfo.PebBaseAddress->Ldr),
&ppldLdrData, &ppldLdrData,
sizeof(ppldLdrData), sizeof(ppldLdrData),
NULL ); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -133,11 +133,11 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
pleListHead = &ppldLdrData->InLoadOrderModuleList; pleListHead = &ppldLdrData->InLoadOrderModuleList;
/* get the address of the first element in the list */ /* get the address of the first element in the list */
Status = NtReadVirtualMemory ( ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
&(ppldLdrData->InLoadOrderModuleList.Flink), &(ppldLdrData->InLoadOrderModuleList.Flink),
&pleCurEntry, &pleCurEntry,
sizeof(pleCurEntry), sizeof(pleCurEntry),
NULL ); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -148,27 +148,26 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
while(pleCurEntry != pleListHead) while(pleCurEntry != pleListHead)
{ {
UNICODE_STRING Unicode; UNICODE_STRING Unicode;
WCHAR Buffer[256 * sizeof(WCHAR)]; WCHAR Buffer[256 * sizeof(WCHAR)];
/* read the current module */ /* read the current module */
Status = NtReadVirtualMemory ( ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
CONTAINING_RECORD(pleCurEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks), CONTAINING_RECORD(pleCurEntry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks),
&lmModule, &lmModule,
sizeof(LDR_DATA_TABLE_ENTRY), sizeof(LDR_DATA_TABLE_ENTRY),
NULL ); NULL);
/* Import module name from remote Process user space. */ /* Import module name from remote Process user space. */
Unicode.Length = lmModule.FullDllName.Length; Unicode.Length = lmModule.FullDllName.Length;
Unicode.MaximumLength = lmModule.FullDllName.MaximumLength; Unicode.MaximumLength = lmModule.FullDllName.MaximumLength;
Unicode.Buffer = Buffer; Unicode.Buffer = Buffer;
Status = NtReadVirtualMemory ( ProcessHandle, Status = NtReadVirtualMemory(ProcessHandle,
lmModule.FullDllName.Buffer, lmModule.FullDllName.Buffer,
Unicode.Buffer, Unicode.Buffer,
Unicode.Length, Unicode.Length,
NULL ); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
@ -226,9 +225,10 @@ RtlpQueryRemoteProcessModules(HANDLE ProcessHandle,
} }
/* /*
* @unimplemented * @unimplemented
*/ */
NTSTATUS NTAPI NTSTATUS
NTAPI
RtlQueryProcessDebugInformation(IN ULONG ProcessId, RtlQueryProcessDebugInformation(IN ULONG ProcessId,
IN ULONG DebugInfoMask, IN ULONG DebugInfoMask,
IN OUT PRTL_DEBUG_INFORMATION Buf) IN OUT PRTL_DEBUG_INFORMATION Buf)
@ -241,17 +241,17 @@ RtlQueryProcessDebugInformation(IN ULONG ProcessId,
DPRINT("QueryProcessDebugInformation Start\n"); DPRINT("QueryProcessDebugInformation Start\n");
/* /*
Currently ROS can not read-only from kenrel space, and doesn't Currently ROS can not read-only from kenrel space, and doesn't
check for boundaries inside kernel space that are page protected check for boundaries inside kernel space that are page protected
from every one but the kernel. aka page 0 - 2 from every one but the kernel. aka page 0 - 2
*/ */
if (ProcessId <= 1) if (ProcessId <= 1)
{ {
Status = STATUS_ACCESS_VIOLATION; Status = STATUS_ACCESS_VIOLATION;
} }
else else
if (Pid == ProcessId) if (Pid == ProcessId)
{ {
if (DebugInfoMask & RTL_DEBUG_QUERY_MODULES) if (DebugInfoMask & RTL_DEBUG_QUERY_MODULES)
{ {
@ -262,10 +262,10 @@ if (Pid == ProcessId)
Mp = (PRTL_PROCESS_MODULES)(Buf + Buf->OffsetFree); Mp = (PRTL_PROCESS_MODULES)(Buf + Buf->OffsetFree);
/* I like this better than the do & while loop. */ /* I like this better than the do & while loop. */
Status = LdrQueryProcessModuleInformation( NULL, Status = LdrQueryProcessModuleInformation(NULL,
0 , 0,
&ReturnSize); &ReturnSize);
Status = LdrQueryProcessModuleInformation( Mp, Status = LdrQueryProcessModuleInformation(Mp,
ReturnSize , ReturnSize ,
&ReturnSize); &ReturnSize);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
@ -287,9 +287,11 @@ if (Pid == ProcessId)
HSize = sizeof(RTL_PROCESS_HEAPS); HSize = sizeof(RTL_PROCESS_HEAPS);
if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_TAGS) if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_TAGS)
{ {
// TODO
} }
if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_BLOCKS) if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_BLOCKS)
{ {
// TODO
} }
Buf->Heaps = Hp; Buf->Heaps = Hp;
Buf->OffsetFree = Buf->OffsetFree + HSize; Buf->OffsetFree = Buf->OffsetFree + HSize;
@ -309,9 +311,9 @@ if (Pid == ProcessId)
DPRINT("QueryProcessDebugInformation end \n"); DPRINT("QueryProcessDebugInformation end \n");
DPRINT("QueryDebugInfo : 0x%lx\n", Buf->OffsetFree); DPRINT("QueryDebugInfo : 0x%lx\n", Buf->OffsetFree);
} }
else else
{ {
HANDLE hProcess; HANDLE hProcess;
CLIENT_ID ClientId; CLIENT_ID ClientId;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
@ -326,7 +328,7 @@ else
NULL, NULL,
NULL); NULL);
Status = NtOpenProcess( &hProcess, Status = NtOpenProcess(&hProcess,
(PROCESS_ALL_ACCESS), (PROCESS_ALL_ACCESS),
&ObjectAttributes, &ObjectAttributes,
&ClientId ); &ClientId );
@ -343,12 +345,12 @@ else
Mp = (PRTL_PROCESS_MODULES)(Buf + Buf->OffsetFree); Mp = (PRTL_PROCESS_MODULES)(Buf + Buf->OffsetFree);
Status = RtlpQueryRemoteProcessModules( hProcess, Status = RtlpQueryRemoteProcessModules(hProcess,
NULL, NULL,
0, 0,
&ReturnSize); &ReturnSize);
Status = RtlpQueryRemoteProcessModules( hProcess, Status = RtlpQueryRemoteProcessModules(hProcess,
Mp, Mp,
ReturnSize , ReturnSize ,
&ReturnSize); &ReturnSize);
@ -371,9 +373,11 @@ else
HSize = sizeof(RTL_PROCESS_HEAPS); HSize = sizeof(RTL_PROCESS_HEAPS);
if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_TAGS) if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_TAGS)
{ {
// TODO
} }
if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_BLOCKS) if (DebugInfoMask & RTL_DEBUG_QUERY_HEAP_BLOCKS)
{ {
// TODO
} }
Buf->Heaps = Hp; Buf->Heaps = Hp;
Buf->OffsetFree = Buf->OffsetFree + HSize; Buf->OffsetFree = Buf->OffsetFree + HSize;
@ -393,9 +397,9 @@ else
DPRINT("QueryProcessDebugInformation end \n"); DPRINT("QueryProcessDebugInformation end \n");
DPRINT("QueryDebugInfo : 0x%lx\n", Buf->OffsetFree); DPRINT("QueryDebugInfo : 0x%lx\n", Buf->OffsetFree);
} }
return Status;
return Status;
} }
/* EOL */ /* EOL */