About Kernel Mode Nativent Windows DDK lazarus / 34-Windows ---------------------------------------------------------------------- yoozaa · 2022-10-22 08:32 When compiling KERNEL MODE Nativent  Driver,, GET :  Error: Entrypoint _NtDriverEntry not defined https://wiki.freepascal.org/Target_NativeNT Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i library helloworld; // this is important - do not try a "program" here // tell FPC that we want to compile a kernel mode application// (NEEDS a RTL that was compiled with KMODE){$apptype native} uses  // for entry point types and debug output  DDK; // this method is called once our driver is unloadedprocedure DriverUnload(aObject: PDriverObject); stdcall;begin  DbgPrint('Unloading driver');end; // during the entry point the variables DriverObject and// RegistryPath are validbegin  DbgPrint('Hello World!');   // we need to setup the unload routine or the driver will  // only be unloaded on shutdown!  DriverObject^.DriverUnload := @DriverUnload;end. system Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$ifdef kmode} // Kernel Mode Entry Point function NtDriverEntry( aDriverObject: Pointer; aRegistryPath: Pointer ): LongInt; stdcall; [public, alias: '_NtDriverEntry'];begin  NtDriverEntry := FPCDriverStartup(aDriverObject, aRegistryPath);end; ---------------------------------------------------------------------- Thaddy · 2022-10-22 09:23 32 or 64 bit? A 64 bit kernel mode driver needs to be signed! And it may be that on win 10+ a 32 bit driver also needs to be signed. You can during development use a local certificate for that as per the DDK documentation on MSDN. 32 bit drivers below or equal to platform WIN7 are known to work. ( see wiki remarks) ---------------------------------------------------------------------- AlexTP · 2022-10-22 10:19 @Thaddy, I wrote your info here https://wiki.freepascal.org/Target_NativeNT#Driver_signing Pls correct if needed. ---------------------------------------------------------------------- yoozaa · 2022-10-22 11:48 @Thaddy  Thanks a lot ! Can you give one i368 or x64  demo for nativent ---------------------------------------------------------------------- Thaddy · 2022-10-22 15:55 That is a bit more complex than you might think, because I have to explain how to sign the driver,,, But I will have a go at it, The code s basically correct, but signing a driver locally is not that straightforward unless you already own a proper (certificate)  license from Microsoft. (And that is a GOOD thing and merely an inconvenience) ---------------------------------------------------------------------- 440bx · 2022-10-22 16:50 A driver need not be signed in order to be loaded. There are ways to configure Windows to make it load and execute unsigned drivers.  There are plenty of sites around that describe the various ways of accomplishing that, among them is : https://www.maketecheasier.com/install-unsigned-drivers-windows10/ steps are similar for most versions of Windows. HTH. ---------------------------------------------------------------------- Thaddy · 2022-10-23 16:14 Quote from: 440bx on October 22, 2022, 06:50:45 pmA driver need not be signed in order to be loaded. That is incorrect for 64 bit drivers.. fake information. Plz read my info very carefully. ---------------------------------------------------------------------- d.ioannidis · 2022-10-23 16:49 Hi, Quote from: Thaddy on October 23, 2022, 06:14:59 pmQuote from: 440bx on October 22, 2022, 06:50:45 pmA driver need not be signed in order to be loaded. That is incorrect for 64 bit drivers.. fake information. Plz read my info very carefully.  I tried today to see how one can use the fpc nativent target to create a kernel driver.  I only tested kernel mode, not user mode, and I found out that you can't load 32 bit unsigned kernel driver on a 64bit Win system ... Not even a 32 bit signed driver with embedded signature . You'll need to install it through a means that does involve a driver package and a catalog file and not using scm managed install ( a.k.a. "legacy driver" using sc.exe ) .  So Thaddy is correct IMHO . There is a lot more to consider when you want to create a driver for a "modern" 64 bit ( 7 and up ) Windows system . regards, ---------------------------------------------------------------------- 440bx · 2022-10-23 17:34 I'll just state what should be obvious, a developer isn't going to get a driver that is currently being developed signed just to be able to test it during development. ---------------------------------------------------------------------- d.ioannidis · 2022-10-23 18:08 Hi, Quote from: 440bx on October 23, 2022, 07:34:48 pmI'll just state what should be obvious, a developer isn't going to get a driver that is currently being developed signed just to be able to test it during development. If by ".. currently being developed signed .." you mean no signature at all then AFAIU you're wrong . It depends on the driver type. For kernel type driver ( see here ) : Quote64-bit versions of Windows starting with Windows Vista The kernel-mode code signing policy requires that a kernel-mode driver be test-signed and that test-signing is enabled. A test signature can be a WHQL test signature or generated in-house by a test certificate. Drivers must be test-signed as follows:     A kernel-mode boot-start driver must have an embedded test signature. This applies to any type of PnP or non-PnP kernel-mode driver.     A kernel-mode driver that is not a boot-start driver must have either a test-signed catalog file or the driver file must include an embedded test signature. This applies to any type of PnP or non-PnP kernel-mode driver. regards,