Oct 7, 2010 at 8:27 PM
Edited Oct 7, 2010 at 8:32 PM
sorry for reopening old post.
I want add some info. There is a problem with RtlProtectMemory.
The solution to problem is:
FORCE(EntrySize = LhRoundToNextInstruction(InEntryPoint, 16)); //originaly was 12
FORCE(EntrySize = LhRoundToNextInstruction(InEntryPoint, 8)); //originaly was 5
value is then used by:
//this code is used only in 32b, so in 64b 12 will probably work
FORCE(RtlProtectMemory(Hook->TargetProc, Hook->EntrySize, PAGE_EXECUTE_READWRITE));
and data are written:
*((ULONGLONG*)(Hook->TargetProc + 0)) = AtomicCache_x64;
*((ULONGLONG*)(Hook->TargetProc + 8)) = AtomicCache; //reason why 16 (not 12)
*((ULONGLONG*)Hook->TargetProc) = AtomicCache; //reason why 8 (not 5)
You may wonder, why it is problem.
It is not problem until LhRoundToNextInstruction is returning >= 8, and this is not happening on some wXP machines with GetWindowDC function --> crash or BSOD.
Finally I hope, this modification wont cause more trouble. :))