Initial commit — leak-hunt project complete
Five bugs identified and patched in retail Asheron's Call client: - v3b: palette refcount over-increment (3-byte NOP at two sites) - v5: RenderSurface PurgeResource no-op stub (vtable slot 2 thunk) - v11: two dangling-pointer crash guards (NULL-check + reorder) - v14: CEnvCell::Destroy ClipPlaneList leak (18-byte JMP to cleanup thunk) - v22: unpacker stale-pointer SEH guard (whole-function __try/__except) All five ship in leakfix.dll (117 KB, SHA d282f23c…) which is loaded by acclient.exe at process start via PE import table patching by tools/install_leakfix.py. Controlled 15-client fleet soak: unpatched control died at 26h with palette exhaustion; all 14 patched clients survived past that point and reached ≥5-day uptime. Residual ~15 MB/h growth traced to d3d9.dll's internal slab allocator (260KB surface backing buffers retained after Release). See REPORT.md §10 for the full investigation; conclusion is that it's unfixable from outside d3d9. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
commit
57b5e43d0e
199 changed files with 1648333 additions and 0 deletions
100
tools/position_sample_dump.py
Normal file
100
tools/position_sample_dump.py
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
"""position_sample_dump.py <pid> [count=10]
|
||||
|
||||
For a few Position hits, print the surrounding bytes raw so we can
|
||||
visually inspect the layout. Goal: see if there's a heap-block
|
||||
header pattern we missed.
|
||||
"""
|
||||
import ctypes
|
||||
import ctypes.wintypes as wt
|
||||
import struct
|
||||
import sys
|
||||
|
||||
POSITION_VT = 0x00797910
|
||||
|
||||
PROCESS_VM_READ = 0x10
|
||||
PROCESS_QUERY_INFORMATION = 0x400
|
||||
|
||||
|
||||
class MBI(ctypes.Structure):
|
||||
_fields_ = [('BaseAddress', ctypes.c_void_p),
|
||||
('AllocationBase', ctypes.c_void_p),
|
||||
('AllocationProtect', wt.DWORD),
|
||||
('PartitionId', wt.WORD),
|
||||
('RegionSize', ctypes.c_size_t),
|
||||
('State', wt.DWORD),
|
||||
('Protect', wt.DWORD),
|
||||
('Type', wt.DWORD)]
|
||||
|
||||
|
||||
k = ctypes.windll.kernel32
|
||||
k.OpenProcess.argtypes = [wt.DWORD, wt.BOOL, wt.DWORD]; k.OpenProcess.restype = wt.HANDLE
|
||||
k.CloseHandle.argtypes = [wt.HANDLE]; k.CloseHandle.restype = wt.BOOL
|
||||
k.ReadProcessMemory.argtypes = [wt.HANDLE, wt.LPCVOID, wt.LPVOID, ctypes.c_size_t,
|
||||
ctypes.POINTER(ctypes.c_size_t)]
|
||||
k.ReadProcessMemory.restype = wt.BOOL
|
||||
k.VirtualQueryEx.argtypes = [wt.HANDLE, ctypes.c_void_p, ctypes.POINTER(MBI), ctypes.c_size_t]
|
||||
k.VirtualQueryEx.restype = ctypes.c_size_t
|
||||
|
||||
|
||||
def hexdump(addr, data, prefix=""):
|
||||
for i in range(0, len(data), 16):
|
||||
chunk = data[i:i+16]
|
||||
h = " ".join(f"{b:02x}" for b in chunk)
|
||||
a = "".join(chr(b) if 32 <= b < 127 else '.' for b in chunk)
|
||||
dws = " ".join(f"{struct.unpack_from('<I', chunk, j)[0]:08x}"
|
||||
for j in range(0, min(16, len(chunk) - (len(chunk) % 4)), 4))
|
||||
print(f"{prefix}0x{addr+i:08x}: {h:<47} | {dws} | {a}")
|
||||
|
||||
|
||||
def main():
|
||||
pid = int(sys.argv[1])
|
||||
want = int(sys.argv[2]) if len(sys.argv) > 2 else 10
|
||||
|
||||
h = k.OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, False, pid)
|
||||
if not h:
|
||||
print(f"OpenProcess err={ctypes.get_last_error()}"); return 1
|
||||
|
||||
shown = 0
|
||||
mbi = MBI()
|
||||
addr = 0
|
||||
while k.VirtualQueryEx(h, addr, ctypes.byref(mbi), ctypes.sizeof(mbi)) and shown < want:
|
||||
pr = mbi.Protect & 0xff
|
||||
if (mbi.State == 0x1000 and mbi.Type == 0x20000
|
||||
and pr in (0x04, 0x40)):
|
||||
buf = (ctypes.c_ubyte * mbi.RegionSize)()
|
||||
sz = ctypes.c_size_t(0)
|
||||
if k.ReadProcessMemory(h, mbi.BaseAddress, buf,
|
||||
mbi.RegionSize, ctypes.byref(sz)):
|
||||
data = bytes(buf[:sz.value])
|
||||
end = (len(data) // 4) * 4
|
||||
# find positions in this region
|
||||
pos_offs = []
|
||||
for off in range(0, end, 4):
|
||||
if struct.unpack_from("<I", data, off)[0] == POSITION_VT:
|
||||
pos_offs.append(off)
|
||||
# sample first few
|
||||
for off in pos_offs[:3]:
|
||||
if shown >= want:
|
||||
break
|
||||
shown += 1
|
||||
va_pos = mbi.BaseAddress + off
|
||||
region_kb = mbi.RegionSize // 1024
|
||||
print(f"\n=== Position #{shown} @ VA 0x{va_pos:08x} "
|
||||
f"(region 0x{mbi.BaseAddress:08x} {region_kb}KB, "
|
||||
f"in-region offset 0x{off:x}, "
|
||||
f"positions-in-region={len(pos_offs)}) ===")
|
||||
# dump 64 bytes BEFORE position vt
|
||||
lo = max(0, off - 64)
|
||||
hexdump(mbi.BaseAddress + lo, data[lo:off], prefix=" before ")
|
||||
print(" POSITION:")
|
||||
hexdump(mbi.BaseAddress + off, data[off:off + 128], prefix=" pos+ctx ")
|
||||
addr = (mbi.BaseAddress or 0) + mbi.RegionSize
|
||||
if addr >= 0x80000000 or shown >= want:
|
||||
break
|
||||
|
||||
k.CloseHandle(h)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue