ReactOS  0.4.13-dev-99-g7e18b6d
mailslot.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for mailslot.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

HANDLE WINAPI CreateMailslotA (IN LPCSTR lpName, IN DWORD nMaxMessageSize, IN DWORD lReadTimeout, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
HANDLE WINAPI CreateMailslotW (IN LPCWSTR lpName, IN DWORD nMaxMessageSize, IN DWORD lReadTimeout, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
 
BOOL WINAPI GetMailslotInfo (IN HANDLE hMailslot, IN LPDWORD lpMaxMessageSize, IN LPDWORD lpNextSize, IN LPDWORD lpMessageCount, IN LPDWORD lpReadTimeout)
 
BOOL WINAPI SetMailslotInfo (IN HANDLE hMailslot, IN DWORD lReadTimeout)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file mailslot.c.

Function Documentation

◆ CreateMailslotA()

HANDLE WINAPI CreateMailslotA ( IN LPCSTR  lpName,
IN DWORD  nMaxMessageSize,
IN DWORD  lReadTimeout,
IN LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)

Definition at line 23 of file mailslot.c.

27 {
28  /* Call the W(ide) function */
29  ConvertWin32AnsiObjectApiToUnicodeApi2(Mailslot, lpName, nMaxMessageSize, lReadTimeout, lpSecurityAttributes);
30 }
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define ConvertWin32AnsiObjectApiToUnicodeApi2(obj, name,...)
Definition: base_x.h:65

Referenced by mailslot_test(), and test_query_object().

◆ CreateMailslotW()

HANDLE WINAPI CreateMailslotW ( IN LPCWSTR  lpName,
IN DWORD  nMaxMessageSize,
IN DWORD  lReadTimeout,
IN LPSECURITY_ATTRIBUTES  lpSecurityAttributes 
)

Definition at line 37 of file mailslot.c.

41 {
43  UNICODE_STRING MailslotName;
44  HANDLE MailslotHandle;
47  LARGE_INTEGER DefaultTimeOut;
51 
53  if (!Result)
54  {
56  return INVALID_HANDLE_VALUE;
57  }
58 
59  DPRINT("Mailslot name: %wZ\n", &MailslotName);
60 
61  if (lpSecurityAttributes)
62  {
63  SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
64  if(lpSecurityAttributes->bInheritHandle) Attributes |= OBJ_INHERIT;
65  }
66 
68  &MailslotName,
69  Attributes,
70  NULL,
72 
73  if (lReadTimeout == MAILSLOT_WAIT_FOREVER)
74  {
75  /* Set the max */
76  DefaultTimeOut.QuadPart = 0xFFFFFFFFFFFFFFFFLL;
77  }
78  else
79  {
80  /* Convert to NT format */
81  DefaultTimeOut.QuadPart = lReadTimeout * -10000LL;
82  }
83 
84  Status = NtCreateMailslotFile(&MailslotHandle,
87  &Iosb,
89  0,
90  nMaxMessageSize,
91  &DefaultTimeOut);
92 
95  {
97  }
98 
99  RtlFreeHeap(RtlGetProcessHeap(), 0, MailslotName.Buffer);
100 
101  if (!NT_SUCCESS(Status))
102  {
103  DPRINT1("NtCreateMailslot failed (Status %x)!\n", Status);
105  return INVALID_HANDLE_VALUE;
106  }
107 
108  return MailslotHandle;
109 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define LL
Definition: tui.h:72
NTSTATUS NTAPI NtCreateMailslotFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG CreateOptions, IN ULONG MailslotQuota, IN ULONG MaxMessageSize, IN PLARGE_INTEGER TimeOut)
Definition: file.c:3788
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void DPRINT(...)
Definition: polytest.cpp:61
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define OBJ_INHERIT
Definition: winternl.h:225
#define WRITE_DAC
Definition: nt_native.h:59
#define SetLastError(x)
Definition: compat.h:409
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define GENERIC_READ
Definition: compat.h:124
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
LONGLONG QuadPart
Definition: typedefs.h:112

◆ GetMailslotInfo()

BOOL WINAPI GetMailslotInfo ( IN HANDLE  hMailslot,
IN LPDWORD  lpMaxMessageSize,
IN LPDWORD  lpNextSize,
IN LPDWORD  lpMessageCount,
IN LPDWORD  lpReadTimeout 
)

Definition at line 116 of file mailslot.c.

121 {
126 
127  Status = NtQueryInformationFile(hMailslot,
128  &Iosb,
129  &Buffer,
132  if (!NT_SUCCESS(Status))
133  {
134  DPRINT1("NtQueryInformationFile failed (Status %x)!\n", Status);
136  return FALSE;
137  }
138 
139  if (lpMaxMessageSize) *lpMaxMessageSize = Buffer.MaximumMessageSize;
140  if (lpNextSize) *lpNextSize = Buffer.NextMessageSize;
141  if (lpMessageCount) *lpMessageCount = Buffer.MessagesAvailable;
142 
143  if (lpReadTimeout)
144  {
145  if (Buffer.ReadTimeout.QuadPart == 0xFFFFFFFFFFFFFFFFLL)
146  {
147  *lpReadTimeout = MAILSLOT_WAIT_FOREVER;
148  }
149  else
150  {
151  Timeout.QuadPart = -Buffer.ReadTimeout.QuadPart;
153  if (Timeout.HighPart == 0)
154  {
155  *lpReadTimeout = Timeout.LowPart;
156  }
157  else
158  {
159  *lpReadTimeout = 0xFFFFFFFE;
160  }
161  }
162  }
163 
164  return TRUE;
165 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI LONGLONG WINAPI RtlExtendedLargeIntegerDivide(LONGLONG, INT, INT *)
Definition: bufpool.h:45
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
Status
Definition: gdiplustypes.h:24
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
static ULONG Timeout
Definition: ping.c:61
#define DPRINT1
Definition: precomp.h:8
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

Referenced by mailslot_test().

◆ SetMailslotInfo()

BOOL WINAPI SetMailslotInfo ( IN HANDLE  hMailslot,
IN DWORD  lReadTimeout 
)

Definition at line 172 of file mailslot.c.

174 {
179 
180  if (lReadTimeout == MAILSLOT_WAIT_FOREVER)
181  {
182  /* Set the max */
183  Timeout.QuadPart = 0xFFFFFFFFFFFFFFFFLL;
184  }
185  else
186  {
187  /* Convert to NT format */
188  Timeout.QuadPart = lReadTimeout * -10000LL;
189  }
190 
191  Buffer.ReadTimeout = &Timeout;
192 
193  Status = NtSetInformationFile(hMailslot,
194  &Iosb,
195  &Buffer,
198  if (!NT_SUCCESS(Status))
199  {
200  DPRINT1("NtSetInformationFile failed (Status %x)!\n", Status);
202  return FALSE;
203  }
204 
205  return TRUE;
206 }
#define TRUE
Definition: types.h:120
#define LL
Definition: tui.h:72
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
static ULONG Timeout
Definition: ping.c:61
#define DPRINT1
Definition: precomp.h:8
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:3042