Is it possible to call the kernel Native APIs from within a Delphi application? Like nt
and zw
syscalls.
Can we call Native Windows API from Delphi?
but we can call nt and zw syscalls in a usermode c/c++ program, they are not only for drivers –
Scruple
Formally you can write a driver in Delphi like in c/c++, there are no language limitations. The only practical problem is that delphi driver frameworks do not exist. –
Ventriloquy
@Serg I'm not sure it's practical in Delphi to write a driver. How do you package the code up? Drivers aren't DLL or EXE files. –
Irade
I thinks drivers are executables either, because they have PE header like other common executables.Serg is write, there is no limitation in writing drivers just in C/C++, there is lack of framework and header translation for delphi. –
Scruple
re Delphi drivers: #2263974 –
Irade
Nt vs. Zw - Clearing Confusion On The Native API –
Interlaminate
You can indeed call the native API from Delphi.
Delphi does not ship with header translations for the native API. So you need to provide your own, or use a pre-existing translation. For example. the JEDI translation of the NT API.
Exactly, you need JwaNative.pas from the Jedi Apilib (+1) –
Luxuriant
As David Heffernan says it's perfectly possible to use the Native API from usermode and thus Delphi. You will need the JwaNative unit from the Jedi Apilib.
Here is small example to enumerate processes using the Native API: (TProcessList is a descendant from TObjectList but the relevant part is the call to 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;
Are you an author of JwaNative? –
Irade
Off-topic: Is it me, or is it really hard to find JEDI through websearch. Whenever I try, I always find loads of links to seemingly lots of different sites. And are there lots of different projects? Perhaps that's what confuses me. –
Irade
@DavidHeffernan Project Jedi is fragmented but we share shortage on resources (hint)... –
Luxuriant
What resources are Jedi looking for? –
Irade
Exactly we need tools that turn C headers into Delphi so we can definitely use both @DavidHeffernan and @WarrenP! –
Luxuriant
@Luxuriant I'm sure I could translate a few C headers. Sounds like fun. The JEDI project that I'd quite like to get involved in is
JclExprEval
mainly because I'm using it and found a few bugs and have some enhancement suggestions. I've reported them on the JEDI bug tracker but I suspect that code doesn't have an active maintainer. How could I go about getting involved? –
Irade @Luxuriant I know this is an old thread but I really have to ask- what's the point in the Jedi projects when there are hardly any demos, documentation or even list of things I can use them for? Just nothing but the source? I read somewhere I could use Jedi to create a driver for virtual disk. Nothing more- no class name, no sample, nothing. –
Everest
@Everest you mean demos like this one? Perhaps your websearch-fu is weak? ;) ... there are actually plenty of samples out there. But it's true, JEDI is a bloody mess. It's badly fragmented and hard to find the information needed. This wasn't exactly better in Borland days, but at least it was less fragmented at the time. Also with JEDI we've seen lots of ideas in the past and little willingness to invest own time and effort. Of course I am speaking from experience about 15 years ago, so it may not be representative of today. –
Darg
@Darg I asked this 5 years ago but thanks or an answer :D –
Everest
@Tom: I know, which means I haven't touched Delphi 5 years longer than 5 years ago. Just thought it'd be nice to point you to sample code, you or future visitors may benefit from it. –
Darg
Does anyone know of any examples of using JwaNative for Windows LPC ? –
Electric
© 2022 - 2024 — McMap. All rights reserved.