so when decompiling a basic zig hello world program, i discovered that it doesn’t use any external imports to get the stdout handle, it uses only numbers i believe, or some kind of PEB. im wondering how i can apply it to my code below and possibly making the write file call directly as nt, just trying to make a more minimal hello world than i already have
Why not look at what std.io.getStdOutHandle is doing?
Zig currently calls kernel32.WriteFile in std.os.windows.WriteFile (relevant issue), but we can check what ntdll functions are called in your program by running it with NtTrace:
So in theory you should be able to replace your WriteFile with a NtWriteFile call using the handle gotten from the PEB and then your program will only depend on ntdll).
All the bindings in the standard library are hand-written based on the documentation (or things like the Wine/ReactOS implementation if no documentation is available).
usize is not the right type for ULONG (ULONG is u32); I’d just use windows.ULONG. I’d also use ?windows.PVOID and windows.PVOID for ApcContext and Buffer, respectively (windows.PVOID is *anyopaque).
EDIT: Actually, [*]const u8 for Buffer seems fine since it’s explicitly a buffer of bytes. I’d still use ?windows.PVOID for ApcContext, though.