home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2004 February
/
Chip_2004-02_cd1.bin
/
zkuste
/
konfig
/
download
/
msic
/
Help
/
Int
/
MiTeC_Native.int
< prev
next >
Wrap
Text File
|
2003-08-26
|
9KB
|
259 lines
{*******************************************************}
{ }
{ MiTeC System Information Components }
{ WinNT Native API }
{ version 1.0 for Delphi 5,6 }
{ }
{ Copyright ⌐ 2002 Michal Mutl }
{ }
{*******************************************************}
{$INCLUDE MITEC_DEF.INC}
unit MiTeC_Native;
interface
uses Windows, SysUtils;
type
TUnicodeString = packed record
Length,
MaximumLength: WORD;
Buffer: PWideChar;
end;
PUnicodeString = ^TUnicodeString;
TSystemInformationClass = (
SystemBasicInformation,
SystemProcessorInformation,
SystemPerformanceInformation,
SystemTimeOfDayInformation,
SystemNotImplemented1,
SystemProcessesAndThreadsInformation,
SystemCallCounts,
SystemConfigurationInformation,
SystemProcessorTimes,
SystemGlobalFlag,
SystemNotImplemented2,
SystemModuleInformation,
SystemLockInformation,
SystemNotImplemented3,
SystemNotImplemented4,
SystemNotImplemented5,
SystemHandleInformation,
SystemObjectInformation,
SystemPagefileInformation,
SystemInstructionEmulationCounts,
SystemInvalidInfoClass1,
SystemCacheInformation,
SystemPoolTagInformation,
SystemProcessorStatistics,
SystemDpcInformation,
SystemNotImplemented6,
SystemLoadImage,
SystemUnloadImage,
SystemTimeAdjustment,
SystemNotImplemented7,
SystemNotImplemented8,
SystemNotImplemented9,
SystemCrashDumpInformation,
SystemExceptionInformation,
SystemCrashDumpStateInformation,
SystemKernelDebuggerInformation,
SystemContextSwitchInformation,
SystemRegistryQuotaInformation,
SystemLoadAndCallImage,
SystemPrioritySeparation,
SystemNotImplemented10,
SystemNotImplemented11,
SystemInvalidInfoClass2,
SystemInvalidInfoClass3,
SystemTimeZoneInformation,
SystemLookasideInformation,
SystemSetTimeSlipEvent,
SystemCreateSession,
SystemDeleteSession,
SystemInvalidInfoClass4,
SystemRangeStartInformation,
SystemVerifierInformation,
SystemAddVerifier,
SystemSessionProcessesInformation);
TSystemProcessorTimes = packed record
IdleTime,
KernelTime,
UserTime,
DpcTime,
InterruptTime: int64;
InterruptCount: DWORD;
end;
PSystemProcessorTimes = ^TSystemProcessorTimes;
_CLIENT_ID = record
UniqueProcess: DWORD;
UniqueThread: DWORD;
end;
TClientID = _CLIENT_ID;
PClientID = ^TClientID;
_SYSTEM_THREAD_INFORMATION = record
KernelTime: LARGE_INTEGER; // time spent in kernel mode
UserTime: LARGE_INTEGER; // time spent in user mode
CreateTime: LARGE_INTEGER; // thread creation time
WaitTime: DWORD; // wait time
StartAddress: Pointer; // start address
ClientId: TClientID; // thread and process IDs
Priority: integer; // dynamic priority
BasePriority: DWORD; // base priority
ContextSwitchCount: DWORD; // number of context switches
State: Integer; // current state
WaitReason: integer; // wait reason
end;
TSystemThreadInformation = _SYSTEM_THREAD_INFORMATION;
PSystemThreadInformation = ^TSystemThreadInformation;
_VM_COUNTERS = record
PeakVirtualSize: DWORD;
VirtualSize: DWORD;
PageFaultCount: DWORD;
PeakWorkingSetSize: DWORD;
WorkingSetSize: DWORD;
QuotaPeakPagedPoolUsage: DWORD;
QuotaPagedPoolUsage: DWORD;
QuotaPeakNonPagedPoolUsage: DWORD;
QuotaNonPagedPoolUsage: DWORD;
PagefileUsage: DWORD;
PeakPagefileUsage: DWORD;
end;
TVMCounters = _VM_COUNTERS;
PVMCounters = ^TVMCounters;
_IO_COUNTERS = record
ReadOperationCount: LARGE_INTEGER;
WriteOperationCount: LARGE_INTEGER;
OtherOperationCount: LARGE_INTEGER;
ReadTransferCount: LARGE_INTEGER;
WriteTransferCount: LARGE_INTEGER;
OtherTransferCount: LARGE_INTEGER;
end;
TIOCounters = _IO_COUNTERS;
PIoCounters = ^TIoCounters;
_SYSTEM_PROCESS_INFORMATION = record
NextEntryDelta: DWORD; // offset to the next entry
ThreadCount: DWORD; // number of threads
Reserved1: array[0..5] of DWORD; // reserved
CreateTime: LARGE_INTEGER; // process creation time
UserTime: LARGE_INTEGER; // time spent in user mode
KernelTime: LARGE_INTEGER; // time spent in kernel mode
ProcessName: TUnicodeString; // process name
BasePriority: Integer; // base process priority
ProcessId: DWORD; // process identifier
InheritedFromProcessId: DWORD; // parent process identifier
HandleCount: DWORD; // number of handles
Reserved2: array[0..1] of DWORD; // reserved
VmCounters: TVmCounters; // virtual memory counters
IoCounters: TIoCounters; // i/o counters
Threads: array[0..0] of TSystemThreadInformation; // threads
end;
TSystemProcessInformation = _SYSTEM_PROCESS_INFORMATION;
PSystemProcessInformation = ^TSystemProcessInformation;
TTokenUser = packed record
User: TSIDAndAttributes;
end;
PTokenUser = ^TTokenUser;
TTokenOwner = packed record
Owner: PSID;
end;
PTokenOwner = ^TTokenOwner;
{TTokenPrivileges = packed record
PrivilegeCount: DWORD;
Privileges: array of TLUIDAndAttributes;
end;
PTokenPrivileges = ^TTokenPrivileges;}
TTokenPrimaryGroup = packed record
PrimaryGroup: PSID;
end;
PTokenPrimaryGroup = ^TTokenPrimaryGroup;
TTokenDefaultDACL = packed record
DefaultDacl: PACL;
end;
PTokenDefaultDACL = ^TTokenDefaultDACL;
{TTokenInformationClass = (TokenPad,TokenUser,TokenGroups,TokenPrivileges,TokenOwner,
TokenPrimaryGroup,TokenDefaultDacl,TokenSource,TokenType,
TokenImpersonationLevel,TokenStatistics,TokenRestrictedSids,
TokenSessionId);}
TObjectAttributes = packed record
Length: DWORD;
RootDirectory: THandle;
ObjectName: PUnicodeString;
Attributes: DWORD;
SecurityDescriptor: Pointer;// Points to type SECURITY_DESCRIPTOR
SecurityQualityOfService: Pointer;// Points to type SECURITY_QUALITY_OF_SERVICE
end;
PObjectAttributes = ^TObjectAttributes;
TNativeQueryInformationToken = function(TokenHandle: THandle;
TokenInformationClass: TTokenInformationClass;
TokenInformation :Pointer;
TokenInformationLength :DWORD;
ReturnLength :PDWORD): DWORD; stdcall;
TNativeOpenProcessToken = function(ProcessHandle: THandle;
DesiredAccess: DWORD;
TokenHandle: PHandle) :DWORD; stdcall;
TNativeOpenProcess = function(ProcessHandle: PHandle;
DesiredAccess: DWORD;
ObjectAttributes: PObjectAttributes;
ClientId: PClientID): DWORD; stdcall;
TNativeOpenSection = function(SectionHandle: PHandle;
DesiredAccess: DWORD;
ObjectAttributes: PObjectAttributes): DWORD; stdcall;
TNativeClose = function(Handle: THandle): DWORD; stdcall;
TNativeQuerySystemInformation = function(SystemInformationClass: TSystemInformationClass;
SystemInformation: Pointer;
SystemInformationLength: DWORD;
ReturnLength: PDWORD): DWORD; stdcall;
const
NTDLL_DLL_Name = 'NTDLL.DLL';
STATUS_SUCCESS = $00000000;
STATUS_INFO_LENGTH_MISMATCH = $C0000004;
STATUS_BUFFER_OVERFLOW = $80000005;
//Valid values for the Attributes field
OBJ_INHERIT = $00000002;
OBJ_PERMANENT = $00000010;
OBJ_EXCLUSIVE = $00000020;
OBJ_CASE_INSENSITIVE = $00000040;
OBJ_OPENIF = $00000080;
OBJ_OPENLINK = $00000100;
OBJ_VALID_ATTRIBUTES = $000001F2;
var
NTDLL_DLL: THandle = 0;
ZwOpenSection: TNativeOpenSection = nil;
ZwClose: TNativeClose = nil;
ZwQueryInformationToken: TNativeQueryInformationToken = nil;
ZwOpenProcessToken: TNativeOpenProcessToken = nil;
ZwOpenProcess: TNativeOpenProcess = nil;
ZwQuerySystemInformation: TNativeQuerySystemInformation = nil;
implementation