コード例 #1
0
 public SendPacket(MemoryReader _memread)
 {
     Process _process = _memread.Process;
     tProcessHandle = _process.Handle;
     tProcess = _process;
     memRead = _memread;
 }
コード例 #2
0
ファイル: Grabber.cs プロジェクト: nlhans/MemoryVision
        public Grabber(CheatEngineReader table, MemoryReader reader)
        {
            Config = new Configuration(this);

            //TEMPORARY configuration!
            Config.SamplesBeforeTrigger = 750;
            Config.SamplesAfterTrigger = 750;
            Config.SampleWaitTime = 10000;//ms, 1ms here

            Config.Trigger_Simple_Channel = 0; // gear
            Config.Trigger_Simple_Condition = TriggerCondition.IN_RANGE; // Rising up
            Config.Trigger_Simple_ValueType = MemoryChannelType.INT32;
            Config.Trigger_Simple_Value = new byte[4] { 3, 0, 0, 0 }; // INT32 (5)
            Config.Trigger_Simple_Value2 = new byte[4] { 5, 0, 0, 0 }; // INT32 (5)
            Config.Trigger_Simple = true;

            Channels = new Channels(this,table);
            Waveform = new Waveform(this);
            Trigger = new Triggering(this);

            this.Reader = reader;

            _mGrabberTiming = new MicroStopwatch();

            TritonBase.PreExit += Stop;
        }
コード例 #3
0
ファイル: MemoryProvider.cs プロジェクト: nlhans/OpenTTDStats
        public MemoryProvider(MemoryReader reader)
        {
            BaseAddress = reader.Process.MainModule.BaseAddress.ToInt32();
            Reader = reader;

            Scanner = new MemorySignatureScanner(this);
        }
コード例 #4
0
		public ReadOnlyMemory(MemoryReader reader)
		{
			if (reader == null)
				throw new ArgumentNullException("reader");

			Reader = reader;
		}
コード例 #5
0
ファイル: Mc.cs プロジェクト: YohanAugusto/MemoryScanner
        public override bool CheckAddress()
        {
            int adr = Address;

            WinApi.PROCESS_INFORMATION pi = new WinApi.PROCESS_INFORMATION();
            WinApi.STARTUPINFO si = new WinApi.STARTUPINFO();
            string path = Util.GlobalVars.FullPath;
            string arguments = "";

            WinApi.CreateProcess(path, " " + arguments, IntPtr.Zero, IntPtr.Zero,
                false, WinApi.CREATE_SUSPENDED, IntPtr.Zero,
                System.IO.Path.GetDirectoryName(path), ref si, out pi);
            IntPtr handle = WinApi.OpenProcess(WinApi.PROCESS_ALL_ACCESS, 0, pi.dwProcessId);
            Process p = Process.GetProcessById(Convert.ToInt32(pi.dwProcessId));
            MemoryReader Writer = new MemoryReader(p);
            Writer.WriteByte(adr, 0xEB);// write jmp short

            WinApi.ResumeThread(pi.hThread);
            p.WaitForInputIdle();
            Writer.WriteByte(Address, 0x75);// write jnz short
            WinApi.CloseHandle(handle);
            WinApi.CloseHandle(pi.hProcess);
            WinApi.CloseHandle(pi.hThread);
            if (p.MainWindowTitle == "Tibia Error")
            {
                return false;
            }
            return true;
        }
コード例 #6
0
ファイル: FFXIVLIB.cs プロジェクト: nalicexiv/ffxivlib
        /// <summary>
        /// Instantiates a FFXIVLIB instance.
        /// PID is optionnal but required if multiple FFXIV process are running.
        /// </summary>
        /// <param name="pid">FFXIV PID (optionnal)</param>
        public FFXIVLIB(int pid = 0)
        {
            if (pid != 0)
                ffxiv_process = Process.GetProcessById(pid);
            else
                {
                    Process[] p = Process.GetProcessesByName(Constants.PROCESS_NAME);
                    if (p.Length <= 0)
                        throw new InvalidOperationException("No FFXIV process.");
                    if (p.Length > 1)
                        throw new NotImplementedException("Call the constructor with PID if multiple process.");
                    ffxiv_process = p[0];
                }

            #region Sanity checks

            if (!ffxiv_process.MainWindowTitle.Equals(Constants.WINDOW_TITLE))
                throw new InvalidOperationException("We might not be attaching to FFXIV, is something wrong?");
            if (ffxiv_process.MainModule.ModuleMemorySize < Constants.PROCESS_MMS)
                throw new InvalidOperationException("Wrong MMS.");

            #endregion

            ffxiv_pid = ffxiv_process.Id;
            _mr = MemoryReader.SetInstance(ffxiv_process);
            _ss = new SigScanner(ffxiv_pid, true);
            Ski = SendKeyInput.SetInstance(ffxiv_process.MainWindowHandle);
        }
コード例 #7
0
ファイル: Telemetry.cs プロジェクト: nlhans/SimTelemetry
        public Telemetry(IPluginTelemetryProvider provider, Process simulatorProcess)
        {
            Provider = provider;

            // Initialize memory objects
            var mem = new MemoryReader();
            mem.Open(simulatorProcess);

            Memory = new MemoryProvider(mem);

            // Initialize telemetry provider; this class gives us the address layout to read.
            Memory.Scanner.Enable();
            Provider.Initialize(Memory);
            Memory.Scanner.Disable();

            // Start outside-world telemetry objects
            Session = new TelemetrySession();
            Simulator = new TelemetryGame();
            Acquisition = new TelemetryAcquisition();
            Support = new TelemetrySupport();

            // Start 40Hz clock signal (25ms)
            Clock = new MMTimer(25);
            Clock.Tick += (o, s) => GlobalEvents.Fire(new TelemetryRefresh(this), true);
            Clock.Start();

            // Hook both events together:
            GlobalEvents.Hook<TelemetryRefresh>(Update, true);
        }
コード例 #8
0
ファイル: Attributes.cs プロジェクト: harib/Afterthought
     protected AttributeDecoder(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader
 )
     {
         this.PEFileToObjectModel = peFileToObjectModel;
           this.SignatureMemoryReader = signatureMemoryReader;
           this.morePermutationsArePossible = true;
     }
コード例 #9
0
ファイル: SignatureHelpers.cs プロジェクト: EkardNT/Roslyn
        internal static MetadataToken DecodeToken(ref MemoryReader ppSig)
        {
            uint value = ppSig.ReadCompressedUInt32();
            if (value == MemoryReader.InvalidCompressedInteger)
            {
                return default(MetadataToken);
            }

            uint tokenType = corEncodeTokenArray[value & 0x3];
            return MetadataTokens.CreateHandle(tokenType | (value >> 2));
        }
コード例 #10
0
ファイル: UIObject.cs プロジェクト: jhurliman/d3research
        public UIObject(MemoryReader memReader, uint ptr, int id, string name, uint vtable, bool visible)
        {
            this.memReader = memReader;
            Pointer = ptr;
            ID = id;
            Name = name;
            this.visible = visible;

            if (!Offsets.UI_VTABLES.TryGetValue(vtable, out Type))
                Type = (UIType)vtable;

            children = new List<UIObject>();
        }
コード例 #11
0
ファイル: D3Scene.cs プロジェクト: jhurliman/d3research
        public D3Scene(MemoryReader memReader, uint ptr, byte[] data)
        {
            this.Pointer = ptr;
            this.InstanceID = BitConverter.ToUInt32(data, 0);
            this.SceneID = BitConverter.ToUInt32(data, 4);
            this.WorldID = BitConverter.ToUInt32(data, 8);
            this.SnoID = BitConverter.ToUInt32(data, 220);
            this.Position = new Vector3f(data, 240);
            this.NavMeshPtr = BitConverter.ToUInt32(data, 380);
            this.Active = (memReader.ReadUInt(ptr + 396) & 1) != 0;

            uint ptr2 = BitConverter.ToUInt32(data, 604);
            if (ptr2 != 0)
                this.Name = memReader.D3.ReadASCIIString(ptr2 + 8, 128);
            else
                this.Name = String.Empty;
        }
コード例 #12
0
        public static int SearchForFunctionStart(MemoryReader memRead,int adr)
        {
            byte[] SearchBytes = new byte[] { 0xCC, 0x55 };
                int i = adr;

                do
                {
                    byte[] value = memRead.ReadBytes(i, 2);
                    if(CompareByteArrays(value,SearchBytes))
                    {
                        return i +1;

                    }
                    i -= 1;

                } while (true);
        }
コード例 #13
0
ファイル: FFXIVLIB.cs プロジェクト: Catacatata/ffxivlib
        /// <summary>
        /// Instantiates a FFXIVLIB instance.
        /// PID is optional but required if multiple FFXIV process are running.
        /// </summary>
        /// <param name="pid">FFXIV PID (optionnal)</param>
        public FFXIVLIB(int pid = 0)
        {
            if (pid != 0)
                ffxiv_process = Process.GetProcessById(pid);
            else
                {
                    Process[] p = Process.GetProcessesByName(Constants.PROCESS_NAME);
                    if (p.Length <= 0)
                        throw new InvalidOperationException("No FFXIV process.");
                    if (p.Length > 1)
                        throw new InvalidOperationException("Call the constructor with PID if multiple process.");
                    ffxiv_process = p[0];
                }

            Pid = ffxiv_process.Id;
            _mr = MemoryReader.SetInstance(ffxiv_process);
            _ss = new SigScanner(Pid, true);
            Ski = SendKeyInput.SetInstance(ffxiv_process.MainWindowHandle);
        }
コード例 #14
0
ファイル: FFXIGameInstance.cs プロジェクト: stsy/mappy
 public FFXISpawn(uint ID, IntPtr pointer, FFXIGameInstance instance)
 {
     base.ID = ID;
     m_pointer = pointer;
     m_instance = instance;
     m_reader = instance.Reader;
     Update(); //read the memory straight away so that the server id is available
 }
コード例 #15
0
 private void LoadSemiStaticData()
 {
     gmAddr = MemoryReader.ReadIntPtr(EngineAddr + gmOffset);
 }
コード例 #16
0
 internal SecurityAttributeDecoder20(PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, SecurityAttribute securityAttribute)
     : base(peFileToObjectModel, signatureMemoryReader)
 {
     this.SecurityAttributes = Enumerable<ICustomAttribute>.Empty;
       byte prolog = this.SignatureMemoryReader.ReadByte();
       if (prolog != SerializationType.SecurityAttribute20Start) return;
       int numberOfAttributes = this.SignatureMemoryReader.ReadCompressedUInt32();
       var securityCustomAttributes = new ICustomAttribute[numberOfAttributes];
       for (int i = 0; i < numberOfAttributes; ++i) {
     var secAttr = this.ReadSecurityAttribute(securityAttribute);
     if (secAttr == null) {
       //  MDError...
       return;
     }
     securityCustomAttributes[i] = secAttr;
       }
       this.SecurityAttributes = IteratorHelper.GetReadonly(securityCustomAttributes);
 }
コード例 #17
0
ファイル: Start.cs プロジェクト: YohanAugusto/MemoryScanner
 public BlistStart(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #18
0
 public WalkFunction(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
コード例 #19
0
        public bool parseE5(MemoryReader mr)
        {
            GameItem item = ToolConfig.Instance.Current;

            hero_num = 0x400;
            heros    = new DicHeroAttr[hero_num];
            for (int i = 0; i < hero_num; i++)
            {
                mr.setIndex(0x18c + i * 0x20);
                heros[i]     = new DicHeroAttr();
                heros[i].hid = (ushort)i;
                heros[i].parseE5(mr);
            }

            job_num = item.e5_job_num;
            jobs    = new DicJobAttr[job_num];
            for (int i = 0; i < job_num; i++)
            {
                mr.setIndex(item.e5_job_attr_offset + i * item.e5_job_attr_size);
                jobs[i]       = new DicJobAttr();
                jobs[i].jobid = (ushort)i;
                jobs[i].parseE5(mr);
            }

            mr.setIndex(0x5973);
            land_num = 0x1e;
            lands    = new LandformAttr[land_num];
            for (int i = 0; i < land_num; i++)
            {
                lands[i]             = new LandformAttr();
                lands[i].landform_id = (ushort)i;
                lands[i].parseE5(mr);
            }

            int jobLandLen = item.e5_jobLandLen;

            job_terrain_info = new byte[jobLandLen][];
            job_walk_info    = new byte[jobLandLen][];
            mr.setIndex(item.e5_job_land_info_offset);
            for (int i = 0; i < jobLandLen; i++)
            {
                job_terrain_info[i] = new byte[land_num];
                job_walk_info[i]    = new byte[land_num];
                mr.readBytes(job_terrain_info[i]);
                mr.readBytes(job_walk_info[i]);
            }

            good_num = item.e5_item_num + item.star_e5_item_num;
            goods    = new DicItemAttr[good_num];
            for (int i = 0; i < item.e5_item_num; i++)
            {
                mr.setIndex(item.e5_item_attr_offset + 0x19 * i);
                goods[i]         = new DicItemAttr();
                goods[i].good_id = (ushort)i;
                goods[i].parseE5(mr);
            }

            job_good_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_good_info[i] = new byte[good_num];
            }

            for (int i = 0; i < 53; i++)
            {
                mr.setIndex(0x53dc + 0x09 + goods[i].itid);
                for (int j = 0; j < job_num; j++)
                {
                    mr.setIndex(0x53dc + 0x09 + goods[i].itid + j * 0x1b);
                    job_good_info[j][i] = mr.readByte();
                }
            }

            for (int i = 53; i < 87; i++)
            {
                DicItemAttr good = goods[i];
                if (good.up_val > 10000)
                {
                    for (int j = 0; j < job_num; j++)
                    {
                        job_good_info[j][i] = 1;
                    }
                }
                else
                {
                    for (int j = 0; j < job_num; j++)
                    {
                        job_good_info[j][i] = 0;
                    }
                    //TODO upgrade_value out of range
                    //occupation_good_info[good.upgrade_value * 3][i] = 1;
                    //occupation_good_info[good.upgrade_value * 3 + 1][i] = 1;
                    //occupation_good_info[good.upgrade_value * 3 + 2][i] = 1;
                }
                good.up_val = 0;
            }

            for (int i = 87; i < 104; i++)
            {
                for (int j = 0; j < job_num; j++)
                {
                    job_good_info[j][i] = 1;
                }
            }

            skill_num      = item.e5_skill_num;
            skills         = new DicSkillAttr[skill_num];
            job_skill_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_skill_info[i] = new byte[skill_num];
            }
            for (int i = 0; i < skill_num; i++)
            {
                mr.setIndex(item.e5_skill_attr_offset + item.e5_skill_attr_size * i);
                skills[i]      = new DicSkillAttr();
                skills[i].skid = (ushort)i;
                skills[i].parseE5(mr);

                for (int j = 0; j < job_num; j++)
                {
                    job_skill_info[j][i] = mr.readByte();
                }
            }

            mr.setIndex(0x4bb4);
            for (int i = 0; i < shop_info.Length; i++)
            {
                shop_info[i] = new ShopAttr();
                shop_info[i].parseE5(mr);
            }

            gk_num = item.e5_gk_num;
            gks    = new DicGkAttr[gk_num];
            mr.setIndex(item.e5_gk_attr_offset);
            for (int i = 0; i < gks.Length; i++)
            {
                gks[i]      = new DicGkAttr();
                gks[i].gkid = (ushort)i;
                gks[i].parseE5(mr);
            }

            return(true);
        }
コード例 #20
0
ファイル: Mob.cs プロジェクト: crazypoultry/Stab_Face
 public UInt64 getTargetGUID()
 {
     return(MemoryReader.readUInt64(Stab_Face.WoW_Process.WoW_Instance.getProcess().Handle, this.objBase + MobOffsets.TARGET_GUID));
 }
コード例 #21
0
ファイル: Experience.cs プロジェクト: 5l1v3r1/MemoryScanner
 public Experience(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
コード例 #22
0
 public RdaHeader(ref MemoryReader reader)
 {
     Magic                  = reader.ReadString(Encoding.UTF8, StringPattern.FixCharCount, 18);// .ReadStringRaw(18);
     Unknown                = reader.Memory[..766];
コード例 #23
0
ファイル: Mob.cs プロジェクト: crazypoultry/Stab_Face
 public UInt32 getName()
 {
     return(MemoryReader.readUInt32(Stab_Face.WoW_Process.WoW_Instance.getProcess().Handle, this.objBase + MobOffsets.NAME));
 }
コード例 #24
0
        public void Init(StreamReader.IReader fileReader, UInt64 offset, ref VGM_Stream vgmStream, bool InitReader, UInt64 fileLength)
        {
            byte[] mibBuffer   = new byte[0x10];
            byte[] testBuffer  = new byte[0x10];
            byte[] testBuffer2 = new byte[0x10];
            byte[] testBuffer3 = new byte[0x10];

            //bool doChannelUpdate=true;
            //bool bDoUpdateInterleave=true;

            UInt64 loopStart  = 0;
            UInt64 loopEnd    = 0;
            UInt64 interleave = 0;
            UInt64 readOffset = offset;

            UInt64[] loopStartPoints      = new UInt64[0x10];
            int      loopStartPointsCount = 0;

            UInt64[] loopEndPoints      = new UInt64[0x10];
            int      loopEndPointsCount = 0;

            byte[] emptyLine        = new byte[0x10];
            bool   loopToEnd        = false;
            bool   forceNoLoop      = false;
            bool   bolSaveEmptyLine = true;

            int    i, channel_count = 0;
            bool   interleave_found = false;
            UInt64 tstCount         = 0;

            UInt64[] emptyLineOffset      = new UInt64[100];
            uint     emptyLineCount       = 0;
            uint     max_interleave       = 0;
            uint     max_interleave_index = 0;

            // Initialize loop point to 0
            for (i = 0; i < 0x10; i++)
            {
                loopStartPoints[i] = 0;
                loopEndPoints[i]   = 0;
                testBuffer[i]      = 0;
                emptyLine[i]       = 0;
            }

            //if (this.Filename.ToUpper().Contains(".MIB"))

            /* Search for interleave value & loop points */
            /* Get the first 16 values */
            mibBuffer = fileReader.Read(offset, 0x10);
            if (MemoryReader.memcmp(mibBuffer, emptyLine, 0x10, 0))
            {
                tstCount = 0x10;
                //readOffset += 0x10;
            }
            else
            {
                tstCount = 0x0e;
            }

            do
            {
                testBuffer = fileReader.Read(readOffset, 0x10);

                // be sure to point to an interleave value
                if (!interleave_found)
                {
                    if (MemoryReader.memcmp(testBuffer, emptyLine, tstCount, 0x10 - tstCount))
                    {
                        // don't need to stock all empty lines :P
                        if (emptyLineCount >= 100)
                        {
                            emptyLineCount = 0;
                        }

                        if (emptyLineCount >= 1)
                        {
                            if ((readOffset - offset) > 0x60000)
                            {
                                bolSaveEmptyLine = false;
                            }
                        }

                        if (bolSaveEmptyLine)
                        {
                            emptyLineOffset[emptyLineCount] = readOffset;
                            emptyLineCount++;
                        }
                    }
                }

                // Loop Start ...
                if (testBuffer[0x01] == 0x06)
                {
                    if (loopStartPointsCount < 0x10)
                    {
                        loopStartPoints[loopStartPointsCount] = readOffset - offset - 0x10;
                        loopStartPointsCount++;
                    }
                }

                // Loop End ...
                if (((testBuffer[0x01] == 0x03) && (testBuffer[0x03] != 0x77)) ||
                    (testBuffer[0x01] == 0x01))
                {
                    if (loopEndPointsCount < 0x10)
                    {
                        loopEndPoints[loopEndPointsCount] = readOffset - offset;                 //-0x10;
                        loopEndPointsCount++;
                    }

                    if (testBuffer[0x01] == 0x01)
                    {
                        forceNoLoop = true;
                    }
                }

                if (testBuffer[0x01] == 0x04)
                {
                    // 0x04 loop points flag can't be with a 0x03 loop points flag
                    if (loopStartPointsCount < 0x10)
                    {
                        if ((readOffset - offset) == 0)
                        {
                            loopStartPoints[loopStartPointsCount] = 0;
                        }
                        else
                        {
                            loopStartPoints[loopStartPointsCount] = readOffset - offset;
                        }

                        loopStartPointsCount++;

                        // Loop end value is not set by flags ...
                        // go until end of file
                        loopToEnd = true;
                    }
                }
                readOffset += 0x10;
            } while (readOffset < (offset + fileLength));

            // Try to find biggest interleave value
            if (emptyLineCount > 1)
            {
                for (uint count = 1; count < emptyLineCount; count++)
                {
                    if (((uint)(emptyLineOffset[count] - emptyLineOffset[count - 1])) > max_interleave)
                    {
                        max_interleave       = (uint)(emptyLineOffset[count] - emptyLineOffset[count - 1]);
                        max_interleave_index = count;
                    }
                }
                if (max_interleave_index != 0)
                {
                    interleave = (uint)(emptyLineOffset[max_interleave_index] - emptyLineOffset[0]);
                }
            }

            if ((testBuffer[0] == 0x0c) && (testBuffer[1] == 0))
            {
                forceNoLoop = true;
            }

            if (channel_count == 0)
            {
                channel_count = 1;
            }

            // Calc Loop Points & Interleave ...
            if (loopStartPointsCount >= channel_count)
            {
                // can't get more then 0x10 loop point !
                // and need at least 2 loop points
                if ((loopStartPointsCount <= 0x0F) && (loopStartPointsCount >= 2))
                {
                    // Always took the first 2 loop points
                    interleave = loopStartPoints[loopStartPointsCount - 1] - loopStartPoints[loopStartPointsCount - 2];
                    loopStart  = loopStartPoints[1];

                    // Can't be one channel .mib with interleave values
                    if ((interleave > 0) && (channel_count == 1))
                    {
                        channel_count = 2;
                    }
                }
                else
                {
                    loopStart = 0;
                }
            }

            if (loopEndPointsCount >= channel_count)
            {
                // can't get more then 0x10 loop point !
                // and need at least 2 loop points
                if ((loopEndPointsCount <= 0x0F) && (loopEndPointsCount >= 2))
                {
                    if (loopEndPointsCount == 4)
                    {
                        if (interleave == 0)
                        {
                            interleave = loopEndPoints[3] - loopEndPoints[1];
                        }
                        else
                        {
                            interleave = loopEndPoints[loopEndPointsCount - 1] - loopEndPoints[loopEndPointsCount - 2];
                        }
                    }
                    loopEnd = loopEndPoints[loopEndPointsCount - 1];

                    if (interleave >= 0x10)
                    {
                        if (channel_count == 1)
                        {
                            channel_count = 2;
                        }
                    }
                }
                else
                {
                    loopToEnd = false;
                    loopEnd   = 0;
                }
            }

            if (loopToEnd)
            {
                loopEnd = fileLength;
            }

            // force no loop
            if (forceNoLoop)
            {
                loopEnd = 0;
            }

            if ((interleave > 0x10) && (channel_count == 1))
            {
                channel_count = 2;
            }

            if (interleave <= 0)
            {
                interleave = 0x10;
            }

            /* build the VGMSTREAM */
            VGM_Utils.allocate_vgmStream(ref vgmStream, channel_count, (loopEnd != 0));

            /* fill in the vital statistics */
            vgmStream.vgmDecoder = new PSX_Decoder();

            if (channel_count == 1)
            {
                vgmStream.vgmLayout = new NoLayout();
            }
            else
            {
                vgmStream.vgmLayout = new Interleave();
            }

            vgmStream.vgmChannelCount        = channel_count;
            vgmStream.vgmInterleaveBlockSize = (int)interleave;
            vgmStream.vgmLoopFlag            = (loopEnd != 0);

            if (m_Description == null)
            {
                vgmStream.vgmSampleRate = 44100;
            }
            else
            {
                if (System.IO.Path.GetExtension(m_Description).ToUpper() == ".MIB")
                {
                    vgmStream.vgmSampleRate = 44100;
                }
            }

            vgmStream.vgmTotalSamples = (int)(fileLength / (UInt64)16 / (UInt64)(channel_count * 28));

            if (loopEnd != 0)
            {
                if (vgmStream.vgmChannelCount == 1)
                {
                    vgmStream.vgmLoopStartSample = (int)loopStart / 16 * 18;
                    vgmStream.vgmLoopEndSample   = (int)loopEnd / 16 * 28;
                }
                else
                {
                    if (loopStart == 0)
                    {
                        vgmStream.vgmLoopStartSample = 0;
                    }
                    else
                    {
                        vgmStream.vgmLoopStartSample = (int)(((UInt64)(((loopStart / interleave) - 1) * interleave)) / (UInt64)((16 * 14 * channel_count) / channel_count));

                        if (loopStart % interleave != 0)
                        {
                            vgmStream.vgmLoopStartSample += (int)(((UInt64)((loopStart % interleave) - 1) / (UInt64)(16 * 14 * channel_count)));
                        }
                    }

                    if (loopEnd == fileLength)
                    {
                        vgmStream.vgmLoopEndSample = (int)((UInt64)loopEnd / (UInt64)((16 * 28) / channel_count));
                    }
                    else
                    {
                        vgmStream.vgmLoopEndSample = (int)((UInt64)(((loopEnd / interleave) - 1) * interleave) / (UInt64)((16 * 14 * channel_count) / channel_count));

                        if (loopEnd % interleave != 0)
                        {
                            vgmStream.vgmLoopEndSample += (int)((UInt64)((loopEnd % interleave) - 1) / (UInt64)(16 * 14 * channel_count));
                        }
                    }
                }
            }
            if (InitReader)
            {
                for (i = 0; i < channel_count; i++)
                {
                    vgmStream.vgmChannel[i].currentOffset = offset + (interleave * (UInt64)i);
                    vgmStream.vgmChannel[i].fReader       = (StreamReader.IReader)Activator.CreateInstance(fileReader.GetType());
                    vgmStream.vgmChannel[i].fReader.Open(fileReader.GetFilename());
                    vgmStream.vgmChannel[i].fReader.SetSessionID(fileReader.GetSessionID());
                }
            }
        }
コード例 #25
0
ファイル: UnrealNetwork.cs プロジェクト: athakral/ChartsNite
 public virtual bool ParseExportData(MemoryReader reader)
 {
     return(ParseNetFieldExports(reader) &&
            ParseNetExportGUIDs(reader));
 }
コード例 #26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private IExecutable analyse(CompilerContext context, int startAddress, bool recursive, int instanceIndex) throws ClassFormatError
        private IExecutable analyse(CompilerContext context, int startAddress, bool recursive, int instanceIndex)
        {
            if (log.TraceEnabled)
            {
                log.trace(string.Format("Compiler.analyse Block 0x{0:X8}", startAddress));
            }
            int            maxBranchInstructions = int.MaxValue;  // 5 for FRONTIER_1337 homebrew
            MemorySections memorySections        = MemorySections.Instance;
            CodeBlock      codeBlock             = new CodeBlock(startAddress, instanceIndex);
            Stack <int>    pendingBlockAddresses = new Stack <int>();

            pendingBlockAddresses.Clear();
            pendingBlockAddresses.Push(startAddress);
            ISet <int> branchingToAddresses = new HashSet <int>();

            while (pendingBlockAddresses.Count > 0)
            {
                int pc = pendingBlockAddresses.Pop();
                if (!isAddressGood(pc))
                {
                    if (IgnoreInvalidMemory)
                    {
                        Console.WriteLine(string.Format("IGNORING: Trying to compile an invalid address 0x{0:X8} while compiling from 0x{1:X8}", pc, startAddress));
                    }
                    else
                    {
                        Console.WriteLine(string.Format("Trying to compile an invalid address 0x{0:X8} while compiling from 0x{1:X8}", pc, startAddress));
                    }
                    return(null);
                }
                bool isBranchTarget = true;
                int  endPc          = MemoryMap.END_RAM;

                // Handle branching to a delayed instruction.
                // The delayed instruction has already been analysed, but the next
                // address maybe not.
                if (context.analysedAddresses.Contains(pc) && !context.analysedAddresses.Contains(pc + 4))
                {
                    pc += 4;
                }

                if (context.analysedAddresses.Contains(pc) && isBranchTarget)
                {
                    codeBlock.IsBranchTarget = pc;
                }
                else
                {
                    IMemoryReader memoryReader = MemoryReader.getMemoryReader(pc, 4);
                    while (!context.analysedAddresses.Contains(pc) && pc <= endPc)
                    {
                        int opcode = memoryReader.readNext();

                        Common.Instruction insn = Decoder.instruction(opcode);

                        context.analysedAddresses.Add(pc);
                        int npc = pc + 4;

                        int  branchingTo           = 0;
                        bool isBranching           = false;
                        bool checkDynamicBranching = false;
                        if (insn.hasFlags(Common.Instruction.FLAG_IS_BRANCHING))
                        {
                            branchingTo = branchTarget(npc, opcode);
                            isBranching = true;
                        }
                        else if (insn.hasFlags(Common.Instruction.FLAG_IS_JUMPING))
                        {
                            branchingTo           = jumpTarget(npc, opcode);
                            isBranching           = true;
                            checkDynamicBranching = true;
                        }

                        if (isEndBlockInsn(pc, opcode, insn))
                        {
                            endPc = npc;
                        }
                        else if (pc < endPc && insn.hasFlags(Common.Instruction.FLAG_SYSCALL))
                        {
                            endPc = pc;
                        }

                        if (insn.hasFlags(Common.Instruction.FLAG_STARTS_NEW_BLOCK))
                        {
                            if (recursive)
                            {
                                context.blocksToBeAnalysed.Push(branchingTo);
                            }
                        }
                        else if (isBranching)
                        {
                            if (branchingTo != 0)
                            {                             // Ignore "J 0x00000000" instruction
                                bool analyseBranch = true;
                                if (maxBranchInstructions < 0)
                                {
                                    analyseBranch = false;
                                }
                                else
                                {
                                    maxBranchInstructions--;

                                    // Analyse only the jump instructions that are jumping to
                                    // non-writable memory sections. A jump to a writable memory
                                    // section has to be interpreted at runtime to check if the
                                    // reached code has not been changed (i.e. invalidated).
                                    if (checkDynamicBranching && memorySections.canWrite(branchingTo, false))
                                    {
                                        analyseBranch = false;
                                    }
                                }

                                if (analyseBranch)
                                {
                                    pendingBlockAddresses.Push(branchingTo);
                                }
                                else
                                {
                                    branchingToAddresses.Add(branchingTo);
                                }
                            }
                        }

                        bool useMMIO = useMMIOAddresses.Contains(pc & Memory.addressMask);

                        codeBlock.addInstruction(pc, opcode, insn, isBranchTarget, isBranching, branchingTo, useMMIO);
                        pc = npc;

                        isBranchTarget = false;
                    }
                }

                foreach (int branchingTo in branchingToAddresses)
                {
                    codeBlock.IsBranchTarget = branchingTo;
                }
            }

            codeBlock.addCodeBlock();

            IExecutable executable;

            if (RuntimeContext.CompilerEnabled || codeBlock.hasFlags(FLAG_SYSCALL))
            {
                executable = codeBlock.getExecutable(context);
            }
            else
            {
                executable = null;
            }
            if (log.TraceEnabled)
            {
                log.trace("Executable: " + executable);
            }

            return(executable);
        }
コード例 #27
0
        private void DebuggerService_MachineCreated(object sender, MachineCreatedEventArgs e)
        {
            var reader = new MemoryReader(storyService.Story.Memory, 0);

            DisassemblyLineViewModel ipLine;

            lines.BeginBulkOperation();
            try
            {
                var routineTable = routineService.RoutineTable;

                for (int rIndex = 0; rIndex < routineTable.Count; rIndex++)
                {
                    var routine = routineTable[rIndex];

                    if (rIndex > 0)
                    {
                        var lastRoutine = routineTable[rIndex - 1];
                        if (lastRoutine.Address + lastRoutine.Length < routine.Address)
                        {
                            var addressGapLine = new DisassemblyAddressGapLineViewModel(lastRoutine, routine)
                            {
                                ShowBlankBefore = true
                            };

                            lines.Add(addressGapLine);
                        }
                    }

                    var routineHeaderLine = new DisassemblyRoutineHeaderLineViewModel(routine)
                    {
                        ShowBlankBefore = rIndex > 0,
                        ShowBlankAfter  = true
                    };

                    routineAddressAndIndexList.Add(new AddressAndIndex(routineHeaderLine.Address, lines.Count));
                    lines.Add(routineHeaderLine);
                    addressToLineMap.Add(routine.Address, routineHeaderLine);

                    var instructions = routine.Instructions;
                    var lastIndex    = instructions.Length - 1;
                    for (int i = 0; i <= lastIndex; i++)
                    {
                        var instruction     = instructions[i];
                        var instructionLine = new DisassemblyInstructionLineViewModel(instruction, i == lastIndex);

                        if (breakpointService.Exists(instruction.Address))
                        {
                            instructionLine.HasBreakpoint = true;
                        }

                        lines.Add(instructionLine);
                        addressToLineMap.Add(instruction.Address, instructionLine);
                    }
                }

                ipLine       = GetLineByAddress(debuggerService.Machine.PC);
                ipLine.HasIP = true;
            }
            finally
            {
                lines.EndBulkOperation();
            }

            BringLineIntoView(ipLine);

            routineService.RoutineTable.RoutineAdded += RoutineTable_RoutineAdded;
        }
コード例 #28
0
 public BundleRecord(ref MemoryReader reader)
 {
     Name             = reader.ReadString(reader.ReadInt32()) + ".bundle.bin";
     UncompressedSize = reader.ReadInt32();
 }
コード例 #29
0
 public StatusBarTime(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #30
0
ファイル: MemoryVision.cs プロジェクト: nlhans/MemoryVision
        private void bt_load_table_Click(object sender, System.EventArgs e)
        {
            if (_mMemory != null)
            {
                _mMemory.CloseHandle();
            }
            string file = "Test.CT";

            _mMemoryList = new CheatEngineReader();
            _mMemoryList.Read(file);

            lbl_table.Text = "Table:" + file;

            // Update UI.
            _mTable.Items.Clear();

            // Search for the exe
            Process[] p = Process.GetProcessesByName(_mMemoryList.ProcessExe.Substring(0, _mMemoryList.ProcessExe.Length - 4));
            if (p.Length == 1)
            {
                _mProcess = p[0];
                _mMemory = new MemoryReader();
                _mMemory.ReadProcess = p[0];
                _mMemory.OpenProcess();

                lbl_exe.Text = "PID:" + p[0].Id + "\r\n[" + p[0].ProcessName + "]";
            }
            else if (p.Length == 0)
            {
                lbl_exe.Text = "Failed";
                MessageBox.Show("Please load only if the process is already running.");
                // TODO: Wait for process.
                return;
            }
            else
            {
                lbl_exe.Text = "Failed";
                MessageBox.Show("Found multiple exe's running! Cannot figure out what to-do.");
                //TODO: Add dialog.
                return;
            }

            IntPtr base_addr = p[0].MainModule.BaseAddress;

            for (int i = 0; i < _mMemoryList.Channels.Count; i++)
            {
                _mMemoryList.Channels[i].UI_ID = i;
                _mMemoryList.Channels[i].Address = new IntPtr(_mMemoryList.Channels[i].Address.ToInt32() + base_addr.ToInt32());
                MemoryChannel ch = _mMemoryList.Channels[i];
                _mTable.Items.Add(new ListViewItem(new string[5]
                                                       {
                                                           ch.ID.ToString(),
                                                           ch.Name,
                                                           "0x"+String.Format("{0,10:X}", ch.Address.ToInt32()),
                                                           ch.TypeToString(),
                                                           "0.000"
                                                       }));
            }

            _mGrabber = new Grabber(_mMemoryList, _mMemory);
            _mGrabber.Done += new Signal(_mGrabber_Done);
        }
コード例 #31
0
 public Status(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
コード例 #32
0
 public OutGoingPacketLen(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #33
0
        public bool parseLM(MemoryReader mr)
        {
            hero_num = mr.readInt32();
            heros    = new DicHeroAttr[hero_num];
            for (int i = 0; i < hero_num; i++)
            {
                heros[i] = new DicHeroAttr();
                heros[i].parseLM(mr);
            }

            job_num = mr.readInt32();
            jobs    = new DicJobAttr[job_num];
            for (int i = 0; i < job_num; i++)
            {
                jobs[i] = new DicJobAttr();
                jobs[i].parseLM(mr);
            }

            good_num = mr.readInt32();
            goods    = new DicItemAttr[good_num];
            for (int i = 0; i < good_num; i++)
            {
                goods[i] = new DicItemAttr();
                goods[i].parseLM(mr);
            }

            skill_num = mr.readInt32();
            skills    = new DicSkillAttr[skill_num];
            for (int i = 0; i < skill_num; i++)
            {
                skills[i] = new DicSkillAttr();
                skills[i].parseLM(mr);
            }

            land_num = mr.readInt32();
            lands    = new LandformAttr[land_num];
            for (int i = 0; i < land_num; i++)
            {
                lands[i] = new LandformAttr();
                lands[i].parseLM(mr);
            }

            goodtype_num = mr.readInt32();
            goodtypes    = new GoodTypeAttr[goodtype_num];
            for (int i = 0; i < goodtype_num; i++)
            {
                goodtypes[i] = new GoodTypeAttr();
                goodtypes[i].parseLM(mr);
            }

            job_skill_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_skill_info[i] = new byte[skill_num];
                mr.readBytes(job_skill_info[i]);
            }

            job_terrain_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_terrain_info[i] = new byte[land_num];
                mr.readBytes(job_terrain_info[i]);
            }

            job_walk_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_walk_info[i] = new byte[land_num];
                mr.readBytes(job_walk_info[i]);
            }

            job_good_info = new byte[job_num][];
            for (int i = 0; i < job_num; i++)
            {
                job_good_info[i] = new byte[good_num];
                mr.readBytes(job_good_info[i]);
            }

            for (int i = 0; i < shop_info.Length; i++)
            {
                shop_info[i] = new ShopAttr();
                shop_info[i].parseLM(mr);
            }

            for (int i = 0; i < skill_land_info.Length; i++)
            {
                skill_land_info[i] = new byte[land_num];
            }

            //
            skill_land_info[0][0]  = 1;
            skill_land_info[0][1]  = 1;
            skill_land_info[0][2]  = 1;
            skill_land_info[0][8]  = 1;
            skill_land_info[0][16] = 1;
            skill_land_info[0][18] = 1;
            skill_land_info[0][19] = 1;
            skill_land_info[0][20] = 1;
            skill_land_info[0][21] = 1;
            skill_land_info[0][22] = 1;
            skill_land_info[0][23] = 1;
            skill_land_info[0][24] = 1;
            skill_land_info[0][25] = 1;
            //
            skill_land_info[1][7]  = 1;
            skill_land_info[1][8]  = 1;
            skill_land_info[1][9]  = 1;
            skill_land_info[1][10] = 1;
            skill_land_info[1][11] = 1;
            skill_land_info[1][12] = 1;
            skill_land_info[1][13] = 1;
            //
            skill_land_info[2][3] = 1;
            skill_land_info[2][4] = 1;
            skill_land_info[2][5] = 1;
            skill_land_info[2][6] = 1;
            //
            skill_land_info[3][0]  = 1;
            skill_land_info[3][1]  = 1;
            skill_land_info[3][2]  = 1;
            skill_land_info[3][3]  = 1;
            skill_land_info[3][4]  = 1;
            skill_land_info[3][5]  = 1;
            skill_land_info[3][6]  = 1;
            skill_land_info[3][7]  = 1;
            skill_land_info[3][8]  = 1;
            skill_land_info[3][9]  = 1;
            skill_land_info[3][10] = 1;
            skill_land_info[3][11] = 1;
            skill_land_info[3][12] = 1;
            skill_land_info[3][13] = 1;

            return(true);
        }
コード例 #34
0
 public SendPointer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #35
0
   internal CustomAttributeDecoder(PEFileToObjectModel peFileToObjectModel, MemoryReader signatureMemoryReader, uint customAttributeRowId,
 IMethodReference attributeConstructor)
       : base(peFileToObjectModel, signatureMemoryReader)
   {
       this.CustomAttribute = Dummy.CustomAttribute;
         ushort prolog = this.SignatureMemoryReader.ReadUInt16();
         if (prolog != SerializationType.CustomAttributeStart) return;
         int len = attributeConstructor.ParameterCount;
         ExpressionBase[]/*?*/ exprList = len == 0 ? null : new ExpressionBase[len];
         int i = 0;
         foreach (var parameter in attributeConstructor.Parameters) {
       var parameterType = parameter.Type;
       if (parameterType == Dummy.TypeReference) {
         //  Error...
         return;
       }
       ExpressionBase/*?*/ argument = this.ReadSerializedValue(parameterType);
       if (argument == null) {
         //  Error...
         this.decodeFailed = true;
         return;
       }
       exprList[i++] = argument;
         }
         ushort numOfNamedArgs = this.SignatureMemoryReader.ReadUInt16();
         FieldOrPropertyNamedArgumentExpression[]/*?*/ namedArgumentArray = null;
         if (numOfNamedArgs > 0) {
       namedArgumentArray = new FieldOrPropertyNamedArgumentExpression[numOfNamedArgs];
       for (i = 0; i < numOfNamedArgs; ++i) {
         bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field;
         ITypeReference/*?*/ memberType = this.GetFieldOrPropType();
         if (memberType == null) {
       //  Error...
       return;
         }
         string/*?*/ memberStr = this.GetSerializedString();
         if (memberStr == null)
       return;
         IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr);
         ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType);
         if (value == null) {
       //  Error...
       return;
         }
         ITypeReference/*?*/ moduleTypeRef = attributeConstructor.ContainingType;
         if (moduleTypeRef == null) {
       //  Error...
       return;
         }
         FieldOrPropertyNamedArgumentExpression namedArg = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeRef, isField, memberType, value);
         namedArgumentArray[i] = namedArg;
       }
         }
         EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments = TypeCache.EmptyExpressionList;
         if (exprList != null)
       arguments = new EnumerableArrayWrapper<ExpressionBase, IMetadataExpression>(exprList, Dummy.Expression);
         EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments = TypeCache.EmptyNamedArgumentList;
         if (namedArgumentArray != null)
       namedArguments = new EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument>(namedArgumentArray, Dummy.NamedArgument);
         this.CustomAttribute = peFileToObjectModel.ModuleReader.metadataReaderHost.Rewrite(peFileToObjectModel.Module,
       new CustomAttribute(peFileToObjectModel, customAttributeRowId, attributeConstructor, arguments, namedArguments));
   }
コード例 #36
0
        public virtual bool checkSimpleInterpretedCodeBlock(CodeBlock codeBlock)
        {
            bool isSimple  = true;
            int  insnCount = 0;

            Common.Instruction[] insns = new Common.Instruction[100];
            int[] opcodes    = new int[100];
            int   opcodeJrRa = AllegrexOpcodes.JR | (Common._ra << 21);           // jr $ra

            IMemoryReader memoryReader   = MemoryReader.getMemoryReader(codeBlock.StartAddress, 4);
            int           notSimpleFlags = FLAG_IS_BRANCHING | FLAG_IS_JUMPING | FLAG_STARTS_NEW_BLOCK | FLAG_ENDS_BLOCK;

            while (true)
            {
                if (insnCount >= insns.Length)
                {
                    // Extend insns array
                    Common.Instruction[] newInsns = new Common.Instruction[insnCount + 100];
                    Array.Copy(insns, 0, newInsns, 0, insnCount);
                    insns = newInsns;
                    // Extend opcodes array
                    int[] newOpcodes = new int[newInsns.Length];
                    Array.Copy(opcodes, 0, newOpcodes, 0, insnCount);
                    opcodes = newOpcodes;
                }

                int opcode = memoryReader.readNext();

                if (opcode == opcodeJrRa)
                {
                    int delaySlotOpcode = memoryReader.readNext();
                    Common.Instruction delaySlotInsn = Decoder.instruction(delaySlotOpcode);
                    insns[insnCount]   = delaySlotInsn;
                    opcodes[insnCount] = delaySlotOpcode;
                    insnCount++;
                    break;
                }

                Common.Instruction insn = Decoder.instruction(opcode);
                if ((insn.Flags & notSimpleFlags) != 0)
                {
                    isSimple = false;
                    break;
                }

                insns[insnCount]   = insn;
                opcodes[insnCount] = opcode;
                insnCount++;
            }

            if (isSimple)
            {
                if (insnCount < insns.Length)
                {
                    // Compact insns array
                    Common.Instruction[] newInsns = new Common.Instruction[insnCount];
                    Array.Copy(insns, 0, newInsns, 0, insnCount);
                    insns = newInsns;
                    // Compact opcodes array
                    int[] newOpcodes = new int[insnCount];
                    Array.Copy(opcodes, 0, newOpcodes, 0, insnCount);
                    opcodes = newOpcodes;
                }
                codeBlock.InterpretedInstructions = insns;
                codeBlock.InterpretedOpcodes      = opcodes;
            }
            else
            {
                codeBlock.InterpretedInstructions = null;
                codeBlock.InterpretedOpcodes      = null;
            }

            return(isSimple);
        }
コード例 #37
0
 public OutgoingBuffer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #38
0
        public FST IsContainer(StreamReader.IReader fileReader, FST.cFile file, int index)
        {
            if (System.IO.Path.GetExtension(file.Filename).ToUpper() != ".IPK")
            {
                return(null);
            }

            FST tmpFST = new FST();

            UInt64 offset = file.FileStartOffset;

            // check for 0x50EC12BA marker
            if (fileReader.Read_32bitsBE(offset) != 0x50EC12BA)
            {
                return(null);
            }

            //string archiveName = fileReader.Read_String(offset + 0x08, 0x50);
            uint fileCount  = (uint)fileReader.Read_32bitsBE(offset + 0x10);
            uint bufferSize = (uint)fileReader.Read_32bitsBE(offset + 0x0C) - 0x30;

            byte[] buffer = fileReader.Read(offset + 0x30, bufferSize);

            uint   buf_offset = 0;
            uint   nameSize   = 0;
            uint   folderSize = 0;
            UInt64 fileOffset = bufferSize + 0x30;

            for (uint i = 0; i < fileCount; i++)
            {
                uint var_temp = MemoryReader.ReadLongBE(ref buffer, buf_offset);
                buf_offset += 4;
                uint fileSizeUncompressed = MemoryReader.ReadLongBE(ref buffer, buf_offset);
                buf_offset += 4;
                uint fileSizeCompressed = MemoryReader.ReadLongBE(ref buffer, buf_offset);
                buf_offset += 4 + 8;
                UInt64 trueFileOffset = MemoryReader.ReadLongLongBE(ref buffer, buf_offset) + fileOffset;
                buf_offset += 8;

                if (var_temp == 2)
                {
                    buf_offset += 8;
                }

                nameSize    = MemoryReader.ReadLongBE(ref buffer, buf_offset);
                buf_offset += 4;
                string filename = string.Empty;
                filename    = MemoryReader.GetString(ref buffer, buf_offset, nameSize);
                buf_offset += nameSize;
                folderSize  = MemoryReader.ReadLongBE(ref buffer, buf_offset);
                buf_offset += 4;
                filename    = MemoryReader.GetString(ref buffer, buf_offset, folderSize) + filename;
                filename    = filename.Replace("/", "\\");
                if (fileSizeCompressed == 0)
                {
                    fileSizeCompressed = fileSizeUncompressed;
                }
                uint fileSize = fileSizeCompressed;
                buf_offset += folderSize + 8;
                tmpFST.FST_File.Add(new FST.cFile(file.SessionID, (uint)index, 0, filename, file.FileOwner, file.FilePath, offset + trueFileOffset, fileSize, tmpFST.EmptyDateTime, false));
            }

            return(tmpFST);
        }
コード例 #39
0
        public static void GiveAllGrids()
        {
            var allGridBytes = new byte[8].Select(gb => gb = (byte)0xFF).ToArray();

            MemoryReader.WriteBytes((int)OffsetType.KnownGarmentGrids, allGridBytes);
        }
コード例 #40
0
 public ChunkArchive(Memory <byte> memory, DemoHeader demoHeader, ReplayHeader replayHeader) : base(demoHeader, replayHeader)
 {
     _reader = new MemoryReader(memory, Endianness.Little);
 }
コード例 #41
0
        private void ProcessCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                Window.Title = ((TibiaProc)processCombo.SelectedItem).WindowTitle.Replace("Tibia", "Bot");
                MemoryReader.Initialize();
                MemoryReader.OpenProcess(((TibiaProc)processCombo.SelectedItem).Process);
            }
            catch (Exception ex)
            {
//                var alert = new Alarm();
//                alert.IsEnabled = true;
//                alert.Play();
//
//                MessageBoxResult result = MessageBox.Show($"{ex}", "Something happened", MessageBoxButton.OK, MessageBoxImage.Exclamation);
//                if (result == MessageBoxResult.OK)
//                {
//                    alert.Stop();
//                    alert.IsEnabled = false;
//                }
                Console.WriteLine(ex);
                //throw;
            }

            try
            {
                var settings = SettingsManager.Instance;
                settings.Deserialize($"{((TibiaProc)processCombo.SelectedItem).WindowTitle}.xml", ref settings);
                settings.ApplyCustomSettings();

                //var list = new List<HealControl>();
                HealControls = new List <HealControl>();
                icHeal.Children.Clear();
                foreach (var settingsHealerSetting in settings.HealerSettings)
                {
                    var heal = new HealControl();
                    heal.Healresfrom.Text = settingsHealerSetting.From;
                    heal.Healresto.Text   = settingsHealerSetting.To;
                    heal.Healreqmana.Text = settingsHealerSetting.RequiredMana;
                    //heal.IsPercent = settingsHealerSetting.IsPercent;
                    //heal.ResourceType = settingsHealerSetting.Type;
                    heal.Keysres.SelectedValue = settingsHealerSetting.Key;
                    heal.slValue.Value         = settingsHealerSetting.Priority;

                    if (settingsHealerSetting.IsPercent == true)
                    {
                        heal.ProcRadio.IsChecked = true;
                    }
                    else if (settingsHealerSetting.IsPercent == false)
                    {
                        heal.FlatRadio.IsChecked = true;
                    }

                    if (settingsHealerSetting.Type == Healer.ResourceType.Health)
                    {
                        heal.HealthRadio.IsChecked = true;
                    }
                    else if (settingsHealerSetting.Type == Healer.ResourceType.Mana)
                    {
                        heal.ManaRadio.IsChecked = true;
                    }



                    HealControls.Add(heal);
                    icHeal.Children.Add(heal);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                //throw;
            }
        }
コード例 #42
0
 protected override void DeserializeWithoutType(ref MemoryReader reader, int maxNestDepth)
 {
     Group = reader.ReadSerializable <ECPoint>();
 }
コード例 #43
0
 public CreatePacket(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #44
0
 public void Deserialize(ref MemoryReader reader)
 {
 }
コード例 #45
0
 public WalkFunction(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #46
0
 public void DeserializeUnsigned(ref MemoryReader reader)
 {
 }
コード例 #47
0
 public AddPacketByte(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #48
0
 public PacketListnerClient(MemoryReader _memread)
 {
     memRead     = _memread;
     TibiaHandle = _memread.Handle;
 }
コード例 #49
0
ファイル: Attributes.cs プロジェクト: harib/Afterthought
     //^ [NotDelayed]
     internal CustomAttributeDecoder(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader,
   uint customAttributeRowId,
   IModuleMethodReference attributeConstructor
 )
         : base(peFileToObjectModel, signatureMemoryReader)
     {
         //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary.
           this.CustomAttribute = Dummy.CustomAttribute;
           //^ base;
           ushort prolog = this.SignatureMemoryReader.ReadUInt16();
           if (prolog != SerializationType.CustomAttributeStart) {
         return;
           }
           List<ExpressionBase> exprList = new List<ExpressionBase>();
           IModuleParameterTypeInformation[] modParams = attributeConstructor.RequiredModuleParameterInfos.RawArray;
           int len = modParams.Length;
           for (int i = 0; i < len; ++i) {
         IModuleTypeReference/*?*/ moduleTypeRef = modParams[i].ModuleTypeReference;
         if (moduleTypeRef == null) {
           //  Error...
           return;
         }
         ExpressionBase/*?*/ argument = this.ReadSerializedValue(moduleTypeRef);
         if (argument == null) {
           //  Error...
           this.decodeFailed = true;
           return;
         }
         exprList.Add(argument);
           }
           ushort numOfNamedArgs = this.SignatureMemoryReader.ReadUInt16();
           FieldOrPropertyNamedArgumentExpression[]/*?*/ namedArgumentArray = null;
           if (numOfNamedArgs > 0) {
         namedArgumentArray = new FieldOrPropertyNamedArgumentExpression[numOfNamedArgs];
         for (ushort i = 0; i < numOfNamedArgs; ++i) {
           bool isField = this.SignatureMemoryReader.ReadByte() == SerializationType.Field;
           IModuleTypeReference/*?*/ memberType = this.GetFieldOrPropType();
           if (memberType == null) {
         //  Error...
         return;
           }
           string/*?*/ memberStr = this.GetSerializedString();
           if (memberStr == null)
         return;
           IName memberName = this.PEFileToObjectModel.NameTable.GetNameFor(memberStr);
           ExpressionBase/*?*/ value = this.ReadSerializedValue(memberType);
           if (value == null) {
         //  Error...
         return;
           }
           IModuleTypeReference/*?*/ moduleTypeRef = attributeConstructor.OwningTypeReference;
           if (moduleTypeRef == null) {
         //  Error...
         return;
           }
           FieldOrPropertyNamedArgumentExpression namedArg = new FieldOrPropertyNamedArgumentExpression(memberName, moduleTypeRef, isField, memberType, value);
           namedArgumentArray[i] = namedArg;
         }
           }
           EnumerableArrayWrapper<ExpressionBase, IMetadataExpression> arguments = TypeCache.EmptyExpressionList;
           if (exprList.Count > 0)
         arguments = new EnumerableArrayWrapper<ExpressionBase, IMetadataExpression>(exprList.ToArray(), Dummy.Expression);
           EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument> namedArguments = TypeCache.EmptyNamedArgumentList;
           if (namedArgumentArray != null)
         namedArguments = new EnumerableArrayWrapper<FieldOrPropertyNamedArgumentExpression, IMetadataNamedArgument>(namedArgumentArray, Dummy.NamedArgument);
           this.CustomAttribute = new CustomAttribute(this.PEFileToObjectModel, customAttributeRowId, attributeConstructor, arguments, namedArguments);
     }
コード例 #50
0
 public ContainerPointer(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type    = _type;
 }
コード例 #51
0
ファイル: Attributes.cs プロジェクト: harib/Afterthought
     //^ [NotDelayed]
     internal SecurityAttributeDecoder20(
   PEFileToObjectModel peFileToObjectModel,
   MemoryReader signatureMemoryReader,
   SecurityAttribute securityAttribute
 )
         : base(peFileToObjectModel, signatureMemoryReader)
     {
         //^ this.SignatureMemoryReader = signatureMemoryReader; //TODO: Spec# bug. This assignment should not be necessary.
           this.SecurityAttributes = TypeCache.EmptySecurityAttributes;
           //^ base;
           byte prolog = this.SignatureMemoryReader.ReadByte();
           if (prolog != SerializationType.SecurityAttribute20Start) {
         return;
           }
           int numberOfAttributes = this.SignatureMemoryReader.ReadCompressedUInt32();
           SecurityCustomAttribute[] securityCustomAttributes = new SecurityCustomAttribute[numberOfAttributes];
           for (int i = 0; i < numberOfAttributes; ++i) {
         SecurityCustomAttribute/*?*/ secAttr = this.ReadSecurityAttribute(securityAttribute);
         if (secAttr == null) {
           //  MDError...
           return;
         }
         securityCustomAttributes[i] = secAttr;
           }
           //^ NonNullType.AssertInitialized(securityCustomAttributes);
           this.SecurityAttributes = new EnumerableArrayWrapper<SecurityCustomAttribute, ICustomAttribute>(securityCustomAttributes, Dummy.CustomAttribute);
     }
コード例 #52
0
 public ReciveStream(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #53
0
 protected abstract Task ApplyEffectLocalAsync(MemoryReader memoryReader);
コード例 #54
0
 private void LoadSemiStaticData()
 {
     heroBeltAddr = MemoryReader.ReadIntPtr(EngineAddr + heroBeltOffset + heroBeltPointerOffset);
 }
コード例 #55
0
 public PrintText(MemoryReader _memread)
 {
     memRead = _memread;
     TibiaHandle = memRead.Handle;
 }
コード例 #56
0
 public MemoryResisdentInfo(ref MemoryReader reader)
 {
     CompressedSize   = reader.ReadUInt64();
     UncompressedSize = reader.ReadUInt64();
 }
コード例 #57
0
ファイル: ShopAttr.cs プロジェクト: qwe00921/game-1
 public override bool parseLM(MemoryReader mr)
 {
     mr.skip(MAX_SHOP_GOOD_NUM * 2 + 4);
     return(true);
 }
コード例 #58
0
        public IEnumerable <ClrObject> EnumerateObjects(Action <ulong, ulong, int, int, uint>?callback)
        {
            bool        large      = IsLargeObjectSegment;
            uint        minObjSize = (uint)IntPtr.Size * 3;
            ulong       obj        = FirstObjectAddress;
            IDataReader dataReader = _helpers.DataReader;

            // C# isn't smart enough to understand that !large means memoryReader is non-null.  We will just be
            // careful here.
            using MemoryReader memoryReader = (!large ? new MemoryReader(dataReader, 0x10000) : null) !;
            byte[] buffer = ArrayPool <byte> .Shared.Rent(IntPtr.Size * 2 + sizeof(uint));

            // The large object heap
            if (!large)
            {
                memoryReader.EnsureRangeInCache(obj);
            }

            while (obj < CommittedEnd)
            {
                ulong mt;
                if (large)
                {
                    if (!dataReader.Read(obj, buffer, out int read) || read != buffer.Length)
                    {
                        break;
                    }

                    if (IntPtr.Size == 4)
                    {
                        mt = Unsafe.As <byte, uint>(ref buffer[0]);
                    }
                    else
                    {
                        mt = Unsafe.As <byte, ulong>(ref buffer[0]);
                    }
                }
                else
                {
                    if (!memoryReader.ReadPtr(obj, out mt))
                    {
                        break;
                    }
                }

                ClrType?type = _helpers.Factory.GetOrCreateType(_clrmdHeap, mt, obj);
                if (type is null)
                {
                    callback?.Invoke(obj, mt, int.MinValue + 1, -1, 0);
                    break;
                }

                int marker = GetMarkerIndex(obj);
                if (marker != -1 && _markers[marker] == 0)
                {
                    _markers[marker] = obj;
                }

                ClrObject result = new ClrObject(obj, type);
                yield return(result);

                ulong size;
                if (type.ComponentSize == 0)
                {
                    size = (uint)type.StaticSize;
                    callback?.Invoke(obj, mt, type.StaticSize, -1, 0);
                }
                else
                {
                    uint count;
                    if (large)
                    {
                        count = Unsafe.As <byte, uint>(ref buffer[IntPtr.Size * 2]);
                    }
                    else
                    {
                        memoryReader.ReadDword(obj + (uint)IntPtr.Size, out count);
                    }

                    // Strings in v4+ contain a trailing null terminator not accounted for.
                    if (_clrmdHeap.StringType == type)
                    {
                        count++;
                    }

                    size = count * (ulong)type.ComponentSize + (ulong)type.StaticSize;
                    callback?.Invoke(obj, mt, type.StaticSize, type.ComponentSize, count);
                }

                size = ClrmdHeap.Align(size, large);
                if (size < minObjSize)
                {
                    size = minObjSize;
                }

                obj += size;
                obj  = _clrmdHeap.SkipAllocationContext(this, obj, mt, callback);
            }

            ArrayPool <byte> .Shared.Return(buffer);
        }
コード例 #59
0
ファイル: PlayerX.cs プロジェクト: YohanAugusto/MemoryScanner
 public PlayerX(MemoryReader _memRead, MemoryScanner _memScan, AddressType _type)
 {
     this.memRead = _memRead;
     this.memScan = _memScan;
     this.Type = _type;
 }
コード例 #60
0
 private static T Read <T>(this FlairPattern pattern, MemoryReader reader, int match, string name)
 {
     return(reader.Read <T>(pattern.AddressOfReference(name, match)));
 }