C++ 源码 转 机器码MCode 后的示例
#Requires AutoHotkey v2.0 ; #include <log> n := 2000 ; logger.info('start') factorial := MCode("1,x64:48895C2408488974241857B8509C0000482BE0488B05000000004833C448898424409C00004533C0BB02000000B801000000488BFA89028BF13BCB0F8CC600000066660F1F8400000000004533DB4533C983E8014C63D07848458D5A010F1F400066660F1F840000000000428B0C97B8676666660FAFCB4103C8F7E9448BC241C1F802418BC0C1E81F4403C0438D048003C02BC842890C8C49FFC14983EA0179CA4585C074300F1F440000B86766666641FFC341F7E8C1FA028BC2C1E81F03D08D049203C0442BC04689048C49FFC1448BC285D275D5498D49FF4885C9781B488BD7660F1F8400000000008B048C4883E9018902488D520479F1FFC3418BC33BDE0F8E44FFFFFF488B8C24409C00004833CC4C8D9C24509C0000498B5B10498B7320498BE35FC3") bf := Buffer(10000 * 4, 0) total := factorial("int", n, "ptr", bf) ; logger.info(total) MsgBox total loop(total) rtn .= NumGet(bf, (A_Index - 1) * 4, "int") MsgBox rtn ; logger.info(rtn) return MCode(hex, argtypes := 0, &code := 0) { static reg := "^([12]?).*" (c := A_PtrSize = 8 ? "x64" : "x86") ":([A-Za-z\d+/=]+)" if (RegExMatch(hex, reg, &m)) hex := m[2], flag := m[1] = "1" ? 4 : m[1] = "2" ? 1 : hex ~= "[+/=]" ? 1 : 4 else flag := hex ~= "[+/=]" ? 1 : 4 if (!DllCall("crypt32\CryptStringToBinary", "str", hex, "uint", 0, "uint", flag, "ptr", 0, "uint*", &s := 0, "ptr", 0, "ptr", 0)) return code := Buffer(s) if (DllCall("crypt32\CryptStringToBinary", "str", hex, "uint", 0, "uint", flag, "ptr", code, "uint*", &s, "ptr", 0, "ptr", 0) && DllCall("VirtualProtect", "ptr", code, "uint", s, "uint", 0x40, "uint*", 0)) { args := [] if (Type(argtypes) = "Array" && argtypes.Length) { args.Length := argtypes.Length * 2 - 1 for i, t in argtypes args[i * 2 - 1] := t } return DllCall.Bind(code, args*) } }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)