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

Pointer dereference after ifstmt reads the wrong value #59

Open
wallds opened this issue Sep 2, 2024 · 0 comments
Open

Pointer dereference after ifstmt reads the wrong value #59

wallds opened this issue Sep 2, 2024 · 0 comments

Comments

@wallds
Copy link

wallds commented Sep 2, 2024

test.cpp

#include <Windows.h>
#include <stdint.h>

int main()
{
    const char* data = "0123456789";
    uint64_t target = 0;
    WriteProcessMemory(GetCurrentProcess(), &target, data, 8, NULL);
}

bug.d

#pragma D option quiet

syscall::NtWriteVirtualMemory:entry
/execname == $1/
{
    if (arg2) {
        printf("NtWriteVirtualMemory\n");
        printf("Buffer Address 0x%p\n", arg2);
        this->p = (uint64_t *)copyin(arg2, 8);
        printf("A 0x%llx\n", *this->p);
        printf("B 0x%llx\n", *this->p);
        if (1) {}
        printf("C 0x%llx\n", *this->p);
    }
}

syscall::NtTerminateProcess:entry
/execname == $1/
{
    exit(0);
}

dtrace -s bug.d test.exe
image

C expected value is 0x3736353433323130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant