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); } }
protected RemoteMemoryRegion GetFunctionRegion(string moduleName, string functionName, byte[] replacementBytes) { var address = GetFunctionAddress(moduleName, functionName); return(RemoteMemoryRegion.Existing( Process, address, (uint)replacementBytes.Length )); }