예제 #1
0
        public void LinkFunction(uint CallAddress, FunctionEntry NativeFunction)
        {
            //Console.WriteLine(NativeFunction);

            CpuProcessor.Memory.WriteSafe(CallAddress + 0, SyscallInfo.NativeCallSyscallOpCode);  // syscall NativeCallSyscallCode
            CpuProcessor.Memory.WriteSafe(CallAddress + 4, (uint)ModuleManager.AllocDelegateSlot(
                Action: CreateDelegate(
                    ModuleManager: ModuleManager,
                    Module: NativeFunction.Module,
                    NID: NativeFunction.NID,
                    ModuleImportName: NativeFunction.ModuleName,
                    NIDName: NativeFunction.Name
                ),
                ModuleImportName: NativeFunction.ModuleName,
                FunctionEntry: NativeFunction
            ));

            Console.WriteLine(
                "    CODE_ADDR({0:X})  :  NID(0x{1,8:X}) : {2} - {3}",
                CallAddress, NativeFunction.NID, NativeFunction.Name, NativeFunction.Description
            );
        }
예제 #2
0
        public void ImportModules()
        {
            foreach (var ModuleImports in ModulesImports)
            {
                HleModuleHost HleModuleHost = null;
                try
                {
                    HleModuleHost = ModuleManager.GetModuleByName(ModuleImports.Name);
                }
                catch (Exception Exception)
                {
                    Console.WriteLine(Exception);
                }

                // Can't use a host module. Try to use a Guest module.
                if (HleModuleHost == null)
                {
                    var HleModuleGuest = ModuleManager.LoadedGuestModules.FirstOrDefault(ModuleExports => (ModuleExports.Name == ModuleImports.Name));
                    if (HleModuleGuest != null)
                    {
                        HleModuleGuest.ExportModules(this);
                        continue;
                    }
                }

                Console.WriteLine("'{0}' - {1}", ModuleImports.Name, (HleModuleHost != null) ? HleModuleHost.ModuleLocation : "?");
                foreach (var Function in ModuleImports.Functions)
                {
                    var NID = Function.Key;
                    var CallAddress = Function.Value.Address;

                    var DefaultEntry = new FunctionEntry()
                    {
                        NID = 0x00000000,
                        Name = CStringFormater.Sprintf("__<unknown:0x%08X>", (int)NID),
                        Description = "Unknown",
                        Module = null,
                        ModuleName = ModuleImports.Name,
                    };
                    var FunctionEntry = (HleModuleHost != null) ? HleModuleHost.EntriesByNID.GetOrDefault(NID, DefaultEntry) : DefaultEntry;
                    FunctionEntry.NID = NID;
                    //var Delegate = Module.DelegatesByNID.GetOrDefault(NID, null);

                    LinkFunction(CallAddress, FunctionEntry);
                }
            }
        }