/// <summary> /// Reads a value from memory /// </summary> /// <param name="dwAddress">Address at which value will be read.</param> /// <param name="nSize">Number of bytes to read from memory.</param> /// <exception cref="Exception">Throws general exception on failure.</exception> /// <returns>Returns the value that was read from memory.</returns> public byte[] ReadBytes(uint dwAddress, int nSize) { if (!this.m_bProcessOpen || this.m_hProcess == IntPtr.Zero) { throw new Exception("Process is not open for read/write."); } return(SMemory.ReadBytes(this.m_hProcess, dwAddress, nSize)); }
/// <summary> /// Finds a pattern or signature inside another process. /// </summary> /// <param name="hProcess">Handle to the process in whose memory pattern will be found.</param> /// <param name="dwStart">Address on which the search will start.</param> /// <param name="nSize">Number of bytes in memory that will be searched.</param> /// <param name="bPattern">A byte-array representing the pattern to be found.</param> /// <param name="szMask">A string of 'x' (match), '!' (not-match), or '?' (wildcard).</param> /// <returns>Returns 0 on failure, or the address of the start of the pattern on success.</returns> public static uint FindPattern(IntPtr hProcess, uint dwStart, int nSize, byte[] bPattern, string szMask) { if (bPattern == null || bPattern.Length == 0) { throw new ArgumentNullException("bData"); } if (bPattern.Length != szMask.Length) { throw new ArgumentException("bData and szMask must be of the same size"); } byte[] bData = SMemory.ReadBytes(hProcess, dwStart, nSize); if (bData == null) { throw new Exception("Could not read memory in FindPattern."); } return((uint)(dwStart + FindPattern(bData, bPattern, szMask))); }