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>
64 lines
2.6 KiB
Python
64 lines
2.6 KiB
Python
"""probe_rs_base.py <pid>
|
|
Walk s_Resources to find a RenderSurface base (vfptr=0x0079a67c) entry.
|
|
Dump its primary view (entry-0x30 .. entry-0x30+0x150) so we can see
|
|
what's at primary+0x64 and primary+0x114 (where v5 reads).
|
|
Also check primary+0x144 which is OOB for RS base (size 0x120)."""
|
|
import ctypes, ctypes.wintypes as wt, sys, struct
|
|
|
|
PROCESS_VM_READ = 0x10
|
|
PROCESS_QUERY_INFORMATION = 0x400
|
|
k = ctypes.windll.kernel32
|
|
k.OpenProcess.argtypes = [wt.DWORD, wt.BOOL, wt.DWORD]; k.OpenProcess.restype = wt.HANDLE
|
|
k.ReadProcessMemory.argtypes = [wt.HANDLE, wt.LPCVOID, wt.LPVOID, ctypes.c_size_t, ctypes.POINTER(ctypes.c_size_t)]
|
|
k.ReadProcessMemory.restype = wt.BOOL
|
|
|
|
S_RESOURCES_M_DATA = 0x008398C4
|
|
S_RESOURCES_M_NUM = 0x008398CC
|
|
RS_BASE_VTABLE = 0x0079a67c
|
|
|
|
def rd(h, va, n):
|
|
buf = (ctypes.c_ubyte * n)(); sz = ctypes.c_size_t(0)
|
|
if not k.ReadProcessMemory(h, va, buf, n, ctypes.byref(sz)): return None
|
|
return bytes(buf[:sz.value])
|
|
|
|
def rd_u32(h, va):
|
|
b = rd(h, va, 4); return struct.unpack('<I', b)[0] if b else None
|
|
|
|
pid = int(sys.argv[1])
|
|
h = k.OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, False, pid)
|
|
if not h: print(f"OpenProcess err={ctypes.get_last_error()}"); sys.exit(2)
|
|
|
|
m_data = rd_u32(h, S_RESOURCES_M_DATA)
|
|
m_num = rd_u32(h, S_RESOURCES_M_NUM)
|
|
print(f"s_Resources: m_data=0x{m_data:08x} m_num={m_num}")
|
|
|
|
if not m_data or not m_num:
|
|
print("empty"); sys.exit(0)
|
|
|
|
# Walk up to first 5 RS base entries
|
|
n_found = 0
|
|
for i in range(min(m_num, 50000)):
|
|
entry = rd_u32(h, m_data + i * 4)
|
|
if not entry: continue
|
|
vt = rd_u32(h, entry)
|
|
if vt != RS_BASE_VTABLE: continue
|
|
# Got a RS base. Entry = GR-view. Primary = entry - 0x30.
|
|
primary = entry - 0x30
|
|
print(f"\n=== RS base entry #{i} ===")
|
|
print(f" entry (GR view) = 0x{entry:08x}")
|
|
print(f" primary = 0x{primary:08x}")
|
|
# Read primary + 0x60..0x70 and 0x110..0x120 and 0x140..0x150
|
|
for off, label in [(0x60, "primary+0x60..0x70 (around 0x64 1st delete)"),
|
|
(0x110, "primary+0x110..0x120 (around 0x114 2nd delete)"),
|
|
(0x120, "primary+0x120..0x130 (RenderSurfaceD3D fields if it were one)"),
|
|
(0x140, "primary+0x140..0x150 (OOB for RS base, what v5 reads)")]:
|
|
b = rd(h, primary + off, 16)
|
|
if b:
|
|
words = ' '.join(f"{struct.unpack('<I', b[j:j+4])[0]:08x}" for j in range(0, 16, 4))
|
|
print(f" {label}: {words}")
|
|
# And read primary+0..0x30 (DBObj part) and primary+0x30..0x60 (GR part)
|
|
n_found += 1
|
|
if n_found >= 3: break
|
|
|
|
if n_found == 0:
|
|
print("no RS base entries found in walk")
|