aardio 文档

fsys.res.menu:探查 EXE/DLL 菜单资源文件

菜单解码:不用手写 Win32 遍历

fsys.res.menu(resName[,moduleOrPath[,langId]]) 读取 RT_MENU,支持标准 MENU 与扩展 MENUEX。纯数据解析,不创建 HMENU 或窗口;读取字段前检查边界,截断、无效头部或超过 64 层子菜单嵌套返回 null, err, 13。

返回包含以下树结构的表对象:

{
    version = 0 或 1;
    helpId = MENUEX 头帮助 ID,标准 MENU 为 0;
    items = [
        {
            id; text; type; state; flags;
            popup; separator;
            // 弹出项还包含:
            helpId; items = [ 子项目... ];
        }
    ];
}

枚举并查找“复制、粘贴、全选”命令:

import fsys.res.menu;
var file = "C:\Windows\System32\notepad.exe";

var commands = [];
var ids,err,code = fsys.res.menu.enum(
    function(text,id,position,item,resId,level){
        //在资源文件里仅 Ctrl+C 写作 Ctl+C  
        if(string.find(text,"Ctr?l\+[CVA]")){
                table.push(commands,{resId=resId;lcommandId=id;position=position;text=text;level=level});
                print(text,id,position,resId,level);
        } 
    }
)

return commands;

遍历全部菜单资源:

import fsys.res.menu;
var file = "C:\Windows\System32\notepad.exe";

for menu,resId in fsys.res.menu.each(file){
    print(menu,resId) // menu 为 fsys.res.menu 对象
}

Markdown 格式