-
Notifications
You must be signed in to change notification settings - Fork 764
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
flush instruction cache after performing relocations #59
base: master
Are you sure you want to change the base?
Conversation
Flush instruction cache to avoid executing stale code after performing relocations. According to MSDN: "Applications should call FlushInstructionCache if they generate or modify code in memory. The CPU cannot detect the change, and may execute the old code it cached.". After performing relocation we have modified executable code, so if we don't flush the cache maybe the old code without relocation is executed instead. So far the code has woked without flushing instruction cache but it's better to be safe. https://msdn.microsoft.com/en-us/library/windows/desktop/ms679350(v=vs.85).aspx
flush instruction cache after performing relocations
flush instruction cache of each base relocation block
Now the instruction cache is flushed only for each page-sized block of image where relocations have been performed. The FlushInstructionCache is now called inside PerformBaseRelocations, and it uses GetCurrentProcess instead of hard-coding (HANDLE)-1 |
I cannot see ANY sense in calling FlushInstructionCache(). |
The correct usage of this function may be called by user code, not MemoryModule itself - after multiple loads in a row, for example.
|
I don't know what you want to say with "additional APIs with unclear functions" ???? |
Flush instruction cache to avoid executing stale code after performing relocations.
According to MSDN: "Applications should call FlushInstructionCache if they generate or modify code in memory. The CPU cannot detect the change, and may execute the old code it cached.".
After performing relocation we have modified executable code, so if we don't flush the cache maybe the old code without relocation is executed instead. So far the code has woked without flushing instruction cache but it's better to be safe.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms679350(v=vs.85).aspx