ReactOS 0.4.15-dev-8146-gdc0ed6d
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}
#define ConvertWin32AnsiObjectApiToUnicodeApi2(obj, name,...)
Definition: base_x.h:65
_In_ LPCSTR lpName
Definition: winbase.h:2789

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 {
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,
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);
106 }
107
108 return MailslotHandle;
109}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
return Iosb
Definition: create.c:4402
#define FILE_WRITE_THROUGH
Definition: from_kernel.h:26
Status
Definition: gdiplustypes.h:25
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_INHERIT
Definition: winternl.h:225
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define MAILSLOT_WAIT_FOREVER
Definition: finfo.c:19
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)
#define SYNCHRONIZE
Definition: nt_native.h:61
#define WRITE_DAC
Definition: nt_native.h:59
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:3789
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define DPRINT
Definition: sndvol32.h:73
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
_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:191
_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:409

◆ 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}
Definition: bufpool.h:45
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ FileMailslotQueryInformation
Definition: from_kernel.h:87
NTSYSAPI LONGLONG WINAPI RtlExtendedLargeIntegerDivide(LONGLONG, INT, INT *)
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
static ULONG Timeout
Definition: ping.c:61

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}
@ FileMailslotSetInformation
Definition: from_kernel.h:88
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:3096