ReactOS 0.4.16-dev-340-g0540c21
om.c File Reference
#include "ntdll_test.h"
#include "winternl.h"
#include "stdio.h"
#include "winnt.h"
#include "stdlib.h"
Include dependency graph for om.c:

Go to the source code of this file.

Macros

#define KEYEDEVENT_WAIT   0x0001
 
#define KEYEDEVENT_WAKE   0x0002
 
#define KEYEDEVENT_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | 0x0003)
 
#define ROUND_UP(value, alignment)   (((value) + ((alignment) - 1)) & ~((alignment)-1))
 
#define DIRECTORY_QUERY   (0x0001)
 
#define SYMBOLIC_LINK_QUERY   0x0001
 
#define DIR_TEST_CREATE_OPEN(n, e)
 

Functions

static HANDLE (WINAPI *pCreateWaitableTimerA)(SECURITY_ATTRIBUTES *
 
static BOOLEAN (WINAPI *pRtlCreateUnicodeStringFromAsciiz)(PUNICODE_STRING
 
static VOID (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING
 
static NTSTATUS (WINAPI *pNtCreateEvent)(PHANDLE
 
static LPCSTR wine_dbgstr_us (const UNICODE_STRING *us)
 
static int strncmpW (const WCHAR *str1, const WCHAR *str2, int n)
 
static void test_case_sensitive (void)
 
static void test_namespace_pipe (void)
 
static BOOL is_correct_dir (HANDLE dir, const char *name)
 
static HANDLE get_base_dir (void)
 
static void test_name_collisions (void)
 
static void test_all_kernel_objects (UINT line, OBJECT_ATTRIBUTES *attr, NTSTATUS create_expect, NTSTATUS open_expect)
 
static void test_name_limits (void)
 
static void test_directory (void)
 
static void test_symboliclink (void)
 
static void test_query_object (void)
 
static BOOL winver_equal_or_newer (WORD major, WORD minor)
 
static void test_query_object_types (void)
 
static void test_type_mismatch (void)
 
static void test_event (void)
 
static DWORD WINAPI keyed_event_thread (void *arg)
 
static void test_keyed_events (void)
 
static void test_null_device (void)
 
static DWORD WINAPI mutant_thread (void *arg)
 
static void test_mutant (void)
 
 START_TEST (om)
 

Variables

static BOOL
 
static LPCSTR
 
static LPCWSTR
 
static ACCESS_MASK
 
static const POBJECT_ATTRIBUTES
 
static const BOOLEAN
 
static PULONG
 
static EVENT_INFORMATION_CLASS
 
static PVOID
 
static ULONG
 
static PIO_STATUS_BLOCK
 
static PLARGE_INTEGER
 
static MUTANT_INFORMATION_CLASS
 
static PLONG
 
static const LONG
 
static const TIMER_TYPE
 
static const const HANDLE
 
static PUNICODE_STRING
 
static OBJECT_INFORMATION_CLASS
 
static const WCHAR keyed_nameW []
 

Macro Definition Documentation

◆ DIR_TEST_CREATE_OPEN

#define DIR_TEST_CREATE_OPEN (   n,
  e 
)
Value:
do { \
HANDLE h; \
pRtlCreateUnicodeStringFromAsciiz(&str, n); \
status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr ); \
ok( status == e, "NtCreateDirectoryObject(%s) got %08x\n", n, status ); \
if (!status) pNtClose( h ); \
status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr ); \
ok( status == e, "NtOpenDirectoryObject(%s) got %08x\n", n, status ); \
if (!status) pNtClose( h ); \
pRtlFreeUnicodeString(&str); \
} while(0)
GLdouble n
Definition: glext.h:7729
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define e
Definition: ke_i.h:82
#define DIRECTORY_QUERY
Definition: om.c:211
const WCHAR * str
Definition: cookie.c:202
Definition: ps.c:97

Definition at line 214 of file om.c.

◆ DIRECTORY_QUERY

#define DIRECTORY_QUERY   (0x0001)

Definition at line 211 of file om.c.

◆ KEYEDEVENT_ALL_ACCESS

#define KEYEDEVENT_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | 0x0003)

Definition at line 76 of file om.c.

◆ KEYEDEVENT_WAIT

#define KEYEDEVENT_WAIT   0x0001

Definition at line 74 of file om.c.

◆ KEYEDEVENT_WAKE

#define KEYEDEVENT_WAKE   0x0002

Definition at line 75 of file om.c.

◆ ROUND_UP

#define ROUND_UP (   value,
  alignment 
)    (((value) + ((alignment) - 1)) & ~((alignment)-1))

Definition at line 78 of file om.c.

◆ SYMBOLIC_LINK_QUERY

#define SYMBOLIC_LINK_QUERY   0x0001

Definition at line 212 of file om.c.

Function Documentation

◆ BOOLEAN()

static BOOLEAN ( WINAPI pRtlCreateUnicodeStringFromAsciiz)
static

◆ get_base_dir()

static HANDLE get_base_dir ( void  )
static

Definition at line 243 of file om.c.

244{
245 static const char objname[] = "om.c_get_base_dir_obj";
249 HANDLE dir, h;
250 char name[40];
251
252 h = CreateMutexA(NULL, FALSE, objname);
253 ok(h != 0, "CreateMutexA failed got ret=%p (%d)\n", h, GetLastError());
255
256 sprintf( name, "\\BaseNamedObjects\\Session\\%u", NtCurrentTeb()->Peb->SessionId );
257 pRtlCreateUnicodeStringFromAsciiz(&str, name );
258 status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
259 pRtlFreeUnicodeString(&str);
260 if (!status && is_correct_dir( dir, objname )) goto done;
261 if (!status) pNtClose( dir );
262
263 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects");
264 status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
265 pRtlFreeUnicodeString(&str);
266 if (!status && is_correct_dir( dir, objname )) goto done;
267 if (!status) pNtClose( dir );
268
269 dir = 0;
270
271done:
272 pNtClose( h );
273 return dir;
274}
unsigned int dir
Definition: maze.c:112
#define ok(value,...)
Definition: atltest.h:57
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
PPEB Peb
Definition: dllmain.c:27
#define OBJ_OPENIF
Definition: winternl.h:229
#define NtCurrentTeb
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static BOOL is_correct_dir(HANDLE dir, const char *name)
Definition: om.c:227
ULONG SessionId
Definition: btrfs_drv.h:1919
Definition: name.c:39
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexA(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:563
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_name_collisions(), test_name_limits(), and test_symboliclink().

◆ HANDLE()

static HANDLE ( WINAPI pCreateWaitableTimerA)
static

◆ is_correct_dir()

static BOOL is_correct_dir ( HANDLE  dir,
const char name 
)
static

Definition at line 227 of file om.c.

228{
232 HANDLE h = 0;
233
234 pRtlCreateUnicodeStringFromAsciiz(&str, name);
236 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
237 pRtlFreeUnicodeString(&str);
238 if (h) pNtClose( h );
240}
#define GENERIC_ALL
Definition: nt_native.h:92
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:114

Referenced by get_base_dir().

◆ keyed_event_thread()

static DWORD WINAPI keyed_event_thread ( void arg)
static

Definition at line 1707 of file om.c.

1708{
1709 HANDLE handle;
1714 ULONG_PTR i;
1715
1716 attr.Length = sizeof(attr);
1717 attr.RootDirectory = 0;
1718 attr.ObjectName = &str;
1719 attr.Attributes = 0;
1720 attr.SecurityDescriptor = NULL;
1721 attr.SecurityQualityOfService = NULL;
1723
1724 status = pNtOpenKeyedEvent( &handle, KEYEDEVENT_ALL_ACCESS, &attr );
1725 ok( !status, "NtOpenKeyedEvent failed %x\n", status );
1726
1727 for (i = 0; i < 20; i++)
1728 {
1729 if (i & 1)
1730 status = pNtWaitForKeyedEvent( handle, (void *)(i * 2), 0, NULL );
1731 else
1732 status = pNtReleaseKeyedEvent( handle, (void *)(i * 2), 0, NULL );
1733 ok( status == STATUS_SUCCESS, "%li: failed %x\n", i, status );
1734 Sleep( 20 - i );
1735 }
1736
1737 status = pNtReleaseKeyedEvent( handle, (void *)0x1234, 0, NULL );
1738 ok( status == STATUS_SUCCESS, "NtReleaseKeyedEvent %x\n", status );
1739
1740 timeout.QuadPart = -10000;
1741 status = pNtWaitForKeyedEvent( handle, (void *)0x5678, 0, &timeout );
1742 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1743 status = pNtReleaseKeyedEvent( handle, (void *)0x9abc, 0, &timeout );
1744 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1745
1746 NtClose( handle );
1747 return 0;
1748}
#define STATUS_TIMEOUT
Definition: d3dkmdt.h:49
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
static const WCHAR keyed_nameW[]
Definition: om.c:1704
#define KEYEDEVENT_ALL_ACCESS
Definition: om.c:76
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: dhcpd.h:245
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by test_keyed_events().

◆ mutant_thread()

static DWORD WINAPI mutant_thread ( void arg)
static

Definition at line 1982 of file om.c.

1983{
1986 HANDLE mutant;
1987 DWORD ret;
1988
1989 mutant = arg;
1990 ret = WaitForSingleObject( mutant, 1000 );
1991 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject failed %08x\n", ret );
1992
1993 memset(&info, 0xcc, sizeof(info));
1994 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), NULL);
1995 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
1996 ok( info.CurrentCount == 0, "expected 0, got %d\n", info.CurrentCount );
1997 ok( info.OwnedByCaller == TRUE, "expected TRUE, got %d\n", info.OwnedByCaller );
1998 ok( info.AbandonedState == FALSE, "expected FALSE, got %d\n", info.AbandonedState );
1999 /* abandon mutant */
2000
2001 return 0;
2002}
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
@ MutantBasicInformation
Definition: extypes.h:323
#define memset(x, y, z)
Definition: compat.h:39
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
int ret
#define WAIT_OBJECT_0
Definition: winbase.h:432
void * arg
Definition: msvc.h:10

Referenced by test_mutant().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtCreateEvent)
static

◆ START_TEST()

START_TEST ( om  )

Definition at line 2097 of file om.c.

2098{
2099 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
2100 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
2101
2102 if (!hntdll)
2103 {
2104 skip("not running on NT, skipping test\n");
2105 return;
2106 }
2107
2108 pCreateWaitableTimerA = (void *)GetProcAddress(hkernel32, "CreateWaitableTimerA");
2109
2110 pRtlCreateUnicodeStringFromAsciiz = (void *)GetProcAddress(hntdll, "RtlCreateUnicodeStringFromAsciiz");
2111 pRtlFreeUnicodeString = (void *)GetProcAddress(hntdll, "RtlFreeUnicodeString");
2112 pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent");
2113 pNtCreateJobObject = (void *)GetProcAddress(hntdll, "NtCreateJobObject");
2114 pNtOpenJobObject = (void *)GetProcAddress(hntdll, "NtOpenJobObject");
2115 pNtCreateKey = (void *)GetProcAddress(hntdll, "NtCreateKey");
2116 pNtOpenKey = (void *)GetProcAddress(hntdll, "NtOpenKey");
2117 pNtDeleteKey = (void *)GetProcAddress(hntdll, "NtDeleteKey");
2118 pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile");
2119 pNtCreateMutant = (void *)GetProcAddress(hntdll, "NtCreateMutant");
2120 pNtOpenEvent = (void *)GetProcAddress(hntdll, "NtOpenEvent");
2121 pNtQueryEvent = (void *)GetProcAddress(hntdll, "NtQueryEvent");
2122 pNtPulseEvent = (void *)GetProcAddress(hntdll, "NtPulseEvent");
2123 pNtOpenMutant = (void *)GetProcAddress(hntdll, "NtOpenMutant");
2124 pNtQueryMutant = (void *)GetProcAddress(hntdll, "NtQueryMutant");
2125 pNtReleaseMutant = (void *)GetProcAddress(hntdll, "NtReleaseMutant");
2126 pNtOpenFile = (void *)GetProcAddress(hntdll, "NtOpenFile");
2127 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
2128 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
2129 pNtCreateNamedPipeFile = (void *)GetProcAddress(hntdll, "NtCreateNamedPipeFile");
2130 pNtOpenDirectoryObject = (void *)GetProcAddress(hntdll, "NtOpenDirectoryObject");
2131 pNtCreateDirectoryObject= (void *)GetProcAddress(hntdll, "NtCreateDirectoryObject");
2132 pNtOpenSymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtOpenSymbolicLinkObject");
2133 pNtCreateSymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtCreateSymbolicLinkObject");
2134 pNtQuerySymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtQuerySymbolicLinkObject");
2135 pNtCreateSemaphore = (void *)GetProcAddress(hntdll, "NtCreateSemaphore");
2136 pNtOpenSemaphore = (void *)GetProcAddress(hntdll, "NtOpenSemaphore");
2137 pNtCreateTimer = (void *)GetProcAddress(hntdll, "NtCreateTimer");
2138 pNtOpenTimer = (void *)GetProcAddress(hntdll, "NtOpenTimer");
2139 pNtCreateSection = (void *)GetProcAddress(hntdll, "NtCreateSection");
2140 pNtOpenSection = (void *)GetProcAddress(hntdll, "NtOpenSection");
2141 pNtQueryObject = (void *)GetProcAddress(hntdll, "NtQueryObject");
2142 pNtReleaseSemaphore = (void *)GetProcAddress(hntdll, "NtReleaseSemaphore");
2143 pNtCreateKeyedEvent = (void *)GetProcAddress(hntdll, "NtCreateKeyedEvent");
2144 pNtOpenKeyedEvent = (void *)GetProcAddress(hntdll, "NtOpenKeyedEvent");
2145 pNtWaitForKeyedEvent = (void *)GetProcAddress(hntdll, "NtWaitForKeyedEvent");
2146 pNtReleaseKeyedEvent = (void *)GetProcAddress(hntdll, "NtReleaseKeyedEvent");
2147 pNtCreateIoCompletion = (void *)GetProcAddress(hntdll, "NtCreateIoCompletion");
2148 pNtOpenIoCompletion = (void *)GetProcAddress(hntdll, "NtOpenIoCompletion");
2149 pNtQuerySystemInformation = (void *)GetProcAddress(hntdll, "NtQuerySystemInformation");
2150
2160 test_event();
2161 test_mutant();
2164}
#define skip(...)
Definition: atltest.h:64
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
static HINSTANCE hkernel32
Definition: process.c:66
static HINSTANCE hntdll
Definition: process.c:66
static void test_name_limits(void)
Definition: om.c:457
static void test_directory(void)
Definition: om.c:900
static void test_case_sensitive(void)
Definition: om.c:93
static void test_type_mismatch(void)
Definition: om.c:1645
static void test_namespace_pipe(void)
Definition: om.c:144
static void test_symboliclink(void)
Definition: om.c:1160
static void test_query_object_types(void)
Definition: om.c:1557
static void test_mutant(void)
Definition: om.c:2004
static void test_event(void)
Definition: om.c:1667
static void test_name_collisions(void)
Definition: om.c:276
static void test_keyed_events(void)
Definition: om.c:1750
static void test_query_object(void)
Definition: om.c:1289
static void test_null_device(void)
Definition: om.c:1891

◆ strncmpW()

static int strncmpW ( const WCHAR str1,
const WCHAR str2,
int  n 
)
inlinestatic

Definition at line 86 of file om.c.

87{
88 if (n <= 0) return 0;
89 while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; }
90 return *str1 - *str2;
91}

◆ test_all_kernel_objects()

static void test_all_kernel_objects ( UINT  line,
OBJECT_ATTRIBUTES attr,
NTSTATUS  create_expect,
NTSTATUS  open_expect 
)
static

Definition at line 383 of file om.c.

385{
388 NTSTATUS status, status2;
389 HANDLE ret, ret2;
390
391 pRtlCreateUnicodeStringFromAsciiz( &target, "\\DosDevices" );
392 size.QuadPart = 4096;
393
394 status = pNtCreateMutant( &ret, GENERIC_ALL, attr, FALSE );
395 ok( status == create_expect, "%u: NtCreateMutant failed %x\n", line, status );
396 status2 = pNtOpenMutant( &ret2, GENERIC_ALL, attr );
397 ok( status2 == open_expect, "%u: NtOpenMutant failed %x\n", line, status2 );
398 if (!status) pNtClose( ret );
399 if (!status2) pNtClose( ret2 );
400 status = pNtCreateSemaphore( &ret, GENERIC_ALL, attr, 1, 2 );
401 ok( status == create_expect, "%u: NtCreateSemaphore failed %x\n", line, status );
402 status2 = pNtOpenSemaphore( &ret2, GENERIC_ALL, attr );
403 ok( status2 == open_expect, "%u: NtOpenSemaphore failed %x\n", line, status2 );
404 if (!status) pNtClose( ret );
405 if (!status2) pNtClose( ret2 );
406 status = pNtCreateEvent( &ret, GENERIC_ALL, attr, 1, 0 );
407 ok( status == create_expect, "%u: NtCreateEvent failed %x\n", line, status );
408 status2 = pNtOpenEvent( &ret2, GENERIC_ALL, attr );
409 ok( status2 == open_expect, "%u: NtOpenEvent failed %x\n", line, status2 );
410 if (!status) pNtClose( ret );
411 if (!status2) pNtClose( ret2 );
412 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, attr, 0 );
413 ok( status == create_expect, "%u: NtCreateKeyedEvent failed %x\n", line, status );
414 status2 = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, attr );
415 ok( status2 == open_expect, "%u: NtOpenKeyedEvent failed %x\n", line, status2 );
416 if (!status) pNtClose( ret );
417 if (!status2) pNtClose( ret2 );
418 status = pNtCreateTimer( &ret, GENERIC_ALL, attr, NotificationTimer );
419 ok( status == create_expect, "%u: NtCreateTimer failed %x\n", line, status );
420 status2 = pNtOpenTimer( &ret2, GENERIC_ALL, attr );
421 ok( status2 == open_expect, "%u: NtOpenTimer failed %x\n", line, status2 );
422 if (!status) pNtClose( ret );
423 if (!status2) pNtClose( ret2 );
424 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, attr, 0 );
425 ok( status == create_expect, "%u: NtCreateCompletion failed %x\n", line, status );
426 status2 = pNtOpenIoCompletion( &ret2, GENERIC_ALL, attr );
427 ok( status2 == open_expect, "%u: NtOpenCompletion failed %x\n", line, status2 );
428 if (!status) pNtClose( ret );
429 if (!status2) pNtClose( ret2 );
430 status = pNtCreateJobObject( &ret, GENERIC_ALL, attr );
431 ok( status == create_expect, "%u: NtCreateJobObject failed %x\n", line, status );
432 status2 = pNtOpenJobObject( &ret2, GENERIC_ALL, attr );
433 ok( status2 == open_expect, "%u: NtOpenJobObject failed %x\n", line, status2 );
434 if (!status) pNtClose( ret );
435 if (!status2) pNtClose( ret2 );
436 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, attr );
437 ok( status == create_expect, "%u: NtCreateDirectoryObject failed %x\n", line, status );
438 status2 = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, attr );
439 ok( status2 == open_expect, "%u: NtOpenDirectoryObject failed %x\n", line, status2 );
440 if (!status) pNtClose( ret );
441 if (!status2) pNtClose( ret2 );
442 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, attr, &target );
443 ok( status == create_expect, "%u: NtCreateSymbolicLinkObject failed %x\n", line, status );
444 status2 = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, attr );
445 ok( status2 == open_expect, "%u: NtOpenSymbolicLinkObject failed %x\n", line, status2 );
446 if (!status) pNtClose( ret );
447 if (!status2) pNtClose( ret2 );
448 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
449 ok( status == create_expect, "%u: NtCreateSection failed %x\n", line, status );
450 status2 = pNtOpenSection( &ret2, SECTION_MAP_WRITE, attr );
451 ok( status2 == open_expect, "%u: NtOpenSection failed %x\n", line, status2 );
452 if (!status) pNtClose( ret );
453 if (!status2) pNtClose( ret2 );
454 pRtlFreeUnicodeString( &target );
455}
GLsizeiptr size
Definition: glext.h:5919
GLenum target
Definition: glext.h:7315
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SECTION_MAP_WRITE
Definition: nt_native.h:1288
#define PAGE_READWRITE
Definition: nt_native.h:1304
@ NotificationTimer
Definition: parser.c:49

Referenced by test_name_limits().

◆ test_case_sensitive()

static void test_case_sensitive ( void  )
static

Definition at line 93 of file om.c.

94{
95 static const WCHAR buffer1[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t',0};
96 static const WCHAR buffer2[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','T','e','s','t',0};
97 static const WCHAR buffer3[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','T','E','s','t',0};
98 static const WCHAR buffer4[] = {'\\','B','A','S','E','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t',0};
102 HANDLE Event, Mutant, h;
103
104 pRtlInitUnicodeString(&str, buffer1);
106 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
107 ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status);
108
109 status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, FALSE, FALSE);
111 "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION or STATUS_OBJECT_TYPE_MISMATCH got (%08x)\n", status);
112
113 pRtlInitUnicodeString(&str, buffer2);
115 status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, FALSE, FALSE);
116 ok(status == STATUS_SUCCESS, "Failed to create Event(%08x)\n", status);
117
118 pRtlInitUnicodeString(&str, buffer3);
120 status = pNtOpenMutant(&h, GENERIC_ALL, &attr);
122 "NtOpenMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status);
123
124 pNtClose(Mutant);
125
126 pRtlInitUnicodeString(&str, buffer4);
128 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
130 "NtCreateMutant should have failed with STATUS_OBJECT_NAME_COLLISION or STATUS_OBJECT_TYPE_MISMATCH got (%08x)\n", status);
131
132 status = pNtCreateEvent(&h, GENERIC_ALL, &attr, FALSE, FALSE);
134 "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION got(%08x)\n", status);
135
136 attr.Attributes = 0;
137 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
139 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08x)\n", status);
140
141 pNtClose(Event);
142}
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: d3dkmdt.h:46
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define STATUS_OBJECT_PATH_NOT_FOUND
Definition: udferr_usr.h:151
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by START_TEST().

◆ test_directory()

static void test_directory ( void  )
static

Definition at line 900 of file om.c.

901{
905 HANDLE dir, dir1, h, h2;
906 BOOL is_nt4;
907
908 /* No name and/or no attributes */
909 status = pNtCreateDirectoryObject(NULL, DIRECTORY_QUERY, &attr);
911 "NtCreateDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08x)\n", status);
912 status = pNtOpenDirectoryObject(NULL, DIRECTORY_QUERY, &attr);
914 "NtOpenDirectoryObject should have failed with STATUS_ACCESS_VIOLATION got(%08x)\n", status);
915
916 status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, NULL);
917 ok(status == STATUS_SUCCESS, "Failed to create Directory without attributes(%08x)\n", status);
918 pNtClose(h);
919 status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, NULL);
921 "NtOpenDirectoryObject should have failed with STATUS_INVALID_PARAMETER got(%08x)\n", status);
922
924 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
925 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
926 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
927 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08x\n", status );
928
929 /* Bad name */
931
932 pRtlCreateUnicodeStringFromAsciiz(&str, "");
933 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
934 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
935 pNtClose(h);
936 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
937 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08x\n", status );
938 pRtlFreeUnicodeString(&str);
939 pNtClose(dir);
940
942 DIR_TEST_CREATE_OPEN( "\\BaseNamedObjects\\", STATUS_OBJECT_NAME_INVALID );
943 DIR_TEST_CREATE_OPEN( "\\\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID );
944 DIR_TEST_CREATE_OPEN( "\\BaseNamedObjects\\\\om.c-test", STATUS_OBJECT_NAME_INVALID );
945 DIR_TEST_CREATE_OPEN( "\\BaseNamedObjects\\om.c-test\\", STATUS_OBJECT_PATH_NOT_FOUND );
946
947 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\om.c-test");
948 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
949 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
950 status = pNtOpenDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
951 ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status );
952 pRtlFreeUnicodeString(&str);
953 pNtClose(h);
954 pNtClose(dir1);
955
956
957 /* Use of root directory */
958
959 /* Can't use symlinks as a directory */
960 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\Local");
962 status = pNtOpenSymbolicLinkObject(&dir, SYMBOLIC_LINK_QUERY, &attr);
963 is_nt4 = (status == STATUS_OBJECT_NAME_NOT_FOUND); /* nt4 doesn't have Local\\ symlink */
964 if (!is_nt4)
965 {
966 WCHAR buffer[256];
967 ULONG len, full_len;
968
969 ok(status == STATUS_SUCCESS, "Failed to open SymbolicLink(%08x)\n", status);
970 pRtlFreeUnicodeString(&str);
972 pRtlCreateUnicodeStringFromAsciiz(&str, "one more level");
973 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
974 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateDirectoryObject got %08x\n", status );
975 pRtlFreeUnicodeString(&str);
976
977 pRtlCreateUnicodeStringFromAsciiz( &str, "\\BaseNamedObjects\\Local\\om.c-test" );
979 status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
980 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
981 pRtlFreeUnicodeString( &str );
982 pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test" );
984 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
985 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "Failed to open directory %08x\n", status );
986 if (!status) pNtClose(h);
987 pRtlFreeUnicodeString( &str );
988
989 pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-event" );
990 InitializeObjectAttributes( &attr, &str, 0, dir1, NULL );
991 status = pNtCreateEvent( &h, GENERIC_ALL, &attr, 1, 0 );
992 ok( status == STATUS_SUCCESS, "NtCreateEvent failed %x\n", status );
993 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
994 ok( status == STATUS_SUCCESS, "NtOpenEvent failed %x\n", status );
995 pNtClose( h2 );
996 pRtlFreeUnicodeString( &str );
997 pRtlCreateUnicodeStringFromAsciiz( &str, "om.c-test\\om.c-event" );
999 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
1000 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenEvent failed %x\n", status );
1001 pRtlFreeUnicodeString( &str );
1002 pRtlCreateUnicodeStringFromAsciiz( &str, "\\BasedNamedObjects\\Local\\om.c-test\\om.c-event" );
1004 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
1005 ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "NtOpenEvent failed %x\n", status );
1006 pRtlFreeUnicodeString( &str );
1007 pNtClose( h );
1008 pNtClose( dir1 );
1009
1010 str.Buffer = buffer;
1011 str.MaximumLength = sizeof(buffer);
1012 len = 0xdeadbeef;
1013 memset( buffer, 0xaa, sizeof(buffer) );
1014 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1015 ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status );
1016 if (status != STATUS_SUCCESS)
1017 goto error;
1018 full_len = str.Length + sizeof(WCHAR);
1019 ok( len == full_len, "bad length %u/%u\n", len, full_len );
1020 if (len == full_len)
1021 ok( buffer[len / sizeof(WCHAR) - 1] == 0, "no terminating null\n" );
1022
1023 str.MaximumLength = str.Length;
1024 len = 0xdeadbeef;
1025 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1026 ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status );
1027 ok( len == full_len, "bad length %u/%u\n", len, full_len );
1028
1029 str.MaximumLength = 0;
1030 len = 0xdeadbeef;
1031 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1032 ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08x\n", status );
1033 ok( len == full_len, "bad length %u/%u\n", len, full_len );
1034
1035 str.MaximumLength = str.Length + sizeof(WCHAR);
1036 len = 0xdeadbeef;
1037 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1038 ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08x\n", status );
1039 ok( len == full_len, "bad length %u/%u\n", len, full_len );
1040
1041error:
1042 pNtClose(dir);
1043 }
1044
1045 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects");
1047 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1048 ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status );
1049 pRtlFreeUnicodeString(&str);
1050
1052 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1053 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenDirectoryObject got %08x\n", status );
1054
1061
1062 pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test");
1063 status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
1064 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1065 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1066 ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status );
1067 pRtlFreeUnicodeString(&str);
1068
1069 pNtClose(h);
1070 pNtClose(dir1);
1071 pNtClose(dir);
1072
1073 /* Nested directories */
1074 pRtlCreateUnicodeStringFromAsciiz(&str, "\\");
1076 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1077 ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status );
1079 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1080 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08x\n", status );
1081 pRtlFreeUnicodeString(&str);
1082 pNtClose(dir);
1083
1085 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\om.c-test");
1086 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1087 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1088 pRtlFreeUnicodeString(&str);
1089 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\om.c-test\\one more level");
1090 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1091 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1092 pRtlFreeUnicodeString(&str);
1093 pNtClose(h);
1095 pRtlCreateUnicodeStringFromAsciiz(&str, "one more level");
1096 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1097 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1098 pRtlFreeUnicodeString(&str);
1099 pNtClose(h);
1100
1101 pNtClose(dir);
1102
1103 if (!is_nt4)
1104 {
1106 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\Global\\om.c-test");
1107 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1108 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1109 pRtlFreeUnicodeString(&str);
1110 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects\\Local\\om.c-test\\one more level");
1111 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1112 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1113 pRtlFreeUnicodeString(&str);
1114 pNtClose(h);
1116 pRtlCreateUnicodeStringFromAsciiz(&str, "one more level");
1117 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1118 ok( status == STATUS_SUCCESS, "Failed to create directory %08x\n", status );
1119 pRtlFreeUnicodeString(&str);
1120 pNtClose(h);
1121 pNtClose(dir);
1122 }
1123
1124 /* Create other objects using RootDirectory */
1125
1127 pRtlCreateUnicodeStringFromAsciiz(&str, "\\BaseNamedObjects");
1128 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1129 ok( status == STATUS_SUCCESS, "Failed to open directory %08x\n", status );
1130 pRtlFreeUnicodeString(&str);
1132
1133 /* Test invalid paths */
1134 pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-mutant");
1135 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1137 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status);
1138 pRtlFreeUnicodeString(&str);
1139 pRtlCreateUnicodeStringFromAsciiz(&str, "\\om.c-mutant\\");
1140 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1142 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status);
1143 pRtlFreeUnicodeString(&str);
1144
1145 pRtlCreateUnicodeStringFromAsciiz(&str, "om.c\\-mutant");
1146 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1148 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08x)\n", status);
1149 pRtlFreeUnicodeString(&str);
1150
1151 pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-mutant");
1152 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1153 ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status);
1154 pRtlFreeUnicodeString(&str);
1155 pNtClose(h);
1156
1157 pNtClose(dir);
1158}
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
#define error(str)
Definition: mkdosfs.c:1605
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:295
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define SYMBOLIC_LINK_QUERY
Definition: om.c:212
#define DIR_TEST_CREATE_OPEN(n, e)
Definition: om.c:214
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

Referenced by START_TEST().

◆ test_event()

static void test_event ( void  )
static

Definition at line 1667 of file om.c.

1668{
1669 HANDLE Event;
1670 HANDLE Event2;
1675 static const WCHAR eventName[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','t','e','s','t','E','v','e','n','t',0};
1676
1677 pRtlInitUnicodeString(&str, eventName);
1679
1680 status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, 1, 0);
1681 ok( status == STATUS_SUCCESS, "NtCreateEvent failed %08x\n", status );
1682
1683 status = pNtPulseEvent(Event, NULL);
1684 ok( status == STATUS_SUCCESS, "NtPulseEvent failed %08x\n", status );
1685
1686 status = pNtQueryEvent(Event, EventBasicInformation, &info, sizeof(info), NULL);
1687 ok( status == STATUS_SUCCESS, "NtQueryEvent failed %08x\n", status );
1688 ok( info.EventType == 1 && info.EventState == 0,
1689 "NtQueryEvent failed, expected 1 0, got %d %d\n", info.EventType, info.EventState );
1690
1691 status = pNtOpenEvent(&Event2, GENERIC_ALL, &attr);
1692 ok( status == STATUS_SUCCESS, "NtOpenEvent failed %08x\n", status );
1693
1694 pNtClose(Event);
1695
1696 status = pNtQueryEvent(Event2, EventBasicInformation, &info, sizeof(info), NULL);
1697 ok( status == STATUS_SUCCESS, "NtQueryEvent failed %08x\n", status );
1698 ok( info.EventType == 1 && info.EventState == 0,
1699 "NtQueryEvent failed, expected 1 0, got %d %d\n", info.EventType, info.EventState );
1700
1701 pNtClose(Event2);
1702}
@ EventBasicInformation
Definition: extypes.h:357

Referenced by START_TEST().

◆ test_keyed_events()

static void test_keyed_events ( void  )
static

Definition at line 1750 of file om.c.

1751{
1757 ULONG_PTR i;
1758
1759 if (!pNtCreateKeyedEvent)
1760 {
1761 win_skip( "Keyed events not supported\n" );
1762 return;
1763 }
1764
1765 attr.Length = sizeof(attr);
1766 attr.RootDirectory = 0;
1767 attr.ObjectName = &str;
1768 attr.Attributes = 0;
1769 attr.SecurityDescriptor = NULL;
1770 attr.SecurityQualityOfService = NULL;
1772
1773 status = pNtCreateKeyedEvent( &handle, KEYEDEVENT_ALL_ACCESS | SYNCHRONIZE, &attr, 0 );
1774 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1775
1777 ok( status == 0, "WaitForSingleObject %x\n", status );
1778
1779 timeout.QuadPart = -100000;
1780 status = pNtWaitForKeyedEvent( handle, (void *)255, 0, &timeout );
1781 ok( status == STATUS_INVALID_PARAMETER_1, "NtWaitForKeyedEvent %x\n", status );
1782 status = pNtReleaseKeyedEvent( handle, (void *)255, 0, &timeout );
1783 ok( status == STATUS_INVALID_PARAMETER_1, "NtReleaseKeyedEvent %x\n", status );
1784
1785 status = pNtWaitForKeyedEvent( handle, (void *)254, 0, &timeout );
1786 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1787 status = pNtReleaseKeyedEvent( handle, (void *)254, 0, &timeout );
1788 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1789
1790 status = pNtWaitForKeyedEvent( handle, NULL, 0, &timeout );
1791 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1792 status = pNtReleaseKeyedEvent( handle, NULL, 0, &timeout );
1793 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1794
1795 status = pNtWaitForKeyedEvent( (HANDLE)0xdeadbeef, (void *)9, 0, &timeout );
1796 ok( status == STATUS_INVALID_PARAMETER_1, "NtWaitForKeyedEvent %x\n", status );
1797 status = pNtReleaseKeyedEvent( (HANDLE)0xdeadbeef, (void *)9, 0, &timeout );
1798 ok( status == STATUS_INVALID_PARAMETER_1, "NtReleaseKeyedEvent %x\n", status );
1799
1800 status = pNtWaitForKeyedEvent( (HANDLE)0xdeadbeef, (void *)8, 0, &timeout );
1801 ok( status == STATUS_INVALID_HANDLE, "NtWaitForKeyedEvent %x\n", status );
1802 status = pNtReleaseKeyedEvent( (HANDLE)0xdeadbeef, (void *)8, 0, &timeout );
1803 ok( status == STATUS_INVALID_HANDLE, "NtReleaseKeyedEvent %x\n", status );
1804
1806 for (i = 0; i < 20; i++)
1807 {
1808 if (i & 1)
1809 status = pNtReleaseKeyedEvent( handle, (void *)(i * 2), 0, NULL );
1810 else
1811 status = pNtWaitForKeyedEvent( handle, (void *)(i * 2), 0, NULL );
1812 ok( status == STATUS_SUCCESS, "%li: failed %x\n", i, status );
1813 Sleep( i );
1814 }
1815 status = pNtWaitForKeyedEvent( handle, (void *)0x1234, 0, &timeout );
1816 ok( status == STATUS_SUCCESS, "NtWaitForKeyedEvent %x\n", status );
1817 status = pNtWaitForKeyedEvent( handle, (void *)0x5678, 0, &timeout );
1818 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1819 status = pNtReleaseKeyedEvent( handle, (void *)0x9abc, 0, &timeout );
1820 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1821
1822 ok( WaitForSingleObject( thread, 30000 ) == 0, "wait failed\n" );
1823
1824 NtClose( handle );
1825
1826 /* test access rights */
1827
1828 status = pNtCreateKeyedEvent( &handle, KEYEDEVENT_WAIT, &attr, 0 );
1829 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1830 status = pNtWaitForKeyedEvent( handle, (void *)8, 0, &timeout );
1831 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1832 status = pNtReleaseKeyedEvent( handle, (void *)8, 0, &timeout );
1833 ok( status == STATUS_ACCESS_DENIED, "NtReleaseKeyedEvent %x\n", status );
1834 NtClose( handle );
1835
1836 status = pNtCreateKeyedEvent( &handle, KEYEDEVENT_WAKE, &attr, 0 );
1837 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1838 status = pNtWaitForKeyedEvent( handle, (void *)8, 0, &timeout );
1839 ok( status == STATUS_ACCESS_DENIED, "NtWaitForKeyedEvent %x\n", status );
1840 status = pNtReleaseKeyedEvent( handle, (void *)8, 0, &timeout );
1841 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1842 NtClose( handle );
1843
1844 status = pNtCreateKeyedEvent( &handle, KEYEDEVENT_ALL_ACCESS, &attr, 0 );
1845 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1848 "WaitForSingleObject %x err %u\n", status, GetLastError() );
1849 status = pNtWaitForKeyedEvent( handle, (void *)8, 0, &timeout );
1850 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1851 status = pNtReleaseKeyedEvent( handle, (void *)8, 0, &timeout );
1852 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1853 NtClose( handle );
1854
1855 /* GENERIC_READ gives wait access */
1856 status = pNtCreateKeyedEvent( &handle, GENERIC_READ, &attr, 0 );
1857 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1858 status = pNtWaitForKeyedEvent( handle, (void *)8, 0, &timeout );
1859 ok( status == STATUS_TIMEOUT, "NtWaitForKeyedEvent %x\n", status );
1860 status = pNtReleaseKeyedEvent( handle, (void *)8, 0, &timeout );
1861 ok( status == STATUS_ACCESS_DENIED, "NtReleaseKeyedEvent %x\n", status );
1862 NtClose( handle );
1863
1864 /* GENERIC_WRITE gives wake access */
1865 status = pNtCreateKeyedEvent( &handle, GENERIC_WRITE, &attr, 0 );
1866 ok( !status, "NtCreateKeyedEvent failed %x\n", status );
1867 status = pNtWaitForKeyedEvent( handle, (void *)8, 0, &timeout );
1868 ok( status == STATUS_ACCESS_DENIED, "NtWaitForKeyedEvent %x\n", status );
1869 status = pNtReleaseKeyedEvent( handle, (void *)8, 0, &timeout );
1870 ok( status == STATUS_TIMEOUT, "NtReleaseKeyedEvent %x\n", status );
1871
1872 /* it's not an event */
1873 status = pNtPulseEvent( handle, NULL );
1874 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtPulseEvent %x\n", status );
1875
1876 status = pNtCreateEvent( &event, GENERIC_ALL, &attr, FALSE, FALSE );
1878 "CreateEvent %x\n", status );
1879
1880 NtClose( handle );
1881
1882 status = pNtCreateEvent( &event, GENERIC_ALL, &attr, FALSE, FALSE );
1883 ok( status == 0, "CreateEvent %x\n", status );
1884 status = pNtWaitForKeyedEvent( event, (void *)8, 0, &timeout );
1885 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtWaitForKeyedEvent %x\n", status );
1886 status = pNtReleaseKeyedEvent( event, (void *)8, 0, &timeout );
1887 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtReleaseKeyedEvent %x\n", status );
1888 NtClose( event );
1889}
static HANDLE thread
Definition: service.c:33
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define GENERIC_READ
Definition: compat.h:135
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
struct _cl_event * event
Definition: glext.h:7739
#define SYNCHRONIZE
Definition: nt_native.h:61
#define GENERIC_WRITE
Definition: nt_native.h:90
#define STATUS_INVALID_PARAMETER_1
Definition: ntstatus.h:475
#define KEYEDEVENT_WAIT
Definition: om.c:74
#define KEYEDEVENT_WAKE
Definition: om.c:75
static DWORD WINAPI keyed_event_thread(void *arg)
Definition: om.c:1707
#define win_skip
Definition: test.h:163
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define WAIT_FAILED
Definition: winbase.h:439

Referenced by START_TEST().

◆ test_mutant()

static void test_mutant ( void  )
static

Definition at line 2004 of file om.c.

2005{
2006 static const WCHAR name[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s',
2007 '\\','t','e','s','t','_','m','u','t','a','n','t',0};
2012 HANDLE mutant;
2013 HANDLE thread;
2014 DWORD ret;
2015 ULONG len;
2016 LONG prev;
2017
2018 pRtlInitUnicodeString(&str, name);
2020 status = pNtCreateMutant(&mutant, GENERIC_ALL, &attr, TRUE);
2021 ok( status == STATUS_SUCCESS, "Failed to create Mutant(%08x)\n", status );
2022
2023 /* bogus */
2024 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, 0, NULL);
2026 "Failed to NtQueryMutant, expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status );
2027 status = pNtQueryMutant(mutant, 0x42, &info, sizeof(info), NULL);
2028 ok( status == STATUS_INVALID_INFO_CLASS || broken(status == STATUS_NOT_IMPLEMENTED), /* 32-bit on Vista/2k8 */
2029 "Failed to NtQueryMutant, expected STATUS_INVALID_INFO_CLASS, got %08x\n", status );
2030 status = pNtQueryMutant((HANDLE)0xdeadbeef, MutantBasicInformation, &info, sizeof(info), NULL);
2032 "Failed to NtQueryMutant, expected STATUS_INVALID_HANDLE, got %08x\n", status );
2033
2034 /* new */
2035 len = -1;
2036 memset(&info, 0xcc, sizeof(info));
2037 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), &len);
2038 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
2039 ok( info.CurrentCount == 0, "expected 0, got %d\n", info.CurrentCount );
2040 ok( info.OwnedByCaller == TRUE, "expected TRUE, got %d\n", info.OwnedByCaller );
2041 ok( info.AbandonedState == FALSE, "expected FALSE, got %d\n", info.AbandonedState );
2042 ok( len == sizeof(info), "got %u\n", len );
2043
2044 ret = WaitForSingleObject( mutant, 1000 );
2045 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject failed %08x\n", ret );
2046
2047 memset(&info, 0xcc, sizeof(info));
2048 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), NULL);
2049 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
2050 ok( info.CurrentCount == -1, "expected -1, got %d\n", info.CurrentCount );
2051 ok( info.OwnedByCaller == TRUE, "expected TRUE, got %d\n", info.OwnedByCaller );
2052 ok( info.AbandonedState == FALSE, "expected FALSE, got %d\n", info.AbandonedState );
2053
2054 prev = 0xdeadbeef;
2055 status = pNtReleaseMutant(mutant, &prev);
2056 ok( status == STATUS_SUCCESS, "NtQueryRelease failed %08x\n", status );
2057 ok( prev == -1, "NtQueryRelease failed, expected -1, got %d\n", prev );
2058
2059 prev = 0xdeadbeef;
2060 status = pNtReleaseMutant(mutant, &prev);
2061 ok( status == STATUS_SUCCESS, "NtQueryRelease failed %08x\n", status );
2062 ok( prev == 0, "NtQueryRelease failed, expected 0, got %d\n", prev );
2063
2064 memset(&info, 0xcc, sizeof(info));
2065 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), NULL);
2066 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
2067 ok( info.CurrentCount == 1, "expected 1, got %d\n", info.CurrentCount );
2068 ok( info.OwnedByCaller == FALSE, "expected FALSE, got %d\n", info.OwnedByCaller );
2069 ok( info.AbandonedState == FALSE, "expected FALSE, got %d\n", info.AbandonedState );
2070
2071 /* abandoned */
2072 thread = CreateThread( NULL, 0, mutant_thread, mutant, 0, NULL );
2073 ret = WaitForSingleObject( thread, 1000 );
2074 ok( ret == WAIT_OBJECT_0, "WaitForSingleObject failed %08x\n", ret );
2076
2077 memset(&info, 0xcc, sizeof(info));
2078 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), NULL);
2079 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
2080 ok( info.CurrentCount == 1, "expected 0, got %d\n", info.CurrentCount );
2081 ok( info.OwnedByCaller == FALSE, "expected FALSE, got %d\n", info.OwnedByCaller );
2082 ok( info.AbandonedState == TRUE, "expected TRUE, got %d\n", info.AbandonedState );
2083
2084 ret = WaitForSingleObject( mutant, 1000 );
2085 ok( ret == WAIT_ABANDONED_0, "WaitForSingleObject failed %08x\n", ret );
2086
2087 memset(&info, 0xcc, sizeof(info));
2088 status = pNtQueryMutant(mutant, MutantBasicInformation, &info, sizeof(info), NULL);
2089 ok( status == STATUS_SUCCESS, "NtQueryMutant failed %08x\n", status );
2090 ok( info.CurrentCount == 0, "expected 0, got %d\n", info.CurrentCount );
2091 ok( info.OwnedByCaller == TRUE, "expected TRUE, got %d\n", info.OwnedByCaller );
2092 ok( info.AbandonedState == FALSE, "expected FALSE, got %d\n", info.AbandonedState );
2093
2094 NtClose( mutant );
2095}
#define broken(x)
Definition: atltest.h:178
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define CloseHandle
Definition: compat.h:739
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
static DWORD WINAPI mutant_thread(void *arg)
Definition: om.c:1982
long LONG
Definition: pedump.c:60
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
#define WAIT_ABANDONED_0
Definition: winbase.h:433

Referenced by START_TEST().

◆ test_name_collisions()

static void test_name_collisions ( void  )
static

Definition at line 276 of file om.c.

277{
281 HANDLE dir, h, h1, h2;
284
286 pRtlCreateUnicodeStringFromAsciiz(&str, "\\");
287 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
288 ok( status == STATUS_OBJECT_NAME_COLLISION, "NtCreateDirectoryObject got %08x\n", status );
290
291 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
292 ok( status == STATUS_OBJECT_NAME_EXISTS, "NtCreateDirectoryObject got %08x\n", status );
293 pNtClose(h);
294 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
296 "NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status);
297 pRtlFreeUnicodeString(&str);
298
299 pRtlCreateUnicodeStringFromAsciiz(&str, "\\??\\PIPE\\om.c-mutant");
300 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
302 "NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status);
303 pRtlFreeUnicodeString(&str);
304
305 if (!(dir = get_base_dir()))
306 {
307 win_skip( "couldn't find the BaseNamedObjects dir\n" );
308 return;
309 }
310 pRtlCreateUnicodeStringFromAsciiz(&str, "om.c-test");
312 h = CreateMutexA(NULL, FALSE, "om.c-test");
313 ok(h != 0, "CreateMutexA failed got ret=%p (%d)\n", h, GetLastError());
314 status = pNtCreateMutant(&h1, GENERIC_ALL, &attr, FALSE);
316 "NtCreateMutant should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status);
317 h2 = CreateMutexA(NULL, FALSE, "om.c-test");
319 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
320 "CreateMutexA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr);
321 pNtClose(h);
322 pNtClose(h1);
323 pNtClose(h2);
324
325 h = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
326 ok(h != 0, "CreateEventA failed got ret=%p (%d)\n", h, GetLastError());
327 status = pNtCreateEvent(&h1, GENERIC_ALL, &attr, FALSE, FALSE);
329 "NtCreateEvent should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status);
330 h2 = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
332 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
333 "CreateEventA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr);
334 pNtClose(h);
335 pNtClose(h1);
336 pNtClose(h2);
337
338 h = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
339 ok(h != 0, "CreateSemaphoreA failed got ret=%p (%d)\n", h, GetLastError());
340 status = pNtCreateSemaphore(&h1, GENERIC_ALL, &attr, 1, 2);
342 "NtCreateSemaphore should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status);
343 h2 = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
345 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
346 "CreateSemaphoreA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr);
347 pNtClose(h);
348 pNtClose(h1);
349 pNtClose(h2);
350
351 h = pCreateWaitableTimerA(NULL, TRUE, "om.c-test");
352 ok(h != 0, "CreateWaitableTimerA failed got ret=%p (%d)\n", h, GetLastError());
353 status = pNtCreateTimer(&h1, GENERIC_ALL, &attr, NotificationTimer);
355 "NtCreateTimer should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status);
356 h2 = pCreateWaitableTimerA(NULL, TRUE, "om.c-test");
358 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
359 "CreateWaitableTimerA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr);
360 pNtClose(h);
361 pNtClose(h1);
362 pNtClose(h2);
363
365 ok(h != 0, "CreateFileMappingA failed got ret=%p (%d)\n", h, GetLastError());
366 size.u.LowPart = 256;
367 size.u.HighPart = 0;
368 status = pNtCreateSection(&h1, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0);
370 "NtCreateSection should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08x)\n", status);
371 h2 = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 256, "om.c-test");
373 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
374 "CreateFileMappingA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%d)\n", h2, winerr);
375 pNtClose(h);
376 pNtClose(h1);
377 pNtClose(h2);
378
379 pRtlFreeUnicodeString(&str);
380 pNtClose(dir);
381}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
unsigned long winerr
Definition: doserrmap.h:7
HANDLE NTAPI CreateFileMappingA(IN HANDLE hFile, IN LPSECURITY_ATTRIBUTES lpFileMappingAttributes, IN DWORD flProtect, IN DWORD dwMaximumSizeHigh, IN DWORD dwMaximumSizeLow, IN LPCSTR lpName)
Definition: filemap.c:23
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static HANDLE get_base_dir(void)
Definition: om.c:243
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:430
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:637

Referenced by START_TEST().

◆ test_name_limits()

static void test_name_limits ( void  )
static

Definition at line 457 of file om.c.

458{
459 static const WCHAR localW[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s','\\','L','o','c','a','l',0};
460 static const WCHAR pipeW[] = {'\\','D','e','v','i','c','e','\\','N','a','m','e','d','P','i','p','e','\\'};
461 static const WCHAR mailslotW[] = {'\\','D','e','v','i','c','e','\\','M','a','i','l','S','l','o','t','\\'};
462 static const WCHAR registryW[] = {'\\','R','E','G','I','S','T','R','Y','\\','M','a','c','h','i','n','e','\\','S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\'};
463 OBJECT_ATTRIBUTES attr, attr2, attr3;
468 HANDLE ret, ret2;
469 DWORD i;
470
472 InitializeObjectAttributes( &attr2, &str, 0, (HANDLE)0xdeadbeef, NULL );
473 InitializeObjectAttributes( &attr3, &str, 0, 0, NULL );
474 str.Buffer = HeapAlloc( GetProcessHeap(), 0, 65536 + sizeof(registryW));
475 str.MaximumLength = 65534;
476 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i] = 'a';
477 size.QuadPart = 4096;
478 pRtlCreateUnicodeStringFromAsciiz( &target, "\\DosDevices" );
479
480 if (!(attr.RootDirectory = get_base_dir()))
481 {
482 win_skip( "couldn't find the BaseNamedObjects dir\n" );
483 return;
484 }
485
486 str.Length = 0;
487 status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE );
488 ok( status == STATUS_SUCCESS, "%u: NtCreateMutant failed %x\n", str.Length, status );
489 attr3.RootDirectory = ret;
490 status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr );
491 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenMutant failed %x\n", str.Length, status );
492 status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr3 );
494 "%u: NtOpenMutant failed %x\n", str.Length, status );
495 pNtClose( ret );
496 status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 );
497 ok( status == STATUS_SUCCESS, "%u: NtCreateSemaphore failed %x\n", str.Length, status );
498 attr3.RootDirectory = ret;
499 status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr );
500 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSemaphore failed %x\n", str.Length, status );
501 status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr3 );
503 "%u: NtOpenSemaphore failed %x\n", str.Length, status );
504 pNtClose( ret );
505 status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, 1, 0 );
506 ok( status == STATUS_SUCCESS, "%u: NtCreateEvent failed %x\n", str.Length, status );
507 attr3.RootDirectory = ret;
508 status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr );
509 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenEvent failed %x\n", str.Length, status );
510 status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr3 );
512 "%u: NtOpenEvent failed %x\n", str.Length, status );
513 pNtClose( ret );
514 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 );
515 ok( status == STATUS_SUCCESS, "%u: NtCreateKeyedEvent failed %x\n", str.Length, status );
516 attr3.RootDirectory = ret;
517 status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr );
518 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenKeyedEvent failed %x\n", str.Length, status );
519 status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr3 );
521 "%u: NtOpenKeyedEvent failed %x\n", str.Length, status );
522 pNtClose( ret );
523 status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer );
524 ok( status == STATUS_SUCCESS, "%u: NtCreateTimer failed %x\n", str.Length, status );
525 attr3.RootDirectory = ret;
526 status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr );
527 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenTimer failed %x\n", str.Length, status );
528 status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr3 );
530 "%u: NtOpenTimer failed %x\n", str.Length, status );
531 pNtClose( ret );
532 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 );
533 ok( status == STATUS_SUCCESS, "%u: NtCreateCompletion failed %x\n", str.Length, status );
534 attr3.RootDirectory = ret;
535 status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr );
536 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenCompletion failed %x\n", str.Length, status );
537 status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr3 );
539 "%u: NtOpenCompletion failed %x\n", str.Length, status );
540 pNtClose( ret );
541 status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 );
542 ok( status == STATUS_SUCCESS, "%u: NtCreateJobObject failed %x\n", str.Length, status );
543 attr3.RootDirectory = ret;
544 status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr );
545 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenJobObject failed %x\n", str.Length, status );
546 status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr3 );
548 "%u: NtOpenJobObject failed %x\n", str.Length, status );
549 pNtClose( ret );
550 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 );
551 ok( status == STATUS_SUCCESS, "%u: NtCreateDirectoryObject failed %x\n", str.Length, status );
552 attr3.RootDirectory = ret;
553 status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr );
555 "%u: NtOpenDirectoryObject failed %x\n", str.Length, status );
556 if (!status) pNtClose( ret2 );
557 status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr3 );
558 ok( status == STATUS_SUCCESS, "%u: NtOpenDirectoryObject failed %x\n", str.Length, status );
559 pNtClose( ret2 );
560 pNtClose( ret );
561 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target );
562 ok( status == STATUS_SUCCESS, "%u: NtCreateSymbolicLinkObject failed %x\n", str.Length, status );
563 attr3.RootDirectory = ret;
564 status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr );
565 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status );
566 status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr3 );
567 ok( status == STATUS_SUCCESS, "%u: NtOpenSymbolicLinkObject failed %x\n", str.Length, status );
568 pNtClose( ret2 );
569 pNtClose( ret );
570 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
571 ok( status == STATUS_SUCCESS, "%u: NtCreateSection failed %x\n", str.Length, status );
572 attr3.RootDirectory = ret;
573 status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr );
574 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSection failed %x\n", str.Length, status );
575 status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr3 );
577 "%u: NtOpenSection failed %x\n", str.Length, status );
578 pNtClose( ret );
579
580 str.Length = 67;
582
583 str.Length = 65532;
585
586 str.Length = 65534;
588
589 str.Length = 128;
590 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
591 {
592 if (attr.Length == sizeof(attr))
594 else
596 }
597 attr.Length = sizeof(attr);
598
599 /* null attributes or ObjectName, with or without RootDirectory */
600 attr3.RootDirectory = 0;
601 attr2.ObjectName = attr3.ObjectName = NULL;
604
605 attr3.ObjectName = &str2;
606 pRtlInitUnicodeString( &str2, localW );
607 status = pNtOpenSymbolicLinkObject( &ret, SYMBOLIC_LINK_QUERY, &attr3 );
608 ok( status == STATUS_SUCCESS, "can't open BaseNamedObjects\\Local %x\n", status );
609 attr3.ObjectName = &str;
610 attr3.RootDirectory = ret;
612 pNtClose( attr3.RootDirectory );
613
614 status = pNtCreateMutant( &ret, GENERIC_ALL, NULL, FALSE );
615 ok( status == STATUS_SUCCESS, "NULL: NtCreateMutant failed %x\n", status );
616 pNtClose( ret );
617 status = pNtOpenMutant( &ret, GENERIC_ALL, NULL );
618 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenMutant failed %x\n", status );
619 status = pNtCreateSemaphore( &ret, GENERIC_ALL, NULL, 1, 2 );
620 ok( status == STATUS_SUCCESS, "NULL: NtCreateSemaphore failed %x\n", status );
621 pNtClose( ret );
622 status = pNtOpenSemaphore( &ret, GENERIC_ALL, NULL );
623 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSemaphore failed %x\n", status );
624 status = pNtCreateEvent( &ret, GENERIC_ALL, NULL, 1, 0 );
625 ok( status == STATUS_SUCCESS, "NULL: NtCreateEvent failed %x\n", status );
626 pNtClose( ret );
627 status = pNtOpenEvent( &ret, GENERIC_ALL, NULL );
628 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenEvent failed %x\n", status );
629 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, NULL, 0 );
630 ok( status == STATUS_SUCCESS, "NULL: NtCreateKeyedEvent failed %x\n", status );
631 pNtClose( ret );
632 status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, NULL );
633 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenKeyedEvent failed %x\n", status );
634 status = pNtCreateTimer( &ret, GENERIC_ALL, NULL, NotificationTimer );
635 ok( status == STATUS_SUCCESS, "NULL: NtCreateTimer failed %x\n", status );
636 pNtClose( ret );
637 status = pNtOpenTimer( &ret, GENERIC_ALL, NULL );
638 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenTimer failed %x\n", status );
639 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, NULL, 0 );
640 ok( status == STATUS_SUCCESS, "NULL: NtCreateCompletion failed %x\n", status );
641 pNtClose( ret );
642 status = pNtOpenIoCompletion( &ret, GENERIC_ALL, NULL );
643 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenCompletion failed %x\n", status );
644 status = pNtCreateJobObject( &ret, GENERIC_ALL, NULL );
645 ok( status == STATUS_SUCCESS, "NULL: NtCreateJobObject failed %x\n", status );
646 pNtClose( ret );
647 status = pNtOpenJobObject( &ret, GENERIC_ALL, NULL );
648 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenJobObject failed %x\n", status );
649 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, NULL );
650 ok( status == STATUS_SUCCESS, "NULL: NtCreateDirectoryObject failed %x\n", status );
651 pNtClose( ret );
652 status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, NULL );
653 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenDirectoryObject failed %x\n", status );
654 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, NULL, &target );
656 "NULL: NtCreateSymbolicLinkObject failed %x\n", status );
657 if (!status) pNtClose( ret );
658 status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, NULL );
659 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSymbolicLinkObject failed %x\n", status );
660 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
661 ok( status == STATUS_SUCCESS, "NULL: NtCreateSection failed %x\n", status );
662 pNtClose( ret );
663 status = pNtOpenSection( &ret, SECTION_MAP_WRITE, NULL );
664 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSection failed %x\n", status );
665 attr2.ObjectName = attr3.ObjectName = &str;
666
667 /* named pipes */
668 memcpy( str.Buffer, pipeW, sizeof(pipeW) );
669 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(pipeW)/sizeof(WCHAR)] = 'a';
670 str.Length = 0;
671 attr.RootDirectory = 0;
672 attr.Attributes = OBJ_CASE_INSENSITIVE;
673 timeout.QuadPart = -10000;
674 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
675 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
676 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
677 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
678 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
679 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
680 str.Length = 67;
681 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
682 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
683 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
684 str.Length = 128;
685 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
686 {
687 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
688 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
689 if (attr.Length == sizeof(attr))
690 {
691 ok( status == STATUS_SUCCESS, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
692 pNtClose( ret );
693 }
695 "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
696 }
697 attr.Length = sizeof(attr);
698 str.Length = 65532;
699 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
700 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
701 ok( status == STATUS_SUCCESS, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
702 pNtClose( ret );
703 str.Length = 65534;
704 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
705 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
706 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %x\n", str.Length, status );
707 attr3.RootDirectory = 0;
708 attr2.ObjectName = attr3.ObjectName = NULL;
709 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
710 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
711 ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateNamedPipeFile failed %x\n", status );
712 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr3, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
713 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
714 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateNamedPipeFile failed %x\n", status );
715 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, NULL, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
716 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
717 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtCreateNamedPipeFile failed %x\n", status );
718 attr2.ObjectName = attr3.ObjectName = &str;
719
720 /* mailslots */
721 memcpy( str.Buffer, mailslotW, sizeof(mailslotW) );
722 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(mailslotW)/sizeof(WCHAR)] = 'a';
723 str.Length = 0;
724 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
725 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
726 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
727 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
728 str.Length = 67;
729 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
730 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
731 str.Length = 128;
732 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
733 {
734 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
735 if (attr.Length == sizeof(attr))
736 {
737 ok( status == STATUS_SUCCESS, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
738 pNtClose( ret );
739 }
741 "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
742 }
743 attr.Length = sizeof(attr);
744 str.Length = 65532;
745 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
746 ok( status == STATUS_SUCCESS, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
747 pNtClose( ret );
748 str.Length = 65534;
749 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
750 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %x\n", str.Length, status );
751 attr3.RootDirectory = 0;
752 attr2.ObjectName = attr3.ObjectName = NULL;
753 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
754 ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateMailslotFile failed %x\n", status );
755 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr3, &iosb, 0, 0, 0, NULL );
756 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateMailslotFile failed %x\n", status );
757 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, NULL, &iosb, 0, 0, 0, NULL );
758 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtCreateMailslotFile failed %x\n", status );
759 attr2.ObjectName = attr3.ObjectName = &str;
760
761 /* registry keys */
762 memcpy( str.Buffer, registryW, sizeof(registryW) );
763 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + sizeof(registryW)/sizeof(WCHAR)] = 'a';
764 str.Length = 0;
765 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
767 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateKey failed %x\n", str.Length, status );
768 status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL );
769 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateKey failed %x\n", str.Length, status );
770 status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 );
771 ok( status == STATUS_INVALID_HANDLE, "%u: NtOpenKey failed %x\n", str.Length, status );
772 str.Length = sizeof(registryW) + 250 * sizeof(WCHAR) + 1;
773 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
776 broken( status == STATUS_SUCCESS ), /* wow64 */
777 "%u: NtCreateKey failed %x\n", str.Length, status );
778 if (!status)
779 {
780 pNtDeleteKey( ret );
781 pNtClose( ret );
782 }
783 str.Length = sizeof(registryW) + 256 * sizeof(WCHAR);
784 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
786 "%u: NtCreateKey failed %x\n", str.Length, status );
787 if (!status)
788 {
789 status = pNtOpenKey( &ret2, KEY_READ, &attr );
790 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %x\n", str.Length, status );
791 pNtClose( ret2 );
792 attr3.RootDirectory = ret;
793 str.Length = 0;
794 status = pNtOpenKey( &ret2, KEY_READ, &attr3 );
795 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %x\n", str.Length, status );
796 pNtClose( ret2 );
797 pNtDeleteKey( ret );
798 pNtClose( ret );
799
800 str.Length = sizeof(registryW) + 256 * sizeof(WCHAR);
801 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
802 {
803 if (attr.Length == sizeof(attr))
804 {
805 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
806 ok( status == STATUS_SUCCESS, "%u: NtCreateKey failed %x\n", str.Length, status );
807 status = pNtOpenKey( &ret2, KEY_READ, &attr );
808 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %x\n", str.Length, status );
809 pNtClose( ret2 );
810 pNtDeleteKey( ret );
811 pNtClose( ret );
812 }
813 else
814 {
815 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
816 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status );
817 status = pNtOpenKey( &ret2, KEY_READ, &attr );
818 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %x\n", str.Length, status );
819 }
820 }
821 attr.Length = sizeof(attr);
822 }
823 str.Length = sizeof(registryW) + 256 * sizeof(WCHAR) + 1;
824 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
827 broken( status == STATUS_SUCCESS ), /* win7 */
828 "%u: NtCreateKey failed %x\n", str.Length, status );
829 if (!status)
830 {
831 pNtDeleteKey( ret );
832 pNtClose( ret );
833 }
834 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
838 "%u: NtOpenKey failed %x\n", str.Length, status );
839 str.Length++;
840 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
841 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status );
842 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
844 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %x\n", str.Length, status );
845 str.Length = 2000;
846 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
847 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %x\n", str.Length, status );
848 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
850 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %x\n", str.Length, status );
851 /* some Windows versions change the error past 2050 chars, others past 4066 chars, some don't */
852 str.Length = 5000;
853 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
857 "%u: NtCreateKey failed %x\n", str.Length, status );
858 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
863 "%u: NtOpenKey failed %x\n", str.Length, status );
864 str.Length = 65534;
865 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
869 "%u: NtCreateKey failed %x\n", str.Length, status );
870 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
875 "%u: NtOpenKey failed %x\n", str.Length, status );
876 attr3.RootDirectory = 0;
877 attr2.ObjectName = attr3.ObjectName = NULL;
878 status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL );
881 "NULL: NtCreateKey failed %x\n", status );
882 status = pNtCreateKey( &ret, GENERIC_ALL, &attr3, 0, NULL, 0, NULL );
884 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %x\n", status );
885 status = pNtCreateKey( &ret, GENERIC_ALL, NULL, 0, NULL, 0, NULL );
886 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %x\n", status );
887 status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 );
889 "NULL: NtOpenKey failed %x\n", status );
890 status = pNtOpenKey( &ret, GENERIC_ALL, &attr3 );
891 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %x\n", status );
892 status = pNtOpenKey( &ret, GENERIC_ALL, NULL );
893 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %x\n", status );
894 attr2.ObjectName = attr3.ObjectName = &str;
895
896 pRtlFreeUnicodeString( &str );
897 pRtlFreeUnicodeString( &target );
898}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define FILE_SHARE_READ
Definition: compat.h:136
#define FILE_CREATE
Definition: from_kernel.h:55
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define todo_wine
Definition: custom.c:89
static PIO_STATUS_BLOCK iosb
Definition: file.c:98
#define FILE_PIPE_FULL_DUPLEX
Definition: iotypes.h:83
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define KEY_READ
Definition: nt_native.h:1023
static void test_all_kernel_objects(UINT line, OBJECT_ATTRIBUTES *attr, NTSTATUS create_expect, NTSTATUS open_expect)
Definition: om.c:383
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
HANDLE RootDirectory
Definition: umtypes.h:184
PUNICODE_STRING ObjectName
Definition: umtypes.h:185

Referenced by START_TEST().

◆ test_namespace_pipe()

static void test_namespace_pipe ( void  )
static

Definition at line 144 of file om.c.

145{
146 static const WCHAR buffer1[] = {'\\','?','?','\\','P','I','P','E','\\','t','e','s','t','\\','p','i','p','e',0};
147 static const WCHAR buffer2[] = {'\\','?','?','\\','P','I','P','E','\\','T','E','S','T','\\','P','I','P','E',0};
148 static const WCHAR buffer3[] = {'\\','?','?','\\','p','i','p','e','\\','t','e','s','t','\\','p','i','p','e',0};
149 static const WCHAR buffer4[] = {'\\','?','?','\\','p','i','p','e','\\','t','e','s','t',0};
155 HANDLE pipe, h;
156
157 timeout.QuadPart = -10000;
158
159 pRtlInitUnicodeString(&str, buffer1);
161 status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
163 ok(status == STATUS_SUCCESS, "Failed to create NamedPipe(%08x)\n", status);
164
165 status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
168 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08x)\n", status);
169
170 pRtlInitUnicodeString(&str, buffer2);
172 status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
175 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08x)\n", status);
176
177 h = CreateFileA("\\\\.\\pipe\\test\\pipe", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
178 OPEN_EXISTING, 0, 0 );
179 ok(h != INVALID_HANDLE_VALUE, "Failed to open NamedPipe (%u)\n", GetLastError());
180 pNtClose(h);
181
182 pRtlInitUnicodeString(&str, buffer3);
187 status == STATUS_OBJECT_NAME_INVALID || /* vista */
189 "NtOpenFile should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08x)\n", status);
190
191 pRtlInitUnicodeString(&str, buffer4);
195 status == STATUS_OBJECT_NAME_INVALID, /* vista */
196 "NtOpenFile should have failed with STATUS_OBJECT_NAME_NOT_FOUND got(%08x)\n", status);
197
198 str.Length -= 4 * sizeof(WCHAR);
200 ok(status == STATUS_SUCCESS, "NtOpenFile should have succeeded got %08x\n", status);
201 pNtClose( h );
202
203 str.Length -= sizeof(WCHAR);
205 ok(status == STATUS_SUCCESS, "NtOpenFile should have succeeded got %08x\n", status);
206 pNtClose( h );
207
208 pNtClose(pipe);
209}
#define OPEN_EXISTING
Definition: compat.h:775
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:740
#define STATUS_PIPE_NOT_AVAILABLE
Definition: ntstatus.h:408
#define STATUS_INSTANCE_NOT_AVAILABLE
Definition: ntstatus.h:407

Referenced by START_TEST().

◆ test_null_device()

static void test_null_device ( void  )
static

Definition at line 1891 of file om.c.

1892{
1897 DWORD num_bytes;
1898 OVERLAPPED ov;
1899 char buf[64];
1900 HANDLE null;
1901 BOOL ret;
1902
1903 memset(buf, 0xAA, sizeof(buf));
1904 memset(&ov, 0, sizeof(ov));
1906
1907 pRtlCreateUnicodeStringFromAsciiz(&str, "\\Device\\Null");
1909 status = pNtOpenSymbolicLinkObject(&null, SYMBOLIC_LINK_QUERY, &attr);
1911 "expected STATUS_OBJECT_TYPE_MISMATCH, got %08x\n", status);
1912
1913 status = pNtOpenFile(&null, GENERIC_READ | GENERIC_WRITE, &attr, &iosb,
1916 "expected STATUS_SUCCESS, got %08x\n", status);
1917
1918 SetLastError(0xdeadbeef);
1919 ret = WriteFile(null, buf, sizeof(buf), &num_bytes, NULL);
1920 ok(!ret, "WriteFile unexpectedly succeeded\n");
1922 "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1923
1924 SetLastError(0xdeadbeef);
1925 ret = ReadFile(null, buf, sizeof(buf), &num_bytes, NULL);
1926 ok(!ret, "ReadFile unexpectedly succeeded\n");
1928 "expected ERROR_INVALID_PARAMETER, got %u\n", GetLastError());
1929
1930 num_bytes = 0xdeadbeef;
1931 SetLastError(0xdeadbeef);
1932 ret = WriteFile(null, buf, sizeof(buf), &num_bytes, &ov);
1933 if (ret || GetLastError() != ERROR_IO_PENDING)
1934 {
1935 ok(ret, "WriteFile failed with error %u\n", GetLastError());
1936 }
1937 else
1938 {
1939 num_bytes = 0xdeadbeef;
1940 ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE);
1941 ok(ret, "GetOverlappedResult failed with error %u\n", GetLastError());
1942 }
1943 ok(num_bytes == sizeof(buf), "expected num_bytes = %u, got %u\n",
1944 (DWORD)sizeof(buf), num_bytes);
1945
1946 num_bytes = 0xdeadbeef;
1947 SetLastError(0xdeadbeef);
1948 ret = ReadFile(null, buf, sizeof(buf), &num_bytes, &ov);
1949 if (ret || GetLastError() != ERROR_IO_PENDING)
1950 {
1951 ok(!ret, "ReadFile unexpectedly succeeded\n");
1952 }
1953 else
1954 {
1955 num_bytes = 0xdeadbeef;
1956 ret = GetOverlappedResult(null, &ov, &num_bytes, TRUE);
1957 ok(!ret, "GetOverlappedResult unexpectedly succeeded\n");
1958 }
1960 "expected ERROR_HANDLE_EOF, got %u\n", GetLastError());
1961
1962 pNtClose(null);
1963
1964 null = CreateFileA("\\\\.\\Null", GENERIC_READ | GENERIC_WRITE,
1967 ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n");
1969 "expected ERROR_FILE_NOT_FOUND, got %u\n", GetLastError());
1970
1971 null = CreateFileA("\\\\.\\Device\\Null", GENERIC_READ | GENERIC_WRITE,
1974 ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n");
1976 "expected ERROR_PATH_NOT_FOUND, got %u\n", GetLastError());
1977
1978 pRtlFreeUnicodeString(&str);
1979 CloseHandle(ov.hEvent);
1980}
int null(void)
Definition: ftp.c:1794
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ReadFile(a, b, c, d, e)
Definition: compat.h:742
#define SetLastError(x)
Definition: compat.h:752
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
BOOL WINAPI GetOverlappedResult(IN HANDLE hFile, IN LPOVERLAPPED lpOverlapped, OUT LPDWORD lpNumberOfBytesTransferred, IN BOOL bWait)
Definition: iocompl.c:221
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HANDLE hEvent
Definition: winbase.h:845
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define ERROR_HANDLE_EOF
Definition: winerror.h:140

Referenced by START_TEST().

◆ test_query_object()

static void test_query_object ( void  )
static

Definition at line 1289 of file om.c.

1290{
1291 static const WCHAR name[] = {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s',
1292 '\\','t','e','s','t','_','e','v','e','n','t'};
1293 static const WCHAR type_event[] = {'E','v','e','n','t'};
1294 static const WCHAR type_file[] = {'F','i','l','e'};
1295 static const WCHAR type_iocompletion[] = {'I','o','C','o','m','p','l','e','t','i','o','n'};
1296 static const WCHAR type_directory[] = {'D','i','r','e','c','t','o','r','y'};
1297 static const WCHAR type_section[] = {'S','e','c','t','i','o','n'};
1298 HANDLE handle;
1299 char buffer[1024];
1301 ULONG len, expected_len;
1304 char dir[MAX_PATH], tmp_path[MAX_PATH], file1[MAX_PATH + 16];
1306
1307 sprintf( tmp_path, "\\Sessions\\%u", NtCurrentTeb()->Peb->SessionId );
1308 pRtlCreateUnicodeStringFromAsciiz( &session, tmp_path );
1309 InitializeObjectAttributes( &attr, &path, 0, 0, 0 );
1310
1311 handle = CreateEventA( NULL, FALSE, FALSE, "test_event" );
1312
1313 len = 0;
1314 status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
1315 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1316 ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len );
1317
1318 len = 0;
1319 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, 0, &len );
1320 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1321 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len );
1322
1323 len = 0;
1324 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len );
1325 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1326 ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len );
1327
1328 len = 0;
1329 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(OBJECT_TYPE_INFORMATION), &len );
1330 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1331 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len );
1332
1333 len = 0;
1334 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1335 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1336 ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1338 ok( sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR) == len, "unexpected len %u\n", len );
1339 ok( str->Length >= sizeof(name), "unexpected len %u\n", str->Length );
1340 ok( len > sizeof(UNICODE_STRING) + sizeof("\\test_event") * sizeof(WCHAR),
1341 "name too short %s\n", wine_dbgstr_w(str->Buffer) );
1342 /* check for \\Sessions prefix in the name */
1343 ok( (str->Length > session.Length &&
1344 !memcmp( str->Buffer, session.Buffer, session.Length ) &&
1345 !memcmp( str->Buffer + session.Length / sizeof(WCHAR), name, sizeof(name) )) ||
1346 broken( !memcmp( str->Buffer, name, sizeof(name) )), /* winxp */
1347 "wrong name %s\n", wine_dbgstr_w(str->Buffer) );
1348 trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
1349
1350 len -= sizeof(WCHAR);
1351 status = pNtQueryObject( handle, ObjectNameInformation, buffer, len, &len );
1352 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1353 ok( len >= sizeof(UNICODE_STRING) + sizeof(name) + sizeof(WCHAR), "unexpected len %u\n", len );
1354
1355 len = 0;
1356 memset( buffer, 0, sizeof(buffer) );
1357 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1358 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1359 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1361 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR), "unexpected len %u\n", len );
1362 ok( str->Buffer && !memcmp( str->Buffer, type_event, sizeof(type_event) ),
1363 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1364
1365 len -= sizeof(WCHAR);
1366 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, len, &len );
1367 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1368 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(type_event) + sizeof(WCHAR), "unexpected len %u\n", len );
1369
1370 pNtClose( handle );
1371
1373 len = 0;
1374 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1375 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1376 ok( len == sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1378 ok( str->Length == 0, "unexpected len %u\n", len );
1379 ok( str->Buffer == NULL, "unexpected ptr %p\n", str->Buffer );
1380 pNtClose( handle );
1381
1385 len = 0;
1386 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1387 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1388 ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1390 expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
1391 ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */
1392 "unexpected len %u\n", len );
1393 trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
1394
1395 len = 0;
1396 status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
1398 "NtQueryObject failed %x\n", status );
1399 ok( len == expected_len || broken(!len || len == sizeof(UNICODE_STRING)),
1400 "unexpected len %u\n", len );
1401
1402 len = 0;
1403 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len );
1406 "NtQueryObject failed %x\n", status );
1407 ok( len == expected_len || broken(!len),
1408 "unexpected len %u\n", len );
1409
1410 len = 0;
1411 memset( buffer, 0, sizeof(buffer) );
1412 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1413 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1414 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1416 expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR);
1417 ok( len >= expected_len, "unexpected len %u\n", len );
1418 ok( str->Buffer && !memcmp( str->Buffer, type_file, sizeof(type_file) ),
1419 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1420
1421 pNtClose( handle );
1422
1423 GetTempPathA(MAX_PATH, tmp_path);
1424 GetTempFileNameA(tmp_path, "foo", 0, file1);
1426 len = 0;
1427 memset( buffer, 0, sizeof(buffer) );
1428 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1429 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1430 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1432 expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR);
1433 ok( len >= expected_len, "unexpected len %u\n", len );
1434 ok( str->Buffer && !memcmp( str->Buffer, type_file, sizeof(type_file) ),
1435 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1436 DeleteFileA( file1 );
1437 pNtClose( handle );
1438
1439 status = pNtCreateIoCompletion( &handle, IO_COMPLETION_ALL_ACCESS, NULL, 0 );
1440 ok( status == STATUS_SUCCESS, "NtCreateIoCompletion failed %x\n", status);
1441 len = 0;
1442 memset( buffer, 0, sizeof(buffer) );
1443 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1444 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1445 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1447 expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR);
1448 ok( len >= expected_len, "unexpected len %u\n", len );
1449 ok( str->Buffer && !memcmp( str->Buffer, type_iocompletion, sizeof(type_iocompletion) ),
1450 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1451 pNtClose( handle );
1452
1453 status = pNtCreateDirectoryObject( &handle, DIRECTORY_QUERY, NULL );
1454 ok(status == STATUS_SUCCESS, "Failed to create Directory %08x\n", status);
1455 len = 0;
1456 memset( buffer, 0, sizeof(buffer) );
1457 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1458 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1459 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1461 expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR);
1462 ok( len >= expected_len, "unexpected len %u\n", len );
1463 ok( str->Buffer && !memcmp( str->Buffer, type_directory, sizeof(type_directory) ),
1464 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1465 pNtClose( handle );
1466
1467 size.u.LowPart = 256;
1468 size.u.HighPart = 0;
1469 status = pNtCreateSection( &handle, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
1470 ok( status == STATUS_SUCCESS , "NtCreateSection returned %x\n", status );
1471 len = 0;
1472 memset( buffer, 0, sizeof(buffer) );
1473 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1474 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1475 ok( len > sizeof(OBJECT_TYPE_INFORMATION), "unexpected len %u\n", len );
1477 expected_len = sizeof(OBJECT_TYPE_INFORMATION) + str->Length + sizeof(WCHAR);
1478 ok( len >= expected_len, "unexpected len %u\n", len );
1479 ok( str->Buffer && !memcmp( str->Buffer, type_section, sizeof(type_section) ),
1480 "wrong/bad type name %s (%p)\n", wine_dbgstr_w(str->Buffer), str->Buffer );
1481 pNtClose( handle );
1482
1483 handle = CreateMailslotA( "\\\\.\\mailslot\\test_mailslot", 100, 1000, NULL );
1484 ok( handle != INVALID_HANDLE_VALUE, "CreateMailslot failed err %u\n", GetLastError() );
1485 len = 0;
1486 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1487 ok( status == STATUS_SUCCESS , "NtQueryObject returned %x\n", status );
1489 ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1491 expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
1492 ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */
1493 "unexpected len %u\n", len );
1494 ok( len > sizeof(UNICODE_STRING) + sizeof("\\test_mailslot") * sizeof(WCHAR),
1495 "name too short %s\n", wine_dbgstr_w(str->Buffer) );
1496 trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
1497 pNtClose( handle );
1498
1499 handle = CreateNamedPipeA( "\\\\.\\pipe\\test_pipe", PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE,
1500 1, 1000, 1000, 1000, NULL );
1501 ok( handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed err %u\n", GetLastError() );
1502 len = 0;
1503 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1504 ok( status == STATUS_SUCCESS , "NtQueryObject returned %x\n", status );
1506 ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1508 expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
1509 ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */
1510 "unexpected len %u\n", len );
1511 ok( len > sizeof(UNICODE_STRING) + sizeof("\\test_pipe") * sizeof(WCHAR),
1512 "name too short %s\n", wine_dbgstr_w(str->Buffer) );
1513 trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
1514 pNtClose( handle );
1515
1516 pRtlCreateUnicodeStringFromAsciiz( &path, "\\REGISTRY\\Machine\\Software\\Classes" );
1517 status = pNtCreateKey( &handle, KEY_ALL_ACCESS, &attr, 0, 0, 0, 0 );
1519 "NtCreateKey failed status %x\n", status );
1520 pRtlFreeUnicodeString( &path );
1521 if (status == STATUS_SUCCESS)
1522 {
1523 len = 0;
1524 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1525 ok( status == STATUS_SUCCESS , "NtQueryObject returned %x\n", status );
1527 todo_wine
1528 ok( len > sizeof(UNICODE_STRING), "unexpected len %u\n", len );
1530 expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
1531 todo_wine
1532 ok( len == expected_len || broken(len == expected_len - sizeof(WCHAR)), /* NT4 */
1533 "unexpected len %u\n", len );
1534 todo_wine
1535 ok( len > sizeof(UNICODE_STRING) + sizeof("\\Classes") * sizeof(WCHAR),
1536 "name too short %s\n", wine_dbgstr_w(str->Buffer) );
1537 trace( "got %s len %u\n", wine_dbgstr_w(str->Buffer), len );
1538 pNtClose( handle );
1539 }
1540 pRtlFreeUnicodeString( &session );
1541}
@ ObjectTypeInformation
Definition: DriverTester.h:56
@ ObjectNameInformation
Definition: DriverTester.h:55
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define trace
Definition: atltest.h:70
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
Definition: delete.c:24
HANDLE WINAPI CreateMailslotA(IN LPCSTR lpName, IN DWORD nMaxMessageSize, IN DWORD lReadTimeout, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: mailslot.c:23
UINT WINAPI GetWindowsDirectoryA(OUT LPSTR lpBuffer, IN UINT uSize)
Definition: path.c:2337
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:2054
struct _UNICODE_STRING UNICODE_STRING
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define wine_dbgstr_w
Definition: kernel32.h:34
#define CREATE_ALWAYS
Definition: disk.h:72
#define FILE_FLAG_BACKUP_SEMANTICS
Definition: disk.h:41
#define IO_COMPLETION_ALL_ACCESS
Definition: file.c:72
struct _OBJECT_TYPE_INFORMATION OBJECT_TYPE_INFORMATION
HANDLE WINAPI CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: npipe.c:220
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
#define DELETE
Definition: nt_native.h:57
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define PIPE_READMODE_BYTE
Definition: winbase.h:170
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:165

Referenced by START_TEST().

◆ test_query_object_types()

static void test_query_object_types ( void  )
static

Definition at line 1557 of file om.c.

1558{
1559 static const WCHAR typeW[] = {'T','y','p','e'};
1560 static const WCHAR eventW[] = {'E','v','e','n','t'};
1565 HANDLE handle;
1566 BOOL found;
1567 ULONG len, i, event_type_index = 0;
1568
1570 ok( buffer != NULL, "Failed to allocate memory\n" );
1571
1572 status = pNtQueryObject( NULL, ObjectTypesInformation, buffer, sizeof(OBJECT_TYPES_INFORMATION), &len );
1573 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %x\n", status );
1574 ok( len, "len is zero\n");
1575
1577 ok( buffer != NULL, "Failed to allocate memory\n" );
1578
1579 memset( buffer, 0, len );
1580 status = pNtQueryObject( NULL, ObjectTypesInformation, buffer, len, &len );
1581 ok( status == STATUS_SUCCESS, "NtQueryObject failed %x\n", status );
1582 ok( buffer->NumberOfTypes, "NumberOfTypes is zero\n" );
1583
1585 for (i = 0; i < buffer->NumberOfTypes; i++)
1586 {
1587 USHORT length = type->TypeName.MaximumLength;
1588 trace( "Type %u: %s\n", i, wine_dbgstr_us(&type->TypeName) );
1589
1590 if (i == 0)
1591 {
1592 ok( type->TypeName.Length == sizeof(typeW) && !strncmpW(typeW, type->TypeName.Buffer, 4),
1593 "Expected 'Type' as first type, got %s\n", wine_dbgstr_us(&type->TypeName) );
1594 }
1595 if (type->TypeName.Length == sizeof(eventW) && !strncmpW(eventW, type->TypeName.Buffer, 5))
1596 {
1597 if (winver_equal_or_newer( 6, 2 ))
1598 event_type_index = type->TypeIndex;
1599 else
1600 event_type_index = winver_equal_or_newer( 6, 1 ) ? i + 2 : i + 1;
1601 }
1602
1604 }
1605
1607
1608 ok( event_type_index, "Could not find object type for events\n" );
1609
1611 ok( handle != NULL, "Failed to create event\n" );
1612
1613 shi = HeapAlloc( GetProcessHeap(), 0, sizeof(*shi) );
1614 ok( shi != NULL, "Failed to allocate memory\n" );
1615
1616 status = pNtQuerySystemInformation( SystemExtendedHandleInformation, shi, sizeof(*shi), &len );
1617 ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status );
1618
1619 shi = HeapReAlloc( GetProcessHeap(), 0, shi, len );
1620 ok( shi != NULL, "Failed to allocate memory\n" );
1621
1622 status = pNtQuerySystemInformation( SystemExtendedHandleInformation, shi, len, &len );
1623 ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
1624
1625 found = FALSE;
1626 for (i = 0; i < shi->Count; i++)
1627 {
1629 continue;
1630 if ((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue != handle)
1631 continue;
1632
1633 ok( shi->Handle[i].ObjectTypeIndex == event_type_index, "Event type does not match: %u vs %u\n",
1634 shi->Handle[i].ObjectTypeIndex, event_type_index );
1635
1636 found = TRUE;
1637 break;
1638 }
1639 ok( found, "Expected to find event handle %p (pid %x) in handle list\n", handle, GetCurrentProcessId() );
1640
1641 HeapFree( GetProcessHeap(), 0, shi );
1643}
#define HeapReAlloc
Definition: compat.h:734
#define HeapFree(x, y, z)
Definition: compat.h:735
static const WCHAR typeW[]
Definition: name.c:51
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
@ ObjectTypesInformation
Definition: winternl.h:851
@ SystemExtendedHandleInformation
Definition: extypes.h:281
static LPCSTR wine_dbgstr_us(const UNICODE_STRING *us)
Definition: om.c:80
#define ROUND_UP(value, alignment)
Definition: om.c:78
static BOOL winver_equal_or_newer(WORD major, WORD minor)
Definition: om.c:1543
unsigned short USHORT
Definition: pedump.c:61
#define strncmpW(s1, s2, n)
Definition: unicode.h:42
SYSTEM_HANDLE_TABLE_ENTRY_INFO_EX Handle[1]
Definition: extypes.h:1432
ULONG_PTR HandleValue
Definition: extypes.h:1420
USHORT ObjectTypeIndex
Definition: extypes.h:1423
ULONG_PTR UniqueProcessId
Definition: extypes.h:1419
uint32_t DWORD_PTR
Definition: typedefs.h:65
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1158

Referenced by START_TEST().

◆ test_symboliclink()

static void test_symboliclink ( void  )
static

Definition at line 1160 of file om.c.

1161{
1165 HANDLE dir, link, h;
1167
1168 /* No name and/or no attributes */
1170 pRtlCreateUnicodeStringFromAsciiz(&target, "\\DosDevices");
1171 status = pNtCreateSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr, &target );
1173 "NtCreateSymbolicLinkObject got %08x\n", status );
1174 status = pNtOpenSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr );
1176 "NtOpenSymbolicLinkObject got %08x\n", status );
1177
1178 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, NULL);
1180 "NtCreateSymbolicLinkObject should have failed with STATUS_ACCESS_VIOLATION got(%08x)\n", status);
1181 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL);
1183 "NtOpenSymbolicLinkObject should have failed with STATUS_INVALID_PARAMETER got(%08x)\n", status);
1184
1185 /* No attributes */
1186 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, &target);
1188 "NtCreateSymbolicLinkObject failed(%08x)\n", status);
1189 pRtlFreeUnicodeString(&target);
1190 if (!status) pNtClose(h);
1191
1193 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1195 broken(status == STATUS_SUCCESS), /* nt4 */
1196 "NtCreateSymbolicLinkObject should have failed with STATUS_INVALID_PARAMETER got(%08x)\n", status);
1197 if (!status) pNtClose(h);
1198 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr);
1200 "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status);
1201
1202 /* Bad name */
1203 pRtlCreateUnicodeStringFromAsciiz(&target, "anywhere");
1205
1206 pRtlCreateUnicodeStringFromAsciiz(&str, "");
1207 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1208 ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08x)\n", status);
1209 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr);
1211 "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08x)\n", status);
1212 pNtClose(link);
1213 pRtlFreeUnicodeString(&str);
1214
1215 pRtlCreateUnicodeStringFromAsciiz(&str, "\\");
1216 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr, &target);
1218 "NtCreateSymbolicLinkObject should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08x)\n", status);
1219 pRtlFreeUnicodeString(&str);
1220 pRtlFreeUnicodeString(&target);
1221
1222 pRtlCreateUnicodeStringFromAsciiz( &target, "->Somewhere");
1223
1224 pRtlCreateUnicodeStringFromAsciiz( &str, "BaseNamedObjects" );
1225 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1226 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtCreateSymbolicLinkObject got %08x\n", status );
1227 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1228 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenSymbolicLinkObject got %08x\n", status );
1229 pRtlFreeUnicodeString( &str );
1230
1231 pRtlCreateUnicodeStringFromAsciiz( &str, "\\BaseNamedObjects\\" );
1232 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1233 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status );
1234 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1235 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status );
1236 pRtlFreeUnicodeString( &str );
1237
1238 pRtlCreateUnicodeStringFromAsciiz( &str, "\\\\BaseNamedObjects" );
1239 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1240 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status );
1241 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1242 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status );
1243 pRtlFreeUnicodeString( &str );
1244
1245 pRtlCreateUnicodeStringFromAsciiz( &str, "\\BaseNamedObjects\\\\om.c-test" );
1246 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1247 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08x\n", status );
1248 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1249 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08x\n", status );
1250 pRtlFreeUnicodeString( &str );
1251
1252 pRtlCreateUnicodeStringFromAsciiz( &str, "\\BaseNamedObjects\\om.c-test\\" );
1253 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1255 "NtCreateSymbolicLinkObject got %08x\n", status );
1256 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1258 "NtOpenSymbolicLinkObject got %08x\n", status );
1259 pRtlFreeUnicodeString( &str );
1260 pRtlFreeUnicodeString(&target);
1261
1262 /* Compound test */
1263 if (!(dir = get_base_dir()))
1264 {
1265 win_skip( "couldn't find the BaseNamedObjects dir\n" );
1266 return;
1267 }
1268
1270 pRtlCreateUnicodeStringFromAsciiz(&str, "test-link");
1271 pRtlCreateUnicodeStringFromAsciiz(&target, "\\DosDevices");
1272 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1273 ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08x)\n", status);
1274 pRtlFreeUnicodeString(&str);
1275 pRtlFreeUnicodeString(&target);
1276
1277 pRtlCreateUnicodeStringFromAsciiz(&str, "test-link\\NUL");
1279 ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08x)\n", status);
1281 ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08x)\n", status);
1282 pRtlFreeUnicodeString(&str);
1283
1284 pNtClose(h);
1285 pNtClose(link);
1286 pNtClose(dir);
1287}
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
const WCHAR * link
Definition: db.cpp:997

Referenced by START_TEST().

◆ test_type_mismatch()

static void test_type_mismatch ( void  )
static

Definition at line 1645 of file om.c.

1646{
1647 HANDLE h;
1648 NTSTATUS res;
1650
1651 attr.Length = sizeof(attr);
1652 attr.RootDirectory = 0;
1653 attr.ObjectName = NULL;
1654 attr.Attributes = 0;
1655 attr.SecurityDescriptor = NULL;
1656 attr.SecurityQualityOfService = NULL;
1657
1658 res = pNtCreateEvent( &h, 0, &attr, 0, 0 );
1659 ok(!res, "can't create event: %x\n", res);
1660
1661 res = pNtReleaseSemaphore( h, 30, NULL );
1662 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "expected 0xc0000024, got %x\n", res);
1663
1664 pNtClose( h );
1665}
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ VOID()

static VOID ( WINAPI pRtlInitUnicodeString)
static

◆ wine_dbgstr_us()

static LPCSTR wine_dbgstr_us ( const UNICODE_STRING us)
static

Definition at line 80 of file om.c.

81{
82 if (!us) return "(null)";
83 return wine_dbgstr_wn(us->Buffer, us->Length / sizeof(WCHAR));
84}
static const BYTE us[]
Definition: encode.c:689
#define wine_dbgstr_wn
Definition: testlist.c:2

Referenced by test_query_object_types().

◆ winver_equal_or_newer()

static BOOL winver_equal_or_newer ( WORD  major,
WORD  minor 
)
static

Definition at line 1543 of file om.c.

1544{
1545 OSVERSIONINFOEXW info = {sizeof(info)};
1546 ULONGLONG mask = 0;
1547
1548 info.dwMajorVersion = major;
1549 info.dwMinorVersion = minor;
1550
1553
1555}
BOOL WINAPI VerifyVersionInfoW(IN LPOSVERSIONINFOEXW lpVersionInformation, IN DWORD dwTypeMask, IN DWORDLONG dwlConditionMask)
Definition: version.c:118
GLenum GLint GLuint mask
Definition: glext.h:6028
#define VER_MAJORVERSION
Definition: rtltypes.h:229
#define VER_GREATER_EQUAL
Definition: rtltypes.h:241
#define VER_MINORVERSION
Definition: rtltypes.h:228
#define VER_SET_CONDITION(ConditionMask, TypeBitMask, ComparisonType)
#define minor(rdev)
Definition: propsheet.cpp:929
#define major(rdev)
Definition: propsheet.cpp:928
uint64_t ULONGLONG
Definition: typedefs.h:67

Referenced by test_query_object_types().

Variable Documentation

◆ ACCESS_MASK

Definition at line 32 of file om.c.

◆ BOOL

Definition at line 28 of file om.c.

◆ BOOLEAN

Definition at line 32 of file om.c.

◆ EVENT_INFORMATION_CLASS

Definition at line 35 of file om.c.

◆ HANDLE

Definition at line 53 of file om.c.

◆ keyed_nameW

const WCHAR keyed_nameW[]
static
Initial value:
= {'\\','B','a','s','e','N','a','m','e','d','O','b','j','e','c','t','s',
'\\','W','i','n','e','T','e','s','t','E','v','e','n','t',0}

Definition at line 1704 of file om.c.

Referenced by keyed_event_thread(), and test_keyed_events().

◆ LONG

Definition at line 48 of file om.c.

◆ LPCSTR

Definition at line 28 of file om.c.

◆ LPCWSTR

Definition at line 30 of file om.c.

◆ MUTANT_INFORMATION_CLASS

Definition at line 46 of file om.c.

◆ OBJECT_INFORMATION_CLASS

Definition at line 64 of file om.c.

◆ PIO_STATUS_BLOCK

Definition at line 42 of file om.c.

◆ PLARGE_INTEGER

Definition at line 43 of file om.c.

◆ PLONG

Definition at line 47 of file om.c.

◆ POBJECT_ATTRIBUTES

Definition at line 32 of file om.c.

◆ PULONG

Definition at line 34 of file om.c.

◆ PUNICODE_STRING

Definition at line 62 of file om.c.

◆ PVOID

Definition at line 35 of file om.c.

◆ TIMER_TYPE

Definition at line 50 of file om.c.

◆ ULONG

Definition at line 35 of file om.c.