Bypassing Kernel32.dll for Fun and Nonprofit
a day ago
- #Zig
- #libc
- #Windows API
- Zig's standard library policy is to bypass high-level Windows DLLs like kernel32.dll in favor of lower-level ntdll.dll for better performance and reliability.
- Example 1: Zig avoids using advapi32.dll for entropy by directly accessing \Device\CNG, eliminating unnecessary dependencies and failures.
- Example 2: Zig uses NtReadFile and NtWriteFile from ntdll.dll for file operations, improving error handling and resource management over kernel32.dll's wrappers.
- Zig's libc subproject aims to replace vendored C source files with Zig standard library wrappers, reducing redundancy and improving compilation speed.
- Recent enhancements allow zig libc to share the Zig Compilation Unit, optimizing code elimination and enabling potential future features like io_uring integration.
- Users are encouraged to report libc-related bugs directly to Zig to avoid bothering independent libc maintainers.