Skip to content

fix memory-module crash with dll align with 512 - #21

Closed
progmboy wants to merge 3 commits into
fancycode:masterfrom
progmboy:master
Closed

fix memory-module crash with dll align with 512#21
progmboy wants to merge 3 commits into
fancycode:masterfrom
progmboy:master

Conversation

@progmboy

Copy link
Copy Markdown

if dll align with 512 the section->VirtualAddress will lower than a page size. and virtualalloc will return the page base but not the next page..

eg. section->VirtualAddress = 0x200, codebase = 0x1000000
dest = (unsigned char *)VirtualAlloc(codeBase + section->VirtualAddress,
section->SizeOfRawData,
MEM_COMMIT,
PAGE_READWRITE);
the dest will be 0x1000000..
so the memory-module will crash

@fancycode

Copy link
Copy Markdown
Owner

How can I create such a DLL for testing? Do you use /ALIGN when linking?

@progmboy

Copy link
Copy Markdown
Author

yes. i use /align:512 in order to get the smallest binary

@progmboy

Copy link
Copy Markdown
Author

Hmm. There still some problems. if some sections in one page and any section have different Characteristics.. if the last section's Characteristics have no executable attribute.. the memory-module will be crash cause by DEP

@progmboy

Copy link
Copy Markdown
Author

And here is a test dll link with 512
https://www.dropbox.com/s/v3k0dn7mx68s4zf/dlltest.7z?dl=0

@fancycode

Copy link
Copy Markdown
Owner

Thanks for the initial suggestions. This is implemented now, however I had to change a couple of things to support more cases.

@fancycode fancycode closed this Feb 28, 2015
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

Successfully merging this pull request may close these issues.

2 participants