public void Send(CommandMessage message) { VerifyConnected(); var size = Marshal.SizeOf(message); IntPtr pnt = Marshal.AllocHGlobal(size); try { IntPtr resultSize; Marshal.StructureToPtr(message, pnt, false); Marshal.ThrowExceptionForHR(NativeMethods.FilterSendMessage(port, pnt, size, IntPtr.Zero, 0, out resultSize)); } finally { Marshal.FreeHGlobal(pnt); } }
public void Send(CommandMessage message, byte[] data) { VerifyConnected(); var size = Marshal.SizeOf(message) + data.Length; IntPtr pnt = Marshal.AllocHGlobal(size); try { IntPtr resultSize; Marshal.StructureToPtr(message, pnt, false); IntPtr address = IntPtr.Add(pnt, Marshal.SizeOf(typeof(CommandMessage))); Marshal.Copy(data, 0, address, data.Length); Marshal.ThrowExceptionForHR(NativeMethods.FilterSendMessage(port, pnt, size, IntPtr.Zero, 0, out resultSize)); } finally { Marshal.FreeHGlobal(pnt); } }
private List<FileSystemEvent> GetFileSystemEvents(CommandMessage message, IntPtr buffer) { IntPtr resultSize; HResult hResult = connector.SendAndRead(message, buffer, out resultSize); if (hResult.IsError) { if (hResult.Code != ERROR_NO_MORE_ITEMS) { Marshal.ThrowExceptionForHR(hResult.Result); } return new List<FileSystemEvent>(); } else { return EventReader.ReadFromBuffer(buffer, resultSize.ToInt64()); } }
private List<FileSystemEvent> GetEvents() { CommandMessage message = new CommandMessage(); message.Command = MinispyCommand.GetMiniSpyLog; var buffer = Marshal.AllocHGlobal(BUFFER_SIZE); try { return GetFileSystemEvents(message, buffer); } finally { Marshal.FreeHGlobal(buffer); } }
public void WatchThread(long threadId) { CommandMessage message = new CommandMessage(); message.Command = MinispyCommand.SetWatchThread; connector.Send(message, BitConverter.GetBytes(threadId)); }
public void WatchProcess(long processId) { CommandMessage message = new CommandMessage(); message.Command = MinispyCommand.SetWatchProcess; connector.Send(message, BitConverter.GetBytes(processId)); }
public void WatchPath(string path) { CommandMessage message = new CommandMessage(); message.Command = MinispyCommand.SetPathFilter; connector.Send(message, PathConverter.ReplaceDriveLetter(path)); }
public DriverVersion GetDriverVersion() { CommandMessage message = new CommandMessage(); message.Command = MinispyCommand.GetMiniSpyVersion; IntPtr resultSize; var buffer = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DriverVersion))); HResult hResult = connector.SendAndRead(message, buffer, out resultSize); Marshal.ThrowExceptionForHR(hResult.Result); var driverVersion = Marshal.PtrToStructure<DriverVersion>(buffer); Marshal.FreeHGlobal(buffer); return driverVersion; }
public HResult SendAndRead(CommandMessage message, IntPtr buffer, out IntPtr resultSize) { VerifyConnected(); var size = Marshal.SizeOf(message); IntPtr command = Marshal.AllocHGlobal(size); try { Marshal.StructureToPtr(message, command, false); return new HResult(NativeMethods.FilterSendMessage(port, command, size, buffer, 4069, out resultSize)); } finally { Marshal.FreeHGlobal(command); } }
public void Send(CommandMessage message, string path) { Send(message, Encoding.Unicode.GetBytes(path + '\0')); }