Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread system error value not preserved when tracing #5

Open
HexKitchen opened this issue Apr 5, 2024 · 3 comments · Fixed by #6
Open

Thread system error value not preserved when tracing #5

HexKitchen opened this issue Apr 5, 2024 · 3 comments · Fixed by #6
Labels
bug Something isn't working

Comments

@HexKitchen
Copy link

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 :
@myr-syn myr-syn added the bug Something isn't working label Jun 3, 2024
@myr-syn
Copy link
Collaborator

myr-syn commented Jun 3, 2024

Hi !
Thank you for your contribution.

We wonder whether this issue might be linked to Frida itself. We also noticed this commit from the 16.2.2 release:

gumjs: Preserve thread’s system error over NativeCallback invocations. Thanks @HexKitchen!

Have you been able to confirm that the problem is now solved without applying this patch?

@HexKitchen
Copy link
Author

HexKitchen commented Jun 3, 2024 via email

@hexa-synacktiv
Copy link
Collaborator

hexa-synacktiv commented Jun 4, 2024

We tested this pull request on arm64 and it broke the tracer for some reason, the pull request was reverted until we understand the problem better.

It is not 100% clear whether the problem was actually due to this commit or some other variable, but we do not have time to test more extensively at the moment. We will potentially re-merge this later after more testing has been done.

@hexa-synacktiv hexa-synacktiv reopened this Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants