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

ALIGN_DOWN produces wrong address on VS 2015 / x64 build #46

Closed
tobias-loew opened this issue Sep 12, 2016 · 0 comments
Closed

ALIGN_DOWN produces wrong address on VS 2015 / x64 build #46

tobias-loew opened this issue Sep 12, 2016 · 0 comments

Comments

@tobias-loew
Copy link

On x64 builds with VS 2015 the ALIGN_DOWN macro produces wrong addresses if the address is larger than 2^32. VS 2015 also produces a warning
MemoryModule.c(247): warning C4319: '~': zero extending 'DWORD' to 'uintptr_t' of greater size
The same applies to ALIGN_VALUE_UP.
A possible solution could be replacing the definition of ALIGN_DOWN and ALIGN_VALUE_UP by

define ALIGN_DOWN(address, alignment) (LPVOID)((uintptr_t)(address) & ~(((uintptr_t)(alignment)) - 1))

define ALIGN_VALUE_UP(value, alignment) (((value) + ((uintptr_t)(alignment)) - 1) & ~(((uintptr_t)(alignment)) - 1))

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