From b3ea65f0e49df49e14ab2365626b433640e0363e Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Tue, 25 Apr 2000 23:22:57 +0000 Subject: [PATCH] Partially implemented (handlers only) NTOSKRNL.NtQuerySystemInformation() and NTOSKRNL.NtSetSystemInformation(). --- Partially implemented (kernel32/process/proc.c) KERNEL32.GetPriorityClass(), KERNEL32.SetPriorityClass() and NTDLL.CsrSetPriorityClass() (stub only). Renamed (in include/csrss/csrss.h) priority class macros: #define CSR_PRIORITY_CLASS_NORMAL (0x10) #define CSR_PRIORITY_CLASS_IDLE (0x20) #define CSR_PRIORITY_CLASS_HIGH (0x40) #define CSR_PRIORITY_CLASS_REALTIME (0x80) --- Implemented (kernel32/misc/error.c) #include DWORD STDCALL SetLastErrorByStatus ( NTSTATUS Status ); to replace SetLastError(RtlNtStatusToDosError(Status)) in KERNEL32, and fixed KERNEL32.SetLastError() KERNEL32.GetLastError() to use the field in NT_TEB (LastError is per thread not per process). --- Implemented (lib/kernel32/sysinfo.c) GetSystemInfo() (to be completed). --- Fixed rosapps/sysutils/makefile to use ROS import libraries. --- Added QSI to the system utilities set. The target is writing a tool that can be used to query as much system information as possible from user mode (to be finished and tested only under nt4sp4/x86; it was NOT tested under ROS: it crashes immediately and needs NtQuerySystemInformation implemented!). svn path=/trunk/; revision=1137 --- reactos/apps/tests/lpc/conport.c | 18 +- reactos/include/csrss/csrss.h | 6 + reactos/include/ddk/defines.h | 16 + reactos/include/ddk/zw.h | 30 +- reactos/include/ddk/zwtypes.h | 757 ++++++-- reactos/include/fmifs.h | 4 +- reactos/include/internal/ps.h | 2 +- reactos/include/kernel32/error.h | 12 + reactos/include/ntdll/csr.h | 8 +- reactos/lib/fmifs/dllmain.c | 6 +- reactos/lib/kernel32/makefile | 4 +- reactos/lib/kernel32/misc/error.c | 21 +- reactos/lib/kernel32/misc/stubs.c | 60 +- reactos/lib/kernel32/misc/sysinfo.c | 100 + reactos/lib/kernel32/process/proc.c | 182 +- reactos/lib/kernel32/synch/critical.c | 5 +- reactos/lib/ntdll/csr/api.c | 19 +- reactos/lib/ntdll/def/ntdll.def | 3 +- reactos/lib/ntdll/def/ntdll.edf | 3 +- reactos/ntoskrnl/ex/sysinfo.c | 798 ++++++-- reactos/ntoskrnl/ex/time.c | 11 +- rosapps/rules.mak | 1 + rosapps/sysutils/chkdsk.c | 8 +- rosapps/sysutils/makefile | 111 +- rosapps/sysutils/qsi.c | 2548 +++++++++++++++++++++++++ rosapps/sysutils/shutdown.c | 7 +- 26 files changed, 4278 insertions(+), 462 deletions(-) create mode 100644 reactos/include/kernel32/error.h create mode 100644 reactos/lib/kernel32/misc/sysinfo.c create mode 100644 rosapps/sysutils/qsi.c diff --git a/reactos/apps/tests/lpc/conport.c b/reactos/apps/tests/lpc/conport.c index b63845637a5..2fd76a7e253 100644 --- a/reactos/apps/tests/lpc/conport.c +++ b/reactos/apps/tests/lpc/conport.c @@ -1,4 +1,4 @@ -/* $Id: conport.c,v 1.5 1999/07/17 23:10:12 ea Exp $ +/* $Id: conport.c,v 1.6 2000/04/25 23:22:46 ea Exp $ * * reactos/apps/lpc/conport.c * @@ -107,14 +107,14 @@ TryConnectPort(char *port_name) */ Port = 0; Status = ConnectPort( - & Port, - & PortName, - & ObjectAttributes, - 0, - 0, - 0, - 0, - LPC_CONNECT_FLAG5 + & Port, /* & PortHandle */ + & PortName, /* & PortName */ + & ObjectAttributes, /* & PortAttributes */ + NULL, /* & SecurityQos */ + NULL, /* & SectionInfo */ + NULL, /* & MapInfo */ + NULL, /* & MaxMessageSize */ + LPC_CONNECT_FLAG5 /* & ConnectInfoLength */ ); if (Status == STATUS_SUCCESS) { diff --git a/reactos/include/csrss/csrss.h b/reactos/include/csrss/csrss.h index c597e0ae0af..03d20c3fb5c 100644 --- a/reactos/include/csrss/csrss.h +++ b/reactos/include/csrss/csrss.h @@ -3,6 +3,12 @@ #include +#define CSR_PRIORITY_CLASS_NORMAL (0x10) +#define CSR_PRIORITY_CLASS_IDLE (0x20) +#define CSR_PRIORITY_CLASS_HIGH (0x40) +#define CSR_PRIORITY_CLASS_REALTIME (0x80) + + typedef struct { } CSRSS_CONNECT_PROCESS_REQUEST, PCSRSS_CONNECT_PROCESS_REQUEST; diff --git a/reactos/include/ddk/defines.h b/reactos/include/ddk/defines.h index 357e211ca4f..5b10ca521ff 100644 --- a/reactos/include/ddk/defines.h +++ b/reactos/include/ddk/defines.h @@ -243,4 +243,20 @@ enum #define FIRST_DEVICE_SPECIFIC_LEVEL (4) #define HIGH_LEVEL (FIRST_DEVICE_SPECIFIC_LEVEL + NR_DEVICE_SPECIFIC_LEVELS) +/* NT's IRQL */ +#if 0 +#define PASSIVE_LEVEL 0 // Passive release level +#define LOW_LEVEL 0 // Lowest interrupt level +#define APC_LEVEL 1 // APC interrupt level +#define DISPATCH_LEVEL 2 // Dispatcher level + +#define PROFILE_LEVEL 27 // timer used for profiling. +#define CLOCK1_LEVEL 28 // Interval clock 1 level - Not used on x86 +#define CLOCK2_LEVEL 28 // Interval clock 2 level +#define IPI_LEVEL 29 // Interprocessor interrupt level +#define POWER_LEVEL 30 // Power failure level +#define HIGH_LEVEL 31 // Highest interrupt level +#define SYNCH_LEVEL (IPI_LEVEL-1) // synchronization level +#endif + #endif /* ndef _DDK_DEFINES_H */ diff --git a/reactos/include/ddk/zw.h b/reactos/include/ddk/zw.h index 7e7cf11044e..548d554c4d5 100644 --- a/reactos/include/ddk/zw.h +++ b/reactos/include/ddk/zw.h @@ -1,5 +1,5 @@ -/* $Id: zw.h,v 1.28 2000/04/03 21:54:34 dwelch Exp $ +/* $Id: zw.h,v 1.29 2000/04/25 23:22:49 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -3379,19 +3379,19 @@ ZwQuerySystemEnvironmentValue( NTSTATUS STDCALL NtQuerySystemInformation( - IN CINT SystemInformationClass, - OUT PVOID SystemInformation, - IN ULONG Length, - OUT PULONG ResultLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + OUT PVOID SystemInformation, + IN ULONG Length, + OUT PULONG ResultLength ); NTSTATUS STDCALL ZwQuerySystemInformation( - IN CINT SystemInformationClass, - OUT PVOID SystemInformation, - IN ULONG Length, - OUT PULONG ResultLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + OUT PVOID SystemInformation, + IN ULONG Length, + OUT PULONG ResultLength ); /* @@ -4450,17 +4450,17 @@ ZwSetSystemEnvironmentValue( NTSTATUS STDCALL NtSetSystemInformation( - IN CINT SystemInformationClass, - IN PVOID SystemInformation, - IN ULONG SystemInformationLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + IN PVOID SystemInformation, + IN ULONG SystemInformationLength ); NTSTATUS STDCALL ZwSetSystemInformation( - IN CINT SystemInformationClass, - IN PVOID SystemInformation, - IN ULONG SystemInformationLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + IN PVOID SystemInformation, + IN ULONG SystemInformationLength ); /* diff --git a/reactos/include/ddk/zwtypes.h b/reactos/include/ddk/zwtypes.h index 432ff63d675..7394c42fffb 100644 --- a/reactos/include/ddk/zwtypes.h +++ b/reactos/include/ddk/zwtypes.h @@ -85,19 +85,590 @@ #define EventBasicInformation 0 // system information +// {Nt|Zw}{Query|Set}SystemInformation + +typedef +enum _SYSTEM_INFORMATION_CLASS +{ + SystemInformationClassMin = 0, + SystemBasicInformation = 0, /* Q */ + SystemProcessorInformation = 1, /* Q */ + SystemPerformanceInformation = 2, /* Q */ + SystemTimeInformation = 3, /* Q */ + SystemPathInformation = 4, + SystemProcessInformation = 5, /* Q */ + SystemServiceDescriptorTableInfo = 6, /* Q */ + SystemIoConfigInformation = 7, /* Q */ + SystemProcessorTimeInformation = 8, /* Q */ + SystemNtGlobalFlagInformation = 9, /* QS */ + SystemInformation10 = 10, + SystemModuleInformation = 11, /* Q */ + SystemResourceLockInformation = 12, /* Q */ + SystemInformation13 = 13, + SystemInformation14 = 14, + SystemInformation15 = 15, + SystemHandleInformation = 16, /* Q */ + SystemObjectInformation = 17, /* Q */ + SystemPageFileInformation = 18, /* Q */ + SystemInstructionEmulationInfo = 19, /* Q */ + SystemInformation20 = 20, + SystemCacheInformation = 21, /* QS */ + SystemPoolTagInformation = 22, /* Q (checked build only) */ + SystemProcessorScheduleInfo = 23, /* Q */ + SystemDpcInformation = 24, /* QS */ + SystemInformation25 = 25, + SystemLoadImage = 26, /* S (callable) */ + SystemUnloadImage = 27, /* S (callable) */ + SystemTimeAdjustmentInformation = 28, /* QS */ + SystemInformation29 = 29, + SystemInformation30 = 30, + SystemInformation31 = 31, + SystemCrashDumpSectionInfo = 32, /* Q */ + SystemProcessorFaultCountInfo = 33, /* Q */ + SystemCrashDumpStateInfo = 34, /* Q */ + SystemDebuggerInformation = 35, /* Q */ + SystemThreadSwitchCountersInfo = 36, /* Q */ + SystemQuotaInformation = 37, /* QS */ + SystemLoadDriver = 38, /* S */ + SystemPrioritySeparationInfo = 39, /* S */ + SystemInformation40 = 40, + SystemInformation41 = 41, + SystemInformation42 = 42, + SystemInformation43 = 43, + SystemTimeZoneInformation = 44, /* QS */ + SystemLookasideInformation = 45, /* Q */ + SystemInformationClassMax + +} SYSTEM_INFORMATION_CLASS; + +// SystemBasicInformation (0) +typedef +struct _SYSTEM_BASIC_INFORMATION +{ + DWORD AlwaysZero; + ULONG KeMaximumIncrement; + ULONG MmPageSize; + ULONG MmNumberOfPhysicalPages; + ULONG MmLowestPhysicalPage; + ULONG MmHighestPhysicalPage; + PVOID MmLowestUserAddress; + PVOID MmLowestUserAddress1; + PVOID MmHighestUserAddress; + DWORD KeActiveProcessors; + USHORT KeNumberProcessors; + +} SYSTEM_BASIC_INFORMATION, *PSYSTEM_BASIC_INFORMATION; + +// SystemProcessorInformation (1) +typedef +struct _SYSTEM_PROCESSOR_INFORMATION +{ + USHORT KeProcessorArchitecture; + USHORT KeProcessorLevel; + USHORT KeProcessorRevision; + USHORT AlwaysZero; + DWORD KeFeatureBits; + +} SYSTEM_PROCESSOR_INFORMATION, *PSYSTEM_PROCESSOR_INFORMATION; + +// SystemPerformanceInfo (2) +typedef +struct _SYSTEM_PERFORMANCE_INFO +{ + LARGE_INTEGER TotalProcessorTime; + LARGE_INTEGER IoReadTransferCount; + LARGE_INTEGER IoWriteTransferCount; + LARGE_INTEGER IoOtherTransferCount; + ULONG IoReadOperationCount; + ULONG IoWriteOperationCount; + ULONG IoOtherOperationCount; + ULONG MmAvailablePages; + ULONG MmTotalCommitedPages; + ULONG MmTotalCommitLimit; + ULONG MmPeakLimit; + ULONG PageFaults; + ULONG WriteCopies; + ULONG TransitionFaults; + ULONG Unknown1; + ULONG DemandZeroFaults; + ULONG PagesInput; + ULONG PagesRead; + ULONG Unknown2; + ULONG Unknown3; + ULONG PagesOutput; + ULONG PageWrites; + ULONG Unknown4; + ULONG Unknown5; + ULONG PoolPagedBytes; + ULONG PoolNonPagedBytes; + ULONG Unknown6; + ULONG Unknown7; + ULONG Unknown8; + ULONG Unknown9; + ULONG MmTotalSystemFreePtes; + ULONG MmSystemCodepage; + ULONG MmTotalSystemDriverPages; + ULONG MmTotalSystemCodePages; + ULONG Unknown10; + ULONG Unknown11; + ULONG Unknown12; + ULONG MmSystemCachePage; + ULONG MmPagedPoolPage; + ULONG MmSystemDriverPage; + ULONG CcFastReadNoWait; + ULONG CcFastReadWait; + ULONG CcFastReadResourceMiss; + ULONG CcFastReadNotPossible; + ULONG CcFastMdlReadNoWait; + ULONG CcFastMdlReadWait; + ULONG CcFastMdlReadResourceMiss; + ULONG CcFastMdlReadNotPossible; + ULONG CcMapDataNoWait; + ULONG CcMapDataWait; + ULONG CcMapDataNoWaitMiss; + ULONG CcMapDataWaitMiss; + ULONG CcPinMappedDataCount; + ULONG CcPinReadNoWait; + ULONG CcPinReadWait; + ULONG CcPinReadNoWaitMiss; + ULONG CcPinReadWaitMiss; + ULONG CcCopyReadNoWait; + ULONG CcCopyReadWait; + ULONG CcCopyReadNoWaitMiss; + ULONG CcCopyReadWaitMiss; + ULONG CcMdlReadNoWait; + ULONG CcMdlReadWait; + ULONG CcMdlReadNoWaitMiss; + ULONG CcMdlReadWaitMiss; + ULONG CcReadaheadIos; + ULONG CcLazyWriteIos; + ULONG CcLazyWritePages; + ULONG CcDataFlushes; + ULONG CcDataPages; + ULONG ContextSwitches; + ULONG Unknown13; + ULONG Unknown14; + ULONG SystemCalls; + +} SYSTEM_PERFORMANCE_INFO, *PSYSTEM_PERFORMANCE_INFO; + +// SystemTimeInformation (3) +typedef +struct _SYSTEM_TIME_INFORMATION +{ + TIME KeBootTime; + TIME KeSystemTime; + TIME ExpTimeZoneBias; + ULONG ExpTimeZoneId; + ULONG Unused; + +} SYSTEM_TIME_INFORMATION, *PSYSTEM_TIME_INFORMATION; + +// SystemPathInformation (4) +// IT DOES NOT WORK +typedef +struct _SYSTEM_PATH_INFORMATION +{ + PVOID Dummy; + +} SYSTEM_PATH_INFORMATION, * PSYSTEM_PATH_INFORMATION; + +// SystemProcessThreadInfo (5) +typedef +struct _SYSTEM_THREAD_INFORMATION +{ + TIME KernelTime; + TIME UserTime; + TIME CreateTime; + ULONG TickCount; + ULONG StartEIP; + CLIENT_ID ClientId; + ULONG DynamicPriority; + ULONG BasePriority; + ULONG nSwitches; + DWORD State; + KWAIT_REASON WaitReason; + +} SYSTEM_THREAD_INFORMATION, *PSYSTEM_THREAD_INFORMATION; + +typedef +struct SYSTEM_PROCESS_INFORMATION +{ + ULONG RelativeOffset; + ULONG ThreadCount; + ULONG Unused1 [6]; + TIME CreateTime; + TIME UserTime; + TIME KernelTime; + UNICODE_STRING Name; + ULONG BasePriority; + ULONG ProcessId; + ULONG ParentProcessId; + ULONG HandleCount; + ULONG Unused2[2]; + ULONG PeakVirtualSizeBytes; + ULONG TotalVirtualSizeBytes; + ULONG PageFaultCount; + ULONG PeakWorkingSetSizeBytes; + ULONG TotalWorkingSetSizeBytes; + ULONG PeakPagedPoolUsagePages; + ULONG TotalPagedPoolUsagePages; + ULONG PeakNonPagedPoolUsagePages; + ULONG TotalNonPagedPoolUsagePages; + ULONG TotalPageFileUsageBytes; + ULONG PeakPageFileUsageBytes; + ULONG TotalPrivateBytes; + SYSTEM_THREAD_INFORMATION ThreadSysInfo [1]; + +} SYSTEM_PROCESS_INFORMATION, *PSYSTEM_PROCESS_INFORMATION; + +// SystemServiceDescriptorTableInfo (6) +typedef +struct _SYSTEM_SDT_INFORMATION +{ + ULONG BufferLength; + ULONG NumberOfSystemServiceTables; + ULONG NumberOfServices [1]; + ULONG ServiceCounters [1]; + +} SYSTEM_SDT_INFORMATION, *PSYSTEM_SDT_INFORMATION; + +// SystemIoConfigInformation (7) +typedef +struct _SYSTEM_IOCONFIG_INFORMATION +{ + ULONG DiskCount; + ULONG FloppyCount; + ULONG CdRomCount; + ULONG TapeCount; + ULONG SerialCount; + ULONG ParallelCount; + +} SYSTEM_IOCONFIG_INFORMATION, *PSYSTEM_IOCONFIG_INFORMATION; + +// SystemProcessorTimeInformation (8) +typedef +struct _SYSTEM_PROCESSORTIME_INFO +{ + TIME TotalProcessorRunTime; + TIME TotalProcessorTime; + TIME TotalProcessorUserTime; + TIME TotalDPCTime; + TIME TotalInterruptTime; + ULONG TotalInterrupts; + ULONG Unused; + +} SYSTEM_PROCESSORTIME_INFO, *PSYSTEM_PROCESSORTIME_INFO; + +// SystemNtGlobalFlagInformation (9) +typedef +struct _SYSTEM_GLOBAL_FLAG_INFO +{ + ULONG NtGlobalFlag; + +} SYSTEM_GLOBAL_FLAG_INFO, * PSYSTEM_GLOBAL_FLAG_INFO; + +// SystemInformation10 (10) +// UNKNOWN + +// SystemModuleInformation (11) +typedef +struct _SYSTEM_MODULE_ENTRY +{ + ULONG Unused; + ULONG Always0; + ULONG ModuleBaseAddress; + ULONG ModuleSize; + ULONG Unknown; + ULONG ModuleEntryIndex; + USHORT ModuleNameLength; /* Length of module name not including the path, this field contains valid value only for NTOSKRNL module*/ + USHORT ModulePathLength; /* Length of 'directory path' part of modulename*/ + CHAR ModuleName [256]; + +} SYSTEM_MODULE_ENTRY, * PSYSTEM_MODULE_ENTRY; + +typedef +struct _SYSTEM_MODULE_INFORMATION +{ + ULONG Count; + SYSTEM_MODULE_ENTRY Module [1]; + +} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION; + +// SystemResourceLockInformation (12) +typedef +struct _SYSTEM_RESOURCE_LOCK_ENTRY +{ + ULONG ResourceAddress; + ULONG Always1; + ULONG Unknown; + ULONG ActiveCount; + ULONG ContentionCount; + ULONG Unused[2]; + ULONG NumberOfSharedWaiters; + ULONG NumberOfExclusiveWaiters; + +} SYSTEM_RESOURCE_LOCK_ENTRY, *PSYSTEM_RESOURCE_LOCK_ENTRY; + +typedef +struct _SYSTEM_RESOURCE_LOCK_INFO +{ + ULONG Count; + SYSTEM_RESOURCE_LOCK_ENTRY Lock [1]; + +} SYSTEM_RESOURCE_LOCK_INFO, *PSYSTEM_RESOURCE_LOCK_INFO; + +// SystemInformation13 (13) +// UNKNOWN + +// SystemInformation14 (14) +// UNKNOWN + +// SystemInformation15 (15) +// UNKNOWN + +// SystemHandleInformation (16) +typedef +struct _SYSTEM_HANDLE_ENTRY +{ + ULONG OwnerPid; + USHORT ObjectType; + USHORT HandleValue; + PVOID ObjectPointer; + ULONG AccessMask; + +} SYSTEM_HANDLE_ENTRY, *PSYSTEM_HANDLE_ENTRY; + +typedef +struct _SYSTEM_HANDLE_INFORMATION +{ + ULONG Count; + SYSTEM_HANDLE_ENTRY Handle [1]; + +} SYSTEM_HANDLE_INFORMATION, *PSYSTEM_HANDLE_INFORMATION; + +// SystemObjectInformation (17) +// UNKNOWN +typedef +struct _SYSTEM_OBJECT_INFORMATION +{ + DWORD Unknown; + /* FIXME */ +} SYSTEM_OBJECT_INFORMATION, *PSYSTEM_OBJECT_INFORMATION; + +// SystemPageFileInformation (18) +typedef +struct _SYSTEM_PAGEFILE_INFORMATION +{ + ULONG RelativeOffset; + ULONG CurrentSizePages; + ULONG TotalUsedPages; + ULONG PeakUsedPages; + UNICODE_STRING PagefileFileName; + +} SYSTEM_PAGEFILE_INFORMATION, *PSYSTEM_PAGEFILE_INFORMATION; + +// SystemInstructionEmulationInfo (19) +typedef +struct _SYSTEM_VDM_INFORMATION +{ + ULONG VdmSegmentNotPresentCount; + ULONG VdmINSWCount; + ULONG VdmESPREFIXCount; + ULONG VdmCSPREFIXCount; + ULONG VdmSSPREFIXCount; + ULONG VdmDSPREFIXCount; + ULONG VdmFSPREFIXCount; + ULONG VdmGSPREFIXCount; + ULONG VdmOPER32PREFIXCount; + ULONG VdmADDR32PREFIXCount; + ULONG VdmINSBCount; + ULONG VdmINSWV86Count; + ULONG VdmOUTSBCount; + ULONG VdmOUTSWCount; + ULONG VdmPUSHFCount; + ULONG VdmPOPFCount; + ULONG VdmINTNNCount; + ULONG VdmINTOCount; + ULONG VdmIRETCount; + ULONG VdmINBIMMCount; + ULONG VdmINWIMMCount; + ULONG VdmOUTBIMMCount; + ULONG VdmOUTWIMMCount; + ULONG VdmINBCount; + ULONG VdmINWCount; + ULONG VdmOUTBCount; + ULONG VdmOUTWCount; + ULONG VdmLOCKPREFIXCount; + ULONG VdmREPNEPREFIXCount; + ULONG VdmREPPREFIXCount; + ULONG VdmHLTCount; + ULONG VdmCLICount; + ULONG VdmSTICount; + ULONG VdmBopCount; + +} SYSTEM_VDM_INFORMATION, *PSYSTEM_VDM_INFORMATION; + +// SystemInformation20 (20) +// UNKNOWN + +// SystemCacheInformation (21) +typedef +struct _SYSTEM_CACHE_INFORMATION +{ + ULONG CurrentSize; + ULONG PeakSize; + ULONG PageFaultCount; + ULONG MinimumWorkingSet; + ULONG MaximumWorkingSet; + ULONG Unused[4]; + +} SYSTEM_CACHE_INFORMATION; + +// SystemPoolTagInformation (22) +// found by Klaus P. Gerlicher +// (implemented only in checked builds) +typedef +struct _POOL_TAG_STATS +{ + ULONG AllocationCount; + ULONG FreeCount; + ULONG SizeBytes; + +} POOL_TAG_STATS; + +typedef +struct _SYSTEM_POOL_TAG_ENTRY +{ + ULONG Tag; + POOL_TAG_STATS Paged; + POOL_TAG_STATS NonPaged; + +} SYSTEM_POOL_TAG_ENTRY, * PSYSTEM_POOL_TAG_ENTRY; + +typedef +struct _SYSTEM_POOL_TAG_INFO +{ + ULONG Count; + SYSTEM_POOL_TAG_ENTRY PoolEntry [1]; + +} SYSTEM_POOL_TAG_INFO, *PSYSTEM_POOL_TAG_INFO; + +// SystemProcessorScheduleInfo (23) +typedef +struct _SYSTEM_PROCESSOR_SCHEDULE_INFO +{ + ULONG nContextSwitches; + ULONG nDPCQueued; + ULONG nDPCRate; + ULONG TimerResolution; + ULONG nDPCBypasses; + ULONG nAPCBypasses; + +} SYSTEM_PROCESSOR_SCHEDULE_INFO, *PSYSTEM_PROCESSOR_SCHEDULE_INFO; + +// SystemDpcInformation (24) +typedef +struct _SYSTEM_DPC_INFORMATION +{ + ULONG Unused; + ULONG KiMaximumDpcQueueDepth; + ULONG KiMinimumDpcRate; + ULONG KiAdjustDpcThreshold; + ULONG KiIdealDpcRate; + +} SYSTEM_DPC_INFORMATION, *PSYSTEM_DPC_INFORMATION; + +// SystemInformation25 (25) +// UNKNOWN + +// SystemLoadImage (26) +typedef +struct _SYSTEM_IMAGE_LOAD +{ + UNICODE_STRING ModuleFileName IN; + PVOID BaseAddress OUT; + PVOID Section OUT; + PVOID EntryPoint OUT; + PVOID ExportDirectory OUT; + +} SYSTEM_IMAGE_LOAD, *PSYSTEM_IMAGE_LOAD; + +// SystemUnloadImage (27) +typedef +struct _SYSTEM_IMAGE_UNLOAD +{ + PVOID Section IN; /* see SYSTEM_IMAGE_LOAD.ModuleSection */ + +} SYSTEM_IMAGE_UNLOAD, *PSYSTEM_IMAGE_UNLOAD; + + +// SystemTimeAdjustmentInformation (28) +// (what is the right one?) +#if 0 +typedef +struct _SYSTEM_TIME_ADJUSTMENT_INFO +{ + TIME TimeAdjustment; + BOOL TimeAdjustmentDisabled; + +} SYSTEM_TIME_ADJUSTMENT_INFO, *PSYSTEM_TIME_ADJUSTMENT_INFO; +#else +typedef +struct _SYSTEM_TIME_ADJUSTMENT_INFO +{ + ULONG KeTimeAdjustment; + ULONG KeMaximumIncrement; + BOOLEAN KeTimeSynchronization; + +} SYSTEM_TIME_ADJUSTMENT_INFO, *PSYSTEM_TIME_ADJUSTMENT_INFO; +#endif + +// SystemProcessorFaultCountInfo (33) +typedef +struct _SYSTEM_PROCESSOR_FAULT_INFO +{ + ULONG nAlignmentFixup; + ULONG nExceptionDispatches; + ULONG nFloatingEmulation; + ULONG Unknown; + +} SYSTEM_PROCESSOR_FAULT_INFO, *PSYSTEM_PROCESSOR_FAULT_INFO; + +// SystemCrashDumpStateInfo (34) +// + +// SystemDebuggerInformation (35) +typedef +struct _SYSTEM_DEBUGGER_INFO +{ + BOOLEAN KdDebuggerEnabled; + BOOLEAN KdDebuggerPresent; + +} SYSTEM_DEBUGGER_INFO, *PSYSTEM_DEBUGGER_INFO; + +// SystemInformation36 (36) +// UNKNOWN + +// SystemQuotaInformation (37) +typedef +struct _SYSTEM_QUOTA_INFORMATION +{ + ULONG CmpGlobalQuota; + ULONG CmpGlobalQuotaUsed; + ULONG MmSizeofPagedPoolInBytes; + +} SYSTEM_QUOTA_INFORMATION, *PSYSTEM_QUOTA_INFORMATION; + +// SystemLoadDriver (38) +typedef +struct _SYSTEM_DRIVER_LOAD +{ + UNICODE_STRING DriverRegistryEntry; + +} SYSTEM_DRIVER_LOAD, *PSYSTEM_DRIVER_LOAD; + -#define SystemInformation0 0 -#define SystemInformation1 1 -#define SystemPerformanceInformation 2 -#define SystemTimeInformation 3 -#define SystemProcessInformation 5 -#define SystemGlobalFlagInformation 9 -#define SystemDriverInformation 11 -#define SystemPageFileInformation 18 -#define SystemCacheInformation 21 -#define SystemPoolTagStatsInformation 22 -#define SystemTimeAdjustmentInformation 28 -#define SystemTimeZoneInformation 44 // memory information @@ -264,168 +835,6 @@ typedef struct _OBJECT_TYPE_INFORMATION ULONG ReferenceCount; } OBJECT_TYPE_INFORMATION, *POBJECT_TYPE_INFORMATION; -// system information - -#if 0 -#pragma pack(2) -typedef struct _SYSTEM_THREAD_INFORMATION -{ - FILETIME ftCreationTime; - DWORD dwUnknown1; - PVOID dwStartAddress; - DWORD dwOwningPID; - DWORD dwThreadID; - DWORD dwCurrentPriority; - DWORD dwBasePriority; - DWORD dwContextSwitches; - DWORD dwThreadState; - DWORD dwWaitReason; - DWORD dwUnknown2 [ 5 ]; - - -} SYSTEM_THREAD_INFORMATION, * PSYSTEM_THREAD_INFORMATION; - - -typedef struct _SYSTEM_PROCESS_INFORMATION -{ - DWORD dwOffset; - DWORD dwThreadCount; - DWORD dwUnknown1 [6]; - FILETIME ftCreationTime; - DWORD dwUnknown2 [5]; - WCHAR * pszProcessName; - DWORD dwBasePriority; - DWORD dwProcessID; - DWORD dwParentProcessID; - DWORD dwHandleCount; - DWORD dwUnknown3; - DWORD dwUnknown4; - DWORD dwVirtualBytesPeak; - DWORD dwVirtualBytes; - DWORD dwPageFaults; - DWORD dwWorkingSetPeak; - DWORD dwWorkingSet; - DWORD dwUnknown5; - DWORD dwPagedPool; - DWORD dwUnknown6; - DWORD dwNonPagedPool; - DWORD dwPageFileBytesPeak; - DWORD dwPrivateBytes; - DWORD dwPageFileBytes; - DWORD dwUnknown7 [4]; - SYSTEM_THREAD_INFORMATION Threads [1]; - -} SYSTEM_PROCESS_INFORMATION, * PSYSTEM_PROCESS_INFORMATION; -#endif - -typedef struct _SYSTEM_TIME_INFORMATION -{ - LARGE_INTEGER BootTime; - LARGE_INTEGER SystemTime; - LARGE_INTEGER TimeZoneBias; - ULONG TimeZoneId; - ULONG Unknown; -} SYSTEM_TIME_INFORMATION, *PSYSTEM_TIME_INFORMATION; - -typedef struct _SYSTEM_GLOBAL_FLAGS_INFO -{ - DWORD GlobalFlags; - -} SYSTEM_GLOBAL_FLAGS_INFO, * PSYSTEM_GLOBAL_FLAGS_INFO; - -#if 0 -#pragma pack(4) -typedef struct _SYSTEM_DRIVER_INFO -{ - PVOID BaseAddress; - DWORD Unknown1; - DWORD Unknown2; - DWORD EntryIndex; - DWORD Unknown4; - CHAR DriverName [256]; - -} SYSTEM_DRIVER_INFO, * PSYSTEM_DRIVER_INFO; - - -typedef struct _SYSTEM_DRIVERS_INFO -{ - DWORD DriverCount; - SYSTEM_DRIVER_INFO DriverInfo[1]; -} SYSTEM_DRIVERS_INFO, *PSYSTEM_DRIVERS_INFO; - -#pragma pack(4) -typedef struct _SYSTEM_TIME_ADJUSTMENT -{ - TIME TimeAdjustment; - BOOL TimeAdjustmentDisabled; - -} SYSTEM_TIME_ADJUSTMENT, *PSYSTEM_TIME_ADJUSTMENT; - -typedef struct _SYSTEM_CONFIGURATION_INFO { - union { - ULONG OemId; - struct { - WORD ProcessorArchitecture; - WORD Reserved; - } tag1; - } tag2; - ULONG PageSize; - PVOID MinimumApplicationAddress; - PVOID MaximumApplicationAddress; - ULONG ActiveProcessorMask; - ULONG NumberOfProcessors; - ULONG ProcessorType; - ULONG AllocationGranularity; - WORD ProcessorLevel; - WORD ProcessorRevision; -} SYSTEM_CONFIGURATION_INFO, *PSYSTEM_CONFIGURATION_INFO; - - -typedef struct _SYSTEM_PAGEFILE_INFORMATION -{ - DWORD Unknown [6]; - WCHAR PagefileName [16]; - -} SYSTEM_PAGEFILE_INFORMATION, * PSYSTEM_PAGEFILE_INFORMATION; - - -typedef struct _SYSTEM_CACHE_INFORMATION -{ - ULONG CurrentSize; - ULONG PeakSize; - ULONG PageFaultCount; - ULONG MinimumWorkingSet; - ULONG MaximumWorkingSet; - ULONG Unused[4]; -} SYSTEM_CACHE_INFORMATION; - - -/* SYSTEM_POOL_ENTRY_INFO, SYSTEM_POOL_INFORMATION - * found by Klaus P. Gerlicher */ -typedef -struct _SYSTEM_POOL_ENTRY_INFO -{ - ULONG Tag; - ULONG NP_Allocs; - ULONG NP_Frees; - ULONG NP_Used; - ULONG P_Allocs; - ULONG P_Frees; - ULONG P_Used; - -} SYSTEM_POOL_ENTRY_INFO, * PSYSTEM_POOL_ENTRY_INFO; - - -typedef -struct _SYSTEM_POOL_INFORMATION -{ - ULONG Count; - SYSTEM_POOL_ENTRY_INFO PoolEntry [1]; - -} SYSTEM_POOL_INFORMATION, *PSYSTEM_POOL_INFORMATION; - -#endif - // file information typedef struct _FILE_BASIC_INFORMATION diff --git a/reactos/include/fmifs.h b/reactos/include/fmifs.h index 2534780841b..2570dce80b1 100644 --- a/reactos/include/fmifs.h +++ b/reactos/include/fmifs.h @@ -1,6 +1,6 @@ #ifndef _FMIFS_H #define _FMIFS_H -/* $Id: fmifs.h,v 1.1 1999/05/11 21:16:01 ea Exp $ +/* $Id: fmifs.h,v 1.2 2000/04/25 23:22:48 ea Exp $ * * fmifs.h * @@ -67,7 +67,7 @@ BOOL /* Chkdsk command in FMIFS */ VOID STDCALL -ChkDsk( +Chkdsk( PWCHAR DriveRoot, PWCHAR Format, BOOL CorrectErrors, diff --git a/reactos/include/internal/ps.h b/reactos/include/internal/ps.h index 392b7e3e8ea..5999894164d 100644 --- a/reactos/include/internal/ps.h +++ b/reactos/include/internal/ps.h @@ -55,7 +55,7 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle, #define PROCESS_PRIO_NORMAL 8 #define PROCESS_PRIO_HIGH 13 #define PROCESS_PRIO_RT 18 - + /* * Functions the HAL must provide */ diff --git a/reactos/include/kernel32/error.h b/reactos/include/kernel32/error.h new file mode 100644 index 00000000000..8ac4e393b97 --- /dev/null +++ b/reactos/include/kernel32/error.h @@ -0,0 +1,12 @@ +#ifndef _INCLUDE_KERNEL32_H +#define _INCLUDE_KERNEL32_H +/* $Id: error.h,v 1.1 2000/04/25 23:22:52 ea Exp $ */ +#include +#define NTOS_MODE_USER +#include +DWORD +STDCALL +SetLastErrorByStatus ( + NTSTATUS Status + ); +#endif /* _INCLUDE_KERNEL32_H */ diff --git a/reactos/include/ntdll/csr.h b/reactos/include/ntdll/csr.h index f77c3581482..5b9ef47fa59 100644 --- a/reactos/include/ntdll/csr.h +++ b/reactos/include/ntdll/csr.h @@ -1,4 +1,4 @@ -/* $Id: csr.h,v 1.2 2000/03/22 18:35:47 dwelch Exp $ +/* $Id: csr.h,v 1.3 2000/04/25 23:22:52 ea Exp $ * */ @@ -12,6 +12,12 @@ NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply, ULONG Length, ULONG ReplyLength); +NTSTATUS +STDCALL +CsrSetPriorityClass ( + HANDLE hProcess, + DWORD * PriorityClass + ); #endif /* __INCLUDE_NTDLL_CSR_H */ diff --git a/reactos/lib/fmifs/dllmain.c b/reactos/lib/fmifs/dllmain.c index 8d3bfc0a116..9c3c07d939c 100644 --- a/reactos/lib/fmifs/dllmain.c +++ b/reactos/lib/fmifs/dllmain.c @@ -1,9 +1,9 @@ -/* $Id: dllmain.c,v 1.1 1999/05/11 21:19:41 ea Exp $ +/* $Id: dllmain.c,v 1.2 2000/04/25 23:22:53 ea Exp $ * * ReactOS FMIFS.DLL */ #include -INT +BOOLEAN __stdcall DllMain( PVOID hinstDll, @@ -22,6 +22,6 @@ DllMain( case DLL_PROCESS_DETACH: break; } - return(1); + return (TRUE); } /* EOF */ diff --git a/reactos/lib/kernel32/makefile b/reactos/lib/kernel32/makefile index e8269d3ba1b..6d72b899d10 100644 --- a/reactos/lib/kernel32/makefile +++ b/reactos/lib/kernel32/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.32 2000/04/06 17:23:26 ekohl Exp $ +# $Id: makefile,v 1.33 2000/04/25 23:22:53 ea Exp $ # # ReactOS Operating System # @@ -27,7 +27,7 @@ SYNCH_OBJECTS = synch/critical.o synch/event.o synch/wait.o synch/intrlck.o sync MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o \ misc/console.o misc/time.o misc/stubs.o misc/rtl.o misc/ldr.o misc/res.o \ - misc/debug.o + misc/debug.o misc/sysinfo.o FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \ file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \ diff --git a/reactos/lib/kernel32/misc/error.c b/reactos/lib/kernel32/misc/error.c index 950c32a7e9e..fbcef317006 100644 --- a/reactos/lib/kernel32/misc/error.c +++ b/reactos/lib/kernel32/misc/error.c @@ -1,4 +1,4 @@ -/* $Id: error.c,v 1.12 1999/10/07 23:45:07 ekohl Exp $ +/* $Id: error.c,v 1.13 2000/04/25 23:22:53 ea Exp $ * * reactos/lib/kernel32/misc/error.c * @@ -8,9 +8,20 @@ // #define NDEBUG #include +#include -static DWORD LastError=0; +/* INTERNAL */ +DWORD +STDCALL +SetLastErrorByStatus ( + NTSTATUS Status + ) +{ + DWORD Error = RtlNtStatusToDosError (Status); + SetLastError (Error); + return (Error); +} VOID @@ -19,16 +30,14 @@ SetLastError ( DWORD dwErrorCode ) { - /* FIXME: it is per thread */ - LastError = dwErrorCode; + NtCurrentTeb ()->LastErrorValue = (ULONG) dwErrorCode; } DWORD STDCALL GetLastError (VOID) { - /* FIXME: it is per thread */ - return LastError; + return (DWORD) (NtCurrentTeb ()->LastErrorValue); } diff --git a/reactos/lib/kernel32/misc/stubs.c b/reactos/lib/kernel32/misc/stubs.c index 6b7640e2df3..873291cb393 100644 --- a/reactos/lib/kernel32/misc/stubs.c +++ b/reactos/lib/kernel32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.14 2000/04/14 01:49:40 ekohl Exp $ +/* $Id: stubs.c,v 1.15 2000/04/25 23:22:54 ea Exp $ * * KERNEL32.DLL stubs (unimplemented functions) * Remove from this file, if you implement them. @@ -1691,18 +1691,6 @@ GetOEMCP (VOID) } -DWORD -STDCALL -GetPriorityClass ( - HANDLE hProcess - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NORMAL_PRIORITY_CLASS; /* FIXME: call NTOSKRNL.Ps */ -} - - - UINT STDCALL GetPrivateProfileIntW ( @@ -2073,40 +2061,6 @@ GetSystemDefaultLangID (VOID) } -VOID -STDCALL -GetSystemInfo ( - LPSYSTEM_INFO lpSystemInfo - ) -{ - /* FIXME: ??? */ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - - lpSystemInfo->u.s.wProcessorArchitecture = - PROCESSOR_ARCHITECTURE_INTEL; - lpSystemInfo->u.s.wReserved = - 0; - lpSystemInfo->dwPageSize = - 4096; /* FIXME: x86 default; may be 4Mb */ - lpSystemInfo->lpMinimumApplicationAddress = - (PVOID) 0x00010000; /* ? */ - lpSystemInfo->lpMaximumApplicationAddress = - (PVOID) 0x00010000; /* ? */ - lpSystemInfo->dwActiveProcessorMask = - 0x00000001; - lpSystemInfo->dwNumberOfProcessors = - 1; /* ReactOS is UP for now! */ - lpSystemInfo->dwProcessorType = - PROCESSOR_INTEL_PENTIUM; - lpSystemInfo->dwAllocationGranularity = - 65536; /* hard coded on Intel? */ - lpSystemInfo->wProcessorLevel = - 5; /* from cpuid on Intel? */ - lpSystemInfo->wProcessorRevision = - 0x0000; /* from cpuid on Intel? */ -} - - DWORD STDCALL GetSystemPowerStatus ( @@ -3508,18 +3462,6 @@ SetNamedPipeHandleState ( } -WINBOOL -STDCALL -SetPriorityClass ( - HANDLE hProcess, - DWORD dwPriorityClass - ) -{ - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - WINBOOL STDCALL SetProcessShutdownParameters ( diff --git a/reactos/lib/kernel32/misc/sysinfo.c b/reactos/lib/kernel32/misc/sysinfo.c new file mode 100644 index 00000000000..22cc5246e0b --- /dev/null +++ b/reactos/lib/kernel32/misc/sysinfo.c @@ -0,0 +1,100 @@ +/* $Id: sysinfo.c,v 1.1 2000/04/25 23:22:54 ea Exp $ + * + * reactos/lib/kernel32/misc/sysinfo.c + * + */ +#include + +#include +#include + + +#define PV_NT351 0x00030033 + +VOID +STDCALL +GetSystemInfo ( + LPSYSTEM_INFO Si + ) +{ + SYSTEM_BASIC_INFORMATION Sbi; + SYSTEM_PROCESSOR_INFORMATION Spi; + DWORD ProcessVersion; + NTSTATUS Status; + + RtlZeroMemory (Si, sizeof (SYSTEM_INFO)); + Status = NtQuerySystemInformation ( + SystemBasicInformation, /* 0 */ + & Sbi, + sizeof Sbi, /* 44 */ + 0 + ); + if (STATUS_SUCCESS != Status) + { + SetLastErrorByStatus (Status); + return; + } + Status = NtQuerySystemInformation ( + SystemProcessorInformation, /* 1 */ + & Spi, + sizeof Spi, /* 12 */ + 0 + ); + if (STATUS_SUCCESS != Status) + { + SetLastErrorByStatus (Status); + return; + } + /* + * PROCESSOR_ARCHITECTURE_INTEL 0 + * PROCESSOR_ARCHITECTURE_MIPS 1 + * PROCESSOR_ARCHITECTURE_ALPHA 2 + * PROCESSOR_ARCHITECTURE_PPC 3 + * PROCESSOR_ARCHITECTURE_UNKNOWN 0xFFFF + */ + Si->u.s.wProcessorArchitecture = Spi.KeProcessorArchitecture; + /* For future use: always zero */ + Si->u.s.wReserved = 0; + Si->dwPageSize = Sbi.MmPageSize; + Si->lpMinimumApplicationAddress = Sbi.MmLowestUserAddress; + Si->lpMaximumApplicationAddress = Sbi.MmHighestUserAddress; + Si->dwActiveProcessorMask = Sbi.KeActiveProcessors; + Si->dwNumberOfProcessors = Sbi.KeNumberProcessors; + /* + * Compatibility: + * PROCESSOR_INTEL_386 386 + * PROCESSOR_INTEL_486 486 + * PROCESSOR_INTEL_PENTIUM 586 + * PROCESSOR_MIPS_R4000 4000 + * PROCESSOR_ALPHA_21064 21064 + */ +#if 0 + switch (Spi.KeProcessorArchitecture) + { + case : +#endif + Si->dwProcessorType = PROCESSOR_INTEL_PENTIUM; +#if 0 + break; + } +#endif + Si->dwAllocationGranularity = 65536; /* hard coded on Intel? */ + Si->wProcessorRevision = Spi.KeProcessorRevision; + /* + * Get the version of Windows on which + * the process expects to run. + */ +#if 0 + ProcessVersion = GetProcessVersion (0); /* current process */ +#endif + + /* In NT 3.1, these fields were always zero. */ + if (PV_NT351 > ProcessVersion) + { + Si->wProcessorLevel = 0; + Si->wProcessorRevision = 0; + } +} + + +/* EOF */ diff --git a/reactos/lib/kernel32/process/proc.c b/reactos/lib/kernel32/process/proc.c index a3cf0b7cfbf..5292447dff1 100644 --- a/reactos/lib/kernel32/process/proc.c +++ b/reactos/lib/kernel32/process/proc.c @@ -1,4 +1,4 @@ -/* $Id: proc.c,v 1.31 2000/03/16 01:14:37 ekohl Exp $ +/* $Id: proc.c,v 1.32 2000/04/25 23:22:54 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -16,10 +16,13 @@ #include #include #include +#include #include #include #include #include +#include + #define NDEBUG #include @@ -61,8 +64,35 @@ GetProcessTimes ( LPFILETIME lpUserTime ) { - DPRINT("GetProcessTimes is unimplemented\n"); - return FALSE; + NTSTATUS Status; + KERNEL_USER_TIMES Kut; + + Status = NtQueryInformationProcess ( + hProcess, + ProcessTimes, + & Kut, + sizeof Kut, + NULL + ); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus (Status); + return (FALSE); + } + + lpCreationTime->dwLowDateTime = Kut.CreateTime.u.LowPart; + lpCreationTime->dwHighDateTime = Kut.CreateTime.u.HighPart; + + lpExitTime->dwLowDateTime = Kut.ExitTime.u.LowPart; + lpExitTime->dwHighDateTime = Kut.ExitTime.u.HighPart; + + lpKernelTime->dwLowDateTime = Kut.KernelTime.u.LowPart; + lpKernelTime->dwHighDateTime = Kut.KernelTime.u.HighPart; + + lpUserTime->dwLowDateTime = Kut.UserTime.u.LowPart; + lpUserTime->dwHighDateTime = Kut.UserTime.u.HighPart; + + return (TRUE); } @@ -102,7 +132,7 @@ GetExitCodeProcess ( &BytesWritten); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return FALSE; } memcpy(lpExitCode, &ProcessBasic.ExitStatus, sizeof(DWORD)); @@ -128,7 +158,7 @@ GetProcessId ( &BytesWritten); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return FALSE; } memcpy( lpProcessId ,&ProcessBasic.UniqueProcessId,sizeof(DWORD)); @@ -169,7 +199,7 @@ OpenProcess ( &ClientId); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return NULL; } return ProcessHandle; @@ -207,10 +237,15 @@ WinExec ( dosErr = GetLastError(); return dosErr; } - if ( lpfnGlobalRegisterWaitForInputIdle != NULL ) - lpfnGlobalRegisterWaitForInputIdle(ProcessInformation.hProcess,10000); - NtClose(ProcessInformation.hProcess); - NtClose(ProcessInformation.hThread); + if (NULL != lpfnGlobalRegisterWaitForInputIdle) + { + lpfnGlobalRegisterWaitForInputIdle ( + ProcessInformation.hProcess, + 10000 + ); + } + NtClose (ProcessInformation.hProcess); + NtClose (ProcessInformation.hThread); return 0; } @@ -260,10 +295,10 @@ SleepEx ( Interval.QuadPart = dwMilliseconds * 1000; - errCode = NtDelayExecution(bAlertable,&Interval); + errCode = NtDelayExecution (bAlertable, & Interval); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return -1; } return 0; @@ -390,13 +425,13 @@ FlushInstructionCache ( { NTSTATUS errCode; - errCode = NtFlushInstructionCache( + errCode = NtFlushInstructionCache ( hProcess, (PVOID) lpBaseAddress, dwSize); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return FALSE; } return TRUE; @@ -423,10 +458,10 @@ TerminateProcess ( { NTSTATUS errCode; - errCode = NtTerminateProcess(hProcess, uExitCode); + errCode = NtTerminateProcess (hProcess, uExitCode); if (!NT_SUCCESS(errCode)) { - SetLastError(RtlNtStatusToDosError(errCode)); + SetLastErrorByStatus (errCode); return FALSE; } return TRUE; @@ -443,11 +478,11 @@ FatalAppExitA ( UNICODE_STRING MessageTextU; ANSI_STRING MessageText; - RtlInitAnsiString (&MessageText, - (LPSTR)lpMessageText); + RtlInitAnsiString (& MessageText, + (LPSTR) lpMessageText); - RtlAnsiStringToUnicodeString (&MessageTextU, - &MessageText, + RtlAnsiStringToUnicodeString (& MessageTextU, + & MessageText, TRUE); FatalAppExitW (uAction, @@ -467,4 +502,111 @@ FatalAppExitW ( return; } + +DWORD +STDCALL +GetPriorityClass ( + HANDLE hProcess + ) +{ + HANDLE hProcessTmp; + DWORD CsrPriorityClass; + NTSTATUS Status; + + Status = NtDuplicateObject ( + GetCurrentProcess(), + hProcess, + GetCurrentProcess(), + & hProcessTmp, + (PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION), + FALSE, + 0 + ); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus (Status); + return (0); /* ERROR */ + } + /* Ask CSRSS to set it */ + CsrSetPriorityClass ( + hProcessTmp, + & CsrPriorityClass + ); + NtClose (hProcessTmp); + /* Translate CSR->W32 priorities */ + switch (CsrPriorityClass) + { + case CSR_PRIORITY_CLASS_NORMAL: + return (NORMAL_PRIORITY_CLASS); /* 32 */ + case CSR_PRIORITY_CLASS_IDLE: + return (IDLE_PRIORITY_CLASS); /* 64 */ + case CSR_PRIORITY_CLASS_HIGH: + return (HIGH_PRIORITY_CLASS); /* 128 */ + case CSR_PRIORITY_CLASS_REALTIME: + return (REALTIME_PRIORITY_CLASS); /* 256 */ + } + SetLastError (ERROR_ACCESS_DENIED); + return (0); /* ERROR */ +} + + + +WINBOOL +STDCALL +SetPriorityClass ( + HANDLE hProcess, + DWORD dwPriorityClass + ) +{ + HANDLE hProcessTmp; + DWORD CsrPriorityClass; + NTSTATUS Status; + + switch (dwPriorityClass) + { + case NORMAL_PRIORITY_CLASS: /* 32 */ + CsrPriorityClass = CSR_PRIORITY_CLASS_NORMAL; + break; + case IDLE_PRIORITY_CLASS: /* 64 */ + CsrPriorityClass = CSR_PRIORITY_CLASS_IDLE; + break; + case HIGH_PRIORITY_CLASS: /* 128 */ + CsrPriorityClass = CSR_PRIORITY_CLASS_HIGH; + break; + case REALTIME_PRIORITY_CLASS: /* 256 */ + CsrPriorityClass = CSR_PRIORITY_CLASS_REALTIME; + break; + default: + SetLastError (ERROR_INVALID_PARAMETER); + return (FALSE); + } + Status = NtDuplicateObject ( + GetCurrentProcess(), + hProcess, + GetCurrentProcess(), + & hProcessTmp, + (PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION), + FALSE, + 0 + ); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus (Status); + return (FALSE); /* ERROR */ + } + /* Ask CSRSS to set it */ + Status = CsrSetPriorityClass ( + hProcessTmp, + & CsrPriorityClass + ); + NtClose (hProcessTmp); + if (!NT_SUCCESS(Status)) + { + SetLastErrorByStatus (Status); + return (FALSE); + } + return (TRUE); +} + + /* EOF */ diff --git a/reactos/lib/kernel32/synch/critical.c b/reactos/lib/kernel32/synch/critical.c index ecdd659c9cd..d3a374b4a1b 100644 --- a/reactos/lib/kernel32/synch/critical.c +++ b/reactos/lib/kernel32/synch/critical.c @@ -1,4 +1,4 @@ -/* $Id: critical.c,v 1.8 2000/04/20 05:28:31 phreak Exp $ +/* $Id: critical.c,v 1.9 2000/04/25 23:22:55 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -14,6 +14,9 @@ #include +#define NTOS_MODE_USER +#include + /* FUNCTIONS *****************************************************************/ diff --git a/reactos/lib/ntdll/csr/api.c b/reactos/lib/ntdll/csr/api.c index 966745cd3ac..40397d34693 100644 --- a/reactos/lib/ntdll/csr/api.c +++ b/reactos/lib/ntdll/csr/api.c @@ -1,4 +1,4 @@ -/* $Id: api.c,v 1.5 2000/04/03 21:54:36 dwelch Exp $ +/* $Id: api.c,v 1.6 2000/04/25 23:22:55 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -83,3 +84,19 @@ NTSTATUS STDCALL CsrClientConnectToServer(VOID) } return(STATUS_SUCCESS); } + + +NTSTATUS +STDCALL +CsrSetPriorityClass ( + HANDLE hProcess, + DWORD * PriorityClass + ) +{ + /* FIXME: call csrss to get hProcess' priority */ + *PriorityClass = PS_PRIORITY_CLASS_NORMAL; + + return (STATUS_NOT_IMPLEMENTED); +} + +/* EOF */ diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 62b4bc6126f..d81758fdfcd 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,4 +1,4 @@ -; $Id: ntdll.def,v 1.52 2000/04/15 23:10:02 ekohl Exp $ +; $Id: ntdll.def,v 1.53 2000/04/25 23:22:55 ea Exp $ ; ; ReactOS Operating System ; @@ -7,6 +7,7 @@ LIBRARY ntdll.dll EXPORTS CsrClientCallServer@16 ;CsrClientConnectToServer@24 +CsrSetPriorityClass@8 DbgBreakPoint@0 DbgPrint ;DbgPrompt diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index ab1422c7927..4d96f5b1086 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,4 +1,4 @@ -; $Id: ntdll.edf,v 1.41 2000/04/15 23:10:02 ekohl Exp $ +; $Id: ntdll.edf,v 1.42 2000/04/25 23:22:56 ea Exp $ ; ; ReactOS Operating System ; @@ -7,6 +7,7 @@ LIBRARY ntdll.dll EXPORTS CsrClientCallServer=CsrClientCallServer@16 ;CsrClientConnectToServer=CsrClientConnectToServer@24 +CsrSetPriorityClass=CsrSetPriorityClass@8 DbgBreakPoint=DbgBreakPoint@0 DbgPrint ;DbgPrompt diff --git a/reactos/ntoskrnl/ex/sysinfo.c b/reactos/ntoskrnl/ex/sysinfo.c index 970e3d1c6e0..3c21750327e 100644 --- a/reactos/ntoskrnl/ex/sysinfo.c +++ b/reactos/ntoskrnl/ex/sysinfo.c @@ -1,4 +1,4 @@ -/* $Id: sysinfo.c,v 1.4 2000/03/26 19:38:18 ea Exp $ +/* $Id: sysinfo.c,v 1.5 2000/04/25 23:22:56 ea Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -18,6 +18,8 @@ #include +extern ULONG NtGlobalFlag; /* FIXME: it should go in a ddk/?.h */ + /* FUNCTIONS *****************************************************************/ NTSTATUS @@ -44,13 +46,656 @@ NtSetSystemEnvironmentValue ( } +/* --- Query/Set System Information --- */ + + +/* + * NOTE: QSI_DEF(n) and SSI_DEF(n) define _cdecl function symbols + * so the stack is popped only in one place on x86 platform. + */ +#define QSI_USE(n) QSI##n +#define QSI_DEF(n) \ +static NTSTATUS QSI_USE(n) (PVOID Buffer, ULONG Size, PULONG ReqSize) + +#define SSI_USE(n) SSI##n +#define SSI_DEF(n) \ +static NTSTATUS SSI_USE(n) (PVOID Buffer, ULONG Size) + +/* Class 0 - Basic Information */ +QSI_DEF(SystemBasicInformation) +{ + PSYSTEM_BASIC_INFORMATION Sbi + = (PSYSTEM_BASIC_INFORMATION) Buffer; + + *ReqSize = sizeof (SYSTEM_BASIC_INFORMATION); + /* + * Check user buffer's size + */ + if (Size < sizeof (SYSTEM_BASIC_INFORMATION)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + + Sbi->AlwaysZero = 0; + Sbi->KeMaximumIncrement = 0; /* FIXME */ + Sbi->MmPageSize = PAGESIZE; /* FIXME: it should be PAGE_SIZE */ + Sbi->MmNumberOfPhysicalPages = 0; /* FIXME */ + Sbi->MmLowestPhysicalPage = 0; /* FIXME */ + Sbi->MmHighestPhysicalPage = 0; /* FIXME */ + Sbi->MmLowestUserAddress = 0; /* FIXME */ + Sbi->MmLowestUserAddress1 = 0; /* FIXME */ + Sbi->MmHighestUserAddress = 0; /* FIXME */ + Sbi->KeActiveProcessors = 0x00000001; /* FIXME */ + Sbi->KeNumberProcessors = 1; /* FIXME */ + + return (STATUS_SUCCESS); +} + +/* Class 1 - Processor Information */ +QSI_DEF(SystemProcessorInformation) +{ + PSYSTEM_PROCESSOR_INFORMATION Spi + = (PSYSTEM_PROCESSOR_INFORMATION) Buffer; + + *ReqSize = sizeof (SYSTEM_PROCESSOR_INFORMATION); + /* + * Check user buffer's size + */ + if (Size < sizeof (SYSTEM_PROCESSOR_INFORMATION)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + + /* FIXME: add CPU type detection code */ + Spi->KeProcessorArchitecture = 0; /* FIXME */ + Spi->KeProcessorLevel = 0; /* FIXME */ + Spi->KeProcessorRevision = 0; /* FIXME */ + Spi->AlwaysZero = 0; + Spi->KeFeatureBits = 0x00000000; /* FIXME */ + + return (STATUS_SUCCESS); +} + +/* Class 2 - Performance Information */ +QSI_DEF(SystemPerformanceInfo) +{ + PSYSTEM_PERFORMANCE_INFO Spi + = (PSYSTEM_PERFORMANCE_INFO) Buffer; + + *ReqSize = sizeof (SYSTEM_PERFORMANCE_INFO); + /* + * Check user buffer's size + */ + if (Size < sizeof (SYSTEM_PERFORMANCE_INFO)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + + Spi->TotalProcessorTime.QuadPart = 0; /* FIXME */ + Spi->IoReadTransferCount.QuadPart = 0; /* FIXME */ + Spi->IoWriteTransferCount.QuadPart = 0; /* FIXME */ + Spi->IoOtherTransferCount.QuadPart = 0; /* FIXME */ + Spi->IoReadOperationCount = 0; /* FIXME */ + Spi->IoWriteOperationCount = 0; /* FIXME */ + Spi->IoOtherOperationCount = 0; /* FIXME */ + Spi->MmAvailablePages = 0; /* FIXME */ + Spi->MmTotalCommitedPages = 0; /* FIXME */ + Spi->MmTotalCommitLimit = 0; /* FIXME */ + Spi->MmPeakLimit = 0; /* FIXME */ + Spi->PageFaults = 0; /* FIXME */ + Spi->WriteCopies = 0; /* FIXME */ + Spi->TransitionFaults = 0; /* FIXME */ + Spi->Unknown1 = 0; /* FIXME */ + Spi->DemandZeroFaults = 0; /* FIXME */ + Spi->PagesInput = 0; /* FIXME */ + Spi->PagesRead = 0; /* FIXME */ + Spi->Unknown2 = 0; /* FIXME */ + Spi->Unknown3 = 0; /* FIXME */ + Spi->PagesOutput = 0; /* FIXME */ + Spi->PageWrites = 0; /* FIXME */ + Spi->Unknown4 = 0; /* FIXME */ + Spi->Unknown5 = 0; /* FIXME */ + Spi->PoolPagedBytes = 0; /* FIXME */ + Spi->PoolNonPagedBytes = 0; /* FIXME */ + Spi->Unknown6 = 0; /* FIXME */ + Spi->Unknown7 = 0; /* FIXME */ + Spi->Unknown8 = 0; /* FIXME */ + Spi->Unknown9 = 0; /* FIXME */ + Spi->MmTotalSystemFreePtes = 0; /* FIXME */ + Spi->MmSystemCodepage = 0; /* FIXME */ + Spi->MmTotalSystemDriverPages = 0; /* FIXME */ + Spi->MmTotalSystemCodePages = 0; /* FIXME */ + Spi->Unknown10 = 0; /* FIXME */ + Spi->Unknown11 = 0; /* FIXME */ + Spi->Unknown12 = 0; /* FIXME */ + Spi->MmSystemCachePage = 0; /* FIXME */ + Spi->MmPagedPoolPage = 0; /* FIXME */ + Spi->MmSystemDriverPage = 0; /* FIXME */ + Spi->CcFastReadNoWait = 0; /* FIXME */ + Spi->CcFastReadWait = 0; /* FIXME */ + Spi->CcFastReadResourceMiss = 0; /* FIXME */ + Spi->CcFastReadNotPossible = 0; /* FIXME */ + Spi->CcFastMdlReadNoWait = 0; /* FIXME */ + Spi->CcFastMdlReadWait = 0; /* FIXME */ + Spi->CcFastMdlReadResourceMiss = 0; /* FIXME */ + Spi->CcFastMdlReadNotPossible = 0; /* FIXME */ + Spi->CcMapDataNoWait = 0; /* FIXME */ + Spi->CcMapDataWait = 0; /* FIXME */ + Spi->CcMapDataNoWaitMiss = 0; /* FIXME */ + Spi->CcMapDataWaitMiss = 0; /* FIXME */ + Spi->CcPinMappedDataCount = 0; /* FIXME */ + Spi->CcPinReadNoWait = 0; /* FIXME */ + Spi->CcPinReadWait = 0; /* FIXME */ + Spi->CcPinReadNoWaitMiss = 0; /* FIXME */ + Spi->CcPinReadWaitMiss = 0; /* FIXME */ + Spi->CcCopyReadNoWait = 0; /* FIXME */ + Spi->CcCopyReadWait = 0; /* FIXME */ + Spi->CcCopyReadNoWaitMiss = 0; /* FIXME */ + Spi->CcCopyReadWaitMiss = 0; /* FIXME */ + Spi->CcMdlReadNoWait = 0; /* FIXME */ + Spi->CcMdlReadWait = 0; /* FIXME */ + Spi->CcMdlReadNoWaitMiss = 0; /* FIXME */ + Spi->CcMdlReadWaitMiss = 0; /* FIXME */ + Spi->CcReadaheadIos = 0; /* FIXME */ + Spi->CcLazyWriteIos = 0; /* FIXME */ + Spi->CcLazyWritePages = 0; /* FIXME */ + Spi->CcDataFlushes = 0; /* FIXME */ + Spi->CcDataPages = 0; /* FIXME */ + Spi->ContextSwitches = 0; /* FIXME */ + Spi->Unknown13 = 0; /* FIXME */ + Spi->Unknown14 = 0; /* FIXME */ + Spi->SystemCalls = 0; /* FIXME */ + + return (STATUS_SUCCESS); +} + +/* Class 3 - Time Information */ +QSI_DEF(SystemTimeInformation) +{ + PSYSTEM_TIME_INFORMATION Sti + = (PSYSTEM_TIME_INFORMATION) Buffer; + + *ReqSize = sizeof (SYSTEM_TIME_INFORMATION); + /* + * Check user buffer's size + */ + if (Size < sizeof (SYSTEM_TIME_INFORMATION)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + + Sti->KeBootTime.QuadPart = 0; /* FIXME */ + Sti->KeSystemTime.QuadPart = 0; /* FIXME */ + Sti->ExpTimeZoneBias.QuadPart = 0; /* FIXME */ + Sti->ExpTimeZoneId = 0; /* FIXME */ + Sti->Unused = 0; /* FIXME */ + + return (STATUS_SUCCESS); +} + +/* Class 4 - Path Information */ +QSI_DEF(SystemPathInformation) +{ + /* FIXME: QSI returns STATUS_BREAKPOINT. Why? */ + return (STATUS_BREAKPOINT); +} + +/* Class 5 - Process Information */ +QSI_DEF(SystemProcessInformation) +{ + /* FIXME: scan the process+thread list */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 6 - SDT Information */ +QSI_DEF(SystemServiceDescriptorTableInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 7 - I/O Configuration Information */ +QSI_DEF(SystemIoConfigInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 8 - Processor Time Information */ +QSI_DEF(SystemProcessorTimeInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 9 - Global Flag Information */ +QSI_DEF(SystemNtGlobalFlagInformation) +{ + if (sizeof (SYSTEM_GLOBAL_FLAG_INFO) != Size) + { + * ReqSize = sizeof (SYSTEM_GLOBAL_FLAG_INFO); + return (STATUS_INFO_LENGTH_MISMATCH); + } + ((PSYSTEM_GLOBAL_FLAG_INFO) Buffer)->NtGlobalFlag = NtGlobalFlag; + return (STATUS_SUCCESS); +} + +SSI_DEF(SystemNtGlobalFlagInformation) +{ + if (sizeof (SYSTEM_GLOBAL_FLAG_INFO) != Size) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + NtGlobalFlag = ((PSYSTEM_GLOBAL_FLAG_INFO) Buffer)->NtGlobalFlag; + return (STATUS_SUCCESS); +} + +/* Class 10 - ? Information */ +QSI_DEF(SystemInformation10) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 11 - Modules Information */ +QSI_DEF(SystemModuleInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 12 - Resource Lock Information */ +QSI_DEF(SystemResourceLockInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 13 - ? Information */ +QSI_DEF(SystemInformation13) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 14 - ? Information */ +QSI_DEF(SystemInformation14) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 15 - ? Information */ +QSI_DEF(SystemInformation15) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 16 - Handle Information */ +QSI_DEF(SystemHandleInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 17 - Information */ +QSI_DEF(SystemObjectInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 18 - Information */ +QSI_DEF(SystemPageFileInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 19 - Information */ +QSI_DEF(SystemInstructionEmulationInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 20 - ? Information */ +QSI_DEF(SystemInformation20) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 21 - Information */ +QSI_DEF(SystemCacheInformation) +{ + if (Size < sizeof (SYSTEM_CACHE_INFORMATION)) + { + * ReqSize = sizeof (SYSTEM_CACHE_INFORMATION); + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +SSI_DEF(SystemCacheInformation) +{ + if (Size < sizeof (SYSTEM_CACHE_INFORMATION)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 22 - Pool Tag Information */ +QSI_DEF(SystemPoolTagInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 23 - Processor Schedule Information */ +QSI_DEF(SystemProcessorScheduleInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 24 - DPC Information */ +QSI_DEF(SystemDpcInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +SSI_DEF(SystemDpcInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 25 - ? Information */ +QSI_DEF(SystemInformation25) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 26 - Load Image (callable) */ +SSI_DEF(SystemLoadImage) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 27 - Unload Image (callable) */ +SSI_DEF(SystemUnloadImage) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 28 - Information */ +QSI_DEF(SystemTimeAdjustmentInformation) +{ + if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size) + { + * ReqSize = sizeof (SYSTEM_TIME_ADJUSTMENT_INFO); + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* FIXME: */ + return (STATUS_NOT_IMPLEMENTED); +} + +SSI_DEF(SystemTimeAdjustmentInformation) +{ + if (sizeof (SYSTEM_TIME_ADJUSTMENT_INFO) > Size) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* FIXME: */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 29 - ? Information */ +QSI_DEF(SystemInformation29) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 30 - ? Information */ +QSI_DEF(SystemInformation30) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 31 - ? Information */ +QSI_DEF(SystemInformation31) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 32 - Crach Dump Information */ +QSI_DEF(SystemCrashDumpSectionInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 33 - Processor Fault Information */ +QSI_DEF(SystemProcessorFaultCountInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 34 - Crach Dump State Information */ +QSI_DEF(SystemCrashDumpStateInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 35 - Debugger Information */ +QSI_DEF(SystemDebuggerInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 36 - Thread Switch Counters Information */ +QSI_DEF(SystemThreadSwitchCountersInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 37 - Quota Information */ +QSI_DEF(SystemQuotaInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +SSI_DEF(SystemQuotaInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 38 - Load Driver Information */ +SSI_DEF(SystemLoadDriverInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 39 - Priority Separation Information */ +SSI_DEF(SystemPrioritySeparationInfo) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 40 - ? Information */ +QSI_DEF(SystemInformation40) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 41 - ? Information */ +QSI_DEF(SystemInformation41) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 42 - ? Information */ +QSI_DEF(SystemInformation42) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 43 - ? Information */ +QSI_DEF(SystemInformation43) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + +/* Class 44 - Information */ +QSI_DEF(SystemTimeZoneInformation) +{ + * ReqSize = sizeof (TIME_ZONE_INFORMATION); + + if (sizeof (TIME_ZONE_INFORMATION) != Size) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* Copy the time zone information struct */ + memcpy ( + Buffer, + & SystemTimeZoneInfo, + sizeof (TIME_ZONE_INFORMATION) + ); + + return (STATUS_SUCCESS); +} + + +SSI_DEF(SystemTimeZoneInformation) +{ + /* + * Check user buffer's size + */ + if (Size < sizeof (TIME_ZONE_INFORMATION)) + { + return (STATUS_INFO_LENGTH_MISMATCH); + } + /* Copy the time zone information struct */ + memcpy ( + & SystemTimeZoneInfo, + (TIME_ZONE_INFORMATION *) Buffer, + sizeof (TIME_ZONE_INFORMATION) + ); + return (STATUS_SUCCESS); +} + + +/* Class 45 - Information */ +QSI_DEF(SystemLookasideInformation) +{ + /* FIXME */ + return (STATUS_NOT_IMPLEMENTED); +} + + +/* Query/Set Calls Table */ +typedef +struct _QSSI_CALLS +{ + NTSTATUS (* Query) (PVOID,ULONG,PULONG); + NTSTATUS (* Set) (PVOID,ULONG); + +} QSSI_CALLS; + +// QS Query & Set +// QX Query +// XQ Set +// XX unknown behaviour +// +#define SI_QS(n) {QSI_USE(n),SSI_USE(n)} +#define SI_QX(n) {QSI_USE(n),NULL} +#define SI_XS(n) {NULL,SSI_USE(n)} +#define SI_XX(n) {NULL,NULL} + +static +QSSI_CALLS +CallQS [] = +{ + SI_QX(SystemBasicInformation), + SI_QX(SystemProcessorInformation), + SI_QX(SystemPerformanceInfo), + SI_QX(SystemTimeInformation), + SI_QX(SystemPathInformation), /* should be SI_XX */ + SI_QX(SystemProcessInformation), + SI_QX(SystemServiceDescriptorTableInfo), + SI_QX(SystemIoConfigInfo), + SI_QX(SystemProcessorTimeInfo), + SI_QS(SystemNtGlobalFlagInformation), + SI_QX(SystemInformation10), /* should be SI_XX */ + SI_QX(SystemModuleInfo), + SI_QX(SystemResourceLockInfo), + SI_QX(SystemInformation13), /* should be SI_XX */ + SI_QX(SystemInformation14), /* should be SI_XX */ + SI_QX(SystemInformation15), /* should be SI_XX */ + SI_QX(SystemHandleInfo), + SI_QX(SystemObjectInformation), + SI_QX(SystemPageFileInformation), + SI_QX(SystemInstructionEmulationInfo), + SI_QX(SystemInformation20), /* it should be SI_XX */ + SI_QS(SystemCacheInformation), + SI_QX(SystemPoolTagInformation), + SI_QX(SystemProcessorScheduleInfo), + SI_QS(SystemDpcInformation), + SI_QX(SystemInformation25), /* it should be SI_XX */ + SI_XS(SystemLoadImage), + SI_XS(SystemUnloadImage), + SI_QS(SystemTimeAdjustmentInformation), + SI_QX(SystemInformation29), /* it should be SI_XX */ + SI_QX(SystemInformation30), /* it should be SI_XX */ + SI_QX(SystemInformation31), /* it should be SI_XX */ + SI_QX(SystemCrashDumpSectionInfo), + SI_QX(SystemProcessorFaultCountInfo), + SI_QX(SystemCrashDumpStateInfo), + SI_QX(SystemDebuggerInfo), + SI_QX(SystemThreadSwitchCountersInfo), + SI_QS(SystemQuotaInformation), + SI_XS(SystemLoadDriverInfo), + SI_XS(SystemPrioritySeparationInfo), + SI_QX(SystemInformation40), /* it should be SI_XX */ + SI_QX(SystemInformation41), /* it should be SI_XX */ + SI_QX(SystemInformation42), /* it should be SI_XX */ + SI_QX(SystemInformation43), /* it should be SI_XX */ + SI_QS(SystemTimeZoneInformation), /* it should be SI_QX */ + SI_QX(SystemLookasideInformation) +}; + + NTSTATUS STDCALL NtQuerySystemInformation ( - IN CINT SystemInformationClass, - OUT PVOID SystemInformation, - IN ULONG Length, - OUT PULONG ResultLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + OUT PVOID SystemInformation, + IN ULONG Length, + OUT PULONG ResultLength ) { /* @@ -74,118 +719,36 @@ NtQuerySystemInformation ( /* * Clear the user buffer. */ - memset( - SystemInformation, - 0, - Length - ); + RtlZeroMemory (SystemInformation, Length); /* * Check the request is valid. */ - switch (SystemInformationClass) + if ( (SystemInformationClass >= SystemInformationClassMin) + && (SystemInformationClass < SystemInformationClassMax) + ) { -#if 0 - /*---*/ - case SystemPerformanceInformation: - /* - * Check user buffer's size - */ - if (Length < sizeof()) - { - *ResultLength = - return STATUS_INFO_LENGTH_MISMATCH; - } - /* FIXME */ - return STATUS_SUCCESS; - /*---*/ - case SystemDriverInformation: - /* Check user buffer's size */ - if (Length < sizeof (SYSTEM_DRIVER_INFO)) - { - *ResultLength = sizeof (SYSTEM_DRIVER_INFO); - return STATUS_INFO_LENGTH_MISMATCH; - } - /* FIXME: */ - return STATUS_SUCCESS; - /*---*/ - case SystemCacheInformation: - /* Check user buffer's size */ - if (Length < sizeof (SYSTEM_CACHE_INFORMATION)) - { - *ResultLength = sizeof (SYSTEM_CACHE_INFORMATION); - return STATUS_INFO_LENGTH_MISMATCH; - } - return STATUS_SUCCESS; - /*---*/ - case SystemTimeAdjustmentInformation: - /* - * Check user buffer's size - */ - if (Length < sizeof (SYSTEM_TIME_ADJUSTMENT)) - { - *ResultLength = sizeof (SYSTEM_TIME_ADJUSTMENT); - return STATUS_INFO_LENGTH_MISMATCH; - } - /* FIXME: */ - return STATUS_SUCCESS; - /*---*/ - case SystemConfigurationInformation: + if (NULL != CallQS [SystemInformationClass].Query) { - PSYSTEM_CONFIGURATION_INFO Sci - = (PSYSTEM_CONFIGURATION_INFO) SystemInformation; - - *ResultLength = sizeof (SYSTEM_CONFIGUTATION_INFO); /* - * Check user buffer's size + * Hand the request to a subhandler. */ - if (Length < sizeof (SYSTEM_CONFIGURATION_INFO)) - { - return STATUS_INFO_LENGTH_MISMATCH; - } - /* - * Fill the object with config data. - * FIXME: some data should come from the - * registry. - */ - Sci->tag2.tag1.ProcessorAchitecture - = 80586; - Sci->tag2.tag1.Reserved - = 0x00000000; - Sci->PageSize - = 4096; - return STATUS_SUCCESS; + return CallQS [SystemInformationClass].Query ( + SystemInformation, + Length, + ResultLength + ); } -#endif - - case SystemTimeZoneInformation: /* 44 */ - *ResultLength = sizeof (TIME_ZONE_INFORMATION); - - /* - * Check user buffer's size - */ - if (Length < sizeof (TIME_ZONE_INFORMATION)) - { - return STATUS_INFO_LENGTH_MISMATCH; - } - - /* Copy the time zone information struct */ - memcpy (SystemInformation, - &SystemTimeZoneInfo, - sizeof (TIME_ZONE_INFORMATION)); - - return STATUS_SUCCESS; - } - return STATUS_INVALID_INFO_CLASS; + return (STATUS_INVALID_INFO_CLASS); } NTSTATUS STDCALL NtSetSystemInformation ( - IN CINT SystemInformationClass, - IN PVOID SystemInformation, - IN ULONG SystemInformationLength + IN SYSTEM_INFORMATION_CLASS SystemInformationClass, + IN PVOID SystemInformation, + IN ULONG SystemInformationLength ) { /* @@ -206,32 +769,25 @@ NtSetSystemInformation ( // ); } #endif - /* * Check the request is valid. */ - switch (SystemInformationClass) + if ( (SystemInformationClass >= SystemInformationClassMin) + && (SystemInformationClass < SystemInformationClassMax) + ) { - - - case SystemTimeZoneInformation: /* 44 */ + if (NULL != CallQS [SystemInformationClass].Set) + { /* - * Check user buffer's size + * Hand the request to a subhandler. */ - if (SystemInformationLength < sizeof (TIME_ZONE_INFORMATION)) - { - return STATUS_INFO_LENGTH_MISMATCH; - } - - /* Copy the time zone information struct */ - memcpy (&SystemTimeZoneInfo, - &SystemInformation, - sizeof (TIME_ZONE_INFORMATION)); - - return STATUS_SUCCESS; + return CallQS [SystemInformationClass].Set ( + SystemInformation, + SystemInformationLength + ); + } } - - return STATUS_INVALID_INFO_CLASS; + return (STATUS_INVALID_INFO_CLASS); } diff --git a/reactos/ntoskrnl/ex/time.c b/reactos/ntoskrnl/ex/time.c index 430942de2ea..f9207bf7c23 100644 --- a/reactos/ntoskrnl/ex/time.c +++ b/reactos/ntoskrnl/ex/time.c @@ -1,4 +1,5 @@ -/* +/* $Id: time.c,v 1.9 2000/04/25 23:22:56 ea Exp $ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: kernel/excutive/time.c @@ -22,7 +23,7 @@ /* GLOBALS ******************************************************************/ /* Note: Bias[minutes] = UTC - local time */ -TIME_ZONE_INFORMATION SystemTimeZoneInfo; +TIME_ZONE_INFORMATION _SystemTimeZoneInfo; /* FUNCTIONS ****************************************************************/ @@ -31,7 +32,7 @@ VOID ExInitTimeZoneInfo (VOID) { /* Initialize system time zone information */ - memset (&SystemTimeZoneInfo, 0, sizeof(TIME_ZONE_INFORMATION)); + memset (& _SystemTimeZoneInfo, 0, sizeof(TIME_ZONE_INFORMATION)); /* FIXME: Read time zone information from the registry */ @@ -69,7 +70,7 @@ ExLocalTimeToSystemTime ( ) { SystemTime->QuadPart = LocalTime->QuadPart + - SystemTimeZoneInfo.Bias * TICKSPERMINUTE; + _SystemTimeZoneInfo.Bias * TICKSPERMINUTE; } @@ -80,7 +81,7 @@ ExSystemTimeToLocalTime ( ) { LocalTime->QuadPart = SystemTime->QuadPart - - SystemTimeZoneInfo.Bias * TICKSPERMINUTE; + _SystemTimeZoneInfo.Bias * TICKSPERMINUTE; } /* EOF */ diff --git a/rosapps/rules.mak b/rosapps/rules.mak index 4bec7a6c58c..b329b8bb7fa 100644 --- a/rosapps/rules.mak +++ b/rosapps/rules.mak @@ -64,6 +64,7 @@ endif CC = $(PREFIX)gcc NATIVE_CC = gcc CFLAGS = \ + $(BASE_CFLAGS) \ -pipe \ -O2 \ -Wall \ diff --git a/rosapps/sysutils/chkdsk.c b/rosapps/sysutils/chkdsk.c index 38c9f3974d8..edd28177b70 100644 --- a/rosapps/sysutils/chkdsk.c +++ b/rosapps/sysutils/chkdsk.c @@ -1,6 +1,6 @@ //====================================================================== // -// $Id: chkdsk.c,v 1.2 2000/02/29 23:57:46 ea Exp $ +// $Id: chkdsk.c,v 1.3 2000/04/25 23:22:57 ea Exp $ // // Chkdskx // @@ -63,7 +63,7 @@ WCHAR CurrentDirectory[1024]; // // FMIFS function // -//PCHKDSK ChkDsk; +//PCHKDSK Chkdsk; #endif /* ndef FMIFS_IMPORT_DLL */ @@ -306,7 +306,7 @@ LoadFMIFSEntryPoints(VOID) { LoadLibraryW( L"fmifs.dll" ); - if( !(ChkDsk = + if( !(Chkdsk = (void *) GetProcAddress( GetModuleHandleW(L"fmifs.dll"), "Chkdsk" )) @@ -459,7 +459,7 @@ ReactOS adaptation 1999 by Emanuele Aliberti\n\n" L"The type of file system is %s.\n", fileSystem ); - ChkDsk( + Chkdsk( Drive, fileSystem, FixErrors, diff --git a/rosapps/sysutils/makefile b/rosapps/sysutils/makefile index b8a0c5a2290..49a81ddae4d 100644 --- a/rosapps/sysutils/makefile +++ b/rosapps/sysutils/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.3 2000/02/29 23:57:47 ea Exp $ +# $Id: makefile,v 1.4 2000/04/25 23:22:57 ea Exp $ # # ReactOS System Utilities # @@ -15,69 +15,110 @@ # 1999-12-19 (ea) # Added qsi.c # +# 2000-04-23 (ea) +# Added pedump.c +# +BASE_CFLAGS = -I../../reactos/include -ROSINC=../../reactos/include -TARGET=regnav.exe chklib.exe -# chkdsk.exe format.exe \ -# chklib.exe shutdown.exe regnav.exe -# login.exe chklib.exe shutdown.exe regnav.exe +ROS_DIR=../../reactos +ROS_INC=$(ROS_DIR)/include +ROS_LIB=$(ROS_DIR)/lib +IMPORT_NTDLL=$(ROS_LIB)/ntdll/ntdll.a +IMPORT_FMIFS=$(ROS_LIB)/fmifs/fmifs.a +IMPORT_KERNEL32=$(ROS_LIB)/kernel32/kernel32.a +IMPORT_USER32=$(ROS_LIB)/user32/user32.a +IMPORT_CRTDLL=$(ROS_LIB)/crtdll/crtdll.a + +TARGET=\ + regnav.exe \ + chklib.exe \ + qsi.exe +# pedump.exe \ +# shutdown.exe \ +# chkdsk.exe \ +# format.exe \ all: $(TARGET) # By Mark Russinovich chkdsk.exe: chkdsk.o win32err.o wmain.o - $(CC) chkdsk.o win32err.o wmain.o \ - -o chkdsk.exe \ - -lkernel32 \ - -lcrtdll \ - -lfmifs + $(CC) \ + chkdsk.o \ + win32err.o \ + wmain.o \ + $(IMPORT_FMIFS) \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o chkdsk.exe $(NM) --numeric-sort chkdsk.exe > chkdsk.sym format.exe: format.o win32err.o wmain.o - $(CC) format.o win32err.o wmain.o \ - -o format.exe \ - -lkernel32 \ - -lcrtdll \ - -lfmifs + $(CC) \ + format.o \ + win32err.o \ + wmain.o \ + $(IMPORT_FMIFS) \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o format.exe $(NM) --numeric-sort format.exe > format.sym #--- chklib.exe: chklib.o win32err.o - $(CC) chklib.o win32err.o \ - -o chklib.exe \ - -lkernel32 \ - -lcrtdll + $(CC) \ + chklib.o \ + win32err.o \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o chklib.exe $(NM) --numeric-sort chklib.exe > chklib.sym regnav.exe: regnav.o win32err.o - $(CC) regnav.o win32err.o \ - -o regnav.exe \ - -lkernel32 \ - -lcrtdll + $(CC) \ + regnav.o \ + win32err.o \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o regnav.exe $(NM) --numeric-sort regnav.exe > regnav.sym shutdown.exe: shutdown.o win32err.o - $(CC) shutdown.o win32err.o \ - -o shutdown.exe \ - -lkernel32 \ - -luser32 \ - -lcrtdll + $(CC) \ + shutdown.o \ + win32err.o \ + $(IMPORT_KERNEL32) \ + $(IMPORT_USER32) \ + $(IMPORT_CRTDLL) \ + -o shutdown.exe $(NM) --numeric-sort shutdown.exe > shutdown.sym qsi.exe: qsi.o - $(CC) qsi.o \ - ../../reactos/lib/ntdll/ntdll.a - -o qsi.exe \ - -lkernel32 \ - -lcrtdll + echo $(BASE_CFLAGS) + $(CC) \ + qsi.o \ + $(IMPORT_NTDLL) \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o qsi.exe $(NM) --numeric-sort qsi.exe > qsi.sym -qsi.o: qsi.c +qsi.o: qsi.c $(ROS_INC)/ddk/zwtypes.h + +pedump.exe: pedump.o + $(CC) \ + pedump.o \ + $(IMPORT_NTDLL) \ + $(IMPORT_KERNEL32) \ + $(IMPORT_CRTDLL) \ + -o pedump.exe + $(NM) --numeric-sort pedump.exe > pedump.sym + +pedump.o: pedump.c #--- diff --git a/rosapps/sysutils/qsi.c b/rosapps/sysutils/qsi.c new file mode 100644 index 00000000000..fa6989ed57f --- /dev/null +++ b/rosapps/sysutils/qsi.c @@ -0,0 +1,2548 @@ +/* $Id: qsi.c,v 1.1 2000/04/25 23:22:57 ea Exp $ + * + * PROJECT : ReactOS Operating System (see http://www.reactos.com/) + * DESCRIPTION: Tool to query system information + * FILE : rosapps/sysutils/qsi.c + * AUTHOR : Emanuele Aliberti + * LICENSE : GNU GPL (see http://www.gnu.org/) + * DATE : 1999-07-28 + * + * BUILD INSTRUCTIONS + * If you got this code directly from the CVS repository on + * mok.lcvm.com, it should be ok to run "make sqi.exe" from the + * current directory. Otherwise, be sure the directories + * "rosapps" and "reactos" are siblings (see the FILE file + * in the header). + * + * REVISIONS + * 2000-02-12 (ea) + * Partially rewritten to run as a tool to query + * every system information class data. + * 2000-04-23 (ea) + * Added almost all structures for getting system + * information (from UNDOCNT.H by Dabak et alii). + */ +#include +#include +#include +#include +#include + +#define NTOS_MODE_USER +#include + +typedef +struct _FLAGS +{ + DWORD Verbose:1; /* print unknown, unused, service fields */ + DWORD Dump:1; /* raw dump output buffer */ + DWORD Batch:1; /* no shell (for future use) */ +} FLAGS; + +static +struct +{ + FLAGS Flag; + BOOL Active; + HANDLE Heap; + INT ExitCode; + +} Application = +{ + {0, 0}, + FALSE +}; + +#define ONOFF(b) ((b)?"on":"off") + +#define ARGV_SIZE 64 + +#define BUFFER_SIZE_DEFAULT 65536 + +#define TF(b) ((b)?"true":"false") + +typedef +INT (* COMMAND_CALL) (INT ArgC,LPCSTR ArgV []); + + + +VOID STDCALL PrintStatus (NTSTATUS Status); + +#define CMD_REF(n) CMD_##n +#define CMD_DEF(n) INT CMD_REF(n) (INT argc, LPCSTR argv []) +#define CMD_NOT_IMPLEMENTED {printf("%s not implemented\n", argv[0]);return(0);} + +typedef +struct _COMMAND_DESCRIPTOR +{ + LPCSTR Name; + COMMAND_CALL EntryPoint; + LPCSTR Description; + +} COMMAND_DESCRIPTOR, * PCOMMAND_DESCRIPTOR; + + + +/* --- */ +VOID +STDCALL +DumpData (int Size, PVOID pData ) +{ + PBYTE Buffer = (PBYTE) pData; + PBYTE Base = Buffer; + int i; + const int Width = 16; + + if (! Application.Flag.Dump) + { + return; + } + while (Size > 0) + { + printf ("%04x: ", (Buffer - Base)); + for ( i = 0; + (i < Width); + ++i + ) + { + if (Size - i > 0) + { + printf ( + "%02x%c", + Buffer[i], + (i % 4 == 3) ? '|' : ' ' + ); + } + else + { + printf (" "); + } + } + printf (" "); + for ( i = 0; + (i < Width); + ++i + ) + { + if (Size - i > 0) + { + printf ( + "%c", + ( (Buffer[i] > ' ') + && (Buffer[i] < 127) + ) + ? Buffer[i] + : ' ' + ); + } + } + printf ("\n"); + Buffer += Width; + Size -= Width; + } + printf ("\n"); +} + + +int +STDCALL +FindRequiredBufferSize (int i, int step) +{ + NTSTATUS Status = STATUS_INFO_LENGTH_MISMATCH; + BYTE Buffer [BUFFER_SIZE_DEFAULT]; + INT Size; + LONG Length = 0; + + + Size = step = (step > 0 ? step : 1); + while ( (Size < sizeof Buffer) + && (Status == STATUS_INFO_LENGTH_MISMATCH) + ) + { + if (Application.Flag.Verbose) + { + printf ("\tTry %d", Size); + } + RtlZeroMemory (Buffer, sizeof Buffer); + Length = 0; + Status = NtQuerySystemInformation ( + i, + & Buffer, + Size, + & Length + ); + if (STATUS_SUCCESS == Status) + { + printf ("Length = %d\n", Size); + return Size; + } + if (Length > 0) + { + Size = Length; + } + else + { + /* FIXME: slow linear search! */ + Size += step; + } + } + printf ("No valid buffer length found!\n"); + return -1; +} + + +VOID +STDCALL +PrintStatus (NTSTATUS Status) +{ + LPCSTR StatusName = NULL; + + switch (Status) + { + case STATUS_INVALID_INFO_CLASS: + StatusName = "STATUS_INVALID_INFO_CLASS"; + break; + case STATUS_INFO_LENGTH_MISMATCH: + StatusName = "STATUS_INFO_LENGTH_MISMATCH"; + break; + case STATUS_ACCESS_VIOLATION: + StatusName = "STATUS_ACCESS_VIOLATION"; + break; + case STATUS_NOT_IMPLEMENTED: + StatusName = "STATUS_NOT_IMPLEMENTED"; + break; + case STATUS_BREAKPOINT: + StatusName = "STATUS_BREAKPOINT"; + break; + } + if (NULL != StatusName) + { + printf ("\tStatus = %s\n", StatusName); + return; + } + printf ("\tStatus = 0x%08lX\n", Status ); +} + +/* Auxiliary functions */ + +PCHAR +DaysOfWeek [] = +{ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday" +}; + +VOID +STDCALL +PrintUtcDateTime (LPCSTR Template, PTIME UtcTime) +{ + CHAR UtcTimeString [64]; + TIME_FIELDS UtcTimeFields; + + RtlTimeToTimeFields ( + (PLARGE_INTEGER) UtcTime, + & UtcTimeFields + ); + sprintf ( + UtcTimeString, + "%s %d-%02d-%02d %02d:%02d:%02d.%03d UTC", + DaysOfWeek[UtcTimeFields.Weekday], + UtcTimeFields.Year, + UtcTimeFields.Month, + UtcTimeFields.Day, + UtcTimeFields.Hour, + UtcTimeFields.Minute, + UtcTimeFields.Second, + UtcTimeFields.Milliseconds + ); + printf ( + Template, + UtcTimeString + ); +} + + +/********************************************************************** + * Dumpers + **********************************************************************/ + + +/********************************************************************** + * + * DESCRIPTION + * Dump whatever we get by calling NtQuerySystemInformation with + * a user provided system information class id. + * NOTE + * NtQuerySystemInformation called with user class id. + */ +CMD_DEF(unknown) +{ + int _id = atoi ((char*)(argv[0] + 1)); /* "#24" */ + /* ^ */ + int Size = -1; + PBYTE Buffer = NULL; + NTSTATUS Status; + + + printf ("SystemInformation %d:\n", _id); + /* Find buffer size */ + Size = FindRequiredBufferSize (_id, 1); + if (-1 == Size) + { + printf("\t(no data)\n"); + return EXIT_FAILURE; + } + /* Allocate the buffer */ + Buffer = GlobalAlloc (GMEM_ZEROINIT, Size); + if (NULL == Buffer) + { + printf ("#%d: could not allocate %d bytes\n", _id, Size); + return EXIT_FAILURE; + } + /* Query the executive */ + Status = NtQuerySystemInformation ( + _id, + Buffer, + Size, + NULL + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + FindRequiredBufferSize (_id, 1); + GlobalFree (Buffer); + return EXIT_FAILURE; + } + /* Print the data */ + DumpData (Size, Buffer); + /* --- */ + GlobalFree (Buffer); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 0. + */ +CMD_DEF(Basic) +{ + NTSTATUS Status; + SYSTEM_BASIC_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemBasicInformation:\n"); + } + RtlZeroMemory ( + (PVOID) & Info, + sizeof Info + ); + Status = NtQuerySystemInformation ( + SystemBasicInformation, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tAlwaysZero = 0x%08x\n", Info.AlwaysZero); + printf ("\tKeMaximumIncrement = %ld\n", Info.KeMaximumIncrement); + printf ("\tMmPageSize = %ld\n", Info.MmPageSize); + printf ("\tMmNumberOfPhysicalPages = %ld\n", Info.MmNumberOfPhysicalPages); + printf ("\tMmLowestPhysicalPage = %ld\n", Info.MmLowestPhysicalPage); + printf ("\tMmHighestPhysicalPage = %ld\n", Info.MmHighestPhysicalPage); + printf ("\tMmLowestUserAddress = 0x%08x\n", Info.MmLowestUserAddress); + printf ("\tMmLowestUserAddress1 = 0x%08x\n", Info.MmLowestUserAddress1); + printf ("\tMmHighestUserAddress = 0x%08x\n", Info.MmHighestUserAddress); + printf ("\tKeActiveProcessors = 0x%08x\n", Info.KeActiveProcessors); + printf ("\tKeNumberProcessors = %ld\n", Info.KeNumberProcessors); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 1. + */ +CMD_DEF(Processor) +{ + NTSTATUS Status; + SYSTEM_PROCESSOR_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemProcessorInformation:\n"); + } + RtlZeroMemory ( + (PVOID) & Info, + sizeof Info + ); + Status = NtQuerySystemInformation ( + SystemProcessorInformation, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tKeProcessorArchitecture = %ld\n", Info.KeProcessorArchitecture); + printf ("\tKeProcessorLevel = %ld\n", Info.KeProcessorLevel); + printf ("\tKeProcessorRevision = %ld\n", Info.KeProcessorRevision); + if (Application.Flag.Verbose) + { + printf ("\tAlwaysZero = 0x%08x\n", Info.AlwaysZero); + } + printf ("\tKeFeatureBits = %08x\n", Info.KeFeatureBits); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * System performance information. + * + * NOTE + * Class 2. + */ +CMD_DEF(Performance) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSYSTEM_PERFORMANCE_INFO Info; + LONG Length = 0; + + + if (Application.Flag.Verbose) + { + printf ("SystemPerformanceInformation:\n"); + } + Status = NtQuerySystemInformation ( + SystemPerformanceInformation, + & Info, + sizeof Info, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("Not implemented.\n"); +#if 0 + LARGE_INTEGER TotalProcessorTime; + LARGE_INTEGER IoReadTransferCount; + LARGE_INTEGER IoWriteTransferCount; + LARGE_INTEGER IoOtherTransferCount; + ULONG IoReadOperationCount; + ULONG IoWriteOperationCount; + ULONG IoOtherOperationCount; + ULONG MmAvailablePages; + ULONG MmTotalCommitedPages; + ULONG MmTotalCommitLimit; + ULONG MmPeakLimit; + ULONG PageFaults; + ULONG WriteCopies; + ULONG TransitionFaults; + ULONG Unknown1; + ULONG DemandZeroFaults; + ULONG PagesInput; + ULONG PagesRead; + ULONG Unknown2; + ULONG Unknown3; + ULONG PagesOutput; + ULONG PageWrites; + ULONG Unknown4; + ULONG Unknown5; + ULONG PoolPagedBytes; + ULONG PoolNonPagedBytes; + ULONG Unknown6; + ULONG Unknown7; + ULONG Unknown8; + ULONG Unknown9; + ULONG MmTotalSystemFreePtes; + ULONG MmSystemCodepage; + ULONG MmTotalSystemDriverPages; + ULONG MmTotalSystemCodePages; + ULONG Unknown10; + ULONG Unknown11; + ULONG Unknown12; + ULONG MmSystemCachePage; + ULONG MmPagedPoolPage; + ULONG MmSystemDriverPage; + ULONG CcFastReadNoWait; + ULONG CcFastReadWait; + ULONG CcFastReadResourceMiss; + ULONG CcFastReadNotPossible; + ULONG CcFastMdlReadNoWait; + ULONG CcFastMdlReadWait; + ULONG CcFastMdlReadResourceMiss; + ULONG CcFastMdlReadNotPossible; + ULONG CcMapDataNoWait; + ULONG CcMapDataWait; + ULONG CcMapDataNoWaitMiss; + ULONG CcMapDataWaitMiss; + ULONG CcPinMappedDataCount; + ULONG CcPinReadNoWait; + ULONG CcPinReadWait; + ULONG CcPinReadNoWaitMiss; + ULONG CcPinReadWaitMiss; + ULONG CcCopyReadNoWait; + ULONG CcCopyReadWait; + ULONG CcCopyReadNoWaitMiss; + ULONG CcCopyReadWaitMiss; + ULONG CcMdlReadNoWait; + ULONG CcMdlReadWait; + ULONG CcMdlReadNoWaitMiss; + ULONG CcMdlReadWaitMiss; + ULONG CcReadaheadIos; + ULONG CcLazyWriteIos; + ULONG CcLazyWritePages; + ULONG CcDataFlushes; + ULONG CcDataPages; + ULONG ContextSwitches; + ULONG Unknown13; + ULONG Unknown14; + ULONG SystemCalls; +#endif + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 3. + */ +CMD_DEF(Time) +{ + NTSTATUS Status; + SYSTEM_TIME_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemTimeInformation:\n"); + } + Status = NtQuerySystemInformation ( + SystemTimeInformation, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + PrintUtcDateTime ("\tKeBootTime : %s\n", & Info.KeBootTime); + PrintUtcDateTime ("\tKeSystemTime : %s\n", & Info.KeSystemTime); + PrintUtcDateTime ("\tExpTimeZoneBias: %s\n", & Info.ExpTimeZoneBias); /* FIXME */ + printf ("\tExpTimeZoneId : %ld\n", Info.ExpTimeZoneId); + if (Application.Flag.Verbose) + { + printf ("\tUnused : %08x (?)\n", Info.Unused); + } + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 4. + */ +CMD_DEF(Path) +{ + NTSTATUS Status; + SYSTEM_PATH_INFORMATION Info; + CHAR _Info [_MAX_PATH]; + ULONG Length = 0; + + RtlZeroMemory (& Info, _MAX_PATH); + Status = NtQuerySystemInformation ( + SystemPathInformation, + & _Info, + _MAX_PATH, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + DumpData (_MAX_PATH, & _Info); + return EXIT_FAILURE; + } + DumpData (_MAX_PATH, & _Info); + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * A snapshot of the process+thread tables. + * + * NOTE + * Class 5. + */ +CMD_DEF(Process) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSYSTEM_PROCESS_INFORMATION pInfo = NULL; + LONG Length = 0; + ULONG ThreadIndex; + + pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT); + /* FIXME: check NULL==pInfo */ + + if (Application.Flag.Verbose) + { + printf ("SystemProcessInformation:\n"); + } + /* + * Obtain required buffer size + */ + Status = NtQuerySystemInformation ( + SystemProcessInformation, + pInfo, + BUFFER_SIZE_DEFAULT, + & Length + ); + if (STATUS_SUCCESS != Status) + { + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT); + if (NULL == pInfo) + { + printf ("\tCould not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + } + /* + * Get process+thread list from ntoskrnl.exe + */ + Status = NtQuerySystemInformation ( + SystemProcessInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + + while (1) + { + wprintf (L"%s:\n", (pInfo->Name.Length ? pInfo->Name.Buffer : L"*idle*") ); + if (Application.Flag.Verbose) + { + wprintf (L"\tRelativeOffset = 0x%08x\n", pInfo->RelativeOffset); + } + wprintf (L"\tThreads = %ld\n", pInfo->ThreadCount); + wprintf (L"\tHandles = %ld\n", pInfo->HandleCount); + wprintf (L"\tBasePriority = %ld\n", pInfo->BasePriority); + wprintf (L"\tPID = %ld\n", pInfo->ProcessId); + wprintf (L"\tPPID = %ld\n", pInfo->ParentProcessId); + wprintf (L"\tVirtualSize:\t\tWorkingSetSize:\n"); + wprintf (L"\t\tPeak : %ld\t\t\tPeak : %ld\n", + pInfo->PeakVirtualSizeBytes, + pInfo->PeakWorkingSetSizeBytes + ); + wprintf (L"\t\tTotal: %ld\t\t\tTotal: %ld\n", + pInfo->TotalVirtualSizeBytes, + pInfo->TotalWorkingSetSizeBytes + ); + wprintf (L"\tPagedPoolUsage:\t\tNonPagedPoolUsage:\n"); + wprintf (L"\t\tPeak : %ld\t\t\tPeak : %ld\n", + pInfo->PeakPagedPoolUsagePages, + pInfo->TotalPagedPoolUsagePages + ); + wprintf (L"\t\tTotal: %ld\t\t\tTotal: %ld\n", + pInfo->PeakNonPagedPoolUsagePages, + pInfo->TotalNonPagedPoolUsagePages + ); + wprintf (L"\tPageFileUsage:\n"); + wprintf (L"\t\tPeak : %ld\n", pInfo->PeakPageFileUsageBytes); + wprintf (L"\t\tTotal: %ld\n", pInfo->TotalPageFileUsageBytes); + + wprintf (L"\tPageFaultCount = %ld\n", pInfo->PageFaultCount); + wprintf (L"\tTotalPrivateBytes = %ld\n", pInfo->TotalPrivateBytes); + /* Threads */ + for ( ThreadIndex = 0; + (ThreadIndex < pInfo->ThreadCount); + ThreadIndex ++ + ) + { + wprintf (L"\t%x in %x:\n", + pInfo->ThreadSysInfo[ThreadIndex].ClientId.UniqueThread, + pInfo->ThreadSysInfo[ThreadIndex].ClientId.UniqueProcess + ); + PrintUtcDateTime ( + "\t\tKernelTime = %s\n", + & (pInfo->ThreadSysInfo[ThreadIndex].KernelTime) + ); + PrintUtcDateTime ( + "\t\tUserTime = %s\n", + & (pInfo->ThreadSysInfo[ThreadIndex].UserTime) + ); + PrintUtcDateTime ( + "\t\tCreateTime = %s\n", + & (pInfo->ThreadSysInfo[ThreadIndex].CreateTime) + ); + wprintf (L"\t\tTickCount = %ld\n", + pInfo->ThreadSysInfo[ThreadIndex].TickCount + ); + wprintf (L"\t\tStartEIP = 0x%08x\n", + pInfo->ThreadSysInfo[ThreadIndex].StartEIP + ); + /* CLIENT_ID ClientId; */ + wprintf (L"\t\tDynamicPriority = %d\n", + pInfo->ThreadSysInfo[ThreadIndex].DynamicPriority + ); + wprintf (L"\t\tBasePriority = %d\n", + pInfo->ThreadSysInfo[ThreadIndex].BasePriority + ); + wprintf (L"\t\tnSwitches = %ld\n", + pInfo->ThreadSysInfo[ThreadIndex].nSwitches + ); + wprintf (L"\t\tState = 0x%08x\n", + pInfo->ThreadSysInfo[ThreadIndex].State + ); + wprintf (L"\t\tWaitReason = %ld\n", + pInfo->ThreadSysInfo[ThreadIndex].WaitReason + ); + } + /* Next */ + if (0 == pInfo->RelativeOffset) + { + break; + } + (ULONG) pInfo += pInfo->RelativeOffset; + } + + DumpData (Length, pInfo); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 6. + */ +CMD_DEF(ServiceDescriptorTable) +{ + NTSTATUS Status; + SYSTEM_SDT_INFORMATION Info; + ULONG Length = 0; + +/* FIXME */ + if (Application.Flag.Verbose) + { + printf ("SystemServiceDescriptorTableInfo:\n"); + } + RtlZeroMemory (& Info, sizeof Info); + Status = NtQuerySystemInformation ( + SystemServiceDescriptorTableInfo, + & Info, + sizeof Info, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + DumpData (Length, & Info); + return EXIT_FAILURE; + } + printf ("\tBufferLength = %ld\n", Info.BufferLength); + printf ("\tNumberOfSystemServiceTables = %ld\n", Info.NumberOfSystemServiceTables); + printf ("\tNumberOfServices = %ld\n", Info.NumberOfServices [0]); + printf ("\tServiceCounters = %ld\n", Info.ServiceCounters [0]); + + DumpData (Length, & Info); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 7. + */ +CMD_DEF(IoConfig) +{ + NTSTATUS Status = STATUS_SUCCESS; + SYSTEM_IOCONFIG_INFORMATION Info; + ULONG Length = 0; + + if (Application.Flag.Verbose) + { + printf ("SystemIoConfigInformation:\n"); + } + Status = NtQuerySystemInformation ( + SystemIoConfigInformation, + & Info, + sizeof Info, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tDiskCount : %ld\n", Info.DiskCount); + printf ("\tFloppyCount : %ld\n", Info.FloppyCount); + printf ("\tCdRomCount : %ld\n", Info.CdRomCount); + printf ("\tTapeCount : %ld\n", Info.TapeCount); + printf ("\tSerialCount : %ld\n", Info.SerialCount); + printf ("\tParallelCount: %ld\n", Info.ParallelCount); + + DumpData (Length, & Info); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 8. + */ +CMD_DEF(ProcessorTime) +{ + NTSTATUS Status; + SYSTEM_PROCESSORTIME_INFO Info; + ULONG Length = 0; + + if (Application.Flag.Verbose) + { + printf ("SystemProcessorTimeInformation:\n"); + } + Status = NtQuerySystemInformation ( + SystemProcessorTimeInformation, + & Info, + sizeof Info, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + PrintUtcDateTime ("\tTotalProcessorRunTime : %s\n", & Info.TotalProcessorRunTime); + PrintUtcDateTime ("\tTotalProcessorTime : %s\n", & Info.TotalProcessorTime); + PrintUtcDateTime ("\tTotalProcessorUserTime: %s\n", & Info.TotalProcessorUserTime); + PrintUtcDateTime ("\tTotalDPCTime : %s\n", & Info.TotalDPCTime); + PrintUtcDateTime ("\tTotalInterruptTime : %s\n", & Info.TotalInterruptTime); + printf ("\tTotalInterrupts : %ld\n", Info.TotalInterrupts); + if (Application.Flag.Verbose) + { + printf ("\tUnused : %08x\n", Info.Unused); + } + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 9. + */ +CMD_DEF(NtGlobalFlag) +{ + NTSTATUS Status; + SYSTEM_GLOBAL_FLAG_INFO Info; + ULONG Length = 0; + + if (Application.Flag.Verbose) + { + printf ("SystemNtGlobalFlagInformation:\n"); + } + Status = NtQuerySystemInformation ( + SystemNtGlobalFlagInformation, + & Info, + sizeof Info, + & Length + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tNtGlobalFlag: %08x\n", Info.NtGlobalFlag); + /* FIXME: decode each flag */ + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 10. + */ +CMD_DEF(10) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 11. + * + * NOTE + * Code originally in Yariv Kaplan's NtDriverList, + * at http://www.internals.com/, adapted to ReactOS + * structures layout. + */ +CMD_DEF(Module) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSYSTEM_MODULE_INFORMATION pInfo = NULL; + LONG Length = 0; + INT Index; + const PCHAR hr = + "-------- -------- -------- ---------------------------------------\n"; + + + if (Application.Flag.Verbose) + { + printf ("SystemModuleInformation:\n"); + } + /* + * Obtain required buffer size + */ + Status = NtQuerySystemInformation ( + SystemModuleInformation, + & pInfo, + 0, /* query size */ + & Length + ); + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalAlloc (GMEM_ZEROINIT, Length); + if (NULL == pInfo) + { + printf ("Could not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + return EXIT_FAILURE; + } + /* + * Get module list from ntoskrnl.exe + */ + Status = NtQuerySystemInformation ( + SystemModuleInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("Index Address Size Name\n"); + printf (hr); + + for ( Index = 0; + (Index < (int) pInfo->Count); + Index ++ + ) + { + printf ( + "%8x %08x %8x %s\n", + pInfo->Module[Index].ModuleEntryIndex, + pInfo->Module[Index].ModuleBaseAddress, + pInfo->Module[Index].ModuleSize, + pInfo->Module[Index].ModuleName + ); + } + printf (hr); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 12. + */ +CMD_DEF(ResourceLock) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSYSTEM_RESOURCE_LOCK_INFO pInfo = NULL; + LONG Length = 0; + INT Index; + const PCHAR hr = + "-------- -------- -------- -------- -------- -------- ------------\n"; + + pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT); + /* FIXME: check NULL==pInfo */ + + if (Application.Flag.Verbose) + { + printf ("SystemResourceLockInformation:\n"); + } + /* + * Obtain required buffer size + */ + Status = NtQuerySystemInformation ( + SystemResourceLockInformation, + pInfo, + BUFFER_SIZE_DEFAULT, /* query size */ + & Length + ); + if (STATUS_SUCCESS != Status) + { + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT); + if (NULL == pInfo) + { + printf ("Could not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + } + /* + * Get locked resource list from ntoskrnl.exe + */ + Status = NtQuerySystemInformation ( + SystemResourceLockInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + printf ("Address Active # Content# Sh/Wait Exc/Wait\n"); + printf (hr); + + for ( Index = 0; + (Index < (int) pInfo->Count); + Index ++ + ) + { + printf ( + "%08x %8ld %8ld %8ld %8ld %08x\n", + pInfo->Lock[Index].ResourceAddress, + pInfo->Lock[Index].ActiveCount, + pInfo->Lock[Index].ContentionCount, + pInfo->Lock[Index].NumberOfSharedWaiters, + pInfo->Lock[Index].NumberOfExclusiveWaiters, + pInfo->Lock[Index].Unknown + ); + } + printf (hr); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 13. + */ +CMD_DEF(13) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 14. + */ +CMD_DEF(14) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 15. + */ +CMD_DEF(15) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 16. You can not pass 0 as the initial output buffer's + * size to get back the needed buffer size. + */ +CMD_DEF(Handle) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSYSTEM_HANDLE_INFORMATION pInfo = NULL; + LONG Length = 0; + INT Index; + const PCHAR hr = + "-------- -------- -------- -------- --------\n"; + + pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT); + + if (Application.Flag.Verbose) + { + printf ("SystemHandleInformation:\n"); + } + /* + * Obtain required buffer size + */ + Status = NtQuerySystemInformation ( + SystemHandleInformation, + pInfo, + BUFFER_SIZE_DEFAULT, + & Length + ); + if (STATUS_SUCCESS != Status) + { + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT); + if (NULL == pInfo) + { + printf ("\tCould not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + } + /* + * Get handle table from ntoskrnl.exe + */ + Status = NtQuerySystemInformation ( + SystemHandleInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + printf ("Handle OwnerPID ObjType ObjPtr Access\n"); + printf (hr); + + for ( Index = 0; + (Index < (int) pInfo->Count); + Index ++ + ) + { + printf ( + "%8x %8x %8x %8x %8x\n", + pInfo->Handle[Index].HandleValue, + pInfo->Handle[Index].OwnerPid, + pInfo->Handle[Index].ObjectType, + pInfo->Handle[Index].ObjectPointer, + pInfo->Handle[Index].AccessMask + ); + } + printf (hr); + + DumpData (Length, pInfo); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 17. + */ +CMD_DEF(Object) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 18. + */ +CMD_DEF(PageFile) +{ + NTSTATUS Status; + PSYSTEM_PAGEFILE_INFORMATION pInfo = NULL; + LONG Length = 0; + + pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT); + /* FIXME: check pInfo */ + + if (Application.Flag.Verbose) + { + printf ("SystemPageFileInformation:\n"); + } + Status = NtQuerySystemInformation( + SystemPageFileInformation, + pInfo, + BUFFER_SIZE_DEFAULT, + & Length + ); + if (STATUS_SUCCESS != Status) + { + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT); + if (NULL == pInfo) + { + printf ("Could not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + } + Status = NtQuerySystemInformation ( + SystemPageFileInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + + while (1) + { + wprintf (L"\t\"%s\":\n", pInfo->PagefileFileName.Buffer); + if (Application.Flag.Verbose) + { + wprintf (L"\t\tRelativeOffset = %08x\n", pInfo->RelativeOffset); + } + wprintf (L"\t\tCurrentSizePages = %ld\n", pInfo->CurrentSizePages); + wprintf (L"\t\tTotalUsedPages = %ld\n", pInfo->TotalUsedPages); + wprintf (L"\t\tPeakUsedPages = %ld\n", pInfo->PeakUsedPages); + + if (0 == pInfo->RelativeOffset) + { + break; + } + printf ("\n"); + (ULONG) pInfo += pInfo->RelativeOffset; + } + + DumpData (Length, pInfo); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 19. + */ +CMD_DEF(InstructionEmulation) +{ + NTSTATUS Status; + SYSTEM_VDM_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemInstructionEmulationInfo:\n"); + } + RtlZeroMemory (& Info, sizeof Info); + Status = NtQuerySystemInformation ( + SystemInstructionEmulationInfo, + & Info, + sizeof Info, + NULL + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tVdmSegmentNotPresentCount = %ld\n", Info.VdmSegmentNotPresentCount); + printf ("\tVdmINSWCount = %ld\n", Info.VdmINSWCount); + printf ("\tVdmESPREFIXCount = %ld\n", Info.VdmESPREFIXCount); + printf ("\tVdmCSPREFIXCount = %ld\n", Info.VdmCSPREFIXCount); + printf ("\tVdmSSPREFIXCount = %ld\n", Info.VdmSSPREFIXCount); + printf ("\tVdmDSPREFIXCount = %ld\n", Info.VdmDSPREFIXCount); + printf ("\tVdmFSPREFIXCount = %ld\n", Info.VdmFSPREFIXCount); + printf ("\tVdmGSPREFIXCount = %ld\n", Info.VdmGSPREFIXCount); + printf ("\tVdmOPER32PREFIXCount = %ld\n", Info.VdmOPER32PREFIXCount); + printf ("\tVdmADDR32PREFIXCount = %ld\n", Info.VdmADDR32PREFIXCount); + printf ("\tVdmINSBCount = %ld\n", Info.VdmINSBCount); + printf ("\tVdmINSWV86Count = %ld\n", Info.VdmINSWV86Count); + printf ("\tVdmOUTSBCount = %ld\n", Info.VdmOUTSBCount); + printf ("\tVdmOUTSWCount = %ld\n", Info.VdmOUTSWCount); + printf ("\tVdmPUSHFCount = %ld\n", Info.VdmPUSHFCount); + printf ("\tVdmPOPFCount = %ld\n", Info.VdmPOPFCount); + printf ("\tVdmINTNNCount = %ld\n", Info.VdmINTNNCount); + printf ("\tVdmINTOCount = %ld\n", Info.VdmINTOCount); + printf ("\tVdmIRETCount = %ld\n", Info.VdmIRETCount); + printf ("\tVdmINBIMMCount = %ld\n", Info.VdmINBIMMCount); + printf ("\tVdmINWIMMCount = %ld\n", Info.VdmINWIMMCount); + printf ("\tVdmOUTBIMMCount = %ld\n", Info.VdmOUTBIMMCount); + printf ("\tVdmOUTWIMMCount = %ld\n", Info.VdmOUTWIMMCount); + printf ("\tVdmINBCount = %ld\n", Info.VdmINBCount); + printf ("\tVdmINWCount = %ld\n", Info.VdmINWCount); + printf ("\tVdmOUTBCount = %ld\n", Info.VdmOUTBCount); + printf ("\tVdmOUTWCount = %ld\n", Info.VdmOUTWCount); + printf ("\tVdmLOCKPREFIXCount = %ld\n", Info.VdmLOCKPREFIXCount); + printf ("\tVdmREPNEPREFIXCount = %ld\n", Info.VdmREPNEPREFIXCount); + printf ("\tVdmREPPREFIXCount = %ld\n", Info.VdmREPPREFIXCount); + printf ("\tVdmHLTCount = %ld\n", Info.VdmHLTCount); + printf ("\tVdmCLICount = %ld\n", Info.VdmCLICount); + printf ("\tVdmSTICount = %ld\n", Info.VdmSTICount); + printf ("\tVdmBopCount = %ld\n", Info.VdmBopCount); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 20. + */ +CMD_DEF(20) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 21. + */ +CMD_DEF(Cache) +{ + NTSTATUS Status; + SYSTEM_CACHE_INFORMATION Si; + + if (Application.Flag.Verbose) + { + printf ("SystemCacheInformation:\n"); + } + RtlZeroMemory ( + (PVOID) & Si, + sizeof Si + ); + Status = NtQuerySystemInformation ( + SystemCacheInformation, + & Si, + sizeof Si, + 0 + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tSize:\n"); + printf ("\t\tCurrent = %ld\n", Si.CurrentSize); + printf ("\t\tPeak = %ld\n\n", Si.PeakSize); + printf ("\tPageFaults:\n\t\tCount = %ld\n\n", Si.PageFaultCount); + printf ("\tWorking Set:\n"); + printf ("\t\tMinimum = %ld\n", Si.MinimumWorkingSet ); + printf ("\t\tMaximum = %ld\n", Si.MaximumWorkingSet ); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * Get statistic data about tagged pools. Not implemented in the + * free build. + * + * NOTE + * Class 22. + */ +CMD_DEF(PoolTag) +{ + NTSTATUS Status; + PSYSTEM_POOL_TAG_INFO pInfo = NULL; + ULONG Length; + ULONG PoolIndex; + + pInfo = GlobalAlloc (GMEM_ZEROINIT, BUFFER_SIZE_DEFAULT); + /* FIXME: check pInfo */ + + if (Application.Flag.Verbose) + { + printf ("SystemPoolTagInformation:\n"); + } + Status = NtQuerySystemInformation( + SystemPoolTagInformation, + pInfo, + BUFFER_SIZE_DEFAULT, + & Length + ); + if (STATUS_SUCCESS != Status) + { + if (STATUS_INFO_LENGTH_MISMATCH == Status) + { + /* + * Allocate buffer + */ + pInfo = GlobalReAlloc (pInfo, Length, GMEM_ZEROINIT); + if (NULL == pInfo) + { + printf ("Could not allocate memory.\n"); + return EXIT_FAILURE; + } + } + else + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + } + Status = NtQuerySystemInformation ( + SystemPoolTagInformation, + pInfo, + Length, + & Length + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + GlobalFree (pInfo); + return EXIT_FAILURE; + } + + for ( PoolIndex = 0; + (PoolIndex < pInfo->Count); + PoolIndex ++ + ) + { + wprintf (L"\t%08x:\n", pInfo->PoolEntry[PoolIndex].Tag); + wprintf (L"\t\tPaged:\t\tNon Paged:\n"); + wprintf ( + L"\t\tAllocationCount = %ld\tAllocationCount = %ld\n", + pInfo->PoolEntry[PoolIndex].Paged.AllocationCount, + pInfo->PoolEntry[PoolIndex].NonPaged.AllocationCount + ); + wprintf ( + L"\t\tFreeCount = %ld\tFreeCount = %ld\n", + pInfo->PoolEntry[PoolIndex].Paged.FreeCount, + pInfo->PoolEntry[PoolIndex].NonPaged.FreeCount + ); + wprintf ( + L"\t\tSizeBytes = %ld\tSizeBytes = %ld\n", + pInfo->PoolEntry[PoolIndex].Paged.SizeBytes, + pInfo->PoolEntry[PoolIndex].NonPaged.SizeBytes + ); + } + + DumpData (Length, pInfo); + + GlobalFree (pInfo); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 23. + */ +CMD_DEF(ProcessorSchedule) +{ + NTSTATUS Status; + SYSTEM_PROCESSOR_SCHEDULE_INFO Info; + + if (Application.Flag.Verbose) + { + printf ("SystemProcessorScheduleInfo:\n"); + } + RtlZeroMemory ( + & Info, + sizeof Info + ); + Status = NtQuerySystemInformation ( + SystemProcessorScheduleInfo, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + + printf ("\tnContextSwitches = %ld\n", Info.nContextSwitches); + printf ("\tnDPCQueued = %ld\n", Info.nDPCQueued); + printf ("\tnDPCRate = %ld\n", Info.nDPCRate); + printf ("\tTimerResolution = %ld\n", Info.TimerResolution); + printf ("\tnDPCBypasses = %ld\n", Info.nDPCBypasses); + printf ("\tnAPCBypasses = %ld\n", Info.nAPCBypasses); + + DumpData (sizeof Info, & Info); + + return EXIT_SUCCESS; + +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 24. + */ +CMD_DEF(Dpc) +{ + NTSTATUS Status; + SYSTEM_DPC_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemDpcInformation:\n"); + } + RtlZeroMemory ( + & Info, + sizeof Info + ); + Status = NtQuerySystemInformation ( + SystemDpcInformation, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + + if (Application.Flag.Verbose) + { + printf ("\tUnused = %ld\n", Info.Unused); + } + printf ("\tKiMaximumDpcQueueDepth = %ld\n", Info.KiMaximumDpcQueueDepth); + printf ("\tKiMinimumDpcRate = %ld\n", Info.KiMinimumDpcRate); + printf ("\tKiAdjustDpcThreshold = %ld\n", Info.KiAdjustDpcThreshold); + printf ("\tKiIdealDpcRate = %ld\n", Info.KiIdealDpcRate); + + DumpData (sizeof Info, & Info); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 25. + */ +CMD_DEF(25) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 26. + */ +INT CMD_LoadImage (INT argc, LPCSTR argv []) +CMD_NOT_IMPLEMENTED + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 27. + */ +CMD_DEF(UnloadImage) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 28. + */ +CMD_DEF(TimeAdjustment) +{ + NTSTATUS Status = STATUS_SUCCESS; + SYSTEM_TIME_ADJUSTMENT_INFO Info; + + if (Application.Flag.Verbose) + { + printf ("SystemTimeAdjustmentInformation:\n"); + } + RtlZeroMemory (& Info, sizeof Info); + Status = NtQuerySystemInformation ( + SystemTimeAdjustmentInformation, + & Info, + sizeof Info, + 0 + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tKeTimeAdjustment = %ld\n", Info.KeTimeAdjustment); + printf ("\tKeMaximumIncrement = %ld\n", Info.KeMaximumIncrement); + printf ("\tKeTimeSynchronization = %s\n", TF(Info.KeTimeSynchronization)); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 29. + */ +CMD_DEF(29) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 30. + */ +CMD_DEF(30) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 31. + */ +CMD_DEF(31) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 32. + */ +CMD_DEF(CrashDumpSection) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 33. + */ +CMD_DEF(ProcessorFaultCount) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 34. + */ +CMD_DEF(CrashDumpState) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 35. + */ +CMD_DEF(Debugger) +{ + NTSTATUS Status; + SYSTEM_DEBUGGER_INFO Info; + + RtlZeroMemory (& Info, sizeof Info); + Status = NtQuerySystemInformation ( + SystemDebuggerInformation, + & Info, + sizeof Info, + NULL + ); + if (STATUS_SUCCESS != Status) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tKdDebuggerEnabled = %s\n", TF(Info.KdDebuggerEnabled)); + printf ("\tKdDebuggerPresent = %s\n", TF(Info.KdDebuggerPresent)); + + DumpData (sizeof Info, & Info); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 36. + */ +CMD_DEF(ThreadSwitchCounters) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 37. + */ +CMD_DEF(Quota) +{ + NTSTATUS Status = STATUS_SUCCESS; + SYSTEM_QUOTA_INFORMATION Info; + + if (Application.Flag.Verbose) + { + printf ("SystemQuotaInformation:\n"); + } + RtlZeroMemory (& Info, sizeof Info); + Status = NtQuerySystemInformation ( + SystemQuotaInformation, + & Info, + sizeof Info, + 0 + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ("\tCmpGlobalQuota = %ld\n", Info.CmpGlobalQuota); + printf ("\tCmpGlobalQuotaUsed = %ld\n", Info.CmpGlobalQuotaUsed); + printf ("\tMmSizeofPagedPoolInBytes = %ld\n", Info.MmSizeofPagedPoolInBytes); + + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 38. + */ +CMD_DEF(LoadDriver) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 39. + */ +CMD_DEF(PrioritySeparation) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 40. + */ +CMD_DEF(40) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 41. + */ +CMD_DEF(41) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 42. + */ +CMD_DEF(42) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 43. + */ +CMD_DEF(43) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * + * DESCRIPTION + * Dump the system TIME_ZONE_INFORMATION object. + * + * NOTE + * Class 44. + */ +CMD_DEF(TimeZone) +{ +#if 0 + NTSTATUS Status; + TIME_ZONE_INFORMATION Tzi; + WCHAR Name [33]; + + if (Application.Flag.Verbose) + { + printf ("SystemTimeZoneInformation:\n"); + } + RtlZeroMemory (& Tzi, sizeof Tzi); + Status = NtQuerySystemInformation( + SystemTimeZoneInformation, + & Tzi, + sizeof Tzi, + 0 + ); + if (!NT_SUCCESS(Status)) + { + PrintStatus (Status); + return EXIT_FAILURE; + } + printf ( + "12h/24h.....: %dh\n", + 0 /* FIXME: */ + ); + printf ( + "Bias........: %d'\n", + Tzi.Bias /* LONG */ + ); + + printf ("Standard\n"); + RtlZeroMemory ( + (PVOID) Name, + sizeof Name + ); + lstrcpynW ( + Name, + Tzi.StandardName, /* WCHAR [32] */ + 32 + ); + wprintf ( + L"\tName: \"%s\"\n", + Name + ); + + PrintUtcDateTime ( + "\tDate: %s\n", + & Tzi.StandardDate /* SYSTEMTIME */ + ); + + printf ("\tBias: %d'\n", + Tzi.StandardBias /* LONG */ + ); + + printf ("Daylight\n"); + RtlZeroMemory ( + (PVOID) Name, + sizeof Name + ); + lstrcpynW ( + Name, + Tzi.DaylightName, /* WCHAR [32] */ + 32 + ); + wprintf ( + L"\tName: \"%s\"\n", + Name + ); + + PrintUtcDateTime ( + "\tDate: %s\n", + & Tzi.DaylightDate /* SYSTEMTIME */ + ); + + printf ( + "\tBias: %d'\n", + Tzi.DaylightBias /* LONG */ + ); + +#endif + return EXIT_SUCCESS; +} + + +/********************************************************************** + * + * DESCRIPTION + * + * NOTE + * Class 45. + */ +CMD_DEF(Lookaside) +CMD_NOT_IMPLEMENTED + + +/********************************************************************** + * Miscellanea Commands + **********************************************************************/ + +CMD_DEF(ver) +{ + INT Total = 0; + + Total = + printf ( + "ReactOS Operating System - http://www.reactos.com/\n" + "QSI - Query System Information (compiled on %s, %s)\n" + "Copyright (c) 1999, 2000 Emanuele Aliberti et alii\n\n", + __DATE__, __TIME__ + ); + + if (Application.Flag.Verbose) + { + Total += + printf ( + "This program is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n\n" + + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n\n" + + "You should have received a copy of the GNU General Public License\n" + "along with this program; if not, write to the Free Software\n" + "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n" + "(See also http://www.fsf.org/).\n" + ); + } + return (Total); +} + + +CMD_DEF(exit) +{ + Application.Active = FALSE; + return EXIT_SUCCESS; +} + + +extern COMMAND_DESCRIPTOR Commands []; + +CMD_DEF(help) +{ + int i; + + if (Application.Flag.Verbose) + { + printf ("Commands:\n"); + } + for ( i = 0; + (NULL != Commands[i].Name); + i ++ + ) + { + printf ( + (strlen (Commands[i].Name) > 7) + ? "%s\t: %s\n" + : "%s\t\t: %s\n", + Commands[i].Name, + Commands[i].Description + ); + } + return EXIT_SUCCESS; +} + + +CMD_DEF(credits) +{ + return + printf ( + "\nReactOS (http://www.reactos.com/):\n" + "\tEmanuele Aliberti\n" + "\tEric Kohl\n\n" + + "HandleEx:\n" + "\tMark Russinovich (http://www.sysinternals.com/)\n\n" + + "NtDriverList:\n" + "\tYariv Kaplan (http://www.internals.com/)\n\n" + + "Undocumented SYSTEM_POOL_INFORMATION:\n" + "\tKlaus P. Gerlicher\n\n" + + "Undocumented Windows NT:\n" + "\tPrasad Dabak, Sandeep Phadke, and Milind Borate\n\n" + + "Windows NT/2000 Native API Reference:\n" + "\tGary Nebbet\n\n" + + "comp.os.ms-windows.programmer.nt.kernel-mode\n" + "\t(many postings with sample code)\n" + ); +} + + +CMD_DEF(verbose) +{ + Application.Flag.Verbose = ~Application.Flag.Verbose; + return printf ( + "Verbose mode is %s.\n", + ONOFF(Application.Flag.Verbose) + ); +} + + +CMD_DEF(dump) +{ + Application.Flag.Dump = ~Application.Flag.Dump; + return printf ( + "Dump mode is %s.\n", + ONOFF(Application.Flag.Dump) + ); +} + + +/********************************************************************** + * Commands table + **********************************************************************/ + +COMMAND_DESCRIPTOR +Commands [] = +{ +/* System information classes */ + + { /* 0 Q */ + "basic", + CMD_REF(Basic), + "Basic system information" + }, + { /* 1 Q */ + "processor", + CMD_REF(Processor), + "Processor characteristics" + }, + { /* 2 Q */ + "perf", + CMD_REF(Performance), + "System performance data" + }, + { /* 3 Q */ + "time", + CMD_REF(Time), + "System times" + }, + { /* 4 Q */ + "path", + CMD_REF(Path), + "unknown" + }, + { /* 5 Q */ + "process", + CMD_REF(Process), + "Process & thread tables" + }, + { /* 6 Q */ + "sdt", + CMD_REF(ServiceDescriptorTable), + "Service descriptor table (SDT)" + }, + { /* 7 Q */ + "ioconfig", + CMD_REF(IoConfig), + "I/O devices in the system, by class" + }, + { /* 8 Q */ + "proctime", + CMD_REF(ProcessorTime), + "Print processor times" + }, + { /* 9 QS */ + "flag", + CMD_REF(NtGlobalFlag), + "Print the system wide flags" + }, + { /* 10 */ + "#10", + CMD_REF(10), + "UNKNOWN" + }, + { /* 11 Q */ + "module", + CMD_REF(Module), + "Table of kernel modules" + }, + { /* 12 Q */ + "reslock", + CMD_REF(ResourceLock), + "Table of locks on resources" + }, + { /* 13 */ + "#13", + CMD_REF(13), + "UNKNOWN" + }, + { /* 14 */ + "#14", + CMD_REF(14), + "UNKNOWN" + }, + { /* 15 */ + "#15", + CMD_REF(15), + "UNKNOWN" + }, + { /* 16 Q */ + "handle", + CMD_REF(Handle), + "Table of handles (Ps Manager)" + }, + { /* 17 Q */ + "object", + CMD_REF(Object), + "Table of objects (Ob Manager)" + }, + { /* 18 Q */ + "pagefile", + CMD_REF(PageFile), + "Virtual memory paging files (Cc Subsystem)" + }, + { /* 19 Q */ + "emulation", + CMD_REF(InstructionEmulation), + "Virtual DOS Machine instruction emulation (VDM)" + }, + { /* 20 */ + "#20", + CMD_REF(20), + "UNKNOWN" + }, + { /* 21 QS */ + "cache", + CMD_REF(Cache), + "Cache Manager Status" + }, + { /* 22 Q */ + "pooltag", + CMD_REF(PoolTag), + "Tagged pools statistics (checked build only)" + }, + { /* 23 Q */ + "procsched", + CMD_REF(ProcessorSchedule), + "Processor schedule information" + }, + { /* 24 QS */ + "dpc", + CMD_REF(Dpc), + "Deferred procedure call (DPC)" + }, + { /* 25 */ + "#25", + CMD_REF(25), + "UNKNOWN" + }, + { /* 26 S (callable) */ + "loadpe", + CMD_REF(LoadImage), + "Load a kernel mode DLL (in PE format)" + }, + { /* 27 S (callable) */ + "unloadpe", + CMD_REF(UnloadImage), + "Unload a kernel mode DLL (module)" + }, + { /* 28 QS */ + "timeadj", + CMD_REF(TimeAdjustment), + "Time adjustment" + }, + { /* 29 */ + "#29", + CMD_REF(29), + "UNKNOWN" + }, + { /* 30 */ + "#30", + CMD_REF(30), + "UNKNOWN" + }, + { /* 31 */ + "#31", + CMD_REF(31), + "UNKNOWN" + }, + { /* 32 Q */ + "crashsect", + CMD_REF(CrashDumpSection), + "Crash Dump Section" + }, + { /* 33 Q */ + "procfault", + CMD_REF(ProcessorFaultCount), + "Processor fault count" + }, + { /* 34 Q */ + "crashstate", + CMD_REF(CrashDumpState), + "Crash Dump State" + }, + { /* 35 Q */ + "debugger", + CMD_REF(Debugger), + "System debugger" + }, + { /* 36 Q */ + "threadsw", + CMD_REF(ThreadSwitchCounters), + "Thread switch counters" + }, + { /* 37 QS */ + "quota", + CMD_REF(Quota), + "System quota values" + }, + { /* 38 S */ + "loaddrv", + CMD_REF(LoadDriver), + "Load kernel driver (SYS)" + }, + { /* 39 S */ + "prisep", + CMD_REF(PrioritySeparation), + "Priority Separation" + }, + { /* 40 */ + "#40", + CMD_REF(40), + "UNKNOWN" + }, + { /* 41 */ + "#41", + CMD_REF(41), + "UNKNOWN" + }, + { /* 42 */ + "#42", + CMD_REF(42), + "UNKNOWN" + }, + { /* 43 */ + "#43", + CMD_REF(43), + "UNKNOWN" + }, + { /* 44 QS */ + "tz", + CMD_REF(TimeZone), + "Time zone (TZ) information" + }, + { /* 45 Q */ + "lookaside", + CMD_REF(Lookaside), + "Lookaside" + }, +/* User commands */ + { + "?", + CMD_REF(help), + "Same as 'help'" + }, + { + "help", + CMD_REF(help), + "Print this command directory" + }, + { + "credits", + CMD_REF(credits), + "Print the list of people and sources that made QSI possible" + }, + { + "ver", + CMD_REF(ver), + "Print version number and license information" + }, + { + "exit", + CMD_REF(exit), + "Exit to operating system" + }, + { + "dump", + CMD_REF(dump), + "Enable/disable dumping raw data returned by system" + }, + { + "verbose", + CMD_REF(verbose), + "Enable/disable printing unused, unknown, and service fields" + }, + + { NULL, NULL } +}; + + + +/* user input --> command decoder */ + + +COMMAND_CALL +DecodeCommand (LPCSTR Command) +{ + int i; + + for ( i = 0; + ( Commands[i].Name + && stricmp (Commands[i].Name,Command) + ); + ++i + ); + return Commands[i].EntryPoint; +} + +INT +ParseCommandLine ( + LPCSTR CommandLine, + LPCSTR CommandArgv [] + ) +{ + INT ArgC = 0; + LPCSTR Separators = " \t"; + + for ( CommandArgv [ArgC] = strtok ((char*)CommandLine, (char*)Separators); + (ArgC < ARGV_SIZE); + CommandArgv [ArgC] = (LPCSTR) strtok (NULL, (char*)Separators) + ) + { + if (NULL == CommandArgv [ArgC++]) + { + break; + } + } + return (ArgC); +} + + +int +main (int argc, char * argv []) +{ + CHAR CommandLine [_MAX_PATH]; + + INT CommandArgc; + LPCSTR CommandArgv [ARGV_SIZE]; + + /* + * Initialize rt data. + */ + Application.Heap = GetProcessHeap (); + Application.Active = TRUE; + /* + * r-e-p loop. + */ + while (Application.Active) + { + /* Print the prompt string. */ + if (! Application.Flag.Batch) + { + printf ("\r\nsystem> "); + } + /* Read user command. */ + gets (CommandLine); + /* Parse the user command */ + CommandArgc = ParseCommandLine ( + CommandLine, + CommandArgv + ); + if (0 != CommandArgc) + { + COMMAND_CALL CommandCall = NULL; + + /* decode */ + if ((CommandCall = DecodeCommand (CommandArgv[0]))) + { + /* execute */ + Application.ExitCode = + CommandCall ( + CommandArgc, + CommandArgv + ); + } + else + { + printf ("Unknown command (type help for a list of valid commands).\n"); + } + } + + } + if (! Application.Flag.Batch) + { + printf ("Bye\n"); + } + return (EXIT_SUCCESS); +} + +/* EOF */ diff --git a/rosapps/sysutils/shutdown.c b/rosapps/sysutils/shutdown.c index b5696eebfcc..ce16ad6916d 100644 --- a/rosapps/sysutils/shutdown.c +++ b/rosapps/sysutils/shutdown.c @@ -1,4 +1,4 @@ -/* $Id: shutdown.c,v 1.1 1999/05/16 07:27:35 ea Exp $ +/* $Id: shutdown.c,v 1.2 2000/04/25 23:22:57 ea Exp $ * * EAU shutdown.c 1.4.1 * @@ -34,6 +34,11 @@ #include #include "win32err.h" +#ifndef SE_PRIVILEGE_ENABLED +#define NTOS_MODE_USER +#include +#endif + struct _EWX {