diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2023-10-31 02:15:16 -0700 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-11-03 19:25:46 +0200 |
| commit | ae6df9e96749cdd7cd4f84245ce20cfb3d4d6354 (patch) | |
| tree | f375ed81001ba2885ab5e6ca5c9a321094b49179 /lib/std/start.zig | |
| parent | 94cee4fb27a433824c2540dc37375dc14befdf47 (diff) | |
| download | zig-ae6df9e96749cdd7cd4f84245ce20cfb3d4d6354.tar.gz zig-ae6df9e96749cdd7cd4f84245ce20cfb3d4d6354.zip | |
start.zig: Replace kernel32 usage with ntdll
Co-authored-by: e4m2 <git@e4m2.com>
Diffstat (limited to 'lib/std/start.zig')
| -rw-r--r-- | lib/std/start.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/std/start.zig b/lib/std/start.zig index 7ed59a4675..7925ea9168 100644 --- a/lib/std/start.zig +++ b/lib/std/start.zig @@ -168,15 +168,13 @@ fn exit2(code: usize) noreturn { // exits(0) .plan9 => std.os.plan9.exits(null), .windows => { - ExitProcess(@as(u32, @truncate(code))); + std.os.windows.ntdll.RtlExitUserProcess(@as(u32, @truncate(code))); }, else => @compileError("TODO"), } unreachable; } -extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn; - //////////////////////////////////////////////////////////////////////////////// fn _DllMainCRTStartup( @@ -345,7 +343,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn { std.debug.maybeEnableSegfaultHandler(); - std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain()); + std.os.windows.ntdll.RtlExitUserProcess(initEventLoopAndCallMain()); } fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { @@ -357,7 +355,7 @@ fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { std.debug.maybeEnableSegfaultHandler(); const result: std.os.windows.INT = initEventLoopAndCallWinMain(); - std.os.windows.kernel32.ExitProcess(@as(std.os.windows.UINT, @bitCast(result))); + std.os.windows.ntdll.RtlExitUserProcess(@as(std.os.windows.UINT, @bitCast(result))); } fn posixCallMainAndExit() callconv(.C) noreturn { @@ -605,8 +603,8 @@ pub fn callMain() u8 { pub fn call_wWinMain() std.os.windows.INT { const peb = std.os.windows.peb(); const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; - const hInstance = @as(MAIN_HINSTANCE, @ptrCast(std.os.windows.kernel32.GetModuleHandleW(null).?)); - const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); + const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress)); + const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer); // There are various types used for the 'show window' variable through the Win32 APIs: // - u16 in STARTUPINFOA.wShowWindow / STARTUPINFOW.wShowWindow |
