コード例 #1
0
        public AheadlibCodeGenerator(string codeGenPath, string oldDllName, bool isCodegenFunctionTrace, CodeGenDllMode dllMode, string logPath, DisplayModuleInfo dlltarget, string cfg)
        {
            CodeGenPath            = codeGenPath;
            OldDllName             = oldDllName;
            IsCodegenFunctionTrace = isCodegenFunctionTrace;
            DllMode = dllMode;
            LogPath = logPath;

            DllTarget         = dlltarget;
            Functions         = new List <AheadlibFunction>();
            ReplaceRuleLoader = ReplaceRuleLoader.GetReplaceRules(cfg);
            PhSymbolProvider symbolProvider = new PhSymbolProvider();

            foreach (var expfunction in dlltarget.Exports)
            {
                AheadlibFunction function = new AheadlibFunction();
                function.Ordinal = expfunction.Ordinal;
                function.Name    = expfunction.Name;
                var dx = new DisplayPeExport(expfunction, symbolProvider);
                function.UndecorateName = dx.Name;
                //function.SubstituteSymbol = function.UndecorateName; //ReplaceRuleLoader.Get_NameInSourceCode_From_Name(function.Name);
                function.ExportByOrdinal = expfunction.ExportByOrdinal;
                function.VirtualAddress  = expfunction.VirtualAddress;
                Functions.Add(function);
            }
        }
コード例 #2
0
        public static ReplaceRuleLoader GetReplaceRules(string cfg)
        {
            ReplaceRuleLoader loader = new ReplaceRuleLoader();

            try
            {
                var s = File.ReadAllText(cfg);
                loader.ReplaceRules = JsonConvert.DeserializeObject <Dictionary <char, string> >(s);
            }
            catch
            {
                loader.ReplaceRules      = new Dictionary <char, string>();
                loader.ReplaceRules['?'] = "_H3F_";//ascii number
                loader.ReplaceRules['@'] = "_H40_";
                loader.ReplaceRules['$'] = "_H24_";

                var save = JsonConvert.SerializeObject(loader.ReplaceRules, Formatting.Indented);
                File.WriteAllText(cfg, save);
            }
            return(loader);
        }