Advertisement
TKGP

DS1Hook

Feb 15th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. class DS1Hook : PHook
  2.     {
  3.         private PHPointer CharData2;
  4.         private PHPointer InventoryData;
  5.  
  6.         public DS1Hook() : base(p => p.MainWindowTitle == "DARK SOULS", 5000)
  7.         {
  8.             CharData2 = RegisterPointer((IntPtr)0x1378700, 0, 8);
  9.             InventoryData = RegisterPointer(CharData2, 0x2DC);
  10.         }
  11.  
  12.         public InventoryItem[] GetInventoryItems()
  13.         {
  14.             var result = new InventoryItem[2048];
  15.             byte[] bytes = InventoryData.ReadBytes(0, 2048 * 0x1C);
  16.             for (int i = 0; i < 2048; i++)
  17.             {
  18.                 result[i] = new InventoryItem(bytes, i * 0x1C);
  19.             }
  20.             return result;
  21.         }
  22.     }
  23.  
  24.     public struct InventoryItem
  25.     {
  26.         public int Category { get; }
  27.  
  28.         public int ID { get; }
  29.  
  30.         public int Quantity { get; }
  31.  
  32.         public int Unk0C { get; }
  33.  
  34.         public int Unk10 { get; }
  35.  
  36.         public int Durability { get; }
  37.  
  38.         public int Unk18 { get; }
  39.  
  40.         public InventoryItem(byte[] bytes, int index)
  41.         {
  42.             Category = BitConverter.ToInt32(bytes, index + 0x00) >> 28;
  43.             ID = BitConverter.ToInt32(bytes, index + 0x04);
  44.             Quantity = BitConverter.ToInt32(bytes, index + 0x08);
  45.             Unk0C = BitConverter.ToInt32(bytes, index + 0x0C);
  46.             Unk10 = BitConverter.ToInt32(bytes, index + 0x10);
  47.             Durability = BitConverter.ToInt32(bytes, index + 0x14);
  48.             Unk18 = BitConverter.ToInt32(bytes, index + 0x18);
  49.         }
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement