Windower 日本語Wiki

クラスPC

最終更新:

ff11windower2

- view
だれでも歓迎! 編集
【クラスPCとは】
  • FFACE非依存で、MP、HPなどを取得するクラスです。rcm氏のXIACEの別ソリューションです。
  • SendTextをメソッドに取り込む等直感的に記述できるようにしてます。

【ソース】
  1.   public unsafe class PC
  2.   {
  3.    public int HP, MP, TP, HPP, MPP, area, status;
  4.    public bool fighting;
  5.   
  6.    [System.Runtime.InteropServices.DllImport("kernel32.dll")]
  7.    private extern static IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  8.  
  9.    //win32api CloseHandle用
  10.    [System.Runtime.InteropServices.DllImport("kernel32.dll")]
  11.    private extern static bool CloseHandle(IntPtr hObject);
  12.  
  13.    //win32api ReadProcessMemory用
  14.    [System.Runtime.InteropServices.DllImport("kernel32.dll")]
  15.    private extern static bool ReadProcessMemory(IntPtr hProcess, int lpBaseAddress, void* lpBuffer, int nSize, int* lpNumberOfBytesRead);
  16.  
  17.  
  18.    public IntPtr handle = (IntPtr)null;
  19.    public int baseaddr = 0;
  20.    Windower.MainFunctions w;
  21.  
  22.    public PC(Process p, Windower.MainFunctions warg)
  23.    {
  24.     w = warg;
  25.     
  26.     foreach (ProcessModule m in p.Modules)
  27.     {
  28.       if (m.ModuleName == "FFXiMain.dll")
  29.       {
  30.        baseaddr = m.BaseAddress.ToInt32();
  31.        break;
  32.       }
  33.     }
  34.     const int PROCESS_ALL_ACCESS = 0x1F0FFF;
  35.     handle = OpenProcess(PROCESS_ALL_ACCESS, false, p.Id);
  36.  
  37.  
  38.    }
  39.  
  40.    public void Do(string command, double waitsec)
  41.    {
  42.     int milisec = (int)waitsec * 1000;
  43.     w.SendText(command);
  44.     Thread.Sleep(milisec);
  45.    }
  46.  
  47.    public void Do(string command)
  48.    {
  49.     Do(command, 0.1);
  50.    }
  51.  
  52.    public void update()
  53.    {
  54.     HpMpStruct HpMpTp = new HpMpStruct();
  55.     ReadProcessMemory(handle, baseaddr + 0x8ccb6c
  56.                , &HpMpTp, Marshal.SizeOf(HpMpTp), null);
  57.     byte[] charaNameBuff = new byte[20];
  58.     for (int i = 0; i < 20; i++)
  59.     {
  60.       charaNameBuff[i] = HpMpTp.name[i];
  61.       if (HpMpTp.name[i] == 0) break;
  62.     }
  63.     string charName = Encoding.Default.GetString(charaNameBuff).Replace("\0", "");
  64.  
  65.     HP = HpMpTp.HP;
  66.     MP = HpMpTp.MP;
  67.     TP = HpMpTp.TP;
  68.     HPP = HpMpTp.HPP;
  69.     MPP = HpMpTp.MPP;
  70.     area = HpMpTp.area;
  71.  
  72.     byte bstatus;
  73.     ReadProcessMemory(handle, baseaddr + 0x536790
  74.            , &bstatus, 1, null);
  75.     status = bstatus;
  76.  
  77.     fighting = false;
  78.     if (1 == status) fighting = true;
  79.  
  80.    }
  81.  
  82.    unsafe struct HpMpStruct
  83.    {
  84.     internal fixed byte name[20];
  85.     internal fixed byte dummy[12];
  86.     internal int HP;
  87.     internal int MP;
  88.     internal int TP ;
  89.     internal byte HPP;
  90.     internal byte MPP;
  91.     internal byte area;
  92.    }
  93.  
  94.  
  95.    public bool Icon(int se)
  96.    {
  97.     int IconAddr = 0;
  98.     ReadProcessMemory(handle, baseaddr + 0x57d57c, &IconAddr, 4, null);
  99.  
  100.     IconStruct icons = new IconStruct();
  101.     ReadProcessMemory(handle, IconAddr + 644, &icons, Marshal.SizeOf(icons), null);
  102.  
  103.     for (Byte i = 0; i < icons.Count; i++)
  104.     {
  105.       if (icons.IconArray[i] == se) return true;
  106.     }
  107.     return false;
  108.    }
  109.  
  110.    public bool Icon(i se)
  111.    {
  112.     return Icon((int)se);
  113.    }
  114.  
  115.  
  116.    internal unsafe struct IconStruct
  117.    {
  118.     internal fixed short IconArray[32];
  119.     internal fixed byte SelfCut[32];
  120.     internal fixed byte unkown[4];
  121.     internal short Count;
  122.    }
  123.  
  124.  
  125.  
  126.   }
  127.  
  128.   public enum i : short
  129.   {
  130.    KO = 0,
  131.    Weakness = 1,
  132.    Sleep = 2,
  133.    Poison = 3,
  134.    Paralysis = 4,
  135.    Blindness = 5,
  136.    Silence = 6,
  137.    <以下略>
  138.   }
  139.  

タグ:

+ タグ編集
  • タグ:
記事メニュー
ウィキ募集バナー