Skip to content

Thread system error value not preserved when tracing #5

@HexKitchen

Description

@HexKitchen

When tracing an executable, the tracing code interferes with the thread's system error code, which can cause incorrect execution of the traced process.

Example:

#include <iostream>
#include <Windows.h>

int main()
{
    SetLastError(1337);


    std::cout << "Last error: " << GetLastError() << std::endl;
    std::cout << "Last error: " << GetLastError() << std::endl;
}

Output (without tracing):

Last error: 1337
Last error: 1337

Output (with tracing):

...
2024-04-04 20:15:07,773     INFO | Writing trace data of 1025258 bytes...
STDOUT : Last error: 0
STDOUT :
STDOUT : Last error: 0
STDOUT :

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions