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

Crash due to wrong prototype for NtAllocateVirtualMemoryEx #52

Closed
michaelweiser opened this issue Dec 23, 2022 · 2 comments
Closed

Crash due to wrong prototype for NtAllocateVirtualMemoryEx #52

michaelweiser opened this issue Dec 23, 2022 · 2 comments

Comments

@michaelweiser
Copy link

I've been seeing crashes in the NtAllocateVirtualMemoryEx hook as can be seen here:
virtualallocex-access-violation
(please excuse the German UI, the debug machine was not mine)

It looked like a call-by-value with a large operand to me and pointed me towards the __inout MEM_EXTENDED_PARAMETER Parameters argument to the function. Since I've never seen such a large structure being passed by value in any API I dug a bit and found this alternative usage much more in line with my experience: dotnet/runtime#12779

After changing the prototype to use a pointer like so, the crashes went away:

	__inout  MEM_EXTENDED_PARAMETER *Parameters,

See also: https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualalloc2

This also jives with Parameters being an array of MEM_EXTENDED_PARAMETERs defined by last argument ParameterCount.

@michaelweiser
Copy link
Author

The hook for NtMapViewOfSectionEx might also be affected by this.

kevoreilly added a commit that referenced this issue Dec 23, 2022
…MEM_EXTENDED_PARAMETER is a pointer) - thanks Michael Weiser #52
@kevoreilly
Copy link
Owner

Thanks a lot!

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