Esempio n. 1
0
        static public Action <CpuThreadState> CreateAndCacheDelegateForPC(this CpuProcessor CpuProcessor, Stream MemoryStream, uint EntryPC)
        {
            var Delegate = CpuProcessor.MethodCache.TryGetMethodAt(EntryPC);

            if (Delegate == null)
            {
                Delegate = CpuProcessor.CreateDelegateForPC(MemoryStream, EntryPC);
                CpuProcessor.MethodCache.SetMethodAt(EntryPC, Delegate);
            }
            return(Delegate);
        }
Esempio n. 2
0
        static public Action <CpuThreadState> CreateDelegateForString(this CpuProcessor CpuProcessor, String Assembly, bool BreakPoint = false)
        {
            var MemoryStream = new MemoryStream();

            MemoryStream.PreservePositionAndLock(() =>
            {
                var MipsAssembler = new MipsAssembler(MemoryStream);

                MipsAssembler.Assemble(Assembly);
            });
            var Delegate = CpuProcessor.CreateDelegateForPC(MemoryStream, 0);

            return((_CpuThreadState) =>
            {
                _CpuThreadState.StepInstructionCount = 1000000;
                Delegate(_CpuThreadState);
            });
        }