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

Memory leak on call_function #2

Closed
exphck1337 opened this issue Apr 23, 2019 · 2 comments
Closed

Memory leak on call_function #2

exphck1337 opened this issue Apr 23, 2019 · 2 comments

Comments

@exphck1337
Copy link

exphck1337 commented Apr 23, 2019

Hello, I found a memory leak on this line, whenever call_function is called it's allocate a new page, is missing an if or make the call after the declaration of the variable allocated_shellcode.

Fix:

static void* allocated_shellcode = nullptr;

if ( !allocated_shellcode )
{
    // MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE
    allocated_shellcode =
        VirtualAlloc(nullptr, sizeof( shellcode ), 0x00001000 | 0x00002000, 0x40);

    if ( !allocated_shellcode )
        detail::throw_last_error( 
        "VirtualAlloc failed to allocate memory for call_function shellcode" );
}

Alternative fix:

static void* allocated_shellcode = VirtualAlloc(nullptr, sizeof(shellcode), 0x00001000 | 0x00002000, 0x40);
@exphck1337 exphck1337 changed the title Memory leak on call function Memory leak on call_function Apr 23, 2019
@JustasMasiulis
Copy link
Owner

Hopefully fixed (did it on phone so hopefully didnt't make any mistakes)

@exphck1337
Copy link
Author

Now it's correct, thank you.

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

2 participants