TIL: the TEB contains a field for the last error number, so you can emulate GetLastError() by walking through the TIB with two instructions.

@williballenthin