public Memory() { process = ProcessModel.GetProcessId("ffxiv_dx11"); //process = ProcessModel.GetProcessId("notepad"); processHandle = ProcessModel.OpenProcessHandle(process); MemoryLib.SetHandle(processHandle); SystemSearch(); ReadPlayerInfo(); string playerName = PlayerInfo.d.Name; byte[] data = System.Text.Encoding.ASCII.GetBytes(playerName); //ReadParty(); ReadPartyCount(); //SearchMem(); }
//private static IntPtr PartyCount { get; set; } public void ReadPartyCount() { IntPtr PartyCountAddress; PartyCountAddress = GetLocations("PARTYCOUNT"); PartyInfo.PartyCount = MemoryLib.GetByte(PartyCountAddress); }
public void ReadParty() { PartyMap = GetLocations("PARTY"); var source = MemoryLib.GetByteArray(PartyMap, 0x220); PartyInfo.ResolvePartyFromBytes(source); }
public void ReadPlayerInfo() { PlayerInfoMap = GetLocations("PLAYERINFO"); var source = MemoryLib.GetByteArray(PlayerInfoMap, 0x256); PlayerInfo.ResolvePlayerFromBytes(source); }
public static void ResolvePartyFromBytes(byte[] source) { var entry = new PartyDataStructure(); try { entry.X = BitConverter.ToSingle(source, 0x0); entry.Z = BitConverter.ToSingle(source, 0x4); entry.Y = BitConverter.ToSingle(source, 0x8); //entry.Coordinate = new Coordinate(entry.X, entry.Z, entry.Z); entry.ID = BitConverter.ToUInt32(source, 0x10); entry.Name = MemoryLib.GetStringFromBytes(source, 0x20); entry.Job = (Enumes.Job)source[0x61]; entry.Level = source[0x63]; entry.HPCurrent = BitConverter.ToInt32(source, 0x68); entry.HPMax = BitConverter.ToInt32(source, 0x6C); entry.MPCurrent = BitConverter.ToInt16(source, 0x70); entry.MPMax = BitConverter.ToInt16(source, 0x72); } catch (Exception e) { } d = entry; }
public static void ResolvePlayerFromBytes(byte[] source) { var entry = new PlaterInfoStructure(); try { entry.Name = MemoryLib.GetStringFromBytes(source, 1); entry.JobID = source[0x66]; //entry.Job = (Actor.Job)entry.JobID; #region Job Levels var step = 2; var i = 0x68 - step; var nowLv = source[i += step]; entry.PGL = source[i += step]; //格闘士■ entry.GLD = source[i += step]; //剣術士■ entry.MRD = source[i += step]; //斧術士●■ entry.ARC = source[i += step]; //弓術士 entry.LNC = source[i += step]; //槍術士■ entry.THM = source[i += step]; //呪術士 entry.CNJ = source[i += step]; //幻術士■ entry.CPT = source[i += step]; //木工士 entry.BSM = source[i += step]; //黒 entry.ARM = source[i += step]; entry.GSM = source[i += step]; entry.LTW = source[i += step]; entry.WVR = source[i += step]; entry.CUL = source[i += step]; entry.MIN = source[i += step]; //採掘 entry.BTN = source[i += step]; //園芸士 entry.ACN = source[i += step]; entry.FSH = source[i += step]; //漁師● entry.ALC = source[i += step]; //巴術● entry.ROG = source[i += step]; //双剣士● entry.MCH = source[i += step]; //機工■ entry.DRK = source[i += step]; //暗黒■ entry.AST = source[i += step]; //占■ #endregion #region Current Experience step = 4; i = 0x98 - step; entry.PGL_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.GLD_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.MRD_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.ARC_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.LNC_CurrentEXP = BitConverter.ToInt32(source, i += step);//■ entry.THM_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.CNJ_CurrentEXP = BitConverter.ToInt32(source, i += step);//■ entry.CPT_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.BSM_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.ARM_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.GSM_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.LTW_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.WVR_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.ALC_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.CUL_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.MIN_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.BTN_CurrentEXP = BitConverter.ToInt32(source, i += step);//■ entry.ACN_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.FSH_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.ROG_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.MCH_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.DRK_CurrentEXP = BitConverter.ToInt32(source, i += step); entry.AST_CurrentEXP = BitConverter.ToInt32(source, i += step); #endregion #region Base Stats step = 4; i = 0x100; entry.BaseStrength = BitConverter.ToInt16(source, i += step); entry.BaseDexterity = BitConverter.ToInt16(source, i += step); entry.BaseVitality = BitConverter.ToInt16(source, i += step); entry.BaseIntelligence = BitConverter.ToInt16(source, i += step); entry.BaseMind = BitConverter.ToInt16(source, i += step); entry.BasePiety = BitConverter.ToInt16(source, i += step); #endregion #region Base Stats (base+gear+bonus) step = 4; i = 0x11C; entry.Strength = BitConverter.ToInt16(source, i += step); entry.Dexterity = BitConverter.ToInt16(source, i += step); entry.Vitality = BitConverter.ToInt16(source, i += step); entry.Intelligence = BitConverter.ToInt16(source, i += step); entry.Mind = BitConverter.ToInt16(source, i += step); entry.Piety = BitConverter.ToInt16(source, i += step); #endregion #region Basic Info step = 4; i = 0x134; entry.HPMax = BitConverter.ToInt16(source, i += step); entry.MPMax = BitConverter.ToInt16(source, i += step); entry.TPMax = BitConverter.ToInt16(source, i += step); entry.GPMax = BitConverter.ToInt16(source, i += step); entry.CPMax = BitConverter.ToInt16(source, i += step); #endregion #region Offensive Properties entry.Accuracy = BitConverter.ToInt16(source, 0x174); // entry.CriticalHitRate = BitConverter.ToInt16(source, 0x188); // entry.Determination = BitConverter.ToInt16(source, 0x1CC); // #endregion #region Defensive Properties entry.Parry = BitConverter.ToInt16(source, 0x178); // entry.Defense = BitConverter.ToInt16(source, 0x170); // entry.MagicDefense = BitConverter.ToInt16(source, 0x17C); // #endregion #region Phyiscal Properties entry.AttackPower = BitConverter.ToInt16(source, 0x16C); // entry.SkillSpeed = BitConverter.ToInt16(source, 0x1d0); // #endregion #region Mental Properties entry.SpellSpeed = BitConverter.ToInt16(source, 0x1D4); // entry.AttackMagicPotency = BitConverter.ToInt16(source, 0x1A0); // entry.HealingMagicPotency = BitConverter.ToInt16(source, 0x1A4); // #endregion #region Status Resistances //entry.SlowResistance = BitConverter.ToInt16(source, 0x1C8); //entry.SilenceResistance = BitConverter.ToInt16(source, 0x1CC); //entry.BindResistance = BitConverter.ToInt16(source, 0x1D0); //entry.PoisionResistance = BitConverter.ToInt16(source, 0x1D4); //entry.StunResistance = BitConverter.ToInt16(source, 0x1D8); //entry.SleepResistance = BitConverter.ToInt16(source, 0x1DC); //entry.BindResistance = BitConverter.ToInt16(source, 0x1E0); //entry.HeavyResistance = BitConverter.ToInt16(source, 0x1E4); #endregion #region Elemental Resistances //step = 4; //i = 0x1B0; //entry.FireResistance = BitConverter.ToInt16(source, i += step);// //entry.IceResistance = BitConverter.ToInt16(source, i += step);// //entry.WindResistance = BitConverter.ToInt16(source, i += step);// //entry.EarthResistance = BitConverter.ToInt16(source, i += step);// //entry.LightningResistance = BitConverter.ToInt16(source, i += step);// //entry.WaterResistance = BitConverter.ToInt16(source, i += step);// #endregion #region Physical Resistances step = 4; i = 0x190; entry.SlashingResistance = BitConverter.ToInt16(source, i += step); // entry.PiercingResistance = BitConverter.ToInt16(source, i += step); // entry.BluntResistance = BitConverter.ToInt16(source, i += step); // #endregion #region Crafting //entry.Craftmanship = BitConverter.ToInt16(source, 0x230); //entry.Control = BitConverter.ToInt16(source, 0x234); #endregion #region Gathering //entry.Gathering = BitConverter.ToInt16(source, 0x238); //entry.Perception = BitConverter.ToInt16(source, 0x23C); #endregion } catch (Exception ex) { } d = entry; }
private void SystemSearch() { SYSTEM_INFO sys_info = new SYSTEM_INFO(); UnsafeNativeMethods.GetSystemInfo(out sys_info); MEMORY_BASIC_INFORMATION64 mem_basic_info = new MEMORY_BASIC_INFORMATION64(); List <MEMORY_BASIC_INFORMATION64> MemReg = new List <MEMORY_BASIC_INFORMATION64>(); long bip = ProcessModel.GetProcessBaseAddress(process); foreach (Signature sig in Signatures.Resolve(true)) { if (sig.Heap) { IntPtr hModuleSnapshot = new IntPtr(); hModuleSnapshot = UnsafeNativeHeap.CreateToolhelp32Snapshot(UnsafeNativeHeap.TH32CS_SNAPHEAPLIST | UnsafeNativeHeap.TH32CS_SNAPMODULE32, (uint)process.Id); if ((int)hModuleSnapshot == UnsafeNativeHeap.INVALID_HANDLE_VALUE) { System.Windows.Forms.MessageBox.Show("Not Heap Access. " + Marshal.GetLastWin32Error().ToString()); return; } UnsafeNativeHeap.HEAPENTRY64 pe64 = new UnsafeNativeHeap.HEAPENTRY64(); UnsafeNativeHeap.HEAPLIST64 heaplist = new UnsafeNativeHeap.HEAPLIST64(); heaplist.dwSize = (uint)Marshal.SizeOf(heaplist); UnsafeNativeHeap.PROCESS_HEAP_ENTRY64 phe64 = new UnsafeNativeHeap.PROCESS_HEAP_ENTRY64(); System.Threading.Thread.Sleep(10); bool r = UnsafeNativeHeap.Heap32ListFirst(hModuleSnapshot, ref heaplist); r = UnsafeNativeHeap.Heap32ListNext(hModuleSnapshot, ref heaplist); bool r2; while (r) { phe64.lpData = IntPtr.Zero; int a = Marshal.SizeOf(phe64); //28 (32) a = Marshal.SizeOf(phe64.lpData); //4 a = Marshal.SizeOf(phe64.cbData); //4 a = Marshal.SizeOf(phe64.cbOverhead); //2 a = Marshal.SizeOf(phe64.iRegionIndex); //2 a = Marshal.SizeOf(phe64.wFlags); //2 r2 = UnsafeNativeHeap.HeapWalk((IntPtr)heaplist.th32HeapID, ref phe64); System.Windows.Forms.MessageBox.Show("Not Heap Access. " + Marshal.GetLastWin32Error().ToString()); int cc = 0; //System.Windows.Forms.MessageBox.Show("Not Heap Access. " + Marshal.GetLastWin32Error().ToString()); while (r2 && cc < 100) { if (pe64.dwBlockSize == 883) { int t = 1; } r2 = UnsafeNativeHeap.Heap32Next(ref pe64); cc++; } r = UnsafeNativeHeap.Heap32ListNext(hModuleSnapshot, ref heaplist); } System.Windows.Forms.MessageBox.Show(Marshal.GetLastWin32Error().ToString()); UnsafeNativeHeap.CloseHandle(hModuleSnapshot); continue; //この方法もダメ sig.BaseAddress = (long)MemoryLib.ReadPointer((IntPtr)sig.PointerAddress); Locations[sig.Key] = sig; continue; ulong proc_min_address = (ulong)sys_info.minimumApplicationAddress; ulong proc_max_address = (ulong)sys_info.maximumApplicationAddress; // saving the values as long ints so I won't have to do a lot of casts later ulong proc_min_address_l = (ulong)proc_min_address; ulong proc_max_address_l = (ulong)proc_max_address; bool exitFg = true; while (proc_min_address_l < proc_max_address_l && exitFg) { VirtualQueryEx(processHandle, (IntPtr)proc_min_address, out mem_basic_info, (uint)Marshal.SizeOf(typeof(MEMORY_BASIC_INFORMATION64))); // if this memory chunk is accessible if (mem_basic_info.Protect == MemoryLib.PAGE_READWRITE && mem_basic_info.State == MemoryLib.MEM_COMMIT) { /* * * if (sig.Key == "PARTYCOUNT") * { * //check Mmeory PalyerNmae * ReadPlayerInfo(); * byte[] pattan = new byte[PlayerInfo.d.Name.Length]; * byte[] pattan0 = new byte[PlayerInfo.d.Name.Length+1]; * * pattan = System.Text.Encoding.ASCII.GetBytes(PlayerInfo.d.Name); * pattan.CopyTo(pattan0,1); * pattan0[0] = 1; * // read everything in the buffer above * int hp = (int)processHandle; * int readSize = (int)mem_basic_info.RegionSize;// < 64*1024 ? (int)mem_basic_info.RegionSize : 64 * 1024; * byte[] buffer = new byte[readSize]; * int bytesRead = 0; * UnsafeNativeMethods.ReadProcessMemory(hp, (Int64)mem_basic_info.BaseAddress, buffer, readSize, ref bytesRead); * int pickup = MemoryLib.FindSuperSig(buffer, pattan0); * if (pickup == -1) * { * proc_min_address_l += mem_basic_info.RegionSize; * proc_min_address = proc_min_address_l; * continue; * }else * { * sig.BaseAddress = (Int64)mem_basic_info.BaseAddress; * sig.Offset = pickup - (0x10 * 24) - 1; * Locations[sig.Key] = sig; * exitFg = false; * } * } */ } proc_min_address_l += mem_basic_info.RegionSize; proc_min_address = proc_min_address_l; } } else { if (sig.Value == "") { sig.BaseAddress = bip; Locations[sig.Key] = sig; continue; } else { Signature retrnSig = MemoryLib.FindExtendedSignatures(sig); //toDo Active Search... sig.BaseAddress = retrnSig.BaseAddress; Locations[sig.Key] = sig; } } } }