如何知道 DLL / EXE 是X64 還是X32 [.net/原生 都可用]
如何知道 DLL / EXE 是X64 還是X32 [.net/原生 都可用]
資料來源:copilot
在輸出中查找“FI在 CMD/PowerShell 使用 Visual Studio 和相應的工具(dumpbin) 查詢LE HEADER VALUES”部分。
如果看到8664,那麼是X64;如果是14C,那麼是X32。
教學命令:
cd "C:\Program Files\Microsoft Visual Studio\2022\Community" dumpbin /headers \path\yourfile.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext }
實際測試紀錄
cd "C:\Program Files\Microsoft Visual Studio\2022\Community" dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\POS_ECM.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 8664 machine (x64) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\POS_INV.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 8664 machine (x64) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\EZio32.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 14C machine (x86) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\TSCLIB.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 14C machine (x86) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\libeay32.dll| Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 14C machine (x86) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\ssleay32.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 14C machine (x86) dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\QRDLL.dll | Select-String -Pattern "FILE HEADER VALUES" -Context 0,1 | ForEach-Object { $_.Context.PostContext } 14C machine (x86)
ps.CMD不能在單一行直接查詢所要資料因此比較麻煩,語法如下所示(AI提供 未實際測試)
dumpbin /headers yourfile.dll > tempfile.txt findstr /C:"FILE HEADER VALUES" tempfile.txt
單純使用TOOL查詢不進行過濾的狀況備份
dumpbin /headers C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\POS_ECM.dll Microsoft (R) COFF/PE Dumper Version 14.42.34436.0 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file C:\Users\jashv\OneDrive\桌面\GITHUB\127\VPOS_Avalonia\NSIS_Project\net8.0\POS_ECM.dll PE signature found File Type: DLL FILE HEADER VALUES 8664 machine (x64) 3 number of sections 663436AD time date stamp Fri May 3 08:58:21 2024 0 file pointer to symbol table 0 number of symbols F0 size of optional header 2022 characteristics Executable Application can handle large (>2GB) addresses DLL OPTIONAL HEADER VALUES 20B magic # (PE32+) 8.00 linker version 1B4000 size of code 2000 size of initialized data 5C4000 size of uninitialized data 777DF0 entry point (0000000000B77DF0) 5C5000 base of code 400000 image base (0000000000400000 to 0000000000B7AFFF) 1000 section alignment 200 file alignment 5.02 operating system version 5.02 image version 5.02 subsystem version 0 Win32 version 77B000 size of image 1000 size of headers 0 checksum 2 subsystem (Windows GUI) 0 DLL characteristics 0 size of stack reserve 0 size of stack commit 100000 size of heap reserve 2000 size of heap commit 0 loader flags 10 number of directories 77A530 [ 178] RVA [size] of Export Directory 77A1C0 [ 370] RVA [size] of Import Directory 779000 [ 11C0] RVA [size] of Resource Directory 6E2000 [ 58C98] RVA [size] of Exception Directory 0 [ 0] RVA [size] of Certificates Directory 0 [ 0] RVA [size] of Base Relocation Directory 0 [ 0] RVA [size] of Debug Directory 0 [ 0] RVA [size] of Architecture Directory 0 [ 0] RVA [size] of Global Pointer Directory 0 [ 0] RVA [size] of Thread Storage Directory 0 [ 0] RVA [size] of Load Configuration Directory 0 [ 0] RVA [size] of Bound Import Directory 0 [ 0] RVA [size] of Import Address Table Directory 696000 [ 1198] RVA [size] of Delay Import Directory 0 [ 0] RVA [size] of COM Descriptor Directory 0 [ 0] RVA [size] of Reserved Directory SECTION HEADER #1 UPX0 name 5C4000 virtual size 1000 virtual address (0000000000401000 to 00000000009C4FFF) 0 size of raw data 400 file pointer to raw data 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers E0000080 flags Uninitialized Data Execute Read Write SECTION HEADER #2 UPX1 name 1B4000 virtual size 5C5000 virtual address (00000000009C5000 to 0000000000B78FFF) 1B3200 size of raw data 400 file pointer to raw data (00000400 to 001B35FF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers E0000040 flags Initialized Data Execute Read Write SECTION HEADER #3 .rsrc name 2000 virtual size 779000 virtual address (0000000000B79000 to 0000000000B7AFFF) 1800 size of raw data 1B3600 file pointer to raw data (001B3600 to 001B4DFF) 0 file pointer to relocation table 0 file pointer to line numbers 0 number of relocations 0 number of line numbers C0000040 flags Initialized Data Read Write Summary 2000 .rsrc 5C4000 UPX0 1B4000 UPX1