Can I call the Native Windows API from Delphi?

Can I call the Native API core from a Delphi application? Like nt and zw syscalls.

+6
source share
2 answers

You really can call your own API from Delphi.

Delphi does not come with header translations for the embedded API. Therefore, you need to provide your own or use an existing translation. For instance. JEDI translation of NT API.

+13
source

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; 
+9
source

All Articles