Esempio n. 1
0
    public void AddData(string key, byte[] data)
    {
        int    numWritten;
        IntPtr bufferAddress = ProcessMemoryApi.VirtualAllocEx(process.Handle, IntPtr.Zero, data.Length, ProcessMemoryApi.MEM_COMMIT, ProcessMemoryApi.PAGE_READWRITE);

        Debug.Assert(bufferAddress != IntPtr.Zero, "Could not allocate memory in target process.");
        ProcessMemoryApi.WriteProcessMemory(process.Handle, bufferAddress, data, data.Length, out numWritten);
        Debug.Assert(numWritten == data.Length, "Bad write length returned from WriteProcessMemory()");
        dataEntries.Add(key, bufferAddress);
    }