예제 #1
0
 public CalculatorClient(string appUrl)
 {
     this.appUrl = appUrl;
     operand1 = new RemoteMemory(0);
     operand2 = new RemoteMemory(0);
     result = new RemoteMemory(0);
 }
예제 #2
0
        /// <summary>
        /// Enumerates all <see cref="Process"/>es that match a given predicate
        /// </summary>
        /// <param name="processSelector">Predicate used to select <see cref="Process"/>es</param>
        public static IEnumerable <Process> GetProcesses(Func <IRemoteMemory, bool> processSelector)
        {
            foreach (Process proc in Process.GetProcesses())
            {
                if (!ProcessExists(proc))
                {
                    continue;
                }

                try
                {
                    ProcessModule throwTest = proc.MainModule;
                }
                catch (Win32Exception)
                {
                    continue;
                }

                bool yield = false;
                try
                {
                    using var remoteMemory = new RemoteMemory(proc);
                    yield = processSelector(remoteMemory);
                }
                catch (OpenProcessException)
                {
                    continue;
                }

                if (yield)
                {
                    yield return(proc);
                }
            }
        }
예제 #3
0
 public void ReadFloat(float input)
 {
     using (var memory = new RemoteMemory(GetProcess()))
     {
         Assert.AreEqual(input, memory.Read <float>(new IntPtr(&input)));
     }
 }
예제 #4
0
 public void ReadString(string input)
 {
     using (var memory = new RemoteMemory(GetProcess()))
     {
         fixed(char *charPointer = input)
         {
             Assert.AreEqual(input, memory.ReadString(new IntPtr(charPointer), GetEncoding()));
         }
     }
 }
예제 #5
0
 public void ReadBytes()
 {
     byte[] bytes = new byte[] { 1, 2, 3 };
     using (var memory = new RemoteMemory(GetProcess()))
     {
         fixed(byte *bytePointer = bytes)
         {
             CollectionAssert.AreEqual(bytes, memory.ReadBytes(new IntPtr(bytePointer), bytes.Length));
         }
     }
 }
예제 #6
0
        public void WriteShort(short n1, short n2)
        {
            short test = n1;

            using (var memory = new RemoteMemory(GetProcess()))
            {
                Assert.AreEqual(n1, test);
                memory.Write(new IntPtr(&test), n2);
                Assert.AreNotEqual(n1, test);
                Assert.AreEqual(n2, test);
            }
        }
예제 #7
0
        public void WriteLong(long n1, long n2)
        {
            long test = n1;

            using (var memory = new RemoteMemory(GetProcess()))
            {
                Assert.AreEqual(n1, test);
                memory.Write(new IntPtr(&test), n2);
                Assert.AreNotEqual(n1, test);
                Assert.AreEqual(n2, test);
            }
        }
예제 #8
0
        public void WriteString(string s1, string s2)
        {
            using (var memory = new RemoteMemory(GetProcess()))
            {
                fixed(char *charPointer = s1)
                {
                    memory.WriteString(new IntPtr(charPointer), s2, GetEncoding());
                    string written = new(charPointer);

                    Assert.AreNotEqual(s1, written);
                    Assert.AreEqual(s2, written);
                }
            }
        }
예제 #9
0
 public DetourCallback(IntPtr _startAddress, IntPtr _codeCaveAddress, int _overwriteByteCount, byte[] _overwrittenOriginalBytes, byte[] _jumpInBytes, byte[] _jumpOutBytes, byte[] _codeCaveBytes, bool _saveOriginalBytes, bool _putOriginalBytesAfterMnemonics, Classes.RemoteMemory _allocationObject, Classes.RemoteMemory _hitCounter, Classes.RemoteMemory _registerStructs, InterceptHookExecuteDelegate _RaiseEvent, Main _mainReference)
 {
     DetourStartAddress         = _startAddress;
     CodeCaveAddress            = _codeCaveAddress;
     OriginalByteOverwriteCount = _overwriteByteCount;
     OriginalBytes     = _overwrittenOriginalBytes;
     SaveOriginalBytes = _saveOriginalBytes;
     PutOriginalBytesAfterMnemonics = _putOriginalBytesAfterMnemonics;
     JumpInBytes              = _jumpInBytes;
     CodeCaveBytes            = _codeCaveBytes;
     CodeCaveAllocationObject = _allocationObject;
     HitCounter      = _hitCounter;
     RegisterStructs = _registerStructs;
     RaiseEvent      = _RaiseEvent;
     JumpOutBytes    = _jumpOutBytes;
     MainReference   = _mainReference;
 }
예제 #10
0
        public void WriteBytes()
        {
            byte[] bytes    = new byte[] { 1, 2, 3 };
            byte[] preBytes = new byte[bytes.Length];
            byte[] newBytes = new byte[] { 4, 5, 6 };
            bytes.CopyTo(preBytes, 0);
            using (var memory = new RemoteMemory(GetProcess()))
            {
                CollectionAssert.AreEqual(bytes, preBytes);
                fixed(byte *bytePointer = bytes)
                {
                    memory.WriteBytes(new IntPtr(bytePointer), newBytes);
                }

                CollectionAssert.AreNotEqual(preBytes, bytes);
                CollectionAssert.AreEqual(newBytes, bytes);
            }
        }
예제 #11
0
 public void Initialize(bool usePatternScan = false)
 {
     Memory = new RemoteMemory(Process.GetProcessesByName("ConanSandbox")[0]);
     Memory.Initialize();
     #region PatternScanner
     if (usePatternScan)
     {
         var scan      = new SigScan(Memory.Process, Memory.ProcessBaseAddress, Memory.Process.MainModule.ModuleMemorySize);
         var gnamesPtr = scan.FindPattern(GNamesPatternBytes, GNamesPattern, 0);
         int offset    = Memory.ReadInt32(gnamesPtr, 3);
         GNamesPtr = Memory.ReadIntPtr(new IntPtr(gnamesPtr.ToInt64() + offset + 7), 0);
         var gObjectsPtr = scan.FindPattern(GObjectsPatternBytes, GObjectsPattern, 0);
         offset      = Memory.ReadInt32(gObjectsPtr, 3);
         GObjectsPtr = new IntPtr(gObjectsPtr.ToInt64() + offset + 7);
     }
     #endregion
     Names   = new NameStore(GNamesPtr);
     Objects = new ObjectStore(GObjectsPtr);
 }
예제 #12
0
파일: Player.cs 프로젝트: jariz/jZm
 public Stats_(Player a)
 {
     Mem = new RemoteMemory(a.Mem.Process);
     Player = a;
 }
예제 #13
0
 public RemoteProcess(Process process) : base(process)
 {
     Memory = new RemoteMemory(Handle);
 }