Fix dispatcher crash/deadlock, instruction analyzer, cache equality, task leak, and redirection protection
- MainThreadDispatcher: guard DispatchHook with try/catch so exceptions never escape to native caller; drain and fault pending work on Dispose; synchronize Execute/ExecuteAsync/Dispose against race/dispose. - InstructionAnalyzer: require ModRM 0xEC for 0x83/0x81 sub-esp/rsp forms, rejecting unsafe RIP-relative or memory forms. - PatternScannerCache: implement value equality on CacheKey so repeated scans actually hit cache. - BackgroundTaskExecutor: add remote allocations to the free list immediately after VirtualAllocEx, before any write that could fail and leak. - redirect: capture and restore original page protection in Apply/Remove instead of leaving target RWX. - Regression tests for all six fixes. Tests: 198 passing, 4 integration/interactive skipped.
This commit is contained in:
@@ -53,12 +53,12 @@ internal static class PrologueDecoder
|
||||
return i + 2;
|
||||
}
|
||||
|
||||
// sub r/m32/64, imm8.
|
||||
if (op == 0x83 && bytes.Length > i + 2)
|
||||
// sub esp/rsp, imm8 — register-direct ModRM 0xEC only.
|
||||
if (op == 0x83 && bytes.Length > i + 2 && bytes[i + 1] == 0xEC)
|
||||
return i + 3;
|
||||
|
||||
// sub r/m32/64, imm32.
|
||||
if (op == 0x81 && bytes.Length > i + 5)
|
||||
// sub esp/rsp, imm32 — register-direct ModRM 0xEC only.
|
||||
if (op == 0x81 && bytes.Length > i + 5 && bytes[i + 1] == 0xEC)
|
||||
return i + 6;
|
||||
|
||||
return -1;
|
||||
|
||||
Reference in New Issue
Block a user