Repository navigation
Keep AOB scans inside their range and add scanForAOBInMainModule - #16
Conversation
|
When did you encounter said bugs? Do you have some reproducible code that causes the bug? |
scanForAOB searches [min, max] inclusively: a match has to end at or before max, the last valid start is tested, and no read passes the end of a readable region. Adjacent readable regions are searched as one range. scanForAOBInMainModule(pattern) returns the first and the second match in the executable sections of the main module, so a caller can reject an ambiguous signature. The PE headers and section ranges are checked against the loaded image size before they are read. When the headers are invalid, or an executable section is empty, lies outside the image or cannot be read, it returns nil, nil, "incomplete", so an unread duplicate is never reported as unique. Version 1.6.0.
e958409 to
203a694
Compare
This came up while modules checked that a pattern is unique inside a bounded window; Rebalancer added its own filter as a workaround. The old The larger reason for this PR is Posted by Claude on behalf of Krarilotus. |
gynt
left a comment
There was a problem hiding this comment.
All good, except I prefer "scanForAOBsInMainModule" (notice the s for plural)
TL;DR
scanForAOBkeeps exactly to its range. The newscanForAOBInMainModule(pattern)returns the first two matches in the main module's executable sections, so a caller can reject a pattern that is not unique. When it cannot read all of that code, it returnsnil, nil, "incomplete"instead of a match. Version 1.6.0. UCP3 3.0.8 pins it (UnofficialCrusaderPatch/UnofficialCrusaderPatch3#156).Included
AOB::FindPatterntests every start up to the last one where the pattern still fits (<=). Before, the last start was skipped, and a pattern longer than the length underflowed the loop bound.AOB::Scansearches[min, max], both inclusive, so a match has to end at or beforemax.maxper region, searching the region that holdsmaxto its end.MEM_IMAGE, and neitherPAGE_NOACCESSnorPAGE_GUARD. The image-only rule is unchanged.AOB::FindInRangereturns 0 for a pattern with no bytes instead of indexing an empty vector.AOB::FindInMainModuleand the Lua functionscanForAOBInMainModule(pattern).IMAGE_SCN_MEM_EXECUTE.GetModuleInformation'sSizeOfImage) in readable memory. Invalid headers give"incomplete"."incomplete".nil, nil, "incomplete", because a duplicate there could not be ruled out. A guard page keeps its guard.nilfor each one not found). Overlapping matches count.scanForAOB.maxmeaning and the new function's results.tests/test-aob.luain the lunatest suite: an exact-size range, a range one byte too short, two matches, and no match.Directory.Build.propsand the nuspec, a minor version for the new Lua function.Tested
tests/run.ps1with the builtRelease/RPS.dlland Lua 5.4.6: 16 passed, 0 failed, including the 3 new tests.VirtualProtected pages passed:PAGE_NOACCESSpage, with no read into it;a67270a) builds against this source, Release Win32.Not verified
core.AOBScanUniqueusesscanForAOBInMainModule; the 3.0.8 modules rely on it to reject missing or ambiguous patterns.v1.6.0). UCP3 restoresRPS 1.6.0from that feed; the package has not been published or restored yet.