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:
Lucas Santos
2024-07-15 14:49:51 -03:00
committed by GitHub
parent cf36d3fdd3
commit 89942ebd03
9 changed files with 56 additions and 47 deletions

View File

@@ -1781,7 +1781,7 @@ pub const DebugInfo = struct {
const handle = windows.kernel32.CreateToolhelp32Snapshot(windows.TH32CS_SNAPMODULE | windows.TH32CS_SNAPMODULE32, 0);
if (handle == windows.INVALID_HANDLE_VALUE) {
switch (windows.kernel32.GetLastError()) {
switch (windows.GetLastError()) {
else => |err| return windows.unexpectedError(err),
}
}