Existing() public static method

public static Existing ( Process process, IntPtr address, UInt32 size ) : RemoteMemoryRegion
process System.Diagnostics.Process
address System.IntPtr
size System.UInt32
return RemoteMemoryRegion
Example #1
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WM_RPC_MESSAGE)
            {
                byte[] messageData = null;
                UInt32 messageID   = 0;
                if ((m.WParam != IntPtr.Zero) && (m.LParam != IntPtr.Zero))
                {
                    using (var region = RemoteMemoryRegion.Existing(_Process, m.WParam, (uint)m.LParam.ToInt64()))
                        messageData = ReadRemoteData(region, out messageID);
                }

                Future <byte[]> fResult;
                Monitor.Enter(_AwaitingResponses);
                if (_AwaitingResponses.TryGetValue(messageID, out fResult))
                {
                    _AwaitingResponses.Remove(messageID);
                    Monitor.Exit(_AwaitingResponses);
                    fResult.SetResult(messageData, null);
                }
                else
                {
                    Debug.Assert(messageID == 0);

                    Monitor.Exit(_AwaitingResponses);
                    _Messages.Enqueue(messageData);
                }
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Example #2
0
        protected RemoteMemoryRegion GetFunctionRegion(string moduleName, string functionName, byte[] replacementBytes)
        {
            var address = GetFunctionAddress(moduleName, functionName);

            return(RemoteMemoryRegion.Existing(
                       Process, address, (uint)replacementBytes.Length
                       ));
        }