Better implementation of GetLastError. (#20623)
Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB.
As shown by [Wine](34b1606019/include/winternl.h (L439)), the last error lives at offset 0x34 of the TEB in 32-bit Windows and at offset 0x68 in 64-bit Windows.
This commit is contained in:
@@ -178,7 +178,7 @@ const WindowsImpl = struct {
|
||||
|
||||
// Return error.Timeout if we know the timeout elapsed correctly.
|
||||
if (rc == os.windows.FALSE) {
|
||||
assert(os.windows.kernel32.GetLastError() == .TIMEOUT);
|
||||
assert(os.windows.GetLastError() == .TIMEOUT);
|
||||
if (!timeout_overflowed) return error.Timeout;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user