# Better implementation of GetLastError\. \(\#20623\) · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/89942ebd03b2943cbbe84b575a024e156ca5bf52)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 89942ebd03b2943cbbe84b575a024e156ca5bf52

Requested commit: 89942ebd03b2943cbbe84b575a024e156ca5bf52

Commit: 89942ebd03b2943cbbe84b575a024e156ca5bf52

Tree: 0892910484a47d30d4c5f2dccff9f16d0162687e

Author: Lucas Santos

Committer: GitHub

## Message

```
Better implementation of GetLastError. (#20623)

Instead of calling the dynamically loaded kernel32.GetLastError, we can extract it from the TEB.
As shown by [Wine](https://github.com/wine-mirror/wine/blob/34b1606019982b71818780bc84b76460f650af31/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.
```

## Parents

- [cf36d3fdd3674bfb95f22aa7bc7ff450ebdc1c08](https://git.cafe/gitcafe/zig/commit/cf36d3fdd3674bfb95f22aa7bc7ff450ebdc1c08?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/89942ebd03b2943cbbe84b575a024e156ca5bf52?format=markdown)
