用C语言和PECMD各写了一份源码。
附件是C语言编译的程序,由于开启了XP支持,并启用静态编译,程序有点小肥
PECMD源码可以自行定制:
Extract 函数的参数解释: -S: 是否静默模式。yes完全静默,省略此参数时非静默模式。 -IfList: 控制是否返回图标资源列表,0不返回,1返回,2仅返回不提取图标。Strings 为列表变量名。 -Id: 提取指定的图标 ID。比如 1 或 28 或 MAINICON。 -Type: 资源类型,本示例只提取图标,所以仅支持#14。比如 #14 或 #6 或 $EXEDATA,脚本后面有详细说明。 -File: 要提取图标的文件。 -Icon: 指定要提取的图标 ID 的保存路径。 -IconDir: 保存所有图标的目录。 备注: 各参数间无先后顺序。 Extract 函数错误码(error): 0:成功 1:找不到文件 2:没有指定资源类型 3:指定的类型不是图标类型 4:文件加载失败 5:找不到资源 示例1:查询 shell32.dll 的图标 ID 列表,返回值为 Strings call Extract -S yes -IfList 2 -Type #14 -File %WinDir%\System32\shell32.dll mess. [%error%][%Strings%] 示例2:导出所有图标文件,非静默模式 call Extract -IfList 0 -Type #14 -File %WinDir%\System32\shell32.dll -IconDir "%Desktop%\extract_icons" mess. [%error%][%Strings%] 示例3:导出 ID 为 28 的图标文件 call Extract -S yes -IfList 0 -Id 28 -Type #14 -File %WinDir%\System32\shell32.dll -Icon "%Desktop%\abcd.ico" mess. [%error%][%Strings%] 示例4:导出 ID 为 MAINICON 的图标文件 call Extract -IfList 0 -Id MAINICON -Type #14 -S yes -File "C:\Users\Administrator\Desktop\新建文件夹 (2)\Inet Download Manager 6.42.53.exe" -Icon "%Desktop%\abcd.ico" mess. [%error%][%Strings%] 示例5:在不知道shell32.dll图标 ID 的情况下,提取第 2 个图标 call Extract -S yes -IfList 2 -Type #14 -File %WinDir%\System32\shell32.dll //先查询shell32.dll的图标 ID 列表,返回值为Strings mess. [%error%][%Strings%] read -*,2,MyIcon,Strings //读取第1行,就是第1个图标 ID;第2行,就是第2个图标 ID;…… 依次类摧。注意,图标 ID 可能不是从1开始,也可能是一个字符串,比如:MAINICON find *<>MyIcon, { call Extract -S yes -IfList 0 -Id %MyIcon% -Type #14 -File "%WinDir%\System32\shell32.dll" -Icon "%Desktop%\abcd.ico" //开始导出图标 mess. [%error%][%Strings%] } mess ok 示例6:在另一个pecmd进程中调用此脚本 exec* -incmd pecmd a=load "C:\Users\Administrator\Desktop\xxxxxxxx\Project1\Project1\导出图标.wcs" -S yes -IfList 0 -Id 28 -Type #14 -File %WinDir%\System32\shell32.dll -Icon "%Desktop%\abcd.ico" mess. [%error%][%a%] 示例7:在批处理中调用此脚本,错误码errorlevel,可用 for 捕获输出。用 PECMD_cli.exe 可直接在控制台输出。 pecmd.exe load "C:\Users\Administrator\Desktop\xxxxxxxx\Project1\Project1\导出图标.wcs" -S yes -IfList 0 -Id 28 -Type #14 -File %WinDir%\System32\shell32.dll -Icon "%Desktop%\abcd.ico"
PECMD源码:
此处内容隐藏,回复后可见!立即回复 回复后请刷新页面!刷新
感谢分享
谢谢分享