private unsafe bool TransmitFromUserToDoor(out bool error) { if (_ClientThread.NodeInfo.Connection.CanRead()) { // If our writeslot doesnt exist yet, create it if (WriteSlot == IntPtr.Zero) { // Create A Write Mail Slot WriteSlot = NativeMethods.CreateFile("\\\\.\\mailslot\\sbbsexec\\wr" + _ClientThread.NodeInfo.Node.ToString(), NativeMethods.FileAccess.GenericWrite, NativeMethods.FileShare.Read, IntPtr.Zero, NativeMethods.CreationDisposition.OpenExisting, NativeMethods.CreateFileAttributes.Normal, IntPtr.Zero); int LastWin32Error = Marshal.GetLastWin32Error(); if (WriteSlot == IntPtr.Zero) { RMLog.Error("CreateFile() failed to create WriteSlot: " + LastWin32Error.ToString()); error = true; return(false); } else if (WriteSlot.ToInt32() == -1) { if (LastWin32Error == 2) { // ERROR_FILE_NOT_FOUND - User must have hit a key really fast to trigger this! RMLog.Warning("CreateFile() failed to find WriteSlot: \\\\.\\mailslot\\sbbsexec\\wr" + _ClientThread.NodeInfo.Node.ToString()); WriteSlot = IntPtr.Zero; Thread.Sleep(100); } else { RMLog.Error("CreateFile() failed to create WriteSlot: " + LastWin32Error.ToString()); error = true; return(false); } } } // Write the text to the program if (WriteSlot != IntPtr.Zero) { byte[] BufBytes = _ClientThread.NodeInfo.Connection.PeekBytes(); bool Result = NativeMethods.WriteFile(WriteSlot, BufBytes, (uint)BufBytes.Length, out uint BytesWritten, null); int LastWin32Error = Marshal.GetLastWin32Error(); if (Result) { _ClientThread.NodeInfo.Connection.ReadBytes((int)BytesWritten); error = false; return(true); } else { RMLog.Error("Error calling WriteFile(): " + LastWin32Error.ToString()); error = true; return(false); } } else { error = false; return(false); } } else { error = false; return(false); } }