模块名称与其图像文件名称不同

问题描述

所以在 Windbg 上调试了一个可执行文件后,我注意到模块名称与图像名称不同。

首次加载可执行文件并在入口点前设置断点后,lm vm/!for_each_module 命令会显示这一点。

start    end        module name
00a30000 00a38000   Injection C (no symbols)           
    Loaded symbol image file: C:\Users\user\Downloads\Bird.exe
    Image path: Injection.exe
    Image name: Injection.exe
    browse all global symbols  functions  data
    Timestamp:        Mon May 24 22:30:53 2021 (60AC0CFD)
    CheckSum:         00000000
    ImageSize:        00008000

如上所示,Image Name 字段与 Loaded symbol image file 名称不对应。

知道为什么吗?是否与 .pdb 文件路径有关?

我在 PE 格式中找不到任何相关信息。

如何才能做到这一点?

解决方法

有人提到,lm!for_each_module 的文档中可能有显着差异

事实上 !for_each_module 有两个命令字符串,一个是 @#ModuleName,另一个是 @#ImageName

我看起来并不多,但有时我会看到诸如 foo_1480xxx 之类的替代品

您是否有可共享的二进制文件来显示此行为

编辑

刚刚浏览了一下文件,它出现了二进制文件中的 pdb 文件的名称 是注射.pdb 并且可执行文件在编译后已重命名

F:\Latebird>ls
LateBird.exe

F:\Latebird>file LateBird.exe
LateBird.exe: PE32 executable (console) Intel 80386,for MS Windows

F:\Latebird>certutil -hashfile LateBird.exe sha1
943710a2a04caeae3ab21cc8be83ebc1d556e127
   
F:\Latebird>certutil -hashfile LateBird.exe md5
c8e3b7b9dc2541574335f9141e3ca4bf
   
F:\Latebird>dbh LateBird.exe

LateBird [1000000]: i


      ModuleName : LateBird
       ImageName : LateBird.exe
 LoadedImageName : F:\Latebird\LateBird.exe
   LoadedPdbName :
           CVSig : 0x53445352
          CVData : C:\Users\Dynamic\source\repos\Injection\Release\Injection.pdb

          PdbAge : 0xa
    PdbUnmatched : false

     MachineType : I386

LateBird [1000000]:

再次确认我编译了一个Messagebox,编译后重命名
加载它windbg并检查lmvm

结果如下

ls -lg
total 17
-rwxr-xr-x 1 12800  LateBird.exe
-rw-r--r-- 1   165  LateBirdie.cpp

cat LateBirdie.cpp
#include <windows.h>
int WINAPI WinMain (_In_ HINSTANCE,_In_opt_ HINSTANCE,_In_ LPSTR,_In_ int ){
    return MessageBoxA(NULL,"LateBirdie","Early Birdie",0);
}

cl /Zi /W4 /analyze /Od /nologo LateBirdie.cpp /link /release user32.lib /entry:WinMain
LateBirdie.cpp

file LateBirdie.exe
LateBirdie.exe: PE32+ executable (GUI) x86-64,for MS Windows

ren LateBirdie.exe EarlyBirdie.exe

cdb -c ".reload /f; lmvm *bird*;q" EarlyBirdie.exe | awk "/Reading/,/quit/"
0:000> cdb: Reading initial command '.reload /f; lmvm *bird*;q'
Reloading current modules
start             end                 module name
00007ff6`87e50000 00007ff6`87e54000   LateBirdie     F:\Latebird\LateBirdie.pdb
    Loaded symbol image file: F:\Latebird\EarlyBirdie.exe
    Image path: LateBirdie.exe
    Image name: LateBirdie.exe
    Timestamp:        Tue Jun  1 02:56:35 2021 (60B5548B)
    CheckSum:         0000FCA9
    ImageSize:        00004000
    Translations:     0000.04b0 0000.04e4 0409.04b0 0409.04e4
    Information from resource tables:
quit: