As David Heffernan says, it's quite possible to use the Native API from usermode and thus Delphi. You will need the JwaNative block from Jedi Apilib .
Here is a small example for listing processes using the Native API: (TProcessList is a descendant of TObjectList, but the corresponding part is calling NtQuerySystemInformation)
function EnumProcesses: TProcessList; var Current: PSystemProcesses; SystemProcesses : PSystemProcesses; dwSize: DWORD; nts: NTSTATUS; begin Result := TProcessList.Create; dwSize := 200000; SystemProcesses := AllocMem(dwSize); nts := NtQuerySystemInformation(SystemProcessesAndThreadsInformation, SystemProcesses, dwSize, @dwSize); while nts = STATUS_INFO_LENGTH_MISMATCH do begin ReAllocMem(SystemProcesses, dwSize); nts := NtQuerySystemInformation(SystemProcessesAndThreadsInformation, SystemProcesses, dwSize, @dwSize); end; if nts = STATUS_SUCCESS then begin Current := SystemProcesses; while True do begin Result.Add(TProcess.Create(Current^)); if Current^.NextEntryDelta = 0 then Break; Current := PSYSTEM_PROCESSES(DWORD_PTR(Current) + Current^.NextEntryDelta); end; end; FreeMem(SystemProcesses); end;
Remko source share