private dynamic GetValue(Process p, String type, DeepPointer pointer)
 {
     if (type == "int")
         return pointer.Deref<int>(p);
     else if (type == "uint")
         return pointer.Deref<uint>(p);
     else if (type == "float")
         return pointer.Deref<float>(p);
     else if (type == "double")
         return pointer.Deref<double>(p);
     else if (type == "byte")
         return pointer.Deref<byte>(p);
     else if (type == "sbyte")
         return pointer.Deref<sbyte>(p);
     else if (type == "short")
         return pointer.Deref<short>(p);
     else if (type == "ushort")
         return pointer.Deref<ushort>(p);
     else if (type == "bool")
         return pointer.Deref<bool>(p);
     else if (type.StartsWith("string"))
     {
         var length = Int32.Parse(type.Substring("string".Length));
         return pointer.DerefString(p, length);
     }
     else if (type.StartsWith("byte"))
     {
         var length = Int32.Parse(type.Substring("byte".Length));
         return pointer.DerefBytes(p, length);
     }
     throw new ArgumentException(string.Format("The provided type, '{0}', is not supported", type));
 }
Ejemplo n.º 2
0
 public bool ReadFlags(out byte[] flags)
 {
     flags = new byte[numFlags];
     if (!DPMainManagerFlags.DerefBytes(BfGameProcess, numFlags, out flags))
     {
         flags = null;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 3
0
 public bool ReadEnemyEncounter(out byte[] enemyEncounter)
 {
     enemyEncounter = new byte[nbrBytesEnemyEncounter];
     if (!DPMainManagerEnemyEncounter.DerefBytes(BfGameProcess, nbrBytesEnemyEncounter, out enemyEncounter))
     {
         enemyEncounter = null;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        private static dynamic GetValue(Process p, string type, DeepPointer pointer)
        {
            switch (type)
            {
            case "int":
                return(pointer.Deref <int>(p));

            case "uint":
                return(pointer.Deref <uint>(p));

            case "long":
                return(pointer.Deref <long>(p));

            case "ulong":
                return(pointer.Deref <ulong>(p));

            case "float":
                return(pointer.Deref <float>(p));

            case "double":
                return(pointer.Deref <double>(p));

            case "byte":
                return(pointer.Deref <byte>(p));

            case "sbyte":
                return(pointer.Deref <sbyte>(p));

            case "short":
                return(pointer.Deref <short>(p));

            case "ushort":
                return(pointer.Deref <ushort>(p));

            case "bool":
                return(pointer.Deref <bool>(p));

            default:
                if (type.StartsWith("string"))
                {
                    var length = int.Parse(type.Substring("string".Length));
                    return(pointer.DerefString(p, length));
                }
                else if (type.StartsWith("byte"))
                {
                    var length = int.Parse(type.Substring("byte".Length));
                    return(pointer.DerefBytes(p, length));
                }
                break;
            }

            throw new ArgumentException($"The provided type, '{type}', is not supported");
        }
        private static dynamic GetValue(Process p, string type, DeepPointer pointer)
        {
            switch (type)
            {
                case "int":
                    return pointer.Deref<int>(p);
                case "uint":
                    return pointer.Deref<uint>(p);
                case "float":
                    return pointer.Deref<float>(p);
                case "double":
                    return pointer.Deref<double>(p);
                case "byte":
                    return pointer.Deref<byte>(p);
                case "sbyte":
                    return pointer.Deref<sbyte>(p);
                case "short":
                    return pointer.Deref<short>(p);
                case "ushort":
                    return pointer.Deref<ushort>(p);
                case "bool":
                    return pointer.Deref<bool>(p);
                default:
                    if (type.StartsWith("string"))
                    {
                        var length = int.Parse(type.Substring("string".Length));
                        return pointer.DerefString(p, length);
                    }
                    else if (type.StartsWith("byte"))
                    {
                        var length = int.Parse(type.Substring("byte".Length));
                        return pointer.DerefBytes(p, length);
                    }
                    break;
            }

            throw new ArgumentException($"The provided type, '{type}', is not supported");
        }
Ejemplo n.º 6
0
 public byte[] readflags()
 {
     return(flags.DerefBytes(proc, 875));
 }
Ejemplo n.º 7
0
 public byte[] readbytes()
 {
     return(bytesptr.DerefBytes(proc, 0x1000));
 }
Ejemplo n.º 8
0
        void MemoryReadThread()
        {
            Debug.WriteLine("[NierIntelTracker] MemoryReadThread");

            while (!_cancelSource.IsCancellationRequested)
            {
                try
                {
                    Trace.WriteLine("[NierIntelTracker] Waiting for NieRAutomata.exe...");
                    _intelDisplay.updateComponentDisplayStatus("Checking for game process");

                    Process game;
                    while ((game = GetGameProcess()) == null)
                    {
                        Thread.Sleep(500);
                        if (_cancelSource.IsCancellationRequested)
                        {
                            return;
                        }
                    }

                    Trace.WriteLine("[NierIntelTracker] Got NieRAutomata.exe!");
                    _intelDisplay.updateComponentDisplayStatus("Game process found");

                    IEnumerator coll = game.Modules.GetEnumerator();
                    coll.MoveNext();

                    DeepPointer FishPtr;
                    DeepPointer UnitIntelPtr;
                    var         memSize = ((ProcessModule)coll.Current).ModuleMemorySize;
                    switch (memSize)
                    {
                    case 106266624:
                        FishPtr      = new DeepPointer(0x198452C); // 0x197C460
                        UnitIntelPtr = new DeepPointer(0x19844C8);
                        _intelDisplay.updateComponentDisplayStatus("v1.01");
                        break;

                    default:
                        FishPtr      = new DeepPointer(0x25AF8AC); // 0x25A77E0
                        UnitIntelPtr = new DeepPointer(0x25AF848);
                        _intelDisplay.updateComponentDisplayStatus("vdebug");
                        break;
                    }
                    Debug.WriteLine("[NierIntelTracker] ModuleMemorySize: " + memSize.ToString());

                    while (!game.HasExited)
                    {
                        IntelFishOld     = IntelFishCurrent;
                        IntelFishCurrent = FishPtr.DerefBytes(game, 8);

                        if (!IntelFishCurrent.SequenceEqual(IntelFishOld))
                        {
                            int fishCount = IntelFishCurrent.Select(s => BitCount.PrecomputedBitcount(s)).Sum();
                            this._fishCountDisplay(fishCount);
                            this._intelDisplay.UpdateFishIntel(IntelFishCurrent, fishCount);
                        }

                        IntelUnitOld     = IntelUnitCurrent;
                        IntelUnitCurrent = UnitIntelPtr.DerefBytes(game, 24);

                        if (!IntelUnitCurrent.SequenceEqual(IntelUnitOld))
                        {
                            this._intelDisplay.UpdateUnitIntel(IntelUnitCurrent);
                        }

                        Thread.Sleep(SLEEP_TIME);

                        if (_cancelSource.IsCancellationRequested)
                        {
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("[NierIntelTracker] Exception: " + ex.ToString());
                    Thread.Sleep(1000);
                }
            }
        }