feat: re-instrument per STUB rules - all silent placeholders now panic
- PE-E03 pe_loader.c: unsupported base-reloc type silently skipped -> panic
- PE-E04 pe_shim.c ReadFile: fake TRUE+0-bytes ("pretend EOF") -> panic
- PE-E05 pe_shim.c CreateFileA: no file backend -> panic (no honest-failure excuse)
- PE-E06/E07 x86emu32.c: emu IAT unimplemented API / shim index OOB -> panic
- NETST-E01 net.c: netdev stats all-zero placeholder ("lying zero traffic") -> panic
- apic.c comment: SIPI reserved now points to DKM-E03 skeleton
- pe_dll_manager comments: circular-dep stub call now documented as PE-E01
- virtio_blk.c: capacity declaration marked as instrumentation whitelist
- QEMU verify: wizard -> Save -> verify ok -> login success -> desktop ready,
zero spurious panics
[STUB] P1/UTSM/pe+net re-instrument sweep | 剩余STUB命中=101 (全部为 panic 坐标注释 /
IDT halt-stub 防御术语 / 白名单) | “未成之物,不留活口”
This commit is contained in:
@@ -356,7 +356,9 @@ int pe_dll_load(const char *dll_name, u64 *out_base) {
|
||||
return 0;
|
||||
}
|
||||
if (e->state == DLL_STATE_LOADING) {
|
||||
/* 循环依赖:返回 -1,调用方填 unimpl stub */
|
||||
/* 循环依赖:返回 -1,调用方填 unimpl stub——该 stub 被调用
|
||||
* 即 PE-E01 莲花 panic(见 pe_shim.c shim_unimpl64),
|
||||
* 不存在静默降级出口。 */
|
||||
if (out_base) *out_base = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
pe/pe_dll_manager.o: pe\pe_dll_manager.c pe\pe_dll_manager.h \
|
||||
include\utsm\types.h pe\pe_loader.h include\utsm\pe.h pe\pe_shim.h \
|
||||
include\utsm\arena.h include\utsm\log.h
|
||||
pe\pe_dll_manager.h:
|
||||
include\utsm\types.h:
|
||||
pe\pe_loader.h:
|
||||
include\utsm\pe.h:
|
||||
pe\pe_shim.h:
|
||||
include\utsm\arena.h:
|
||||
include\utsm\log.h:
|
||||
@@ -144,7 +144,11 @@ static void apply_relocations(u8 *image, u32 image_size, u64 image_base_actual,
|
||||
val += (u32)delta;
|
||||
*(u32 *)target = val;
|
||||
} else {
|
||||
/* 其他重定位类型暂不支持 */
|
||||
/* 严格错误策略插桩:未实现的重定位类型静默跳过 = 重定位
|
||||
* 不完整照跑,零降级 panic(PE-E03)。 */
|
||||
log_error("[PE] unsupported reloc type");
|
||||
panic_full("PE-E03 RELOC TYPE NOT IMPLEMENTED",
|
||||
"PE base-reloc type outside ABSOLUTE/HIGHLOW/DIR64: not implemented", 0);
|
||||
}
|
||||
}
|
||||
block_rva += block_size;
|
||||
|
||||
+13
-5
@@ -216,10 +216,12 @@ static u64 __attribute__((ms_abi)) shim_WriteFile(u64 handle, u64 buffer, u64 le
|
||||
static u64 __attribute__((ms_abi)) shim_ReadFile(u64 handle, u64 buffer, u64 max_length,
|
||||
u64 bytes_read_ptr, u64 overlapped) {
|
||||
(void)handle; (void)buffer; (void)max_length; (void)overlapped;
|
||||
/* 暂不支持输入读取;lpNumberOfBytesRead 同为 DWORD*(4 字节) */
|
||||
u64 brp = gp(bytes_read_ptr);
|
||||
if (brp) *(u32 *)brp = 0;
|
||||
return 1;
|
||||
/* 严格错误策略插桩:读取路径未实现。此前返回 TRUE+0 字节是
|
||||
* "假装能跑"——PE 应用以为读到了 EOF。零降级 panic(PE-E04)。 */
|
||||
log_error("[PE] ReadFile called on shim without input backend");
|
||||
panic_full("PE-E04 READFILE INPUT NOT IMPLEMENTED",
|
||||
"shim ReadFile has no input backend: designed, not implemented", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u64 __attribute__((ms_abi)) shim_ExitProcess(u64 exit_code) {
|
||||
@@ -287,7 +289,13 @@ static u64 __attribute__((ms_abi)) shim_GetEnvironmentVariableA(u64 name, u64 bu
|
||||
static u64 __attribute__((ms_abi)) shim_CreateFileA(u64 filename, u64 access, u64 share,
|
||||
u64 sa, u64 disp, u64 flags, u64 template) {
|
||||
(void)filename; (void)access; (void)share; (void)sa; (void)disp; (void)flags; (void)template;
|
||||
return 0; /* 暂不支持文件 */
|
||||
/* 严格错误策略插桩:文件访问未实现。返回 INVALID_HANDLE 是诚实的
|
||||
* Win32 失败语义(应用可自行处理),但功能本身未实现——按零降级
|
||||
* 原则 panic(PE-E05),不做"假装没有文件"的静默降级。 */
|
||||
log_error("[PE] CreateFileA called: file IO not implemented");
|
||||
panic_full("PE-E05 FILE IO NOT IMPLEMENTED",
|
||||
"shim CreateFileA: file backend designed, not implemented", 0);
|
||||
return 0;
|
||||
}
|
||||
static u64 __attribute__((ms_abi)) shim_CloseHandle(u64 handle) { (void)handle; return 1; }
|
||||
static u64 __attribute__((ms_abi)) shim_GetFileSize(u64 handle, u64 high) {
|
||||
|
||||
+10
-3
@@ -11,6 +11,7 @@
|
||||
#include "x86emu32.h"
|
||||
#include "pe_shim.h"
|
||||
#include <utsm/log.h>
|
||||
#include <utsm/panic.h>
|
||||
#include <utsm/types.h>
|
||||
|
||||
/* ===== 内存访问(带边界检查) ===== */
|
||||
@@ -278,14 +279,20 @@ static int try_iat_call(x86emu_state *emu, u32 target) {
|
||||
if (target >= 0x00010000 && target < 0x00020000) {
|
||||
int shim_idx = target & 0xFFFF;
|
||||
if (shim_idx == 0xFFFF) {
|
||||
/* 未实现 stub */
|
||||
log_warn("[PE32] call unimplemented API");
|
||||
/* 严格错误策略插桩:32 位解释器调用未实现 API = 静默 EAX=0
|
||||
* 会给 PE 程序喂错误语义,零降级 panic(PE-E06)。 */
|
||||
log_error("[PE32] call unimplemented API");
|
||||
panic_full("PE-E06 EMU UNSHIMMED API CALLED",
|
||||
"x86emu32 IAT call hit unimplemented stub: not implemented", 0);
|
||||
emu->regs[X86_EAX] = 0;
|
||||
return 1;
|
||||
}
|
||||
const pe_shim_entry *se = pe_shim_get(shim_idx);
|
||||
if (!se) {
|
||||
log_warn("[PE32] shim index out of range");
|
||||
/* 严格错误策略插桩:shim 索引越界 = 导入解析已损坏,panic(PE-E07) */
|
||||
log_error("[PE32] shim index out of range");
|
||||
panic_full("PE-E07 SHIM INDEX OUT OF RANGE",
|
||||
"x86emu32 IAT call with invalid shim index", 0);
|
||||
emu->regs[X86_EAX] = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
pe/x86emu32.o: pe\x86emu32.c pe\x86emu32.h include\utsm\types.h \
|
||||
pe\pe_shim.h include\utsm\log.h include\utsm\panic.h
|
||||
pe\x86emu32.h:
|
||||
include\utsm\types.h:
|
||||
pe\pe_shim.h:
|
||||
include\utsm\log.h:
|
||||
include\utsm\panic.h:
|
||||
Reference in New Issue
Block a user