1 /* Unit test suite for Ntdll file functions
3 * Copyright 2007 Jeff Latimer
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * We use function pointers here as there is no import library for NTDLL on
28 /* Define WIN32_NO_STATUS so MSVC does not give us duplicate macro
29 * definition errors when we get to winnt.h
31 #define WIN32_NO_STATUS
33 #include "wine/test.h"
36 static VOID (WINAPI *pRtlInitUnicodeString)( PUNICODE_STRING, LPCWSTR );
37 static VOID (WINAPI *pRtlFreeUnicodeString)(PUNICODE_STRING);
38 static NTSTATUS (WINAPI *pNtCreateMailslotFile)( PHANDLE, ULONG, POBJECT_ATTRIBUTES, PIO_STATUS_BLOCK,
39 ULONG, ULONG, ULONG, PLARGE_INTEGER );
40 static NTSTATUS (WINAPI *pNtClose)( PHANDLE );
42 static void nt_mailslot_test(void)
45 ACCESS_MASK DesiredAccess;
46 OBJECT_ATTRIBUTES attr;
51 LARGE_INTEGER TimeOut;
52 IO_STATUS_BLOCK IoStatusBlock;
55 WCHAR buffer1[] = { '\\','?','?','\\','M','A','I','L','S','L','O','T','\\',
56 'R',':','\\','F','R','E','D','\0' };
58 TimeOut.QuadPart = -1;
60 pRtlInitUnicodeString(&str, buffer1);
61 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
62 DesiredAccess = CreateOptions = MailslotQuota = MaxMessageSize = 0;
65 * Check for NULL pointer handling
67 rc = pNtCreateMailslotFile(NULL, DesiredAccess,
68 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
70 ok( rc == STATUS_ACCESS_VIOLATION, "rc = %x not c0000005 STATUS_ACCESS_VIOLATION\n", rc);
73 * Test to see if the Timeout can be NULL
75 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
76 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
78 ok( rc == STATUS_SUCCESS, "rc = %x not STATUS_SUCCESS\n", rc);
79 ok( hslot != 0, "Handle is invalid\n");
81 if ( rc == STATUS_SUCCESS ) rc = pNtClose(hslot);
84 * Test that the length field is checked properly
87 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
88 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
90 todo_wine ok( rc == STATUS_INVALID_PARAMETER, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc);
92 if (rc == STATUS_SUCCESS) pNtClose(hslot);
94 attr.Length = sizeof(OBJECT_ATTRIBUTES)+1;
95 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
96 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
98 todo_wine ok( rc == STATUS_INVALID_PARAMETER, "rc = %x not c000000d STATUS_INVALID_PARAMETER\n", rc);
100 if (rc == STATUS_SUCCESS) pNtClose(hslot);
103 * Test handling of a NULL unicode string in ObjectName
105 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
106 attr.ObjectName = NULL;
107 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
108 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
110 ok( rc == STATUS_OBJECT_PATH_SYNTAX_BAD, "rc = %x not c000003b STATUS_OBJECT_PATH_SYNTAX_BAD\n", rc);
112 if (rc == STATUS_SUCCESS) pNtClose(hslot);
117 InitializeObjectAttributes(&attr, &str, OBJ_CASE_INSENSITIVE, 0, NULL);
118 rc = pNtCreateMailslotFile(&hslot, DesiredAccess,
119 &attr, &IoStatusBlock, CreateOptions, MailslotQuota, MaxMessageSize,
121 ok( rc == STATUS_SUCCESS, "Create MailslotFile failed rc = %x %u\n", rc, GetLastError());
122 ok( hslot != 0, "Handle is invalid\n");
124 rc = pNtClose(hslot);
125 ok( rc == STATUS_SUCCESS, "NtClose failed\n");
127 pRtlFreeUnicodeString(&str);
132 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
135 skip("not running on NT, skipping test\n");
139 pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
140 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
141 pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile");
142 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");