Offsets benutzen



  • Hi Leute

    Folgendes ich habe eine Klasse geschrieben wo ich einen Pointer auf eine besimmte addresse setze.Jetzt möchte ich Offsets dazu setzen.Nur wie gehe ich das am besten an?

    Hier meine Klasse:

    #pragma once
    using namespace System;
    using namespace System::Diagnostics;
    using namespace System::Runtime::InteropServices;
    
    ref class memoread
    {
    public:
    	memoread(void);
    	public:
    		literal System::UInt32 PROCESS_ALL_ACCESS = (0x1F0FF);
    
    	public:
    		literal System::UInt32 PROCESS_VM_READ = (0x0010);
    
    		[DllImport("kernel32.dll")]
    		static IntPtr OpenProcess(System::UInt32 dwDesiredAccess, Int32 bInheritHandle, System::UInt32 dwProcessId);
    
    		[DllImport("kernel32.dll")]
    		static Int32 CloseHandle(IntPtr hObject);
    
    		[DllImport("kernel32.dll")]
    		static Int32 ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [In, Out] array<System::Byte> ^buffer, System::UInt32 size, [System::Runtime::InteropServices::Out] IntPtr %lpNumberOfBytesRead);
    
    };
    
    ///anfang klasse ProcessMemoryReader
    	public ref class ProcessMemoryReader
    	{
    
    	public:
    		ProcessMemoryReader()
    		{
    		}
    
    		/// <summary>	
    		/// Process from which to read		
    		/// </summary>
    		property Process ^ReadProcess
    		{
    			Process ^get()
    			{
    				return m_ReadProcess;
    			}
    			void set(Process ^value)
    			{
    				m_ReadProcess = value;
    			}
    		}
    
    	private:
    		Process ^m_ReadProcess;
    
    static IntPtr m_hProcess = IntPtr::Zero;
    
    	public:
    		void OpenProcess()
    		{
    			m_hProcess = memoread::OpenProcess(memoread::PROCESS_VM_READ, 1, safe_cast<System::UInt32>(m_ReadProcess->Id));
    		}
    
    		void CloseHandle()
    		{
    			int iRetValue;
    			iRetValue = memoread::CloseHandle(m_hProcess);
    			if (iRetValue == 0)
    				throw gcnew Exception("CloseHandle failed");
    		}
    
    		array<System::Byte> ^ReadProcessMemory(IntPtr MemoryAddress, System::UInt32 bytesToRead, [System::Runtime::InteropServices::Out] int %bytesReaded)
    		{
    			array<System::Byte> ^buffer = gcnew array<System::Byte>(bytesToRead);
    
    			IntPtr ptrBytesReaded;
    			memoread::ReadProcessMemory(m_hProcess,MemoryAddress,buffer,bytesToRead,ptrBytesReaded);
    
    			bytesReaded = ptrBytesReaded.ToInt32();
    
    			return buffer;
    		}
    	};
    /////ende klasse ProcessMemoryReader
    

Log in to reply