Author Topic: Do you use Native api?  (Read 1367 times)

Offline bitcoin

  • Member
  • *
  • Posts: 106
Do you use Native api?
« on: September 03, 2019, 05:25:45 pm »
I test to create native api program in Pelles C. There are manual in russian but about visual studio.

1. Create new Console application. Change settins (delete all libs, set nodefault lib, change subsystem to NATIVE);
2. Download NDK includes , and change include-dir in project settings to folder with it.
3. put code
Code: [Select]
#define WIN32_NO_STATUS
#include <windows.h>
#include <ntndk.h>

 void winx_sleep(int msec)
        LARGE_INTEGER Interval;
        Interval.QuadPart = -((signed long)msec * 10000);

void NtProcessStartup(void* StartupArgument)
  PPEB pPeb = (PPEB)StartupArgument;
  RtlInitUnicodeString(&str, L"Hello, world!\nCommand line is: ");
  RtlInitUnicodeString(&str, pPeb->ProcessParameters->CommandLine.Buffer);
  NtTerminateProcess(NtCurrentProcess(), 0);

4. this code not compile , because NDK (for some reasons, don't know it) , dont have ntnls.h and ntdll.lib . I get include from PH sources, and lib - from DDK (WDK) XP .

5. In linker settings set entry point to NtProcessStartup@4

6. So, you got exe. If you want to run it without reboot, you can use some small tool, to run native into win32.