Exemplo n.º 1
0
    public static uint NativeAddress(UInt64 nativeHash)
    {
        ulong  nativeTable;
        uint   index;
        UInt64 nativeAddress;

        nativeTable = Address.NativeTable;
        index       = (uint)nativeHash & 0xFF;
        byte[] test = PS4.GetBytes(nativeTable + (index * 8), 8);
        nativeAddress = PS4.Extension.ReadUInt64(nativeTable + (index * 8));
        while (nativeAddress != 0)
        {
            uint count = PS4.Extension.ReadUInt32(nativeAddress + 0x40);
            for (uint i = 0; i < count; i++)
            {
                UInt64 hash = PS4.Extension.ReadUInt64(nativeAddress + 0x48 + (i * 8));
                if (hash == nativeHash)
                {
                    return(PS4.Extension.ReadUInt32(nativeAddress + 0x8 + (i * 8)));
                }
            }
            nativeAddress = PS4.Extension.ReadUInt64(nativeAddress);
        }

        return(0);
    }
Exemplo n.º 2
0
 public static T Call <T>(ulong address, params object[] parameters)
 {
     lock (_locker)
     {
         if (address > uint.MaxValue)
         {
             address = NativeAddress(address);
         }
         if (address == 0)
         {
             throw new Exception("not correct address");
         }
         int   parametersLength = parameters.Length;
         ulong freeSpace        = _freeSpace;
         ulong pFunction        = freeSpace;
         ulong pReturn          = freeSpace + 0xA8;
         ulong pArgs            = freeSpace + 0x28;
         ulong pString          = freeSpace + 0xC8;
         ulong offset           = 0;
         _DestroyAll();
         ApplyParameters(parameters, parametersLength, pArgs, ref pString, ref offset);
         PS4.Extension.WriteUInt64(pFunction, address);
         Type     retType = typeof(T);
         DateTime timeOut = DateTime.Now.AddSeconds(5);
         bool     functionError;
         while ((functionError = (PS4.Extension.ReadUInt64(pFunction) != 0)) && DateTime.Now < timeOut)
         {
         }
         if (functionError)
         {
             PS4.Extension.WriteUInt64(pFunction, 0);
             return(default(T));
         }
         if (retType == typeof(Void))
         {
             return(default(T));
         }
         object retValue = null;
         if (retType.IsPrimitive)
         {
             retValue = PS4.GetBytes(pReturn, 8);
             retValue = ToPrimitive <T>((byte[])retValue, retType.Name);
         }
         else if (retType == typeof(string))
         {
             retValue = PS4.Extension.ReadString(PS4.Extension.ReadUInt64(pReturn));
         }
         else
         {
             Vector3 vec;
             byte[]  vec3 = PS4.GetBytes(pReturn, 8 * 3);
             vec.X    = BitConverter.ToSingle(vec3, 0);
             vec.Y    = BitConverter.ToSingle(vec3, 8);
             vec.Z    = BitConverter.ToSingle(vec3, 16);
             retValue = vec;
         }
         return((T)retValue);
     }
 }