Import scanners read resolved addresses as names when the import name table is missing

未关闭
#76 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
半天
新手友好度
62/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
cpp

调研方向

Start with the import walk in clean/rr_f/proxy/src/hook_dll.cpp around lines 849-861, where names come from OriginalFirstThunk with a FirstThunk fallback, then check the same pattern in clean/rr_f/proxy/src/setupapi_identity.cpp near line 390. The proposed fix is to skip a descriptor whose OriginalFirstThunk is zero and log once. Done means a synthetic PE64 test with a zero OriginalFirstThunk asserts nothing is patched and nothing faults, and the scanner must first be exported or compiled into the test.

由索引模型根据 Issue 内容生成。

描述

area: ray-reconstruction bug

This was found by reading the code. It has not been reproduced.

What happens

The import scanner in clean/rr_f/proxy/src/hook_dll.cpp:853-861 reads names from OriginalFirstThunk, and falls back to FirstThunk when it is zero. It then dereferences base + names->u1.AddressOfData as an IMAGE_IMPORT_BY_NAME. At run time FirstThunk holds resolved absolute addresses. The ordinal check passes (the top bit is clear for user-mode addresses). The result is base + address, which is unmapped, so the read faults.

The scanner runs on every loaded module (hook_dll.cpp:1105-1115). Only descriptors whose DLL name equals the interface file name reach the walk (hook_dll.cpp:849). There is no __try around do_hook.

The same fallback and interpretation is in clean/rr_f/proxy/src/setupapi_identity.cpp:390. That scanner only runs for Spider-Man2.exe.

When it can happen

Only for a module that imports the game interface (or, for the SetupAPI scanner, a Spider-Man2.exe that imports SetupAPI) and was linked or packed without an import name table. Current MSVC and LLVM x64 linkers always emit one. This is old-Borland or packer territory. No known RR game qualifies. Low severity: a crash at load if it ever occurs.

To do

  • In both scanners: if (!OriginalFirstThunk) { log once; continue; }.
  • Optionally bounds-check each name RVA against SizeOfImage.
  • Caution: none in practice. A module without an import name table is simply not patched, and that is logged.

Test

CPU-only. Build a synthetic in-memory PE64 image: DOS and NT headers, one import descriptor naming the interface, OriginalFirstThunk = 0, FirstThunk filled with a real function address. Call the scanner (it needs to be exported to the test or compiled into it). Assert nothing is patched and nothing crashes.

主要语言
C++
星标
12
派生
2
平均合并
3 小时 10 分钟
30 天内合并 PR
171

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

phantoslayer21/wronggpu 的其他 Issue

查看 phantoslayer21/wronggpu 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。