| ... | @@ -168,15 +168,13 @@ fn exit2(code: usize) noreturn { | ... | @@ -168,15 +168,13 @@ fn exit2(code: usize) noreturn { |
| 168 | // exits(0) | 168 | // exits(0) |
| 169 | .plan9 => std.os.plan9.exits(null), | 169 | .plan9 => std.os.plan9.exits(null), |
| 170 | .windows => { | 170 | .windows => { |
| 171 | ExitProcess(@as(u32, @truncate(code))); | 171 | std.os.windows.ntdll.RtlExitUserProcess(@as(u32, @truncate(code))); |
| 172 | }, | 172 | }, |
| 173 | else => @compileError("TODO"), | 173 | else => @compileError("TODO"), |
| 174 | } | 174 | } |
| 175 | unreachable; | 175 | unreachable; |
| 176 | } | 176 | } |
| 177 | | 177 | |
| 178 | extern "kernel32" fn ExitProcess(exit_code: u32) callconv(.C) noreturn; | | |
| 179 | | | |
| 180 | //////////////////////////////////////////////////////////////////////////////// | 178 | //////////////////////////////////////////////////////////////////////////////// |
| 181 | | 179 | |
| 182 | fn _DllMainCRTStartup( | 180 | fn _DllMainCRTStartup( |
| ... | @@ -345,7 +343,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn { | ... | @@ -345,7 +343,7 @@ fn WinStartup() callconv(std.os.windows.WINAPI) noreturn { |
| 345 | | 343 | |
| 346 | std.debug.maybeEnableSegfaultHandler(); | 344 | std.debug.maybeEnableSegfaultHandler(); |
| 347 | | 345 | |
| 348 | std.os.windows.kernel32.ExitProcess(initEventLoopAndCallMain()); | 346 | std.os.windows.ntdll.RtlExitUserProcess(initEventLoopAndCallMain()); |
| 349 | } | 347 | } |
| 350 | | 348 | |
| 351 | fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { | 349 | fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { |
| ... | @@ -357,7 +355,7 @@ fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { | ... | @@ -357,7 +355,7 @@ fn wWinMainCRTStartup() callconv(std.os.windows.WINAPI) noreturn { |
| 357 | std.debug.maybeEnableSegfaultHandler(); | 355 | std.debug.maybeEnableSegfaultHandler(); |
| 358 | | 356 | |
| 359 | const result: std.os.windows.INT = initEventLoopAndCallWinMain(); | 357 | const result: std.os.windows.INT = initEventLoopAndCallWinMain(); |
| 360 | std.os.windows.kernel32.ExitProcess(@as(std.os.windows.UINT, @bitCast(result))); | 358 | std.os.windows.ntdll.RtlExitUserProcess(@as(std.os.windows.UINT, @bitCast(result))); |
| 361 | } | 359 | } |
| 362 | | 360 | |
| 363 | fn posixCallMainAndExit() callconv(.C) noreturn { | 361 | fn posixCallMainAndExit() callconv(.C) noreturn { |
| ... | @@ -605,8 +603,8 @@ pub fn callMain() u8 { | ... | @@ -605,8 +603,8 @@ pub fn callMain() u8 { |
| 605 | pub fn call_wWinMain() std.os.windows.INT { | 603 | pub fn call_wWinMain() std.os.windows.INT { |
| 606 | const peb = std.os.windows.peb(); | 604 | const peb = std.os.windows.peb(); |
| 607 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; | 605 | const MAIN_HINSTANCE = @typeInfo(@TypeOf(root.wWinMain)).Fn.params[0].type.?; |
| 608 | const hInstance = @as(MAIN_HINSTANCE, @ptrCast(std.os.windows.kernel32.GetModuleHandleW(null).?)); | 606 | const hInstance = @as(MAIN_HINSTANCE, @ptrCast(peb.ImageBaseAddress)); |
| 609 | const lpCmdLine = std.os.windows.kernel32.GetCommandLineW(); | 607 | const lpCmdLine: [*:0]u16 = @ptrCast(peb.ProcessParameters.CommandLine.Buffer); |
| 610 | | 608 | |
| 611 | // There are various types used for the 'show window' variable through the Win32 APIs: | 609 | // There are various types used for the 'show window' variable through the Win32 APIs: |
| 612 | // - u16 in STARTUPINFOA.wShowWindow / STARTUPINFOW.wShowWindow | 610 | // - u16 in STARTUPINFOA.wShowWindow / STARTUPINFOW.wShowWindow |