ReactOS 0.4.17-dev-116-ga4b6fe9
om.c File Reference
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winternl.h"
#include "wingdi.h"
#include "winuser.h"
#include "ddk/wdm.h"
#include "wine/test.h"
Include dependency graph for om.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define KEYEDEVENT_WAIT   0x0001
 
#define KEYEDEVENT_WAKE   0x0002
 
#define KEYEDEVENT_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | 0x0003)
 
#define DESKTOP_ALL_ACCESS   0x01ff
 
#define check_unicode_string(a, b)   check_unicode_string_(__LINE__, a, b)
 
#define check_create_open_dir(parent, name, status)   check_create_open_dir_(__LINE__, parent, name, status)
 
#define test_file_info(a)   _test_file_info(__LINE__,a)
 
#define test_no_file_info(a)   _test_no_file_info(__LINE__,a)
 
#define test_object_type(a, b)   _test_object_type(__LINE__,a,b)
 
#define test_object_name(a, b)   _test_object_name(__LINE__,a,b)
 
#define DEBUG_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define DEBUG_GENERIC_READ   (STANDARD_RIGHTS_READ|DEBUG_READ_EVENT)
 
#define DEBUG_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|DEBUG_PROCESS_ASSIGN)
 
#define DESKTOP_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|DESKTOP_SWITCHDESKTOP)
 
#define DESKTOP_GENERIC_READ   (STANDARD_RIGHTS_READ|DESKTOP_ENUMERATE|DESKTOP_READOBJECTS)
 
#define DESKTOP_GENERIC_WRITE
 
#define DIRECTORY_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|DIRECTORY_TRAVERSE|DIRECTORY_QUERY)
 
#define DIRECTORY_GENERIC_READ   (STANDARD_RIGHTS_READ|DIRECTORY_TRAVERSE|DIRECTORY_QUERY)
 
#define DIRECTORY_GENERIC_WRITE
 
#define EVENT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define EVENT_GENERIC_READ   (STANDARD_RIGHTS_READ|EVENT_QUERY_STATE)
 
#define EVENT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|EVENT_MODIFY_STATE)
 
#define IO_COMPLETION_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define IO_COMPLETION_GENERIC_READ   (STANDARD_RIGHTS_READ|IO_COMPLETION_QUERY_STATE)
 
#define IO_COMPLETION_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|IO_COMPLETION_MODIFY_STATE)
 
#define IO_COMPLETION_RESERVE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)
 
#define IO_COMPLETION_RESERVE_GENERIC_READ   (STANDARD_RIGHTS_READ|0x1)
 
#define IO_COMPLETION_RESERVE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|0x2)
 
#define IO_COMPLETION_RESERVE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x3)
 
#define JOB_OBJECT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define JOB_OBJECT_GENERIC_READ   (STANDARD_RIGHTS_READ|JOB_OBJECT_QUERY)
 
#define JOB_OBJECT_GENERIC_WRITE
 
#define KEY_GENERIC_EXECUTE
 
#define KEY_GENERIC_READ
 
#define KEY_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|KEY_CREATE_SUB_KEY|KEY_SET_VALUE)
 
#define KEYEDEVENT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)
 
#define KEYEDEVENT_GENERIC_READ   (STANDARD_RIGHTS_READ|KEYEDEVENT_WAIT)
 
#define KEYEDEVENT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|KEYEDEVENT_WAKE)
 
#define MUTANT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define MUTANT_GENERIC_READ   (STANDARD_RIGHTS_READ|MUTANT_QUERY_STATE)
 
#define MUTANT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)
 
#define PROCESS_GENERIC_EXECUTE
 
#define PROCESS_GENERIC_READ   (STANDARD_RIGHTS_READ|PROCESS_VM_READ|PROCESS_QUERY_INFORMATION)
 
#define PROCESS_GENERIC_WRITE
 
#define SECTION_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SECTION_MAP_EXECUTE)
 
#define SECTION_GENERIC_READ   (STANDARD_RIGHTS_READ|SECTION_QUERY|SECTION_MAP_READ)
 
#define SECTION_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|SECTION_MAP_WRITE)
 
#define SEMAPHORE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define SEMAPHORE_GENERIC_READ   (STANDARD_RIGHTS_READ|SEMAPHORE_QUERY_STATE)
 
#define SEMAPHORE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|SEMAPHORE_MODIFY_STATE)
 
#define SYMBOLIC_LINK_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYMBOLIC_LINK_QUERY)
 
#define SYMBOLIC_LINK_GENERIC_READ   (STANDARD_RIGHTS_READ|SYMBOLIC_LINK_QUERY)
 
#define SYMBOLIC_LINK_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)
 
#define THREAD_GENERIC_EXECUTE
 
#define THREAD_GENERIC_READ   (STANDARD_RIGHTS_READ|THREAD_QUERY_INFORMATION|THREAD_GET_CONTEXT)
 
#define THREAD_GENERIC_WRITE
 
#define TIMER_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)
 
#define TIMER_GENERIC_READ   (STANDARD_RIGHTS_READ|TIMER_QUERY_STATE)
 
#define TIMER_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|TIMER_MODIFY_STATE)
 
#define TOKEN_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|TOKEN_IMPERSONATE|TOKEN_ASSIGN_PRIMARY)
 
#define TOKEN_GENERIC_READ   (STANDARD_RIGHTS_READ|TOKEN_QUERY_SOURCE|TOKEN_QUERY|TOKEN_DUPLICATE)
 
#define TOKEN_GENERIC_WRITE
 
#define TYPE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)
 
#define TYPE_GENERIC_READ   (STANDARD_RIGHTS_READ)
 
#define TYPE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)
 
#define USER_APC_RESERVE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)
 
#define USER_APC_RESERVE_GENERIC_READ   (STANDARD_RIGHTS_READ|0x1)
 
#define USER_APC_RESERVE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|0x2)
 
#define USER_APC_RESERVE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x3)
 
#define WINSTA_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|WINSTA_EXITWINDOWS|WINSTA_ACCESSGLOBALATOMS)
 
#define WINSTA_GENERIC_READ
 
#define WINSTA_GENERIC_WRITE
 
#define WINSTA_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x37f)
 
#define DESKTOP_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x1ff)
 
#define DEVICE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)
 
#define TYPE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x1)
 
#define TYPE(name, gen, extra, broken)
 
#define test_object_name_with_null(a, b)   _test_object_name_with_null(__LINE__,a,b)
 

Functions

static VOID (WINAPI *pRtlInitUnicodeString)(PUNICODE_STRING
 
static NTSTATUS (WINAPI *pNtAllocateReserveObject)(HANDLE *
 
static void check_unicode_string_ (int line, const UNICODE_STRING *string, const WCHAR *expect)
 
static void test_case_sensitive (void)
 
static void test_namespace_pipe (void)
 
static void check_create_open_dir_ (int line, HANDLE parent, const WCHAR *name, NTSTATUS expect)
 
static BOOL is_correct_dir (HANDLE dir, const WCHAR *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_file_info (unsigned line, HANDLE handle)
 
static void _test_no_file_info (unsigned line, HANDLE handle)
 
static void add_object_type (OBJECT_TYPE_INFORMATION *info)
 
static BOOL compare_unicode_string (const UNICODE_STRING *string, const WCHAR *expect)
 
static void _test_object_type (unsigned line, HANDLE handle, const WCHAR *expected_name)
 
static void _test_object_name (unsigned line, HANDLE handle, const WCHAR *expected_name)
 
static void test_query_object (void)
 
static void test_type_mismatch (void)
 
static void test_null_device (void)
 
static void test_process (void)
 
static void test_token (void)
 
static voidalign_ptr (void *ptr)
 
static void test_duplicate_object (void)
 
static void test_object_types (void)
 
static DWORD WINAPI test_get_next_thread_proc (void *arg)
 
static void test_get_next_thread (void)
 
static void test_globalroot (void)
 
static void test_object_identity (void)
 
static void test_query_directory (void)
 
static void _test_object_name_with_null (unsigned line, HANDLE handle, UNICODE_STRING *expect)
 
static void test_null_in_object_name (void)
 
static void test_object_permanence (void)
 
static void test_zero_access (void)
 
static void test_NtAllocateReserveObject (void)
 
 START_TEST (om)
 

Variables

static LPCWSTR
 
static const OBJECT_ATTRIBUTES MEMORY_RESERVE_OBJECT_TYPE
 
static ACCESS_MASK
 
static const POBJECT_ATTRIBUTES
 
static const EVENT_TYPE
 
static const BOOLEAN
 
static ULONG
 
static const UNICODE_STRING PULONG
 
static PIO_STATUS_BLOCK
 
static PLARGE_INTEGER
 
static const LONG
 
static const TIMER_TYPE
 
static const const HANDLE
 
static PUNICODE_STRING
 
static OBJECT_INFORMATION_CLASS
 
static PVOID
 
static void FILE_INFORMATION_CLASS
 
static HANDLE thread
 
static HANDLE ACCESS_MASK access
 
static HANDLE ACCESS_MASK ULONG attributes
 
static HANDLE ACCESS_MASK ULONG ULONG flags
 
static HANDLE ACCESS_MASK ULONG ULONG HANDLEhandle
 
static DWORD
 
static HANDLE *static const OBJECT_ATTRIBUTES const CLIENT_ID *static HANDLE *static OBJECT_ATTRIBUTES TOKEN_TYPE
 
static OBJECT_TYPE_INFORMATION all_types [256]
 

Macro Definition Documentation

◆ check_create_open_dir

#define check_create_open_dir (   parent,
  name,
  status 
)    check_create_open_dir_(__LINE__, parent, name, status)

Definition at line 238 of file om.c.

◆ check_unicode_string

#define check_unicode_string (   a,
  b 
)    check_unicode_string_(__LINE__, a, b)

Definition at line 108 of file om.c.

◆ DEBUG_GENERIC_EXECUTE

#define DEBUG_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2198 of file om.c.

◆ DEBUG_GENERIC_READ

#define DEBUG_GENERIC_READ   (STANDARD_RIGHTS_READ|DEBUG_READ_EVENT)

Definition at line 2199 of file om.c.

◆ DEBUG_GENERIC_WRITE

#define DEBUG_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|DEBUG_PROCESS_ASSIGN)

Definition at line 2200 of file om.c.

◆ DESKTOP_ALL_ACCESS [1/2]

#define DESKTOP_ALL_ACCESS   0x01ff

Definition at line 2280 of file om.c.

◆ DESKTOP_ALL_ACCESS [2/2]

#define DESKTOP_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x1ff)

Definition at line 2280 of file om.c.

◆ DESKTOP_GENERIC_EXECUTE

#define DESKTOP_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|DESKTOP_SWITCHDESKTOP)

Definition at line 2201 of file om.c.

◆ DESKTOP_GENERIC_READ

Definition at line 2202 of file om.c.

◆ DESKTOP_GENERIC_WRITE

#define DESKTOP_GENERIC_WRITE
Value:
#define STANDARD_RIGHTS_WRITE
Definition: nt_native.h:66
#define DESKTOP_CREATEWINDOW
Definition: winuser.h:217
#define DESKTOP_JOURNALRECORD
Definition: winuser.h:221
#define DESKTOP_JOURNALPLAYBACK
Definition: winuser.h:220
#define DESKTOP_CREATEMENU
Definition: winuser.h:216
#define DESKTOP_WRITEOBJECTS
Definition: winuser.h:224
#define DESKTOP_HOOKCONTROL
Definition: winuser.h:219

Definition at line 2203 of file om.c.

◆ DEVICE_ALL_ACCESS

#define DEVICE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x1ff)

Definition at line 2281 of file om.c.

◆ DIRECTORY_GENERIC_EXECUTE

Definition at line 2206 of file om.c.

◆ DIRECTORY_GENERIC_READ

Definition at line 2207 of file om.c.

◆ DIRECTORY_GENERIC_WRITE

#define DIRECTORY_GENERIC_WRITE
Value:

Definition at line 2208 of file om.c.

◆ EVENT_GENERIC_EXECUTE

#define EVENT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2210 of file om.c.

◆ EVENT_GENERIC_READ

#define EVENT_GENERIC_READ   (STANDARD_RIGHTS_READ|EVENT_QUERY_STATE)

Definition at line 2211 of file om.c.

◆ EVENT_GENERIC_WRITE

#define EVENT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|EVENT_MODIFY_STATE)

Definition at line 2212 of file om.c.

◆ IO_COMPLETION_GENERIC_EXECUTE

#define IO_COMPLETION_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2213 of file om.c.

◆ IO_COMPLETION_GENERIC_READ

#define IO_COMPLETION_GENERIC_READ   (STANDARD_RIGHTS_READ|IO_COMPLETION_QUERY_STATE)

Definition at line 2214 of file om.c.

◆ IO_COMPLETION_GENERIC_WRITE

#define IO_COMPLETION_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|IO_COMPLETION_MODIFY_STATE)

Definition at line 2215 of file om.c.

◆ IO_COMPLETION_RESERVE_ALL_ACCESS

#define IO_COMPLETION_RESERVE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x3)

Definition at line 2219 of file om.c.

◆ IO_COMPLETION_RESERVE_GENERIC_EXECUTE

#define IO_COMPLETION_RESERVE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)

Definition at line 2216 of file om.c.

◆ IO_COMPLETION_RESERVE_GENERIC_READ

#define IO_COMPLETION_RESERVE_GENERIC_READ   (STANDARD_RIGHTS_READ|0x1)

Definition at line 2217 of file om.c.

◆ IO_COMPLETION_RESERVE_GENERIC_WRITE

#define IO_COMPLETION_RESERVE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|0x2)

Definition at line 2218 of file om.c.

◆ JOB_OBJECT_GENERIC_EXECUTE

#define JOB_OBJECT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2220 of file om.c.

◆ JOB_OBJECT_GENERIC_READ

#define JOB_OBJECT_GENERIC_READ   (STANDARD_RIGHTS_READ|JOB_OBJECT_QUERY)

Definition at line 2221 of file om.c.

◆ JOB_OBJECT_GENERIC_WRITE

#define JOB_OBJECT_GENERIC_WRITE
Value:
#define JOB_OBJECT_TERMINATE
Definition: pstypes.h:199
#define JOB_OBJECT_ASSIGN_PROCESS
Definition: pstypes.h:196
#define JOB_OBJECT_SET_ATTRIBUTES
Definition: pstypes.h:197

Definition at line 2222 of file om.c.

◆ KEY_GENERIC_EXECUTE

#define KEY_GENERIC_EXECUTE
Value:
#define KEY_QUERY_VALUE
Definition: nt_native.h:1019
#define KEY_ENUMERATE_SUB_KEYS
Definition: nt_native.h:1022
#define KEY_CREATE_LINK
Definition: nt_native.h:1024
#define STANDARD_RIGHTS_EXECUTE
Definition: nt_native.h:67
#define KEY_NOTIFY
Definition: nt_native.h:1023

Definition at line 2224 of file om.c.

◆ KEY_GENERIC_READ

#define KEY_GENERIC_READ
Value:

Definition at line 2226 of file om.c.

◆ KEY_GENERIC_WRITE

Definition at line 2228 of file om.c.

◆ KEYEDEVENT_ALL_ACCESS

#define KEYEDEVENT_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED | 0x0003)

Definition at line 105 of file om.c.

◆ KEYEDEVENT_GENERIC_EXECUTE

#define KEYEDEVENT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)

Definition at line 2229 of file om.c.

◆ KEYEDEVENT_GENERIC_READ

#define KEYEDEVENT_GENERIC_READ   (STANDARD_RIGHTS_READ|KEYEDEVENT_WAIT)

Definition at line 2230 of file om.c.

◆ KEYEDEVENT_GENERIC_WRITE

#define KEYEDEVENT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|KEYEDEVENT_WAKE)

Definition at line 2231 of file om.c.

◆ KEYEDEVENT_WAIT

#define KEYEDEVENT_WAIT   0x0001

Definition at line 103 of file om.c.

◆ KEYEDEVENT_WAKE

#define KEYEDEVENT_WAKE   0x0002

Definition at line 104 of file om.c.

◆ MUTANT_GENERIC_EXECUTE

#define MUTANT_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2232 of file om.c.

◆ MUTANT_GENERIC_READ

#define MUTANT_GENERIC_READ   (STANDARD_RIGHTS_READ|MUTANT_QUERY_STATE)

Definition at line 2233 of file om.c.

◆ MUTANT_GENERIC_WRITE

#define MUTANT_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)

Definition at line 2234 of file om.c.

◆ PROCESS_GENERIC_EXECUTE

#define PROCESS_GENERIC_EXECUTE
Value:
#define PROCESS_TERMINATE
Definition: pstypes.h:153
#define PROCESS_QUERY_LIMITED_INFORMATION
Definition: security.c:89
#define SYNCHRONIZE
Definition: nt_native.h:61

Definition at line 2235 of file om.c.

◆ PROCESS_GENERIC_READ

Definition at line 2237 of file om.c.

◆ PROCESS_GENERIC_WRITE

#define PROCESS_GENERIC_WRITE
Value:
#define PROCESS_SUSPEND_RESUME
Definition: pstypes.h:163
#define PROCESS_VM_WRITE
Definition: pstypes.h:158
#define PROCESS_CREATE_THREAD
Definition: pstypes.h:154
#define PROCESS_VM_OPERATION
Definition: pstypes.h:156
#define PROCESS_SET_INFORMATION
Definition: pstypes.h:161
#define PROCESS_CREATE_PROCESS
Definition: pstypes.h:159
#define PROCESS_SET_QUOTA
Definition: pstypes.h:160
#define PROCESS_DUP_HANDLE

Definition at line 2238 of file om.c.

◆ SECTION_GENERIC_EXECUTE

#define SECTION_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SECTION_MAP_EXECUTE)

Definition at line 2242 of file om.c.

◆ SECTION_GENERIC_READ

Definition at line 2243 of file om.c.

◆ SECTION_GENERIC_WRITE

#define SECTION_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|SECTION_MAP_WRITE)

Definition at line 2244 of file om.c.

◆ SEMAPHORE_GENERIC_EXECUTE

#define SEMAPHORE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2245 of file om.c.

◆ SEMAPHORE_GENERIC_READ

#define SEMAPHORE_GENERIC_READ   (STANDARD_RIGHTS_READ|SEMAPHORE_QUERY_STATE)

Definition at line 2246 of file om.c.

◆ SEMAPHORE_GENERIC_WRITE

#define SEMAPHORE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|SEMAPHORE_MODIFY_STATE)

Definition at line 2247 of file om.c.

◆ SYMBOLIC_LINK_GENERIC_EXECUTE

#define SYMBOLIC_LINK_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYMBOLIC_LINK_QUERY)

Definition at line 2248 of file om.c.

◆ SYMBOLIC_LINK_GENERIC_READ

#define SYMBOLIC_LINK_GENERIC_READ   (STANDARD_RIGHTS_READ|SYMBOLIC_LINK_QUERY)

Definition at line 2249 of file om.c.

◆ SYMBOLIC_LINK_GENERIC_WRITE

#define SYMBOLIC_LINK_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)

Definition at line 2250 of file om.c.

◆ test_file_info

#define test_file_info (   a)    _test_file_info(__LINE__,a)

Definition at line 1559 of file om.c.

◆ test_no_file_info

#define test_no_file_info (   a)    _test_no_file_info(__LINE__,a)

Definition at line 1579 of file om.c.

◆ test_object_name

#define test_object_name (   a,
  b 
)    _test_object_name(__LINE__,a,b)

Definition at line 1665 of file om.c.

◆ test_object_name_with_null

#define test_object_name_with_null (   a,
  b 
)    _test_object_name_with_null(__LINE__,a,b)

Definition at line 2855 of file om.c.

◆ test_object_type

#define test_object_type (   a,
  b 
)    _test_object_type(__LINE__,a,b)

Definition at line 1644 of file om.c.

◆ THREAD_GENERIC_EXECUTE

#define THREAD_GENERIC_EXECUTE
Value:

Definition at line 2251 of file om.c.

◆ THREAD_GENERIC_READ

Definition at line 2253 of file om.c.

◆ THREAD_GENERIC_WRITE

#define THREAD_GENERIC_WRITE
Value:
#define THREAD_SET_CONTEXT
#define THREAD_SUSPEND_RESUME
#define THREAD_SET_LIMITED_INFORMATION
Definition: security.c:105
#define THREAD_TERMINATE
Definition: nt_native.h:1339
#define THREAD_SET_INFORMATION
Definition: nt_native.h:1340

Definition at line 2254 of file om.c.

◆ TIMER_GENERIC_EXECUTE

#define TIMER_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE|SYNCHRONIZE)

Definition at line 2257 of file om.c.

◆ TIMER_GENERIC_READ

#define TIMER_GENERIC_READ   (STANDARD_RIGHTS_READ|TIMER_QUERY_STATE)

Definition at line 2258 of file om.c.

◆ TIMER_GENERIC_WRITE

#define TIMER_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|TIMER_MODIFY_STATE)

Definition at line 2259 of file om.c.

◆ TOKEN_GENERIC_EXECUTE

Definition at line 2260 of file om.c.

◆ TOKEN_GENERIC_READ

Definition at line 2261 of file om.c.

◆ TOKEN_GENERIC_WRITE

#define TOKEN_GENERIC_WRITE
Value:
#define TOKEN_ADJUST_PRIVILEGES
Definition: setypes.h:942
#define TOKEN_ADJUST_SESSIONID
Definition: setypes.h:945
#define TOKEN_ADJUST_DEFAULT
Definition: setypes.h:944
#define TOKEN_ADJUST_GROUPS
Definition: setypes.h:943

Definition at line 2262 of file om.c.

◆ TYPE

#define TYPE (   name,
  gen,
  extra,
  broken 
)
Value:
{ name, { gen ## _GENERIC_READ, gen ## _GENERIC_WRITE, \
gen ## _GENERIC_EXECUTE, gen ## _ALL_ACCESS }, gen ## _ALL_ACCESS | extra, broken }
#define broken(x)
Definition: atltest.h:178
@ extra
Definition: id3.c:95
Definition: name.c:39

◆ TYPE_ALL_ACCESS

#define TYPE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x1)

Definition at line 2282 of file om.c.

◆ TYPE_GENERIC_EXECUTE

#define TYPE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)

Definition at line 2264 of file om.c.

◆ TYPE_GENERIC_READ

#define TYPE_GENERIC_READ   (STANDARD_RIGHTS_READ)

Definition at line 2265 of file om.c.

◆ TYPE_GENERIC_WRITE

#define TYPE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE)

Definition at line 2266 of file om.c.

◆ USER_APC_RESERVE_ALL_ACCESS

#define USER_APC_RESERVE_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x3)

Definition at line 2270 of file om.c.

◆ USER_APC_RESERVE_GENERIC_EXECUTE

#define USER_APC_RESERVE_GENERIC_EXECUTE   (STANDARD_RIGHTS_EXECUTE)

Definition at line 2267 of file om.c.

◆ USER_APC_RESERVE_GENERIC_READ

#define USER_APC_RESERVE_GENERIC_READ   (STANDARD_RIGHTS_READ|0x1)

Definition at line 2268 of file om.c.

◆ USER_APC_RESERVE_GENERIC_WRITE

#define USER_APC_RESERVE_GENERIC_WRITE   (STANDARD_RIGHTS_WRITE|0x2)

Definition at line 2269 of file om.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 27 of file om.c.

◆ WINSTA_ALL_ACCESS

#define WINSTA_ALL_ACCESS   (STANDARD_RIGHTS_REQUIRED|0x37f)

Definition at line 2279 of file om.c.

◆ WINSTA_GENERIC_EXECUTE

Definition at line 2271 of file om.c.

◆ WINSTA_GENERIC_READ

#define WINSTA_GENERIC_READ
Value:
#define WINSTA_READATTRIBUTES
Definition: winuser.h:414
#define WINSTA_READSCREEN
Definition: winuser.h:415
#define WINSTA_ENUMERATE
Definition: winuser.h:412
#define WINSTA_ENUMDESKTOPS
Definition: winuser.h:411

Definition at line 2272 of file om.c.

◆ WINSTA_GENERIC_WRITE

#define WINSTA_GENERIC_WRITE
Value:
#define WINSTA_WRITEATTRIBUTES
Definition: winuser.h:416
#define WINSTA_ACCESSCLIPBOARD
Definition: winuser.h:408
#define WINSTA_CREATEDESKTOP
Definition: winuser.h:410

Definition at line 2274 of file om.c.

Function Documentation

◆ _test_file_info()

static void _test_file_info ( unsigned  line,
HANDLE  handle 
)
static

Definition at line 1560 of file om.c.

1561{
1563 char buf[256];
1565
1566 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), 0xdeadbeef);
1567 ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* Vista+ */,
1568 "expected STATUS_NOT_IMPLEMENTED, got %lx\n", status);
1569
1570 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileAccessInformation);
1571 ok_(__FILE__,line)(status == STATUS_SUCCESS, "FileAccessInformation returned %lx\n", status);
1572
1573 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf),
1575 ok_(__FILE__,line)(status == STATUS_SUCCESS,
1576 "FileIoCompletionNotificationInformation returned %lx\n", status);
1577}
#define ok_(x1, x2)
Definition: atltest.h:61
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
@ FileIoCompletionNotificationInformation
Definition: from_kernel.h:102
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
Definition: file.c:72
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:333
#define FileAccessInformation
Definition: propsheet.cpp:51
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: parser.c:49
Definition: ps.c:97

◆ _test_no_file_info()

static void _test_no_file_info ( unsigned  line,
HANDLE  handle 
)
static

Definition at line 1580 of file om.c.

1581{
1583 char buf[256];
1585
1586 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), 0xdeadbeef);
1587 ok_(__FILE__,line)(status == STATUS_INVALID_INFO_CLASS || status == STATUS_NOT_IMPLEMENTED /* Vista+ */,
1588 "expected STATUS_NOT_IMPLEMENTED, got %lx\n", status);
1589
1590 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf), FileAccessInformation);
1592 "FileAccessInformation returned %lx\n", status);
1593
1594 status = pNtQueryInformationFile(handle, &io, buf, sizeof(buf),
1597 "FileIoCompletionNotificationInformation returned %lx\n", status);
1598}
#define STATUS_OBJECT_TYPE_MISMATCH
Definition: d3dkmdt.h:46

◆ _test_object_name()

static void _test_object_name ( unsigned  line,
HANDLE  handle,
const WCHAR expected_name 
)
static

Definition at line 1666 of file om.c.

1667{
1668 char buffer[1024];
1670 ULONG len = 0;
1672
1673 RtlInitUnicodeString( &expect, expected_name );
1674
1675 memset( buffer, 0, sizeof(buffer) );
1676 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1677 ok_(__FILE__,line)( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1678 ok_(__FILE__,line)( len >= sizeof(OBJECT_NAME_INFORMATION) + str->Length || broken(/* __REACTOS__ */ GetNTVersion() < _WIN32_WINNT_VISTA), "unexpected len %lu\n", len );
1679 ok_(__FILE__,line)( compare_unicode_string( str, expected_name ) || broken(/* __REACTOS__ */ GetNTVersion() < _WIN32_WINNT_VISTA), "got %s, expected %s\n",
1680 debugstr_w(str->Buffer), debugstr_w(expected_name) );
1681}
@ ObjectNameInformation
Definition: DriverTester.h:55
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
#define GetNTVersion()
Definition: apitest.h:17
GLuint buffer
Definition: glext.h:5915
GLenum GLsizei len
Definition: glext.h:6722
#define debugstr_w
Definition: kernel32.h:32
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
static BOOL compare_unicode_string(const UNICODE_STRING *string, const WCHAR *expect)
Definition: om.c:1638
const WCHAR * str
#define memset(x, y, z)
Definition: compat.h:39
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
uint32_t ULONG
Definition: typedefs.h:59

◆ _test_object_name_with_null()

static void _test_object_name_with_null ( unsigned  line,
HANDLE  handle,
UNICODE_STRING expect 
)
static

Definition at line 2856 of file om.c.

2857{
2858 char buffer[1024];
2860 ULONG len = 0;
2862
2863 memset(buffer, 0, sizeof(buffer));
2864 status = pNtQueryObject(handle, ObjectNameInformation, buffer, sizeof(buffer), &len);
2865 ok_(__FILE__,line)(status == STATUS_SUCCESS, "got %08lx\n", status);
2866 ok_(__FILE__,line)(len >= sizeof(OBJECT_NAME_INFORMATION) + str->Length, "got %lu\n", len);
2867 ok_(__FILE__,line)(str->Length == expect->Length, "got %u, expected %u\n", str->Length, expect->Length);
2868 ok_(__FILE__,line)(!wcsnicmp(str->Buffer, expect->Buffer, str->Length/sizeof(WCHAR)), "got %s, expected %s\n",
2869 debugstr_w(str->Buffer), debugstr_w(expect->Buffer));
2870}
#define wcsnicmp
Definition: compat.h:14
short WCHAR
Definition: pedump.c:58

◆ _test_object_type()

static void _test_object_type ( unsigned  line,
HANDLE  handle,
const WCHAR expected_name 
)
static

Definition at line 1645 of file om.c.

1646{
1647 char buffer[1024];
1650 ULONG len = 0;
1652
1653 RtlInitUnicodeString( &expect, expected_name );
1654
1655 memset( buffer, 0, sizeof(buffer) );
1656 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(buffer), &len );
1657 ok_(__FILE__,line)( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1658 ok_(__FILE__,line)( len > sizeof(UNICODE_STRING), "unexpected len %lu\n", len );
1659 ok_(__FILE__,line)( len >= sizeof(*type) + type->TypeName.Length, "unexpected len %lu\n", len );
1660 ok_(__FILE__,line)(compare_unicode_string( &type->TypeName, expected_name ), "wrong name %s\n",
1661 debugstr_w( type->TypeName.Buffer ));
1663}
@ ObjectTypeInformation
Definition: DriverTester.h:56
struct _UNICODE_STRING UNICODE_STRING
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void add_object_type(OBJECT_TYPE_INFORMATION *info)
Definition: om.c:1602

◆ add_object_type()

static void add_object_type ( OBJECT_TYPE_INFORMATION info)
static

Definition at line 1602 of file om.c.

1603{
1604 unsigned int i;
1605
1606 for (i = 0; i < ARRAY_SIZE(all_types); i++)
1607 {
1608 if (!all_types[i].TypeName.Buffer) break;
1609 if (!RtlCompareUnicodeString( &all_types[i].TypeName, &info->TypeName, FALSE )) break;
1610 }
1611 ok( i < ARRAY_SIZE(all_types), "too many types\n" );
1612
1613 if (all_types[i].TypeName.Buffer) /* existing type */
1614 {
1615 ok( !memcmp( &all_types[i].GenericMapping, &info->GenericMapping, sizeof(GENERIC_MAPPING) ),
1616 "%u: mismatched mappings %08lx,%08lx,%08lx,%08lx / %08lx,%08lx,%08lx,%08lx\n", i,
1619 info->GenericMapping.GenericRead, info->GenericMapping.GenericWrite,
1620 info->GenericMapping.GenericExecute, info->GenericMapping.GenericAll );
1621 ok( all_types[i].ValidAccessMask == info->ValidAccessMask,
1622 "%u: mismatched access mask %08lx / %08lx\n", i,
1623 all_types[i].ValidAccessMask, info->ValidAccessMask );
1624 }
1625 else /* add it */
1626 {
1627 all_types[i] = *info;
1629 }
1630 ok( info->TotalNumberOfObjects <= info->HighWaterNumberOfObjects, "%s: wrong object counts %lu/%lu\n",
1631 debugstr_w( all_types[i].TypeName.Buffer ),
1632 info->TotalNumberOfObjects, info->HighWaterNumberOfObjects );
1633 ok( info->TotalNumberOfHandles <= info->HighWaterNumberOfHandles, "%s: wrong handle counts %lu/%lu\n",
1634 debugstr_w( all_types[i].TypeName.Buffer ),
1635 info->TotalNumberOfHandles, info->HighWaterNumberOfHandles );
1636}
static GENERIC_MAPPING GenericMapping
Definition: SeInheritance.c:11
#define ok(value,...)
Definition: atltest.h:57
#define ARRAY_SIZE(A)
Definition: main.h:20
#define FALSE
Definition: types.h:117
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
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
static OBJECT_TYPE_INFORMATION all_types[256]
Definition: om.c:1600
ACCESS_MASK GenericExecute
Definition: nt_native.h:567
ACCESS_MASK GenericRead
Definition: nt_native.h:565
ACCESS_MASK GenericAll
Definition: nt_native.h:568
ACCESS_MASK GenericWrite
Definition: nt_native.h:566
UNICODE_STRING TypeName
Definition: obtypes.h:287
GENERIC_MAPPING GenericMapping
Definition: obtypes.h:301
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)

Referenced by _test_object_type(), and test_object_types().

◆ align_ptr()

static void * align_ptr ( void ptr)
static

Definition at line 2284 of file om.c.

2285{
2286 ULONG_PTR align = sizeof(DWORD_PTR) - 1;
2287 return (void *)(((DWORD_PTR)ptr + align) & ~align);
2288}
int align(int length, int align)
Definition: dsound8.c:36
static PVOID ptr
Definition: dispmode.c:27
#define DWORD_PTR
Definition: treelist.c:76
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by test_object_types().

◆ check_create_open_dir_()

static void check_create_open_dir_ ( int  line,
HANDLE  parent,
const WCHAR name,
NTSTATUS  expect 
)
static

Definition at line 239 of file om.c.

240{
244 HANDLE h;
245
248 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
249 ok_(__FILE__, line)( status == expect, "NtCreateDirectoryObject(%s) got %08lx\n", debugstr_w(name), status );
250 if (!status) pNtClose( h );
251
252 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
253 ok_(__FILE__, line)( status == expect, "NtOpenDirectoryObject(%s) got %08lx\n", debugstr_w(name), status );
254 if (!status) pNtClose( h );
255}
#define NULL
Definition: types.h:112
r parent
Definition: btrfs.c:3010
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:115
#define DIRECTORY_QUERY
Definition: nt_native.h:1257
Definition: cookie.c:202

◆ check_unicode_string_()

static void check_unicode_string_ ( int  line,
const UNICODE_STRING string,
const WCHAR expect 
)
static

Definition at line 109 of file om.c.

110{
111 size_t len = wcslen( expect ) * sizeof(WCHAR);
112
113 ok_(__FILE__, line)( !wcscmp( string->Buffer, expect ), "got string %s\n", debugstr_w( string->Buffer ));
114 ok_(__FILE__, line)( string->Length == len, "got length %u\n", string->Length );
115 ok_(__FILE__, line)( string->MaximumLength == len + sizeof(WCHAR), "got max length %u\n", string->MaximumLength );
116}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1972

◆ compare_unicode_string()

static BOOL compare_unicode_string ( const UNICODE_STRING string,
const WCHAR expect 
)
static

Definition at line 1638 of file om.c.

1639{
1640 return string->Length == wcslen( expect ) * sizeof(WCHAR)
1641 && !wcsnicmp( string->Buffer, expect, string->Length / sizeof(WCHAR) );
1642}

Referenced by _test_object_name(), _test_object_type(), test_globalroot(), and test_query_object().

◆ get_base_dir()

static HANDLE get_base_dir ( void  )
static

Definition at line 272 of file om.c.

273{
274 static const WCHAR objname[] = L"om.c_get_base_dir_obj";
278 HANDLE dir, h;
279 WCHAR name[40];
280
281 h = CreateMutexW( NULL, FALSE, objname );
282 ok(h != 0, "CreateMutexA failed got ret=%p (%ld)\n", h, GetLastError());
284
285 swprintf( name, ARRAY_SIZE(name), L"\\BaseNamedObjects\\Session\\%u", NtCurrentTeb()->Peb->SessionId );
287 status = pNtOpenDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
288 ok(!status, "got %#lx\n", status);
289 ok(is_correct_dir( dir, objname ), "wrong dir\n");
290
291 pNtClose( h );
292 return dir;
293}
unsigned int dir
Definition: maze.c:112
PPEB Peb
Definition: dllmain.c:27
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
#define NtCurrentTeb
static BOOL is_correct_dir(HANDLE dir, const WCHAR *name)
Definition: om.c:257
#define OBJ_OPENIF
Definition: winternl.h:229
ULONG SessionId
Definition: btrfs_drv.h:1919
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexW(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:525
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

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

◆ is_correct_dir()

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

Definition at line 257 of file om.c.

258{
262 HANDLE h = 0;
263
266 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
267 if (h) pNtClose( h );
269}
#define GENERIC_ALL
Definition: nt_native.h:92
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:189

Referenced by get_base_dir().

◆ NTSTATUS()

static NTSTATUS ( WINAPI pNtAllocateReserveObject)
static

◆ START_TEST()

START_TEST ( om  )

Definition at line 3910 of file om.c.

3911{
3912 HMODULE hntdll = GetModuleHandleA("ntdll.dll");
3913
3914 pNtAllocateReserveObject= (void *)GetProcAddress(hntdll, "NtAllocateReserveObject");
3915 pNtCreateEvent = (void *)GetProcAddress(hntdll, "NtCreateEvent");
3916 pNtCreateJobObject = (void *)GetProcAddress(hntdll, "NtCreateJobObject");
3917 pNtOpenJobObject = (void *)GetProcAddress(hntdll, "NtOpenJobObject");
3918 pNtCreateKey = (void *)GetProcAddress(hntdll, "NtCreateKey");
3919 pNtOpenKey = (void *)GetProcAddress(hntdll, "NtOpenKey");
3920 pNtDeleteKey = (void *)GetProcAddress(hntdll, "NtDeleteKey");
3921 pNtCreateMailslotFile = (void *)GetProcAddress(hntdll, "NtCreateMailslotFile");
3922 pNtCreateMutant = (void *)GetProcAddress(hntdll, "NtCreateMutant");
3923 pNtOpenEvent = (void *)GetProcAddress(hntdll, "NtOpenEvent");
3924 pNtOpenMutant = (void *)GetProcAddress(hntdll, "NtOpenMutant");
3925 pNtOpenFile = (void *)GetProcAddress(hntdll, "NtOpenFile");
3926 pNtClose = (void *)GetProcAddress(hntdll, "NtClose");
3927 pRtlInitUnicodeString = (void *)GetProcAddress(hntdll, "RtlInitUnicodeString");
3928 pNtCreateNamedPipeFile = (void *)GetProcAddress(hntdll, "NtCreateNamedPipeFile");
3929 pNtOpenDirectoryObject = (void *)GetProcAddress(hntdll, "NtOpenDirectoryObject");
3930 pNtCreateDirectoryObject= (void *)GetProcAddress(hntdll, "NtCreateDirectoryObject");
3931 pNtOpenSymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtOpenSymbolicLinkObject");
3932 pNtCreateSymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtCreateSymbolicLinkObject");
3933 pNtQuerySymbolicLinkObject = (void *)GetProcAddress(hntdll, "NtQuerySymbolicLinkObject");
3934 pNtCreateSemaphore = (void *)GetProcAddress(hntdll, "NtCreateSemaphore");
3935 pNtOpenSemaphore = (void *)GetProcAddress(hntdll, "NtOpenSemaphore");
3936 pNtCreateTimer = (void *)GetProcAddress(hntdll, "NtCreateTimer");
3937 pNtOpenTimer = (void *)GetProcAddress(hntdll, "NtOpenTimer");
3938 pNtCreateSection = (void *)GetProcAddress(hntdll, "NtCreateSection");
3939 pNtOpenSection = (void *)GetProcAddress(hntdll, "NtOpenSection");
3940 pNtQueryObject = (void *)GetProcAddress(hntdll, "NtQueryObject");
3941 pNtReleaseSemaphore = (void *)GetProcAddress(hntdll, "NtReleaseSemaphore");
3942 pNtCreateKeyedEvent = (void *)GetProcAddress(hntdll, "NtCreateKeyedEvent");
3943 pNtOpenKeyedEvent = (void *)GetProcAddress(hntdll, "NtOpenKeyedEvent");
3944 pNtCreateIoCompletion = (void *)GetProcAddress(hntdll, "NtCreateIoCompletion");
3945 pNtOpenIoCompletion = (void *)GetProcAddress(hntdll, "NtOpenIoCompletion");
3946 pNtQueryInformationFile = (void *)GetProcAddress(hntdll, "NtQueryInformationFile");
3947 pNtOpenProcess = (void *)GetProcAddress(hntdll, "NtOpenProcess");
3948 pNtCreateDebugObject = (void *)GetProcAddress(hntdll, "NtCreateDebugObject");
3949 pNtGetNextThread = (void *)GetProcAddress(hntdll, "NtGetNextThread");
3950 pNtOpenProcessToken = (void *)GetProcAddress(hntdll, "NtOpenProcessToken");
3951 pNtOpenThreadToken = (void *)GetProcAddress(hntdll, "NtOpenThreadToken");
3952 pNtDuplicateToken = (void *)GetProcAddress(hntdll, "NtDuplicateToken");
3953 pNtDuplicateObject = (void *)GetProcAddress(hntdll, "NtDuplicateObject");
3954 pNtCompareObjects = (void *)GetProcAddress(hntdll, "NtCompareObjects");
3955 pNtOpenThread = (void *)GetProcAddress(hntdll, "NtOpenThread");
3956
3957#ifdef __REACTOS__
3959 win_skip("test_null_in_object_name() doesn't work on Windows 2003\n");
3960 else
3961#endif
3972 test_process();
3973 test_token();
3983}
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
#define win_skip
Definition: minitest.h:67
static HINSTANCE hntdll
Definition: process.c:68
static void test_object_types(void)
Definition: om.c:2323
static void test_name_limits(void)
Definition: om.c:641
static void test_globalroot(void)
Definition: om.c:2538
static void test_directory(void)
Definition: om.c:1149
static void test_case_sensitive(void)
Definition: om.c:118
static void test_type_mismatch(void)
Definition: om.c:2015
static void test_query_directory(void)
Definition: om.c:2649
static void test_namespace_pipe(void)
Definition: om.c:163
static void test_object_permanence(void)
Definition: om.c:3201
static void test_symboliclink(void)
Definition: om.c:1377
static void test_NtAllocateReserveObject(void)
Definition: om.c:3846
static void test_zero_access(void)
Definition: om.c:3429
static void test_object_identity(void)
Definition: om.c:2596
static void test_token(void)
Definition: om.c:2166
static void test_get_next_thread(void)
Definition: om.c:2457
static void test_null_in_object_name(void)
Definition: om.c:2872
static void test_duplicate_object(void)
Definition: om.c:2290
static void test_name_collisions(void)
Definition: om.c:295
static void test_query_object(void)
Definition: om.c:1683
static void test_process(void)
Definition: om.c:2110
static void test_null_device(void)
Definition: om.c:2037

◆ 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 460 of file om.c.

462{
465 NTSTATUS status, status2;
466 HANDLE ret, ret2;
467
468 RtlInitUnicodeString( &target, L"\\DosDevices" );
469 size.QuadPart = 4096;
470
471 ret = ret2 = (HANDLE)0xdeadbeef;
472 status = pNtCreateMutant( &ret, GENERIC_ALL, attr, FALSE );
473 ok( status == create_expect, "%u: NtCreateMutant failed %lx\n", line, status );
474 status2 = pNtOpenMutant( &ret2, GENERIC_ALL, attr );
475 ok( status2 == open_expect, "%u: NtOpenMutant failed %lx\n", line, status2 );
476 if (!status) pNtClose( ret );
477 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
478 "%u: NtCreateMutant handle %p\n", line, ret );
479 if (!status2) pNtClose( ret2 );
480 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
481 "%u: NtOpenMutant handle %p\n", line, ret );
482
483 ret = ret2 = (HANDLE)0xdeadbeef;
484 status = pNtCreateSemaphore( &ret, GENERIC_ALL, attr, 1, 2 );
485 ok( status == create_expect, "%u: NtCreateSemaphore failed %lx\n", line, status );
486 status2 = pNtOpenSemaphore( &ret2, GENERIC_ALL, attr );
487 ok( status2 == open_expect, "%u: NtOpenSemaphore failed %lx\n", line, status2 );
488 if (!status) pNtClose( ret );
489 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
490 "%u: NtCreateSemaphore handle %p\n", line, ret );
491 if (!status2) pNtClose( ret2 );
492 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
493 "%u: NtOpenSemaphore handle %p\n", line, ret );
494 ret = (HANDLE)0xdeadbeef;
495 status = pNtCreateSemaphore( &ret, GENERIC_ALL, attr, 2, 1 );
498 "%u: NtCreateSemaphore failed %lx\n", line, status );
499 ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
500 "%u: NtCreateSemaphore handle %p\n", line, ret );
501
502 ret = ret2 = (HANDLE)0xdeadbeef;
503 status = pNtCreateEvent( &ret, GENERIC_ALL, attr, SynchronizationEvent, 0 );
504 ok( status == create_expect, "%u: NtCreateEvent failed %lx\n", line, status );
505 status2 = pNtOpenEvent( &ret2, GENERIC_ALL, attr );
506 ok( status2 == open_expect, "%u: NtOpenEvent failed %lx\n", line, status2 );
507 if (!status) pNtClose( ret );
508 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
509 "%u: NtCreateEvent handle %p\n", line, ret );
510 if (!status2) pNtClose( ret2 );
511 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
512 "%u: NtOpenEvent handle %p\n", line, ret );
513 ret = (HANDLE)0xdeadbeef;
514 status = pNtCreateEvent( &ret, GENERIC_ALL, attr, 2, 0 );
517 "%u: NtCreateEvent failed %lx\n", line, status );
518 ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
519 "%u: NtCreateEvent handle %p\n", line, ret );
520
521 ret = ret2 = (HANDLE)0xdeadbeef;
522 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, attr, 0 );
523 ok( status == create_expect, "%u: NtCreateKeyedEvent failed %lx\n", line, status );
524 status2 = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, attr );
525 ok( status2 == open_expect, "%u: NtOpenKeyedEvent failed %lx\n", line, status2 );
526 if (!status) pNtClose( ret );
527 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
528 "%u: NtCreateKeyedEvent handle %p\n", line, ret );
529 if (!status2) pNtClose( ret2 );
530 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
531 "%u: NtOpenKeyedEvent handle %p\n", line, ret );
532
533 ret = ret2 = (HANDLE)0xdeadbeef;
534 status = pNtCreateTimer( &ret, GENERIC_ALL, attr, NotificationTimer );
535 ok( status == create_expect, "%u: NtCreateTimer failed %lx\n", line, status );
536 status2 = pNtOpenTimer( &ret2, GENERIC_ALL, attr );
537 ok( status2 == open_expect, "%u: NtOpenTimer failed %lx\n", line, status2 );
538 if (!status) pNtClose( ret );
539 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
540 "%u: NtCreateTimer handle %p\n", line, ret );
541 if (!status2) pNtClose( ret2 );
542 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
543 "%u: NtOpenTimer handle %p\n", line, ret );
544 ret = (HANDLE)0xdeadbeef;
545 status = pNtCreateTimer( &ret, GENERIC_ALL, attr, 2 );
548 "%u: NtCreateTimer failed %lx\n", line, status );
549 ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
550 "%u: NtCreateTimer handle %p\n", line, ret );
551
552 ret = ret2 = (HANDLE)0xdeadbeef;
553 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, attr, 0 );
554 ok( status == create_expect, "%u: NtCreateIoCompletion failed %lx\n", line, status );
555 status2 = pNtOpenIoCompletion( &ret2, GENERIC_ALL, attr );
556 ok( status2 == open_expect, "%u: NtOpenIoCompletion failed %lx\n", line, status2 );
557 if (!status) pNtClose( ret );
558 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
559 "%u: NtCreateIoCompletion handle %p\n", line, ret );
560 if (!status2) pNtClose( ret2 );
561 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
562 "%u: NtOpenIoCompletion handle %p\n", line, ret );
563
564 ret = ret2 = (HANDLE)0xdeadbeef;
565 status = pNtCreateJobObject( &ret, GENERIC_ALL, attr );
566 ok( status == create_expect, "%u: NtCreateJobObject failed %lx\n", line, status );
567 status2 = pNtOpenJobObject( &ret2, GENERIC_ALL, attr );
568 ok( status2 == open_expect, "%u: NtOpenJobObject failed %lx\n", line, status2 );
569 if (!status) pNtClose( ret );
570 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
571 "%u: NtCreateJobObject handle %p\n", line, ret );
572 if (!status2) pNtClose( ret2 );
573 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
574 "%u: NtOpenJobObject handle %p\n", line, ret );
575
576 ret = ret2 = (HANDLE)0xdeadbeef;
577 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, attr );
578 ok( status == create_expect, "%u: NtCreateDirectoryObject failed %lx\n", line, status );
579 status2 = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, attr );
580 ok( status2 == open_expect, "%u: NtOpenDirectoryObject failed %lx\n", line, status2 );
581 if (!status) pNtClose( ret );
582 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
583 "%u: NtCreateDirectoryObject handle %p\n", line, ret );
584 if (!status2) pNtClose( ret2 );
585 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
586 "%u: NtOpenDirectoryObject handle %p\n", line, ret );
587
588 ret = ret2 = (HANDLE)0xdeadbeef;
589 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, attr, &target );
590 ok( status == create_expect, "%u: NtCreateSymbolicLinkObject failed %lx\n", line, status );
591 status2 = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, attr );
592 ok( status2 == open_expect, "%u: NtOpenSymbolicLinkObject failed %lx\n", line, status2 );
593 if (!status) pNtClose( ret );
594 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
595 "%u: NtCreateSymbolicLinkObject handle %p\n", line, ret );
596 if (!status2) pNtClose( ret2 );
597 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
598 "%u: NtOpenSymbolicLinkObject handle %p\n", line, ret );
599 ret = (HANDLE)0xdeadbeef;
600 target.MaximumLength = 0;
601 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, attr, &target );
604 "%u: NtCreateSymbolicLinkObject failed %lx\n", line, status );
605 ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
606 "%u: NtCreateSymbolicLinkObject handle %p\n", line, ret );
607
608 ret = ret2 = (HANDLE)0xdeadbeef;
609 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
610 ok( status == create_expect, "%u: NtCreateSection failed %lx\n", line, status );
611 status2 = pNtOpenSection( &ret2, SECTION_MAP_WRITE, attr );
612 ok( status2 == open_expect, "%u: NtOpenSection failed %lx\n", line, status2 );
613 if (!status) pNtClose( ret );
614 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
615 "%u: NtCreateSection handle %p\n", line, ret );
616 if (!status2) pNtClose( ret2 );
617 else ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
618 "%u: NtOpenSection handle %p\n", line, ret );
619 ret = (HANDLE)0xdeadbeef;
620 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, attr, &size, 0x1234, SEC_COMMIT, 0 );
623 "%u: NtCreateSection failed %lx\n", line, status );
624 ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
625 "%u: NtCreateSection handle %p\n", line, ret );
626
627 ret = ret2 = (HANDLE)0xdeadbeef;
628 status = pNtCreateDebugObject( &ret, DEBUG_ALL_ACCESS, attr, 0 );
629 ok( status == create_expect, "%u: NtCreateDebugObject failed %lx\n", line, status );
630 if (!status) pNtClose( ret );
631 else ok( !ret || broken( ret == (HANDLE)0xdeadbeef ) /* vista */,
632 "%u: NtCreateDebugObject handle %p\n", line, ret );
633 status = pNtCreateDebugObject( &ret2, DEBUG_ALL_ACCESS, attr, 0xdead );
636 "%u: NtCreateDebugObject failed %lx\n", line, status );
637 ok( !ret2 || broken( ret2 == (HANDLE)0xdeadbeef ) /* vista */,
638 "%u: NtCreateDebugObject handle %p\n", line, ret );
639}
return ret
Definition: mutex.c:146
#define STATUS_ACCESS_VIOLATION
GLsizeiptr size
Definition: glext.h:5919
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SECTION_MAP_WRITE
Definition: nt_native.h:1291
#define PAGE_READWRITE
Definition: nt_native.h:1307
@ SynchronizationEvent
@ NotificationTimer
#define STATUS_INVALID_PARAMETER_4
Definition: ntstatus.h:572
#define STATUS_INVALID_PAGE_PROTECTION
Definition: ntstatus.h:399
static const const HANDLE
Definition: om.c:74
Definition: tools.h:99
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define DEBUG_ALL_ACCESS
Definition: winternl.h:4375

Referenced by test_name_limits().

◆ test_case_sensitive()

static void test_case_sensitive ( void  )
static

Definition at line 118 of file om.c.

119{
123 HANDLE Event, Mutant, h;
124
125 pRtlInitUnicodeString(&str, L"\\BaseNamedObjects\\test");
127 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
128 ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08lx)\n", status);
129
130 status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, NotificationEvent, FALSE);
132
133 pRtlInitUnicodeString(&str, L"\\BaseNamedObjects\\Test");
135 status = pNtCreateEvent(&Event, GENERIC_ALL, &attr, NotificationEvent, FALSE);
136 ok(status == STATUS_SUCCESS, "Failed to create Event(%08lx)\n", status);
137
138 pRtlInitUnicodeString(&str, L"\\BaseNamedObjects\\TEst");
140 status = pNtOpenMutant(&h, GENERIC_ALL, &attr);
142 "NtOpenMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
143
144 pNtClose(Mutant);
145
146 pRtlInitUnicodeString(&str, L"\\BASENamedObjects\\test");
148 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
150
151 status = pNtCreateEvent(&h, GENERIC_ALL, &attr, NotificationEvent, FALSE);
153 "NtCreateEvent should have failed with STATUS_OBJECT_NAME_COLLISION got(%08lx)\n", status);
154
155 attr.Attributes = 0;
156 status = pNtCreateMutant(&Mutant, GENERIC_ALL, &attr, FALSE);
158 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
159
160 pNtClose(Event);
161}
@ NotificationEvent
#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

Referenced by START_TEST().

◆ test_directory()

static void test_directory ( void  )
static

Definition at line 1149 of file om.c.

1150{
1154 HANDLE dir, dir1, h, h2;
1155 WCHAR buffer[256];
1156 ULONG len, full_len;
1157
1158 /* No name and/or no attributes */
1159 status = pNtCreateDirectoryObject(NULL, DIRECTORY_QUERY, &attr);
1160 ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER /* wow64 */, "got %#lx\n", status);
1161 status = pNtOpenDirectoryObject(NULL, DIRECTORY_QUERY, &attr);
1162 ok(status == STATUS_ACCESS_VIOLATION || status == STATUS_INVALID_PARAMETER /* wow64 */, "got %#lx\n", status);
1163
1164 status = pNtCreateDirectoryObject(&h, DIRECTORY_QUERY, NULL);
1165 ok(status == STATUS_SUCCESS, "Failed to create Directory without attributes(%08lx)\n", status);
1166 pNtClose(h);
1167 status = pNtOpenDirectoryObject(&h, DIRECTORY_QUERY, NULL);
1169 "NtOpenDirectoryObject should have failed with STATUS_INVALID_PARAMETER got(%08lx)\n", status);
1170
1172 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1173 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1174 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1175 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08lx\n", status );
1176
1177 /* Bad name */
1179
1181 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1182 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1183 pNtClose(h);
1184 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1185 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08lx\n", status );
1186 pNtClose(dir);
1187
1189 check_create_open_dir( NULL, L"\\BaseNamedObjects\\", STATUS_OBJECT_NAME_INVALID );
1190 check_create_open_dir( NULL, L"\\\\BaseNamedObjects", STATUS_OBJECT_NAME_INVALID );
1191 check_create_open_dir( NULL, L"\\BaseNamedObjects\\\\om.c-test", STATUS_OBJECT_NAME_INVALID );
1192 check_create_open_dir( NULL, L"\\BaseNamedObjects\\om.c-test\\", STATUS_OBJECT_PATH_NOT_FOUND );
1193
1194 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\om.c-test");
1195 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1196 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1197 status = pNtOpenDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
1198 ok( status == STATUS_SUCCESS, "Failed to open directory %08lx\n", status );
1199 pNtClose(h);
1200 pNtClose(dir1);
1201
1202
1203 /* Use of root directory */
1204
1205 /* Can't use symlinks as a directory */
1206 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\Local");
1208 status = pNtOpenSymbolicLinkObject(&dir, SYMBOLIC_LINK_QUERY, &attr);
1209
1210 ok(status == STATUS_SUCCESS, "Failed to open SymbolicLink(%08lx)\n", status);
1212 RtlInitUnicodeString(&str, L"one more level");
1213 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1214 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtCreateDirectoryObject got %08lx\n", status );
1215
1216 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\Local\\om.c-test" );
1218 status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
1219 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1220 RtlInitUnicodeString( &str, L"om.c-test" );
1222 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1223 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "Failed to open directory %08lx\n", status );
1224
1225 RtlInitUnicodeString( &str, L"om.c-event" );
1226 InitializeObjectAttributes( &attr, &str, 0, dir1, NULL );
1227 status = pNtCreateEvent( &h, GENERIC_ALL, &attr, SynchronizationEvent, 0 );
1228 ok( status == STATUS_SUCCESS, "NtCreateEvent failed %lx\n", status );
1229 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
1230 ok( status == STATUS_SUCCESS, "NtOpenEvent failed %lx\n", status );
1231 pNtClose( h2 );
1232 RtlInitUnicodeString( &str, L"om.c-test\\om.c-event" );
1234 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
1235 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "NtOpenEvent failed %lx\n", status );
1236 RtlInitUnicodeString( &str, L"\\BasedNamedObjects\\Local\\om.c-test\\om.c-event" );
1238 status = pNtOpenEvent( &h2, GENERIC_ALL, &attr );
1239 ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "NtOpenEvent failed %lx\n", status );
1240 pNtClose( h );
1241 pNtClose( dir1 );
1242
1243 str.Buffer = buffer;
1244 str.MaximumLength = sizeof(buffer);
1245 len = 0xdeadbeef;
1246 memset( buffer, 0xaa, sizeof(buffer) );
1247 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1248 ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08lx\n", status );
1249 full_len = str.Length + sizeof(WCHAR);
1250 ok( len == full_len, "bad length %lu/%lu\n", len, full_len );
1251 ok( buffer[len / sizeof(WCHAR) - 1] == 0, "no terminating null\n" );
1252
1253 str.MaximumLength = str.Length;
1254 str.Length = 0x4444;
1255 len = 0xdeadbeef;
1256 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1257 ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08lx\n", status );
1258 ok( len == full_len, "bad length %lu/%lu\n", len, full_len );
1259 ok( str.Length == 0x4444, "len set to %x\n", str.Length );
1260
1261 str.MaximumLength = 0;
1262 str.Length = 0x4444;
1263 len = 0xdeadbeef;
1264 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1265 ok( status == STATUS_BUFFER_TOO_SMALL, "NtQuerySymbolicLinkObject failed %08lx\n", status );
1266 ok( len == full_len, "bad length %lu/%lu\n", len, full_len );
1267 ok( str.Length == 0x4444, "len set to %x\n", str.Length );
1268
1269 str.MaximumLength = full_len;
1270 str.Length = 0x4444;
1271 len = 0xdeadbeef;
1272 status = pNtQuerySymbolicLinkObject( dir, &str, &len );
1273 ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08lx\n", status );
1274 ok( len == full_len, "bad length %lu/%lu\n", len, full_len );
1275 ok( str.Length == full_len - sizeof(WCHAR), "len set to %x\n", str.Length );
1276
1277 pNtClose(dir);
1278
1279 RtlInitUnicodeString(&str, L"\\BaseNamedObjects");
1281 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1282 ok( status == STATUS_SUCCESS, "Failed to open directory %08lx\n", status );
1283
1285 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1286 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenDirectoryObject got %08lx\n", status );
1287
1293
1295 RtlInitUnicodeString(&str, L"om.c-test");
1296 status = pNtCreateDirectoryObject( &dir1, DIRECTORY_QUERY, &attr );
1297 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1298 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1299 ok( status == STATUS_SUCCESS, "Failed to open directory %08lx\n", status );
1300
1301 pNtClose(h);
1302 pNtClose(dir1);
1303 pNtClose(dir);
1304
1305 /* Nested directories */
1306 RtlInitUnicodeString(&str, L"\\");
1308 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1309 ok( status == STATUS_SUCCESS, "Failed to open directory %08lx\n", status );
1311 status = pNtOpenDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1312 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenDirectoryObject got %08lx\n", status );
1313 pNtClose(dir);
1314
1316 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\om.c-test");
1317 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1318 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1319 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\om.c-test\\one more level");
1320 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1321 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1322 pNtClose(h);
1324 RtlInitUnicodeString(&str, L"one more level");
1325 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1326 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1327 pNtClose(h);
1328
1329 pNtClose(dir);
1330
1332 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\Global\\om.c-test");
1333 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1334 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1335 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\Local\\om.c-test\\one more level");
1336 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1337 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1338 pNtClose(h);
1340 RtlInitUnicodeString(&str, L"one more level");
1341 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
1342 ok( status == STATUS_SUCCESS, "Failed to create directory %08lx\n", status );
1343 pNtClose(h);
1344 pNtClose(dir);
1345
1346 /* Create other objects using RootDirectory */
1347
1349 RtlInitUnicodeString(&str, L"\\BaseNamedObjects");
1350 status = pNtOpenDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
1351 ok( status == STATUS_SUCCESS, "Failed to open directory %08lx\n", status );
1353
1354 /* Test invalid paths */
1355 RtlInitUnicodeString(&str, L"\\om.c-mutant");
1356 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1358 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
1359 RtlInitUnicodeString(&str, L"\\om.c-mutant\\");
1360 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1362 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
1363
1364 RtlInitUnicodeString(&str, L"om.c\\-mutant");
1365 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1367 "NtCreateMutant should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
1368
1369 RtlInitUnicodeString(&str, L"om.c-mutant");
1370 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
1371 ok(status == STATUS_SUCCESS, "Failed to create Mutant(%08lx)\n", status);
1372 pNtClose(h);
1373
1374 pNtClose(dir);
1375}
#define SYMBOLIC_LINK_QUERY
Definition: volume.c:47
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:389
#define check_create_open_dir(parent, name, status)
Definition: om.c:238
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148

Referenced by START_TEST().

◆ test_duplicate_object()

static void test_duplicate_object ( void  )
static

Definition at line 2290 of file om.c.

2291{
2293 HANDLE handle;
2294
2295 status = pNtDuplicateObject( GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(),
2296 &handle, PROCESS_ALL_ACCESS, 0, 0 );
2297 ok( !status, "NtDuplicateObject failed %lx\n", status );
2298 pNtClose( handle );
2299 status = pNtDuplicateObject( GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(),
2300 NULL, PROCESS_ALL_ACCESS, 0, 0 );
2301 ok( !status, "NtDuplicateObject failed %lx\n", status );
2302
2303 status = pNtDuplicateObject( GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(),
2304 (HANDLE *)0xdeadbee0, PROCESS_ALL_ACCESS, 0, 0 );
2305 ok( status == STATUS_ACCESS_VIOLATION, "NtDuplicateObject failed %lx\n", status );
2306
2307 handle = (HANDLE)0xdeadbeef;
2308 status = pNtDuplicateObject( GetCurrentProcess(), (HANDLE)0xdead, GetCurrentProcess(),
2309 &handle, PROCESS_ALL_ACCESS, 0, 0 );
2310 ok( status == STATUS_INVALID_HANDLE, "NtDuplicateObject failed %lx\n", status );
2311 ok( !handle, "handle set %p\n", handle );
2312
2313 handle = (HANDLE)0xdeadbeef;
2314 status = pNtDuplicateObject( GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(),
2315 &handle, ~0u, 0, 0 );
2316 todo_wine
2317 ok( status == STATUS_ACCESS_DENIED, "NtDuplicateObject failed %lx\n", status );
2318 todo_wine
2319 ok( !handle, "handle set %p\n", handle );
2320 if (!status) pNtClose( handle );
2321}
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define GetCurrentProcess()
Definition: compat.h:759
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 * u
Definition: glfuncs.h:240
#define todo_wine
Definition: minitest.h:80
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1327
static HANDLE ACCESS_MASK ULONG ULONG HANDLE * handle
Definition: om.c:95
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

Referenced by START_TEST().

◆ test_get_next_thread()

static void test_get_next_thread ( void  )
static

Definition at line 2457 of file om.c.

2458{
2459 HANDLE hprocess = GetCurrentProcess();
2460 HANDLE handle, thread, event, prev;
2463 BOOL found;
2464
2465 if (!pNtGetNextThread)
2466 {
2467 win_skip("NtGetNextThread is not available.\n");
2468 return;
2469 }
2470
2471 event = CreateEventA(NULL, FALSE, FALSE, NULL);
2472
2474
2475 status = pNtGetNextThread(hprocess, NULL, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, NULL);
2476 ok(status == STATUS_ACCESS_VIOLATION, "Got unexpected status %#lx.\n", status);
2477
2478 found = FALSE;
2479 prev = NULL;
2480 while (!(status = pNtGetNextThread(hprocess, prev, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle)))
2481 {
2482 if (prev)
2483 {
2485 found = TRUE;
2486 pNtClose(prev);
2487 }
2488 else
2489 {
2490 ok(GetThreadId(handle) == GetCurrentThreadId(), "Got unexpected thread id %04lx, current %04lx.\n",
2492 }
2493 prev = handle;
2494 handle = (HANDLE)0xdeadbeef;
2495 }
2496 pNtClose(prev);
2497 ok(!handle, "Got unexpected handle %p.\n", handle);
2498 ok(status == STATUS_NO_MORE_ENTRIES, "Unexpected status %#lx.\n", status);
2499 ok(found, "Thread not found.\n");
2500
2501 handle = (HANDLE)0xdeadbeef;
2502 status = pNtGetNextThread((void *)0xdeadbeef, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle);
2503 ok(status == STATUS_INVALID_HANDLE, "Unexpected status %#lx.\n", status);
2504 ok(!handle, "Got unexpected handle %p.\n", handle);
2505 handle = (HANDLE)0xdeadbeef;
2506 status = pNtGetNextThread(hprocess, (void *)0xdeadbeef, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle);
2507 ok(status == STATUS_INVALID_HANDLE, "Unexpected status %#lx.\n", status);
2508 ok(!handle, "Got unexpected handle %p.\n", handle);
2509
2510 /* Reversed search is only supported on recent enough Win10. */
2511 status = pNtGetNextThread(hprocess, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 1, &handle);
2512 ok(!status || broken(status == STATUS_INVALID_PARAMETER), "Unexpected status %#lx.\n", status);
2513 if (!status)
2514 pNtClose(handle);
2515
2516 status = pNtGetNextThread(hprocess, 0, PROCESS_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 2, &handle);
2517 ok(status == STATUS_INVALID_PARAMETER, "Unexpected status %#lx.\n", status);
2518
2519 SetEvent(event);
2521
2522 found = FALSE;
2523 prev = NULL;
2524 while (!(status = pNtGetNextThread(hprocess, prev, THREAD_QUERY_LIMITED_INFORMATION, OBJ_INHERIT, 0, &handle)))
2525 {
2526 if (prev)
2527 pNtClose(prev);
2529 found = TRUE;
2530 prev = handle;
2531 }
2532 pNtClose(prev);
2533 ok(found, "Thread not found.\n");
2534
2536}
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:739
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
DWORD WINAPI GetThreadId(IN HANDLE Thread)
Definition: thread.c:913
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _cl_event * event
Definition: glext.h:7739
static DWORD thread_id
Definition: protocol.c:159
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:285
static DWORD WINAPI test_get_next_thread_proc(void *arg)
Definition: om.c:2449
static HANDLE thread
Definition: om.c:94
#define OBJ_INHERIT
Definition: winternl.h:225
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventA(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:573
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

Referenced by START_TEST().

◆ test_get_next_thread_proc()

static DWORD WINAPI test_get_next_thread_proc ( void arg)
static

Definition at line 2449 of file om.c.

2450{
2451 HANDLE event = (HANDLE)arg;
2452
2454 return 0;
2455}

Referenced by test_get_next_thread().

◆ test_globalroot()

static void test_globalroot ( void  )
static

Definition at line 2538 of file om.c.

2539{
2544 HANDLE h;
2545 WCHAR buffer[256];
2546 ULONG len, full_len, i;
2547 static const struct { const WCHAR *name, *target; } symlinks[] = {
2548 { L"\\??\\GLOBALROOT", L"" },
2549 { L"\\??\\GLOBALROOT\\??\\GLOBALROOT", L"" },
2550 { L"\\??\\GLOBALROOT\\??\\GLOBALROOT\\??\\GLOBALROOT", L"" },
2551 { L"\\??\\GLOBALROOT\\DosDevices", L"\\??" },
2552 { L"\\??\\GLOBALROOT\\BaseNamedObjects\\Global", NULL },
2553 };
2554
2555 for (i = 0; i < ARRAY_SIZE(symlinks); i++)
2556 {
2557 pRtlInitUnicodeString(&str, symlinks[i].name);
2559 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
2560 ok(status == STATUS_SUCCESS, "NtOpenSymbolicLinkObject failed %08lx\n", status);
2561
2562 str.Buffer = buffer;
2563 str.MaximumLength = sizeof(buffer);
2564 len = 0xdeadbeef;
2565 memset( buffer, 0xaa, sizeof(buffer) );
2566 status = pNtQuerySymbolicLinkObject( h, &str, &len);
2567 ok( status == STATUS_SUCCESS, "NtQuerySymbolicLinkObject failed %08lx\n", status );
2568 full_len = str.Length + sizeof(WCHAR);
2569 ok( len == full_len, "bad length %lu (expected %lu)\n", len, full_len );
2570 ok( buffer[len / sizeof(WCHAR) - 1] == 0, "no terminating null\n" );
2571
2572 if (symlinks[i].target)
2573 {
2574 ok( compare_unicode_string( &str, symlinks[i].target ),
2575 "symlink %s: target expected %s, got %s\n",
2576 debugstr_w( symlinks[i].name ),
2577 debugstr_w( symlinks[i].target ),
2578 debugstr_w( str.Buffer ) );
2579 }
2580
2581 pNtClose(h);
2582 }
2583
2584 pRtlInitUnicodeString(&str, L"\\??\\GLOBALROOT\\Device\\Null");
2586 status = pNtOpenFile(&h, GENERIC_READ | GENERIC_WRITE, &attr, &iosb,
2589 "expected STATUS_SUCCESS, got %08lx\n", status);
2590
2591 test_object_type(h, L"File");
2592
2593 pNtClose(h);
2594}
#define GENERIC_READ
Definition: compat.h:135
#define FILE_SHARE_READ
Definition: compat.h:136
static PIO_STATUS_BLOCK iosb
Definition: file.c:70
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define test_object_type(a, b)
Definition: om.c:1644

Referenced by START_TEST().

◆ test_name_collisions()

static void test_name_collisions ( void  )
static

Definition at line 295 of file om.c.

296{
300 HANDLE dir, h, h1, h2;
301 DWORD winerr;
304
307 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
308 ok( status == STATUS_OBJECT_NAME_COLLISION, "NtCreateDirectoryObject got %08lx\n", status );
310
311 status = pNtCreateDirectoryObject( &h, DIRECTORY_QUERY, &attr );
312 ok( status == STATUS_OBJECT_NAME_EXISTS, "NtCreateDirectoryObject got %08lx\n", status );
313 pNtClose(h);
314 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
316 "NtCreateMutant should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
317
318 RtlInitUnicodeString(&str, L"\\??\\PIPE\\om.c-mutant");
319 status = pNtCreateMutant(&h, GENERIC_ALL, &attr, FALSE);
321
322 dir = get_base_dir();
323 RtlInitUnicodeString(&str, L"om.c-test");
325 h = CreateMutexA(NULL, FALSE, "om.c-test");
326 ok(h != 0, "CreateMutexA failed got ret=%p (%ld)\n", h, GetLastError());
327 status = pNtCreateMutant(&h1, GENERIC_ALL, &attr, FALSE);
329 "NtCreateMutant should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
330 h2 = CreateMutexA(NULL, FALSE, "om.c-test");
331 winerr = GetLastError();
332 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
333 "CreateMutexA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%ld)\n", h2, winerr);
334 pNtClose(h);
335 pNtClose(h1);
336 pNtClose(h2);
337
338 h = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
339 ok(h != 0, "CreateEventA failed got ret=%p (%ld)\n", h, GetLastError());
340 status = pNtCreateEvent(&h1, GENERIC_ALL, &attr, NotificationEvent, FALSE);
342 "NtCreateEvent should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
343 h2 = CreateEventA(NULL, FALSE, FALSE, "om.c-test");
344 winerr = GetLastError();
345 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
346 "CreateEventA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%ld)\n", h2, winerr);
347 pNtClose(h);
348 pNtClose(h1);
349 pNtClose(h2);
350
351 h = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
352 ok(h != 0, "CreateSemaphoreA failed got ret=%p (%ld)\n", h, GetLastError());
353 status = pNtCreateSemaphore(&h1, GENERIC_ALL, &attr, 1, 2);
355 "NtCreateSemaphore should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
356 h2 = CreateSemaphoreA(NULL, 1, 2, "om.c-test");
357 winerr = GetLastError();
358 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
359 "CreateSemaphoreA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%ld)\n", h2, winerr);
360 pNtClose(h);
361 pNtClose(h1);
362 pNtClose(h2);
363
364 h = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
365 ok(h != 0, "CreateWaitableTimerA failed got ret=%p (%ld)\n", h, GetLastError());
366 status = pNtCreateTimer(&h1, GENERIC_ALL, &attr, NotificationTimer);
368 "NtCreateTimer should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
369 h2 = CreateWaitableTimerA(NULL, TRUE, "om.c-test");
370 winerr = GetLastError();
371 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
372 "CreateWaitableTimerA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%ld)\n", h2, winerr);
373 pNtClose(h);
374 pNtClose(h1);
375 pNtClose(h2);
376
378 ok(h != 0, "CreateFileMappingA failed got ret=%p (%ld)\n", h, GetLastError());
379 size.u.LowPart = 256;
380 size.u.HighPart = 0;
381 status = pNtCreateSection(&h1, SECTION_MAP_WRITE, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0);
383 "NtCreateSection should have succeeded with STATUS_OBJECT_NAME_EXISTS got(%08lx)\n", status);
384 h2 = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 256, "om.c-test");
385 winerr = GetLastError();
386 ok(h2 != 0 && winerr == ERROR_ALREADY_EXISTS,
387 "CreateFileMappingA should have succeeded with ERROR_ALREADY_EXISTS got ret=%p (%ld)\n", h2, winerr);
388 pNtClose(h);
389 pNtClose(h1);
390 pNtClose(h2);
391
392 pNtClose(dir);
393
394 RtlInitUnicodeString(&str, L"\\??\\PIPE\\named_pipe");
395 attr.RootDirectory = 0;
396 timeout.QuadPart = -10000;
397 status = pNtCreateNamedPipeFile( &h, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
400 FALSE, FALSE, FALSE, 10, 256, 256, &timeout );
401 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "failed to create pipe %08lx\n", status);
402
403 memset( &iosb, 0xcc, sizeof(iosb) );
404 status = pNtCreateNamedPipeFile( &h, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
407 FALSE, FALSE, FALSE, 10, 256, 256, &timeout );
408 ok(status == STATUS_SUCCESS, "failed to create pipe %08lx\n", status);
409 ok( iosb.Status == STATUS_SUCCESS, "wrong status %08lx\n", status);
410 ok( iosb.Information == FILE_CREATED, "wrong info %Ix\n", iosb.Information );
411 pNtClose( h );
412
413 memset( &iosb, 0xcc, sizeof(iosb) );
414 status = pNtCreateNamedPipeFile( &h, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
417 FALSE, FALSE, FALSE, 10, 256, 256, &timeout );
418 ok(status == STATUS_SUCCESS, "failed to create pipe %08lx\n", status);
419 ok( iosb.Status == STATUS_SUCCESS, "wrong status %08lx\n", status);
420 ok( iosb.Information == FILE_CREATED, "wrong info %Ix\n", iosb.Information );
421
422 memset( &iosb, 0xcc, sizeof(iosb) );
423 status = pNtCreateNamedPipeFile( &h1, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
426 FALSE, FALSE, FALSE, 10, 256, 256, &timeout );
427 ok(status == STATUS_SUCCESS, "failed to create pipe %08lx\n", status);
428 ok( iosb.Status == STATUS_SUCCESS, "wrong status %08lx\n", status);
429 ok( iosb.Information == FILE_OPENED, "wrong info %Ix\n", iosb.Information );
430 pNtClose(h1);
431
432 memset( &iosb, 0xcc, sizeof(iosb) );
433 status = pNtCreateNamedPipeFile( &h1, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
436 FALSE, FALSE, FALSE, 10, 256, 256, &timeout );
437 ok(status == STATUS_SUCCESS, "failed to create pipe %08lx\n", status);
438 ok( iosb.Status == STATUS_SUCCESS, "wrong status %08lx\n", status);
439 ok( iosb.Information == FILE_OPENED, "wrong info %Ix\n", iosb.Information );
440 pNtClose(h1);
441
442 memset( &iosb, 0xcc, sizeof(iosb) );
443 status = pNtCreateNamedPipeFile( &h1, GENERIC_READ|GENERIC_WRITE, &attr, &iosb,
446 FALSE, FALSE, FALSE, 10, 256, 256, NULL );
447 ok(status == STATUS_SUCCESS, "failed to create pipe %08lx\n", status);
448 ok( iosb.Status == STATUS_SUCCESS, "wrong status %08lx\n", status);
449 ok( iosb.Information == FILE_OPENED, "wrong info %Ix\n", iosb.Information );
450 pNtClose(h1);
451
452 h1 = CreateNamedPipeA( "\\\\.\\pipe\\named_pipe", PIPE_ACCESS_DUPLEX,
453 PIPE_READMODE_BYTE, 10, 256, 256, 1000, NULL );
454 winerr = GetLastError();
455 ok(h1 != 0 && winerr == ERROR_ALREADY_EXISTS, "CreateNamedPipeA got ret=%p (%ld)\n", h1, winerr);
456 pNtClose(h1);
457 pNtClose(h);
458}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
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 FILE_OPEN
Definition: from_kernel.h:54
#define FILE_CREATE
Definition: from_kernel.h:55
#define FILE_OPEN_IF
Definition: from_kernel.h:56
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define FILE_PIPE_FULL_DUPLEX
Definition: iotypes.h:83
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 FILE_CREATED
Definition: nt_native.h:770
#define FILE_OPENED
Definition: nt_native.h:769
static HANDLE get_base_dir(void)
Definition: om.c:272
Definition: dhcpd.h:248
HANDLE WINAPI DECLSPEC_HOTPATCH CreateMutexA(IN LPSECURITY_ATTRIBUTES lpMutexAttributes OPTIONAL, IN BOOL bInitialOwner, IN LPCSTR lpName OPTIONAL)
Definition: synch.c:512
HANDLE WINAPI CreateWaitableTimerA(IN LPSECURITY_ATTRIBUTES lpTimerAttributes OPTIONAL, IN BOOL bManualReset, IN LPCSTR lpTimerName OPTIONAL)
Definition: synchansi.c:19
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA(IN LPSECURITY_ATTRIBUTES lpSemaphoreAttributes OPTIONAL, IN LONG lInitialCount, IN LONG lMaximumCount, IN LPCSTR lpName OPTIONAL)
Definition: synchansi.c:44
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define PIPE_READMODE_BYTE
Definition: winbase.h:171
#define PIPE_ACCESS_DUPLEX
Definition: winbase.h:166

Referenced by START_TEST().

◆ test_name_limits()

static void test_name_limits ( void  )
static

Definition at line 641 of file om.c.

642{
643 static const WCHAR pipeW[] = L"\\Device\\NamedPipe\\";
644 static const WCHAR mailslotW[] = L"\\Device\\MailSlot\\";
645 static const WCHAR registryW[] = L"\\REGISTRY\\Machine\\SOFTWARE\\Microsoft\\";
646 OBJECT_ATTRIBUTES attr, attr2, attr3;
651 HANDLE ret, ret2;
652 DWORD i;
653
655 InitializeObjectAttributes( &attr2, &str, 0, (HANDLE)0xdeadbeef, NULL );
656 InitializeObjectAttributes( &attr3, &str, 0, 0, NULL );
657 str.Buffer = HeapAlloc( GetProcessHeap(), 0, 65536 + sizeof(registryW));
658 str.MaximumLength = 65534;
659 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i] = 'a';
660 size.QuadPart = 4096;
661 RtlInitUnicodeString( &target, L"\\DosDevices" );
662
663 attr.RootDirectory = get_base_dir();
664 str.Length = 0;
665 status = pNtCreateMutant( &ret, GENERIC_ALL, &attr2, FALSE );
666 ok( status == STATUS_SUCCESS, "%u: NtCreateMutant failed %lx\n", str.Length, status );
667 attr3.RootDirectory = ret;
668 status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr );
669 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenMutant failed %lx\n", str.Length, status);
670 status = pNtOpenMutant( &ret2, GENERIC_ALL, &attr3 );
671 ok( status == (__REACTOS__WinVer_lt(_WIN32_WINNT_WIN7) ? STATUS_INVALID_HANDLE : STATUS_OBJECT_TYPE_MISMATCH), "%u: NtOpenMutant failed %lx\n", str.Length, status );
672 pNtClose( ret );
673 status = pNtCreateSemaphore( &ret, GENERIC_ALL, &attr2, 1, 2 );
674 ok( status == STATUS_SUCCESS, "%u: NtCreateSemaphore failed %lx\n", str.Length, status );
675 attr3.RootDirectory = ret;
676 status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr );
677 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSemaphore failed %lx\n", str.Length, status );
678 status = pNtOpenSemaphore( &ret2, GENERIC_ALL, &attr3 );
679 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenSemaphore failed %lx\n", str.Length, status );
680 pNtClose( ret );
681 status = pNtCreateEvent( &ret, GENERIC_ALL, &attr2, SynchronizationEvent, 0 );
682 ok( status == STATUS_SUCCESS, "%u: NtCreateEvent failed %lx\n", str.Length, status );
683 attr3.RootDirectory = ret;
684 status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr );
685 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenEvent failed %lx\n", str.Length, status );
686 status = pNtOpenEvent( &ret2, GENERIC_ALL, &attr3 );
687 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenEvent failed %lx\n", str.Length, status );
688 pNtClose( ret );
689 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, &attr2, 0 );
690 ok( status == STATUS_SUCCESS, "%u: NtCreateKeyedEvent failed %lx\n", str.Length, status );
691 attr3.RootDirectory = ret;
692 status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr );
693 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenKeyedEvent failed %lx\n", str.Length, status );
694 status = pNtOpenKeyedEvent( &ret2, GENERIC_ALL, &attr3 );
695 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenKeyedEvent failed %lx\n", str.Length, status );
696 pNtClose( ret );
697 status = pNtCreateTimer( &ret, GENERIC_ALL, &attr2, NotificationTimer );
698 ok( status == STATUS_SUCCESS, "%u: NtCreateTimer failed %lx\n", str.Length, status );
699 attr3.RootDirectory = ret;
700 status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr );
701 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenTimer failed %lx\n", str.Length, status );
702 status = pNtOpenTimer( &ret2, GENERIC_ALL, &attr3 );
703 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenTimer failed %lx\n", str.Length, status );
704 pNtClose( ret );
705 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, &attr2, 0 );
706 ok( status == STATUS_SUCCESS, "%u: NtCreateCompletion failed %lx\n", str.Length, status );
707 attr3.RootDirectory = ret;
708 status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr );
709 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenCompletion failed %lx\n", str.Length, status );
710 status = pNtOpenIoCompletion( &ret2, GENERIC_ALL, &attr3 );
711 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenCompletion failed %lx\n", str.Length, status );
712 pNtClose( ret );
713 status = pNtCreateJobObject( &ret, GENERIC_ALL, &attr2 );
714 ok( status == STATUS_SUCCESS, "%u: NtCreateJobObject failed %lx\n", str.Length, status );
715 attr3.RootDirectory = ret;
716 status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr );
717 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenJobObject failed %lx\n", str.Length, status );
718 status = pNtOpenJobObject( &ret2, GENERIC_ALL, &attr3 );
719 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenJobObject failed %lx\n", str.Length, status );
720 pNtClose( ret );
721 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, &attr2 );
722 ok( status == STATUS_SUCCESS, "%u: NtCreateDirectoryObject failed %lx\n", str.Length, status );
723 attr3.RootDirectory = ret;
724 status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr );
725 ok( status == STATUS_SUCCESS, "%u: NtOpenDirectoryObject failed %lx\n", str.Length, status );
726 if (!status) pNtClose( ret2 );
727 status = pNtOpenDirectoryObject( &ret2, GENERIC_ALL, &attr3 );
728 ok( status == STATUS_SUCCESS, "%u: NtOpenDirectoryObject failed %lx\n", str.Length, status );
729 pNtClose( ret2 );
730 pNtClose( ret );
731 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, &attr2, &target );
732 ok( status == STATUS_SUCCESS, "%u: NtCreateSymbolicLinkObject failed %lx\n", str.Length, status );
733 attr3.RootDirectory = ret;
734 status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr );
735 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSymbolicLinkObject failed %lx\n", str.Length, status );
736 status = pNtOpenSymbolicLinkObject( &ret2, GENERIC_ALL, &attr3 );
737 ok( status == STATUS_SUCCESS, "%u: NtOpenSymbolicLinkObject failed %lx\n", str.Length, status );
738 pNtClose( ret2 );
739 pNtClose( ret );
740 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
741 ok( status == STATUS_SUCCESS, "%u: NtCreateSection failed %lx\n", str.Length, status );
742 attr3.RootDirectory = ret;
743 status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr );
744 ok( status == STATUS_OBJECT_TYPE_MISMATCH, "%u: NtOpenSection failed %lx\n", str.Length, status );
745 status = pNtOpenSection( &ret2, SECTION_MAP_WRITE, &attr3 );
746 ok( status == STATUS_OBJECT_TYPE_MISMATCH || /* __REACTOS__ */ broken(status == STATUS_INVALID_HANDLE), "%u: NtOpenSection failed %lx\n", str.Length, status );
747 pNtClose( ret );
748
749 str.Length = 67;
751
752 str.Length = 65532;
754
755 str.Length = 65534;
757
758 str.Length = 128;
759 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
760 {
761 if (attr.Length == sizeof(attr))
763 else
765 }
766 attr.Length = sizeof(attr);
767
768 /* null attributes or ObjectName, with or without RootDirectory */
769 attr3.RootDirectory = 0;
770 attr2.ObjectName = attr3.ObjectName = NULL;
773 attr2.ObjectName = attr3.ObjectName = (void *)0xdeadbeef;
776 attr2.ObjectName = attr3.ObjectName = &str2;
777 str2.Buffer = (WCHAR *)((char *)pipeW + 1); /* misaligned buffer */
778 str2.Length = 3;
781 str2.Buffer = (WCHAR *)0xdeadbee0;
782 str2.Length = 2;
785
786 attr3.ObjectName = &str2;
787 pRtlInitUnicodeString( &str2, L"\\BaseNamedObjects\\Local" );
788 status = pNtOpenSymbolicLinkObject( &ret, SYMBOLIC_LINK_QUERY, &attr3 );
789 ok( status == STATUS_SUCCESS, "can't open BaseNamedObjects\\Local %lx\n", status );
790 attr3.ObjectName = &str;
791 attr3.RootDirectory = ret;
793 pNtClose( attr3.RootDirectory );
794
795 status = pNtCreateMutant( &ret, GENERIC_ALL, NULL, FALSE );
796 ok( status == STATUS_SUCCESS, "NULL: NtCreateMutant failed %lx\n", status );
797 pNtClose( ret );
798 status = pNtCreateMutant( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, FALSE );
799 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateMutant failed %lx\n", status );
800 ret = (HANDLE)0xdeadbeef;
801 status = pNtOpenMutant( &ret, GENERIC_ALL, NULL );
802 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenMutant failed %lx\n", status );
803 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
804 status = pNtOpenMutant( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
805 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenMutant failed %lx\n", status );
806
807 status = pNtCreateSemaphore( &ret, GENERIC_ALL, NULL, 1, 2 );
808 ok( status == STATUS_SUCCESS, "NULL: NtCreateSemaphore failed %lx\n", status );
809 pNtClose( ret );
810 status = pNtCreateSemaphore( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, 1, 2 );
811 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateSemaphore failed %lx\n", status );
812 ret = (HANDLE)0xdeadbeef;
813 status = pNtOpenSemaphore( &ret, GENERIC_ALL, NULL );
814 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSemaphore failed %lx\n", status );
815 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
816 status = pNtOpenSemaphore( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
817 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenSemaphore failed %lx\n", status );
818
819 status = pNtCreateEvent( &ret, GENERIC_ALL, NULL, SynchronizationEvent, 0 );
820 ok( status == STATUS_SUCCESS, "NULL: NtCreateEvent failed %lx\n", status );
821 pNtClose( ret );
822 status = pNtCreateEvent( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, SynchronizationEvent, 0 );
823 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateEvent failed %lx\n", status );
824 ret = (HANDLE)0xdeadbeef;
825 status = pNtOpenEvent( &ret, GENERIC_ALL, NULL );
826 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenEvent failed %lx\n", status );
827 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
828 status = pNtOpenEvent( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
829 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenEvent failed %lx\n", status );
830
831 status = pNtCreateKeyedEvent( &ret, GENERIC_ALL, NULL, 0 );
832 ok( status == STATUS_SUCCESS, "NULL: NtCreateKeyedEvent failed %lx\n", status );
833 pNtClose( ret );
834 status = pNtCreateKeyedEvent( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, 0 );
835 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKeyedEvent failed %lx\n", status );
836 ret = (HANDLE)0xdeadbeef;
837 status = pNtOpenKeyedEvent( &ret, GENERIC_ALL, NULL );
838 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenKeyedEvent failed %lx\n", status );
839 ok( !ret, "handle set %p\n", ret );
840 status = pNtOpenKeyedEvent( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
841 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKeyedEvent failed %lx\n", status );
842
843 status = pNtCreateTimer( &ret, GENERIC_ALL, NULL, NotificationTimer );
844 ok( status == STATUS_SUCCESS, "NULL: NtCreateTimer failed %lx\n", status );
845 pNtClose( ret );
846 status = pNtCreateTimer( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, NotificationTimer );
847 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateTimer failed %lx\n", status );
848 ret = (HANDLE)0xdeadbeef;
849 status = pNtOpenTimer( &ret, GENERIC_ALL, NULL );
850 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenTimer failed %lx\n", status );
851 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
852 status = pNtOpenTimer( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
853 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenTimer failed %lx\n", status );
854
855 status = pNtCreateIoCompletion( &ret, GENERIC_ALL, NULL, 0 );
856 ok( status == STATUS_SUCCESS, "NULL: NtCreateCompletion failed %lx\n", status );
857 pNtClose( ret );
858 status = pNtCreateIoCompletion( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, 0 );
859 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateCompletion failed %lx\n", status );
860 ret = (HANDLE)0xdeadbeef;
861 status = pNtOpenIoCompletion( &ret, GENERIC_ALL, NULL );
862 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenCompletion failed %lx\n", status );
863 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
864 status = pNtOpenIoCompletion( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
865 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenCompletion failed %lx\n", status );
866
867 status = pNtCreateJobObject( &ret, GENERIC_ALL, NULL );
868 ok( status == STATUS_SUCCESS, "NULL: NtCreateJobObject failed %lx\n", status );
869 pNtClose( ret );
870 status = pNtCreateJobObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
871 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateJobObject failed %lx\n", status );
872 ret = (HANDLE)0xdeadbeef;
873 status = pNtOpenJobObject( &ret, GENERIC_ALL, NULL );
874 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenJobObject failed %lx\n", status );
875 ok( !ret || broken(ret == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", ret );
876 status = pNtOpenJobObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
877 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenJobObject failed %lx\n", status );
878
879 status = pNtCreateDirectoryObject( &ret, GENERIC_ALL, NULL );
880 ok( status == STATUS_SUCCESS, "NULL: NtCreateDirectoryObject failed %lx\n", status );
881 pNtClose( ret );
882 status = pNtCreateDirectoryObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
883 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateDirectoryObject failed %lx\n", status );
884 ret = (HANDLE)0xdeadbeef;
885 status = pNtOpenDirectoryObject( &ret, GENERIC_ALL, NULL );
886 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenDirectoryObject failed %lx\n", status );
887 ok( !ret, "handle set %p\n", ret );
888 status = pNtOpenDirectoryObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
889 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenDirectoryObject failed %lx\n", status );
890
891 status = pNtCreateSymbolicLinkObject( &ret, GENERIC_ALL, NULL, &target );
892 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateSymbolicLinkObject failed %lx\n", status );
893 if (!status) pNtClose( ret );
894 status = pNtCreateSymbolicLinkObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL, &target );
895 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateSymbolicLinkObject failed %lx\n", status );
896 ret = (HANDLE)0xdeadbeef;
897 status = pNtOpenSymbolicLinkObject( &ret, GENERIC_ALL, NULL );
898 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSymbolicLinkObject failed %lx\n", status );
899 ok( !ret, "handle set %p\n", ret );
900 status = pNtOpenSymbolicLinkObject( (HANDLE *)0xdeadbee0, GENERIC_ALL, NULL );
901 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenSymbolicLinkObject failed %lx\n", status );
902
903 status = pNtCreateSection( &ret, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
904 ok( status == STATUS_SUCCESS, "NULL: NtCreateSection failed %lx\n", status );
905 pNtClose( ret );
906 status = pNtCreateSection( (HANDLE *)0xdeadbee0, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
907 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateSection failed %lx\n", status );
908 ret = (HANDLE)0xdeadbeef;
909 status = pNtOpenSection( &ret, SECTION_MAP_WRITE, NULL );
910 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtOpenSection failed %lx\n", status );
911 ok( !ret, "handle set %p\n", ret );
912 status = pNtOpenSection( (HANDLE *)0xdeadbee0, SECTION_MAP_WRITE, NULL );
913 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenSection failed %lx\n", status );
914 attr2.ObjectName = attr3.ObjectName = &str;
915
916 /* named pipes */
917 wcscpy( str.Buffer, pipeW );
918 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen( pipeW )] = 'a';
919 str.Length = 0;
920 attr.RootDirectory = 0;
921 attr.Attributes = OBJ_CASE_INSENSITIVE;
922 timeout.QuadPart = -10000;
923 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
924 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
925 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
926 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
927 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
928 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
929 str.Length = 67;
930 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
931 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
932 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
933 str.Length = 128;
934 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
935 {
936 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
937 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
938 if (attr.Length == sizeof(attr))
939 {
940 ok( status == STATUS_SUCCESS, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
941 pNtClose( ret );
942 }
944 "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
945 }
946 attr.Length = sizeof(attr);
947 str.Length = 65532;
948 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
949 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
950 ok( status == STATUS_SUCCESS, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
951 pNtClose( ret );
952 str.Length = 65534;
953 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
954 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
955 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateNamedPipeFile failed %lx\n", str.Length, status );
956 attr3.RootDirectory = 0;
957 attr2.ObjectName = attr3.ObjectName = NULL;
958 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr2, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
959 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
960 ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateNamedPipeFile failed %lx\n", status );
961 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, &attr3, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
962 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
963 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateNamedPipeFile failed %lx\n", status );
964 status = pNtCreateNamedPipeFile( &ret, GENERIC_ALL, NULL, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
965 FILE_CREATE, FILE_PIPE_FULL_DUPLEX, 0, 0, 0, 1, 256, 256, &timeout );
966 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtCreateNamedPipeFile failed %lx\n", status );
967 attr2.ObjectName = attr3.ObjectName = &str;
968
969 /* mailslots */
970 wcscpy( str.Buffer, mailslotW );
971 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen( mailslotW )] = 'a';
972 str.Length = 0;
973 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
974 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
975 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
976 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
977 str.Length = 67;
978 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
979 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
980 str.Length = 128;
981 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
982 {
983 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
984 if (attr.Length == sizeof(attr))
985 {
986 ok( status == STATUS_SUCCESS, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
987 pNtClose( ret );
988 }
990 "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
991 }
992 attr.Length = sizeof(attr);
993 str.Length = 65532;
994 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
995 ok( status == STATUS_SUCCESS, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
996 pNtClose( ret );
997 str.Length = 65534;
998 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
999 ok( status == STATUS_OBJECT_NAME_INVALID, "%u: NtCreateMailslotFile failed %lx\n", str.Length, status );
1000 attr3.RootDirectory = 0;
1001 attr2.ObjectName = attr3.ObjectName = NULL;
1002 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr2, &iosb, 0, 0, 0, NULL );
1003 ok( status == STATUS_OBJECT_NAME_INVALID, "NULL: NtCreateMailslotFile failed %lx\n", status );
1004 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, &attr3, &iosb, 0, 0, 0, NULL );
1005 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NULL: NtCreateMailslotFile failed %lx\n", status );
1006 status = pNtCreateMailslotFile( &ret, GENERIC_ALL, NULL, &iosb, 0, 0, 0, NULL );
1007 ok( status == STATUS_INVALID_PARAMETER, "NULL: NtCreateMailslotFile failed %lx\n", status );
1008 attr2.ObjectName = attr3.ObjectName = &str;
1009
1010 /* registry keys */
1011 wcscpy( str.Buffer, registryW );
1012 for (i = 0; i < 65536 / sizeof(WCHAR); i++) str.Buffer[i + wcslen(registryW)] = 'a';
1013 str.Length = 0;
1014 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1015 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "%u: NtCreateKey failed %lx\n", str.Length, status );
1016 status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL );
1017 ok( status == STATUS_INVALID_HANDLE, "%u: NtCreateKey failed %lx\n", str.Length, status );
1018 status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 );
1019 ok( status == STATUS_INVALID_HANDLE, "%u: NtOpenKey failed %lx\n", str.Length, status );
1020 str.Length = (wcslen( registryW ) + 250) * sizeof(WCHAR) + 1;
1021 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1024 broken( status == STATUS_SUCCESS ), /* wow64 */
1025 "%u: NtCreateKey failed %lx\n", str.Length, status );
1026 if (!status)
1027 {
1028 pNtDeleteKey( ret );
1029 pNtClose( ret );
1030 }
1031 str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR);
1032 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1034 "%u: NtCreateKey failed %lx\n", str.Length, status );
1035 status = pNtCreateKey( (HANDLE *)0xdeadbee0, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1036 ok( status == STATUS_ACCESS_VIOLATION, "%u: NtCreateKey failed %lx\n", str.Length, status );
1037 if (!status)
1038 {
1039 status = pNtOpenKey( &ret2, KEY_READ, &attr );
1040 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %lx\n", str.Length, status );
1041 pNtClose( ret2 );
1042 status = pNtOpenKey( (HANDLE *)0xdeadbee0, KEY_READ, &attr );
1043 ok( status == STATUS_ACCESS_VIOLATION, "%u: NtOpenKey failed %lx\n", str.Length, status );
1044 attr3.RootDirectory = ret;
1045 str.Length = 0;
1046 status = pNtOpenKey( &ret2, KEY_READ, &attr3 );
1047 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %lx\n", str.Length, status );
1048 pNtClose( ret2 );
1049 pNtDeleteKey( ret );
1050 pNtClose( ret );
1051
1052 str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR);
1053 for (attr.Length = 0; attr.Length <= 2 * sizeof(attr); attr.Length++)
1054 {
1055 if (attr.Length == sizeof(attr))
1056 {
1057 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1058 ok( status == STATUS_SUCCESS, "%u: NtCreateKey failed %lx\n", str.Length, status );
1059 status = pNtOpenKey( &ret2, KEY_READ, &attr );
1060 ok( status == STATUS_SUCCESS, "%u: NtOpenKey failed %lx\n", str.Length, status );
1061 pNtClose( ret2 );
1062 pNtDeleteKey( ret );
1063 pNtClose( ret );
1064 }
1065 else
1066 {
1067 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1068 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %lx\n", str.Length, status );
1069 status = pNtOpenKey( &ret2, KEY_READ, &attr );
1070 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %lx\n", str.Length, status );
1071 }
1072 }
1073 attr.Length = sizeof(attr);
1074 }
1075 str.Length = (wcslen( registryW ) + 256) * sizeof(WCHAR) + 1;
1076 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1079 broken( status == STATUS_SUCCESS ), /* win7 */
1080 "%u: NtCreateKey failed %lx\n", str.Length, status );
1081 if (!status)
1082 {
1083 pNtDeleteKey( ret );
1084 pNtClose( ret );
1085 }
1086 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
1089 broken( status == STATUS_OBJECT_NAME_NOT_FOUND ), /* wow64 */
1090 "%u: NtOpenKey failed %lx\n", str.Length, status );
1091 str.Length++;
1092 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1093 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %lx\n", str.Length, status );
1094 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
1095 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %lx\n", str.Length, status );
1096 str.Length = 2000;
1097 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1098 ok( status == STATUS_INVALID_PARAMETER, "%u: NtCreateKey failed %lx\n", str.Length, status );
1099 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
1100 ok( status == STATUS_INVALID_PARAMETER, "%u: NtOpenKey failed %lx\n", str.Length, status );
1101 /* some Windows versions change the error past 2050 chars, others past 4066 chars, some don't */
1102 str.Length = 5000;
1103 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1107 "%u: NtCreateKey failed %lx\n", str.Length, status );
1108 ret = (HANDLE)0xdeadbeef;
1109 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
1113 "%u: NtOpenKey failed %lx\n", str.Length, status );
1114 ok( !ret, "handle set %p\n", ret );
1115 str.Length = 65534;
1116 ret = (HANDLE)0xdeadbeef;
1117 status = pNtCreateKey( &ret, GENERIC_ALL, &attr, 0, NULL, 0, NULL );
1121 "%u: NtCreateKey failed %lx\n", str.Length, status );
1122 ok( !ret, "handle set %p\n", ret );
1123 ret = (HANDLE)0xdeadbeef;
1124 status = pNtOpenKey( &ret, GENERIC_ALL, &attr );
1128 "%u: NtOpenKey failed %lx\n", str.Length, status );
1129 ok( !ret, "handle set %p\n", ret );
1130 attr3.RootDirectory = 0;
1131 attr2.ObjectName = attr3.ObjectName = NULL;
1132 status = pNtCreateKey( &ret, GENERIC_ALL, &attr2, 0, NULL, 0, NULL );
1133 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %lx\n", status );
1134 status = pNtCreateKey( &ret, GENERIC_ALL, &attr3, 0, NULL, 0, NULL );
1135 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %lx\n", status );
1136 status = pNtCreateKey( &ret, GENERIC_ALL, NULL, 0, NULL, 0, NULL );
1137 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtCreateKey failed %lx\n", status );
1138 status = pNtOpenKey( &ret, GENERIC_ALL, &attr2 );
1139 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %lx\n", status );
1140 status = pNtOpenKey( &ret, GENERIC_ALL, &attr3 );
1141 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %lx\n", status );
1142 status = pNtOpenKey( &ret, GENERIC_ALL, NULL );
1143 ok( status == STATUS_ACCESS_VIOLATION, "NULL: NtOpenKey failed %lx\n", status );
1144 attr2.ObjectName = attr3.ObjectName = &str;
1145
1146 HeapFree( GetProcessHeap(), 0, str.Buffer );
1147}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define KEY_READ
Definition: nt_native.h:1026
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:263
static void test_all_kernel_objects(UINT line, OBJECT_ATTRIBUTES *attr, NTSTATUS create_expect, NTSTATUS open_expect)
Definition: om.c:460
wcscpy
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
#define _WIN32_WINNT_WIN7
Definition: sdkddkver.h:28
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
HANDLE RootDirectory
Definition: umtypes.h:186
PUNICODE_STRING ObjectName
Definition: umtypes.h:187

Referenced by START_TEST().

◆ test_namespace_pipe()

static void test_namespace_pipe ( void  )
static

Definition at line 163 of file om.c.

164{
170 HANDLE pipe, h;
171
172 timeout.QuadPart = -10000;
173
174 pRtlInitUnicodeString(&str, L"\\??\\PIPE\\test\\pipe");
176 status = pNtCreateNamedPipeFile((HANDLE *)0xdeadbee0, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
178 ok(status == STATUS_ACCESS_VIOLATION, "Failed to create NamedPipe(%08lx)\n", status);
179
180 status = pNtCreateNamedPipeFile(&pipe, GENERIC_READ|GENERIC_WRITE, &attr, &iosb, FILE_SHARE_READ|FILE_SHARE_WRITE,
182 ok(status == STATUS_SUCCESS, "Failed to create NamedPipe(%08lx)\n", status);
183
184 h = (HANDLE)0xdeadbeef;
188 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08lx)\n", status);
189 ok( !h || broken(h == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", h );
190
191 pRtlInitUnicodeString(&str, L"\\??\\PIPE\\TEST\\PIPE");
193 h = (HANDLE)0xdeadbeef;
197 "NtCreateNamedPipeFile should have failed with STATUS_INSTANCE_NOT_AVAILABLE got(%08lx)\n", status);
198 ok( !h || broken(h == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", h );
199
200 h = CreateFileA("\\\\.\\pipe\\test\\pipe", GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL,
201 OPEN_EXISTING, 0, 0 );
202 ok(h != INVALID_HANDLE_VALUE, "Failed to open NamedPipe (%lu)\n", GetLastError());
203 pNtClose(h);
204
205 pRtlInitUnicodeString(&str, L"\\??\\pipe\\test\\pipe");
207 h = (HANDLE)0xdeadbeef;
211 status == STATUS_OBJECT_NAME_INVALID || /* vista */
213 "NtOpenFile should have failed with STATUS_OBJECT_PATH_NOT_FOUND got(%08lx)\n", status);
214 ok( !h || broken(h == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", h );
215
216 pRtlInitUnicodeString(&str, L"\\??\\pipe\\test");
218 h = (HANDLE)0xdeadbeef;
221 status == STATUS_OBJECT_NAME_INVALID, /* vista */
222 "NtOpenFile should have failed with STATUS_OBJECT_NAME_NOT_FOUND got(%08lx)\n", status);
223 ok( !h || broken(h == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", h );
224
225 str.Length -= 4 * sizeof(WCHAR);
227 ok(status == STATUS_SUCCESS, "NtOpenFile should have succeeded got %08lx\n", status);
228 pNtClose( h );
229
230 str.Length -= sizeof(WCHAR);
232 ok(status == STATUS_SUCCESS, "NtOpenFile should have succeeded got %08lx\n", status);
233 pNtClose( h );
234
235 pNtClose(pipe);
236}
#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:502
#define STATUS_INSTANCE_NOT_AVAILABLE
Definition: ntstatus.h:501

Referenced by START_TEST().

◆ test_NtAllocateReserveObject()

static void test_NtAllocateReserveObject ( void  )
static

Definition at line 3846 of file om.c.

3847{
3848 UNICODE_STRING name = RTL_CONSTANT_STRING(L"\\BaseNamedObjects\\test_NtAllocateReserveObject_name");
3851 HANDLE handle;
3852 int i;
3853
3854 static const struct
3855 {
3857 const WCHAR *type_name;
3858 }
3859 tests[] =
3860 {
3861 {MemoryReserveObjectTypeUserApc, L"UserApcReserve"},
3862 {MemoryReserveObjectTypeIoCompletion, L"IoCompletionReserve"},
3863 };
3864
3865 if (!pNtAllocateReserveObject)
3866 {
3867 win_skip("NtAllocateReserveObject is unavailable.\n");
3868 return;
3869 }
3870
3872
3873 /* Parameter checks */
3874 status = pNtAllocateReserveObject(NULL, &attr, MemoryReserveObjectTypeUserApc);
3875 ok(status == STATUS_ACCESS_VIOLATION, "Got unexpected status %#lx.\n", status);
3876
3877 status = pNtAllocateReserveObject(&handle, NULL, MemoryReserveObjectTypeUserApc);
3878 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3880 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3881
3882 status = pNtAllocateReserveObject(&handle, NULL, MemoryReserveObjectTypeIoCompletion + 1);
3883 ok(status == STATUS_INVALID_PARAMETER, "Got unexpected status %#lx.\n", status);
3884
3885 status = pNtAllocateReserveObject(&handle, &attr, MemoryReserveObjectTypeUserApc);
3886 ok(status == STATUS_OBJECT_NAME_INVALID, "Got unexpected status %#lx.\n", status);
3887
3888 attr.ObjectName = NULL;
3889 status = pNtAllocateReserveObject(&handle, &attr, MemoryReserveObjectTypeUserApc);
3890 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3892 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3893
3894 /* Test creating objects */
3895 for (i = 0; i < ARRAY_SIZE(tests); i++)
3896 {
3897 winetest_push_context("type %d", tests[i].type);
3898
3899 status = pNtAllocateReserveObject(&handle, NULL, tests[i].type);
3900 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3901
3902 test_object_type(handle, tests[i].type_name);
3903
3905 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
3907 }
3908}
#define RTL_CONSTANT_STRING(s)
Definition: combase.c:35
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl void winetest_pop_context(void)
void __cdecl void __cdecl void __cdecl void __cdecl void __cdecl winetest_push_context(const char *fmt,...) __WINE_PRINTF_ATTR(1
Definition: test.h:537
static struct test_info tests[]
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
@ MemoryReserveObjectTypeIoCompletion
Definition: winternl.h:2658
@ MemoryReserveObjectTypeUserApc
Definition: winternl.h:2657
enum _MEMORY_RESERVE_OBJECT_TYPE MEMORY_RESERVE_OBJECT_TYPE

Referenced by START_TEST().

◆ test_null_device()

static void test_null_device ( void  )
static

Definition at line 2037 of file om.c.

2038{
2043 DWORD num_bytes;
2044 OVERLAPPED ov;
2045 char buf[64];
2046 HANDLE null;
2047 BOOL ret;
2048
2049 memset(buf, 0xAA, sizeof(buf));
2050 memset(&ov, 0, sizeof(ov));
2052
2053 RtlInitUnicodeString(&str, L"\\Device\\Null");
2055 status = pNtOpenSymbolicLinkObject(&null, SYMBOLIC_LINK_QUERY, &attr);
2057 "expected STATUS_OBJECT_TYPE_MISMATCH, got %08lx\n", status);
2058
2059 status = pNtOpenFile(&null, GENERIC_READ | GENERIC_WRITE, &attr, &iosb,
2062 "expected STATUS_SUCCESS, got %08lx\n", status);
2063
2064 test_object_type(null, L"File");
2065
2066 SetLastError(0xdeadbeef);
2067 ret = WriteFile(null, buf, sizeof(buf), &num_bytes, NULL);
2068 ok(!ret, "WriteFile unexpectedly succeeded\n");
2070 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
2071
2072 SetLastError(0xdeadbeef);
2073 ret = ReadFile(null, buf, sizeof(buf), &num_bytes, NULL);
2074 ok(!ret, "ReadFile unexpectedly succeeded\n");
2076 "expected ERROR_INVALID_PARAMETER, got %lu\n", GetLastError());
2077
2078 num_bytes = 0xdeadbeef;
2079 SetLastError(0xdeadbeef);
2080 ret = WriteFile(null, buf, sizeof(buf), &num_bytes, &ov);
2081 ok(ret, "got error %lu\n", GetLastError());
2082 ok(num_bytes == sizeof(buf), "expected num_bytes = %lu, got %lu\n",
2083 (DWORD)sizeof(buf), num_bytes);
2084
2085 num_bytes = 0xdeadbeef;
2086 SetLastError(0xdeadbeef);
2087 ret = ReadFile(null, buf, sizeof(buf), &num_bytes, &ov);
2088 ok(!ret, "expected failure\n");
2089 ok(GetLastError() == ERROR_HANDLE_EOF, "got error %lu\n", GetLastError());
2090
2091 pNtClose(null);
2092
2093 null = CreateFileA("\\\\.\\Null", GENERIC_READ | GENERIC_WRITE,
2096 ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n");
2098 "expected ERROR_FILE_NOT_FOUND, got %lu\n", GetLastError());
2099
2100 null = CreateFileA("\\\\.\\Device\\Null", GENERIC_READ | GENERIC_WRITE,
2103 ok(null == INVALID_HANDLE_VALUE, "CreateFileA unexpectedly succeeded\n");
2105 "expected ERROR_PATH_NOT_FOUND, got %lu\n", GetLastError());
2106
2107 CloseHandle(ov.hEvent);
2108}
int null(void)
Definition: ftp.c:1794
#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
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HANDLE hEvent
Definition: minwinbase.h:230
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:228
#define ERROR_HANDLE_EOF
Definition: winerror.h:262

Referenced by START_TEST().

◆ test_null_in_object_name()

static void test_null_in_object_name ( void  )
static

Definition at line 2872 of file om.c.

2873{
2874 WCHAR name[256], name3[256], *p, *name_exp, *name3_exp;
2875 HANDLE handle, handle2;
2877 OBJECT_ATTRIBUTES attr, attr2, attr3;
2878 UNICODE_STRING nameU, name2U, name3U, name2U_exp, name3U_exp;
2880#ifndef _WIN64
2882#endif
2883
2884 trace("running as %d bit\n", (int)sizeof(void *) * 8);
2885
2886 swprintf(name, ARRAY_SIZE(name), L"\\Sessions\\%u\\BaseNamedObjects\\wine_test", NtCurrentTeb()->Peb->SessionId);
2887 swprintf(name3, ARRAY_SIZE(name3), L"\\Sessions\\%u\\BaseNamedObjects\\wine_test", NtCurrentTeb()->Peb->SessionId);
2888 p = wcsrchr(name3, '\\');
2889 p[5] = 0; /* => \\wine\0test */
2890
2891 RtlInitUnicodeString(&nameU, name);
2892 InitializeObjectAttributes(&attr, &nameU, 0, 0, NULL);
2893
2894 name2U = nameU;
2895 name2U.Length += sizeof(WCHAR); /* add terminating \0 to string length */
2896 InitializeObjectAttributes(&attr2, &name2U, 0, 0, NULL);
2897
2898 name3U = nameU;
2899 name3U.Buffer = name3;
2900 InitializeObjectAttributes(&attr3, &name3U, 0, 0, NULL);
2901
2902 status = pNtCreateEvent(&handle, GENERIC_ALL, &attr, NotificationEvent, FALSE);
2903 ok(!status, "got %08lx\n", status);
2905 status = pNtOpenEvent(&handle2, GENERIC_ALL, &attr);
2906 ok(!status, "got %08lx\n", status);
2907 test_object_name(handle2, name);
2908 pNtClose(handle2);
2909 status = pNtOpenEvent(&handle2, GENERIC_ALL, &attr2);
2910 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2911 pNtClose(handle);
2912 status = pNtCreateEvent(&handle, GENERIC_ALL, &attr2, NotificationEvent, FALSE);
2913 ok(!status, "got %08lx\n", status);
2915 status = pNtOpenEvent(&handle2, GENERIC_ALL, &attr2);
2916 ok(!status, "got %08lx\n", status);
2917 test_object_name_with_null(handle2, &name2U);
2918 pNtClose(handle2);
2919 status = pNtOpenEvent(&handle2, GENERIC_ALL, &attr);
2920 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2921 pNtClose(handle);
2922 status = pNtCreateEvent(&handle, GENERIC_ALL, &attr3, NotificationEvent, FALSE);
2923 ok(!status, "got %08lx\n", status);
2925 status = pNtOpenEvent(&handle2, GENERIC_ALL, &attr3);
2926 ok(!status, "got %08lx\n", status);
2927 test_object_name_with_null(handle2, &name3U);
2928 pNtClose(handle2);
2929 pNtClose(handle);
2930
2931 status = pNtCreateDebugObject(&handle, GENERIC_ALL, &attr, 0);
2932 ok(!status, "got %08lx\n", status);
2934 pNtClose(handle);
2935 status = pNtCreateDebugObject(&handle, GENERIC_ALL, &attr2, 0);
2936 ok(!status, "got %08lx\n", status);
2938 pNtClose(handle);
2939 status = pNtCreateDebugObject(&handle, GENERIC_ALL, &attr3, 0);
2940 ok(!status, "got %08lx\n", status);
2942 pNtClose(handle);
2943
2944 status = pNtCreateMutant(&handle, GENERIC_ALL, &attr, 0);
2945 ok(!status, "got %08lx\n", status);
2947 status = pNtOpenMutant(&handle2, GENERIC_ALL, &attr);
2948 ok(!status, "got %08lx\n", status);
2949 test_object_name(handle2, name);
2950 pNtClose(handle2);
2951 status = pNtOpenMutant(&handle2, GENERIC_ALL, &attr2);
2952 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2953 pNtClose(handle);
2954 status = pNtCreateMutant(&handle, GENERIC_ALL, &attr2, 0);
2955 ok(!status, "got %08lx\n", status);
2957 status = pNtOpenMutant(&handle2, GENERIC_ALL, &attr2);
2958 ok(!status, "got %08lx\n", status);
2959 test_object_name_with_null(handle2, &name2U);
2960 pNtClose(handle2);
2961 status = pNtOpenMutant(&handle2, GENERIC_ALL, &attr);
2962 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2963 pNtClose(handle);
2964 status = pNtCreateMutant(&handle, GENERIC_ALL, &attr3, 0);
2965 ok(!status, "got %08lx\n", status);
2967 status = pNtOpenMutant(&handle2, GENERIC_ALL, &attr3);
2968 ok(!status, "got %08lx\n", status);
2969 test_object_name_with_null(handle2, &name3U);
2970 pNtClose(handle2);
2971 pNtClose(handle);
2972
2973 status = pNtCreateSemaphore(&handle, GENERIC_ALL, &attr, 1, 2);
2974 ok(!status, "got %08lx\n", status);
2976 status = pNtOpenSemaphore(&handle2, GENERIC_ALL, &attr);
2977 ok(!status, "got %08lx\n", status);
2978 test_object_name(handle2, name);
2979 pNtClose(handle2);
2980 status = pNtOpenSemaphore(&handle2, GENERIC_ALL, &attr2);
2981 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2982 pNtClose(handle);
2983 status = pNtCreateSemaphore(&handle, GENERIC_ALL, &attr2, 1, 2);
2984 ok(!status, "got %08lx\n", status);
2986 status = pNtOpenSemaphore(&handle2, GENERIC_ALL, &attr2);
2987 ok(!status, "got %08lx\n", status);
2988 test_object_name_with_null(handle2, &name2U);
2989 pNtClose(handle2);
2990 status = pNtOpenSemaphore(&handle2, GENERIC_ALL, &attr);
2991 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
2992 pNtClose(handle);
2993 status = pNtCreateSemaphore(&handle, GENERIC_ALL, &attr3, 1, 2);
2994 ok(!status, "got %08lx\n", status);
2996 status = pNtOpenSemaphore(&handle2, GENERIC_ALL, &attr3);
2997 ok(!status, "got %08lx\n", status);
2998 test_object_name_with_null(handle2, &name3U);
2999 pNtClose(handle2);
3000 pNtClose(handle);
3001
3002 status = pNtCreateKeyedEvent(&handle, GENERIC_ALL, &attr, 0);
3003 ok(!status, "got %08lx\n", status);
3005 status = pNtOpenKeyedEvent(&handle2, GENERIC_ALL, &attr);
3006 ok(!status, "got %08lx\n", status);
3007 test_object_name(handle2, name);
3008 pNtClose(handle2);
3009 status = pNtOpenKeyedEvent(&handle2, GENERIC_ALL, &attr2);
3010 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
3011 pNtClose(handle);
3012 status = pNtCreateKeyedEvent(&handle, GENERIC_ALL, &attr2, 0);
3013 ok(!status, "got %08lx\n", status);
3015 status = pNtOpenKeyedEvent(&handle2, GENERIC_ALL, &attr2);
3016 ok(!status, "got %08lx\n", status);
3017 test_object_name_with_null(handle2, &name2U);
3018 pNtClose(handle2);
3019 status = pNtOpenKeyedEvent(&handle2, GENERIC_ALL, &attr);
3020 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
3021 pNtClose(handle);
3022 status = pNtCreateKeyedEvent(&handle, GENERIC_ALL, &attr3, 0);
3023 ok(!status, "got %08lx\n", status);
3025 status = pNtOpenKeyedEvent(&handle2, GENERIC_ALL, &attr3);
3026 ok(!status, "got %08lx\n", status);
3027 test_object_name_with_null(handle2, &name3U);
3028 pNtClose(handle2);
3029 pNtClose(handle);
3030
3031 status = pNtCreateIoCompletion(&handle, GENERIC_ALL, &attr, 0);
3032 ok(!status, "got %08lx\n", status);
3034 status = pNtOpenIoCompletion(&handle2, GENERIC_ALL, &attr);
3035 ok(!status, "got %08lx\n", status);
3036 test_object_name(handle2, name);
3037 pNtClose(handle2);
3038 pNtClose(handle);
3039 status = pNtCreateIoCompletion(&handle, GENERIC_ALL, &attr2, 0);
3040 ok(!status, "got %08lx\n", status);
3042 status = pNtOpenIoCompletion(&handle2, GENERIC_ALL, &attr2);
3043 ok(!status, "got %08lx\n", status);
3044 test_object_name_with_null(handle2, &name2U);
3045 pNtClose(handle2);
3046 pNtClose(handle);
3047 status = pNtCreateIoCompletion(&handle, GENERIC_ALL, &attr3, 0);
3048 ok(!status, "got %08lx\n", status);
3050 status = pNtOpenIoCompletion(&handle2, GENERIC_ALL, &attr3);
3051 ok(!status, "got %08lx\n", status);
3052 test_object_name_with_null(handle2, &name3U);
3053 pNtClose(handle2);
3054 pNtClose(handle);
3055
3056 status = pNtCreateJobObject(&handle, GENERIC_ALL, &attr);
3057 ok(!status, "got %08lx\n", status);
3059 status = pNtOpenJobObject(&handle2, GENERIC_ALL, &attr);
3060 ok(!status, "got %08lx\n", status);
3061 test_object_name(handle2, name);
3062 pNtClose(handle2);
3063 pNtClose(handle);
3064 status = pNtCreateJobObject(&handle, GENERIC_ALL, &attr2);
3065 ok(!status, "got %08lx\n", status);
3067 status = pNtOpenJobObject(&handle2, GENERIC_ALL, &attr2);
3068 ok(!status, "got %08lx\n", status);
3069 test_object_name_with_null(handle2, &name2U);
3070 pNtClose(handle2);
3071 pNtClose(handle);
3072 status = pNtCreateJobObject(&handle, GENERIC_ALL, &attr3);
3073 ok(!status, "got %08lx\n", status);
3075 status = pNtOpenJobObject(&handle2, GENERIC_ALL, &attr3);
3076 ok(!status, "got %08lx\n", status);
3077 test_object_name_with_null(handle2, &name3U);
3078 pNtClose(handle2);
3079 pNtClose(handle);
3080
3081 status = pNtCreateTimer(&handle, GENERIC_ALL, &attr, NotificationTimer);
3082 ok(!status, "got %08lx\n", status);
3084 status = pNtOpenTimer(&handle2, GENERIC_ALL, &attr);
3085 ok(!status, "got %08lx\n", status);
3086 test_object_name(handle2, name);
3087 pNtClose(handle2);
3088 pNtClose(handle);
3089 status = pNtCreateTimer(&handle, GENERIC_ALL, &attr2, NotificationTimer);
3090 ok(!status, "got %08lx\n", status);
3092 status = pNtOpenTimer(&handle2, GENERIC_ALL, &attr2);
3093 ok(!status, "got %08lx\n", status);
3094 test_object_name_with_null(handle2, &name2U);
3095 pNtClose(handle2);
3096 pNtClose(handle);
3097 status = pNtCreateTimer(&handle, GENERIC_ALL, &attr3, NotificationTimer);
3098 ok(!status, "got %08lx\n", status);
3100 status = pNtOpenTimer(&handle2, GENERIC_ALL, &attr3);
3101 ok(!status, "got %08lx\n", status);
3102 test_object_name_with_null(handle2, &name3U);
3103 pNtClose(handle2);
3104 pNtClose(handle);
3105
3106 size.QuadPart = 4096;
3107 status = pNtCreateSection(&handle, GENERIC_ALL, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0);
3108 ok(!status, "got %08lx\n", status);
3110 status = pNtOpenSection(&handle2, GENERIC_ALL, &attr);
3111 ok(!status, "got %08lx\n", status);
3112 test_object_name(handle2, name);
3113 pNtClose(handle2);
3114 pNtClose(handle);
3115 status = pNtCreateSection(&handle, GENERIC_ALL, &attr2, &size, PAGE_READWRITE, SEC_COMMIT, 0);
3116 ok(!status, "got %08lx\n", status);
3118 status = pNtOpenSection(&handle2, GENERIC_ALL, &attr2);
3119 ok(!status, "got %08lx\n", status);
3120 test_object_name_with_null(handle2, &name2U);
3121 pNtClose(handle2);
3122 pNtClose(handle);
3123 status = pNtCreateSection(&handle, GENERIC_ALL, &attr3, &size, PAGE_READWRITE, SEC_COMMIT, 0);
3124 ok(!status, "got %08lx\n", status);
3126 status = pNtOpenSection(&handle2, GENERIC_ALL, &attr3);
3127 ok(!status, "got %08lx\n", status);
3128 test_object_name_with_null(handle2, &name3U);
3129 pNtClose(handle2);
3130 pNtClose(handle);
3131
3132 wcscpy(name, L"\\Registry\\Machine\\Software\\wine_test");
3133 wcscpy(name3, L"\\Registry\\Machine\\Software\\wine_test");
3134 p = wcsrchr(name3, '\\');
3135 p[5] = 0; /* => \\wine\0test */
3136
3137 RtlInitUnicodeString(&nameU, name);
3138 name2U = nameU;
3139 name3U = nameU;
3140 name3U.Buffer = name3;
3141#ifdef _WIN64
3142 name_exp = name;
3143 name3_exp = name3;
3144 name2U_exp = name2U;
3145#else
3147 {
3148 name_exp = (WCHAR *)L"\\Registry\\Machine\\Software\\WOW6432Node\\wine_test";
3149 name3_exp =(WCHAR *) L"\\Registry\\Machine\\Software\\WOW6432Node\\wine\0test";
3150 }
3151 else
3152 {
3153 name_exp = name;
3154 name3_exp = name3;
3155 }
3156 RtlInitUnicodeString(&name2U_exp, name_exp);
3157#endif
3158 name3U_exp = name2U_exp;
3159 name3U_exp.Buffer = name3_exp;
3160 name2U.Length += sizeof(WCHAR); /* add terminating \0 to string length */
3161 name2U_exp.Length += sizeof(WCHAR); /* add terminating \0 to string length */
3162
3163 status = pNtCreateKey(&handle, GENERIC_ALL, &attr, 0, NULL, 0, NULL);
3164 ok(!status || status == STATUS_ACCESS_DENIED || broken(status == STATUS_OBJECT_PATH_NOT_FOUND) /* win8 */, "got %08lx\n", status);
3165 if (!status)
3166 {
3167 test_object_name(handle, name_exp);
3168 status = pNtOpenKey(&handle2, GENERIC_ALL, &attr);
3169 ok(!status, "got %08lx\n", status);
3170 test_object_name(handle2, name_exp);
3171 pNtClose(handle2);
3172 status = pNtOpenKey(&handle2, GENERIC_ALL, &attr2);
3173 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
3174 pNtDeleteKey(handle);
3175 pNtClose(handle);
3176 status = pNtCreateKey(&handle, GENERIC_ALL, &attr2, 0, NULL, 0, NULL);
3177 ok(!status, "got %08lx\n", status);
3178 test_object_name_with_null(handle, &name2U_exp);
3179 status = pNtOpenKey(&handle2, GENERIC_ALL, &attr2);
3180 ok(!status, "got %08lx\n", status);
3181 test_object_name_with_null(handle, &name2U_exp);
3182 pNtClose(handle2);
3183 status = pNtOpenKey(&handle2, GENERIC_ALL, &attr);
3184 ok(status == STATUS_OBJECT_NAME_NOT_FOUND, "got %08lx\n", status);
3185 pNtDeleteKey(handle);
3186 pNtClose(handle);
3187 status = pNtCreateKey(&handle, GENERIC_ALL, &attr3, 0, NULL, 0, NULL);
3188 ok(!status, "got %08lx\n", status);
3189 test_object_name_with_null(handle, &name3U_exp);
3190 status = pNtOpenKey(&handle2, GENERIC_ALL, &attr3);
3191 ok(!status, "got %08lx\n", status);
3192 test_object_name_with_null(handle, &name3U_exp);
3193 pNtClose(handle2);
3194 pNtDeleteKey(handle);
3195 pNtClose(handle);
3196 }
3197 else
3198 skip("Limited access to \\Registry\\Machine\\Software key, skipping the tests\n");
3199}
#define trace
Definition: atltest.h:70
#define skip(...)
Definition: atltest.h:64
static const WCHAR name3[]
Definition: db.c:2839
#define wcsrchr
Definition: compat.h:16
#define IsWow64Process
Definition: compat.h:760
GLfloat GLfloat p
Definition: glext.h:8902
BOOL is_wow64
Definition: main.c:38
#define test_object_name_with_null(a, b)
Definition: om.c:2855
#define test_object_name(a, b)
Definition: om.c:1665

Referenced by START_TEST().

◆ test_object_identity()

static void test_object_identity ( void  )
static

Definition at line 2596 of file om.c.

2597{
2599 HANDLE h1, h2;
2600
2601 if (!pNtCompareObjects)
2602 {
2603 win_skip("NtCompareObjects is not available.\n");
2604 return;
2605 }
2606
2607 status = pNtCompareObjects( GetCurrentProcess(), GetCurrentProcess() );
2608 ok( status == STATUS_SUCCESS, "comparing GetCurrentProcess() to self failed with %08lx\n", status );
2609
2610 status = pNtCompareObjects( GetCurrentThread(), GetCurrentThread() );
2611 ok( status == STATUS_SUCCESS, "comparing GetCurrentThread() to self failed with %08lx\n", status );
2612
2613 status = pNtCompareObjects( GetCurrentProcess(), GetCurrentThread() );
2614 ok( status == STATUS_NOT_SAME_OBJECT, "comparing GetCurrentProcess() to GetCurrentThread() returned %08lx\n", status );
2615
2616 h1 = NULL;
2617 status = pNtDuplicateObject( GetCurrentProcess(), GetCurrentProcess(), GetCurrentProcess(),
2618 &h1, 0, 0, DUPLICATE_SAME_ACCESS );
2619 ok( status == STATUS_SUCCESS, "failed to duplicate current process handle: %08lx\n", status);
2620
2621 status = pNtCompareObjects( GetCurrentProcess(), h1 );
2622 ok( status == STATUS_SUCCESS, "comparing GetCurrentProcess() with %p failed with %08lx\n", h1, status );
2623
2624 pNtClose( h1 );
2625
2626 h1 = CreateFileA( "\\\\.\\NUL", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
2627 ok( h1 != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
2628
2629 h2 = NULL;
2630 status = pNtDuplicateObject( GetCurrentProcess(), h1, GetCurrentProcess(),
2631 &h2, 0, 0, DUPLICATE_SAME_ACCESS );
2632 ok( status == STATUS_SUCCESS, "failed to duplicate handle %p: %08lx\n", h1, status);
2633
2634 status = pNtCompareObjects( h1, h2 );
2635 ok( status == STATUS_SUCCESS, "comparing %p with %p failed with %08lx\n", h1, h2, status );
2636
2637 pNtClose( h2 );
2638
2639 h2 = CreateFileA( "\\\\.\\NUL", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, 0 );
2640 ok( h2 != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
2641
2642 status = pNtCompareObjects( h1, h2 );
2643 ok( status == STATUS_NOT_SAME_OBJECT, "comparing %p with %p returned %08lx\n", h1, h2, status );
2644
2645 pNtClose( h2 );
2646 pNtClose( h1 );
2647}
#define STATUS_NOT_SAME_OBJECT
Definition: ntstatus.h:755
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1146
#define DUPLICATE_SAME_ACCESS

Referenced by START_TEST().

◆ test_object_permanence()

static void test_object_permanence ( void  )
static

Definition at line 3201 of file om.c.

3202{
3203 static const struct object_permanence_test {
3204 const char *name;
3205 ULONG initial_attr;
3207 BOOLEAN make_temporary;
3208 BOOLEAN make_permanent;
3209 NTSTATUS make_temp_status;
3210 } tests[] = {
3211 {
3212 .name = "permanent object persists",
3213 .initial_attr = OBJ_PERMANENT,
3214 .access = GENERIC_ALL,
3215 },
3216 {
3217 .name = "NtMakeTemporaryObject() succeeds",
3218 .initial_attr = OBJ_PERMANENT,
3219 .access = GENERIC_ALL,
3220 .make_temporary = TRUE,
3221 .make_temp_status = STATUS_SUCCESS,
3222 },
3223 {
3224 .name = "NtMakeTemporaryObject() fails w/o DELETE access",
3225 .initial_attr = OBJ_PERMANENT,
3226 .access = EVENT_ALL_ACCESS & ~DELETE,
3227 .make_temporary = TRUE,
3228 .make_temp_status = STATUS_ACCESS_DENIED,
3229 },
3230 {
3231 .name = "NtMakePermanentObject() succeeds even if already permanent",
3232 .initial_attr = OBJ_PERMANENT,
3233 .access = EVENT_ALL_ACCESS & ~DELETE,
3234 .make_permanent = TRUE,
3235 },
3236 {
3237 .name = "NtMakePermanentObject() reverses effect of NtMakeTemporaryObject()",
3238 .initial_attr = OBJ_PERMANENT,
3239 .access = GENERIC_ALL,
3240 .make_temporary = TRUE,
3241 .make_temp_status = STATUS_SUCCESS,
3242 .make_permanent = TRUE,
3243 },
3244
3245 {
3246 .name = "temporary object disappears",
3247 .initial_attr = 0,
3248 .access = GENERIC_ALL,
3249 },
3250 {
3251 .name = "NtMakeTemporaryObject() succeeds even if already temporary",
3252 .initial_attr = 0,
3253 .access = GENERIC_ALL,
3254 .make_temporary = TRUE,
3255 .make_temp_status = STATUS_SUCCESS,
3256 },
3257 {
3258 .name = "NtMakeTemporaryObject() fails w/o DELETE access even if already temporary",
3259 .initial_attr = 0,
3260 .access = EVENT_ALL_ACCESS & ~DELETE,
3261 .make_temporary = TRUE,
3262 .make_temp_status = STATUS_ACCESS_DENIED,
3263 },
3264 {
3265 .name = "NtMakePermanentObject() makes an object persist",
3266 .initial_attr = 0,
3267 .access = EVENT_ALL_ACCESS & ~DELETE,
3268 .make_permanent = TRUE,
3269 },
3270 {
3271 .name = "NtMakePermanentObject() is not annulled by calling NtMakeTemporaryObject() on an already temporary object",
3272 .initial_attr = 0,
3273 .access = GENERIC_ALL,
3274 .make_temporary = TRUE,
3275 .make_temp_status = STATUS_SUCCESS,
3276 .make_permanent = TRUE,
3277 },
3278 };
3279 const struct object_permanence_test *test;
3280 HANDLE process_token = NULL, thread_token = NULL;
3281 SECURITY_QUALITY_OF_SERVICE token_qos = {
3282 .Length = sizeof(token_qos),
3284 .ContextTrackingMode = SECURITY_STATIC_TRACKING,
3286 };
3287 OBJECT_ATTRIBUTES token_attr = {
3288 .Length = sizeof(token_attr),
3289 .SecurityQualityOfService = &token_qos,
3290 };
3291 TOKEN_PRIVILEGES new_privs = {
3292 .PrivilegeCount = 1,
3293 .Privileges = {
3294 {
3295 .Luid = { .LowPart = SE_CREATE_PERMANENT_PRIVILEGE },
3296 .Attributes = SE_PRIVILEGE_ENABLED,
3297 },
3298 },
3299 };
3301 BOOL creatpermapriv = FALSE;
3302
3304 ok( status == STATUS_SUCCESS, "NtOpenProcessToken returned %08lx\n", status );
3305
3307 &token_attr, FALSE, TokenImpersonation, &thread_token );
3308 ok( status == STATUS_SUCCESS, "NtDuplicateToken returned %08lx\n", status );
3309 NtClose( process_token );
3310
3311 status = NtAdjustPrivilegesToken( thread_token, FALSE, &new_privs, sizeof(new_privs), NULL, NULL );
3312 ok( status == STATUS_SUCCESS || status == STATUS_NOT_ALL_ASSIGNED, "NtAdjustPrivilegesToken returned %08lx\n", status );
3313 creatpermapriv = (status == STATUS_SUCCESS);
3314
3315 status = NtSetInformationThread( GetCurrentThread(), ThreadImpersonationToken, &thread_token, sizeof(thread_token) );
3316 ok( status == STATUS_SUCCESS, "NtSetInformationThread returned %08lx\n", status );
3317 NtClose( thread_token );
3318
3319 if (!creatpermapriv) skip( "no privileges, tests may be limited\n" );
3320
3321 for (test = &tests[0]; test != &tests[ARRAY_SIZE(tests)]; test++)
3322 {
3323 NTSTATUS make_perma_status = creatpermapriv ? STATUS_SUCCESS : STATUS_PRIVILEGE_NOT_HELD;
3324 HANDLE handle, handle2;
3328 BOOL is_permanent;
3329 ULONG len = 0;
3330
3331 winetest_push_context( "test#%Iu", test - &tests[0] );
3332 trace( "(%s)\n", test->name );
3333
3334 RtlInitUnicodeString( &name, L"\\BaseNamedObjects\\test_object_permanence" );
3335 InitializeObjectAttributes( &attr, &name, test->initial_attr, 0, NULL );
3337 if (test->initial_attr & OBJ_PERMANENT)
3338 {
3340 ok( status == make_perma_status, "NtCreateEvent returned %08lx (expected %08lx)\n", status, make_perma_status );
3341 }
3342 else
3343 {
3344 ok( status == STATUS_SUCCESS, "NtCreateEvent returned %08lx\n", status );
3345 }
3346 if (NT_ERROR(status))
3347 {
3349 continue;
3350 }
3351 is_permanent = (test->initial_attr & OBJ_PERMANENT) != 0;
3352
3353 status = NtQueryObject( handle, ObjectBasicInformation, &obi, sizeof(obi), &len );
3354 ok( status == STATUS_SUCCESS, "NtQueryObject returned %08lx\n", status );
3355 todo_wine_if(test->initial_attr != 0)
3356 ok( obi.Attributes == test->initial_attr, "expected attr %08lx, got %08lx\n", test->initial_attr, obi.Attributes );
3357
3358 if (test->make_temporary)
3359 {
3360 if (test->make_temp_status == STATUS_ACCESS_DENIED)
3361 ok( !(obi.GrantedAccess & DELETE), "expected no DELETE access in %08lx\n", obi.GrantedAccess );
3362 if (test->make_temp_status == STATUS_SUCCESS)
3363 ok( !!(obi.GrantedAccess & DELETE), "expected DELETE access in %08lx\n", obi.GrantedAccess );
3364
3366 ok( status == test->make_temp_status, "NtMakeTemporaryObject returned %08lx\n", status );
3367 if (!NT_ERROR(status)) is_permanent = FALSE;
3368 }
3369
3370 if (winetest_debug > 1)
3371 trace( "NOTE: object still has unclosed handle (%p) and shouldn't be deleted", handle );
3372
3373 winetest_push_context( "first handle (%p) still open", handle );
3374 status = pNtOpenEvent( &handle2, GENERIC_ALL, &attr );
3375 ok( status == STATUS_SUCCESS, "NtOpenEvent returned %08lx\n", status );
3376 if (!NT_ERROR(status))
3377 {
3378 ULONG expect_attr = (obi.Attributes & ~OBJ_PERMANENT) | (is_permanent ? OBJ_PERMANENT : 0);
3380
3381 status = NtQueryObject( handle2, ObjectBasicInformation, &obi2, sizeof(obi2), &len );
3382 ok( status == STATUS_SUCCESS, "NtQueryObject returned %08lx\n", status );
3383 todo_wine_if(expect_attr != 0)
3384 ok( obi2.Attributes == expect_attr, "expected attr %08lx, got %08lx\n", expect_attr, obi2.Attributes );
3385
3386 NtClose( handle2 );
3387 }
3389
3390 if (test->make_permanent)
3391 {
3394 ok( status == make_perma_status, "NtMakePermanentObject returned %08lx expected (%08lx)\n", status, make_perma_status );
3395 if (!NT_ERROR(status)) is_permanent = TRUE;
3396 }
3397
3398 if (winetest_debug > 1)
3399 trace( "NOTE: about to close earlier handle (%p) which should be the last", handle );
3400 NtClose( handle );
3401
3402 winetest_push_context( "first handle closed" );
3403 status = pNtOpenEvent( &handle, GENERIC_ALL, &attr );
3404 ok( status == (is_permanent ? STATUS_SUCCESS : STATUS_OBJECT_NAME_NOT_FOUND), "NtOpenEvent returned %08lx\n", status );
3405 if (!NT_ERROR(status))
3406 {
3407 ULONG expect_attr = (obi.Attributes & ~OBJ_PERMANENT) | (is_permanent ? OBJ_PERMANENT : 0);
3409
3410 status = NtQueryObject( handle, ObjectBasicInformation, &obi_new, sizeof(obi_new), &len );
3411 ok( status == STATUS_SUCCESS, "NtQueryObject returned %08lx\n", status );
3412 todo_wine_if(expect_attr != 0)
3413 ok( obi_new.Attributes == expect_attr, "expected attr %08lx, got %08lx\n", expect_attr, obi_new.Attributes );
3414
3415 /* ensure object is deleted */
3417 NtClose( handle );
3418 }
3420
3422 }
3423
3424 thread_token = NULL;
3426 ok( status == STATUS_SUCCESS, "NtSetInformationThread returned %08lx\n", status );
3427}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
@ ObjectBasicInformation
Definition: DriverTester.h:54
unsigned char BOOLEAN
Definition: actypes.h:127
EXTERN_C NTSTATUS WINAPI NtQueryObject(HANDLE, OBJECT_INFORMATION_CLASS, PVOID, ULONG, PULONG)
@ ThreadImpersonationToken
Definition: compat.h:940
GLdouble n
Definition: glext.h:7729
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
if(dx< 0)
Definition: linetemp.h:194
@ SecurityDelegation
Definition: lsa.idl:58
int winetest_debug
#define todo_wine_if(is_todo)
Definition: minitest.h:81
@ TokenImpersonation
Definition: imports.h:274
#define SE_CREATE_PERMANENT_PRIVILEGE
Definition: security.c:600
BOOL expected
Definition: store.c:2000
_In_ ACCESS_MASK _In_opt_ POBJECT_ATTRIBUTES _In_ BOOLEAN EffectiveOnly
Definition: sefuncs.h:410
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define DELETE
Definition: nt_native.h:57
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
NTSTATUS NTAPI NtSetInformationThread(_In_ HANDLE ThreadHandle, _In_ THREADINFOCLASS ThreadInformationClass, _In_reads_bytes_(ThreadInformationLength) PVOID ThreadInformation, _In_ ULONG ThreadInformationLength)
Definition: query.c:2269
NTSTATUS NTAPI NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
Definition: security.c:350
#define STATUS_NOT_ALL_ASSIGNED
Definition: ntstatus.h:138
NTSTATUS NTAPI NtMakePermanentObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1510
NTSTATUS NTAPI NtMakeTemporaryObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1473
#define OBJ_PERMANENT
Definition: winternl.h:226
#define test
Definition: rosglue.h:37
ACCESS_MASK GrantedAccess
Definition: winternl.h:2680
$ULONG PrivilegeCount
Definition: setypes.h:1035
char * name
Definition: compiler.c:66
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtAdjustPrivilegesToken(_In_ HANDLE TokenHandle, _In_ BOOLEAN DisableAllPrivileges, _In_opt_ PTOKEN_PRIVILEGES NewState, _In_ ULONG BufferLength, _Out_writes_bytes_to_opt_(BufferLength, *ReturnLength) PTOKEN_PRIVILEGES PreviousState, _When_(PreviousState!=NULL, _Out_) PULONG ReturnLength)
Removes a certain amount of privileges of a token based upon the request by the caller.
Definition: tokenadj.c:451
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtDuplicateToken(_In_ HANDLE ExistingTokenHandle, _In_ ACCESS_MASK DesiredAccess, _In_opt_ POBJECT_ATTRIBUTES ObjectAttributes, _In_ BOOLEAN EffectiveOnly, _In_ TOKEN_TYPE TokenType, _Out_ PHANDLE NewTokenHandle)
Duplicates a token.
Definition: tokenlif.c:1871
#define NT_ERROR(Status)
Definition: umtypes.h:106
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
_Out_ PBOOLEAN _Out_ PBOOLEAN _Out_ PSECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: psfuncs.h:157
#define TOKEN_DUPLICATE
Definition: setypes.h:938
#define SECURITY_STATIC_TRACKING
Definition: setypes.h:104
#define TOKEN_IMPERSONATE
Definition: setypes.h:939
#define SE_PRIVILEGE_ENABLED
Definition: setypes.h:63

Referenced by START_TEST().

◆ test_object_types()

static void test_object_types ( void  )
static

Definition at line 2323 of file om.c.

2324{
2325 static const struct { const WCHAR *name; GENERIC_MAPPING mapping; ULONG mask, broken; } tests[] =
2326 {
2327#define TYPE(name,gen,extra,broken) { name, { gen ## _GENERIC_READ, gen ## _GENERIC_WRITE, \
2328 gen ## _GENERIC_EXECUTE, gen ## _ALL_ACCESS }, gen ## _ALL_ACCESS | extra, broken }
2329 TYPE( L"DebugObject", DEBUG, 0, 0 ),
2330 TYPE( L"Desktop", DESKTOP, 0, 0 ),
2331 TYPE( L"Device", FILE, 0, 0 ),
2332 TYPE( L"Directory", DIRECTORY, 0, 0 ),
2333 TYPE( L"Event", EVENT, 0, 0 ),
2334 TYPE( L"File", FILE, 0, 0 ),
2335 TYPE( L"IoCompletion", IO_COMPLETION, 0, 0 ),
2336 TYPE( L"IoCompletionReserve", IO_COMPLETION_RESERVE, 0, 0 ),
2337#ifdef __REACTOS__
2338 TYPE( L"Job", JOB_OBJECT, 0, JOB_OBJECT_IMPERSONATE ),
2340#else
2341 TYPE( L"Job", JOB_OBJECT, 0, JOB_OBJECT_IMPERSONATE | 0x3C0 ),
2342 TYPE( L"Key", KEY, SYNCHRONIZE, 0 ),
2343#endif
2344 TYPE( L"KeyedEvent", KEYEDEVENT, SYNCHRONIZE, 0 ),
2345 TYPE( L"Mutant", MUTANT, 0, 0 ),
2346#ifdef __REACTOS__
2347 TYPE( L"Process", PROCESS, 0, PROCESS_TERMINATE ),
2348#else
2349 TYPE( L"Process", PROCESS, 0, 0 ),
2350#endif
2351 TYPE( L"Section", SECTION, SYNCHRONIZE, 0 ),
2352 TYPE( L"Semaphore", SEMAPHORE, 0, 0 ),
2353 TYPE( L"SymbolicLink", SYMBOLIC_LINK, 0, 0xfffe ),
2354#ifdef __REACTOS__
2356#else
2357 TYPE( L"Thread", THREAD, 0, THREAD_RESUME ),
2358#endif
2359 TYPE( L"Timer", TIMER, 0, 0 ),
2360#ifdef __REACTOS__
2362#else
2363 TYPE( L"Token", TOKEN, SYNCHRONIZE, 0 ),
2364#endif
2365 TYPE( L"Type", TYPE, SYNCHRONIZE, 0 ),
2366 TYPE( L"UserApcReserve", USER_APC_RESERVE, 0, 0 ),
2367 TYPE( L"WindowStation", WINSTA, 0, 0 ),
2368#undef TYPE
2369 };
2370 unsigned int i, j;
2371 BOOLEAN tested[ARRAY_SIZE(all_types)] = { 0 };
2372 char buffer[256];
2376 ULONG len, retlen;
2377
2378 memset( buffer, 0xcc, sizeof(buffer) );
2379 status = pNtQueryObject( NULL, ObjectTypesInformation, info, sizeof(buffer), &len );
2380 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
2381 ok( info->NumberOfTypes < 100 || info->NumberOfTypes == 0xcccccccc, /* wow64 */
2382 "wrong number of types %lu\n", info->NumberOfTypes );
2383
2384 info = malloc( len + 16 ); /* Windows gets the length wrong on WoW64 and overflows the buffer */
2385 memset( info, 0xcc, sizeof(*info) );
2386 status = pNtQueryObject( NULL, ObjectTypesInformation, info, len, &retlen );
2387 ok( retlen <= len + 16, "wrong len %lx/%lx\n", len, retlen );
2388 ok( len == retlen || broken( retlen >= len - 32 && retlen <= len + 32 ), /* wow64 */
2389 "wrong len %lx/%lx\n", len, retlen );
2390 ok( !status, "NtQueryObject failed %lx\n", status );
2391 if (!status)
2392 {
2394 for (i = 0; i < info->NumberOfTypes; i++)
2395 {
2397 type = align_ptr( (char *)type->TypeName.Buffer + type->TypeName.MaximumLength );
2398 }
2399 }
2400 free( info );
2401
2402 for (i = 0; i < ARRAY_SIZE(tests); i++)
2403 {
2404#ifdef __REACTOS__
2406 {
2407 if (!wcscmp(tests[i].name, L"IoCompletionReserve") ||
2408 !wcscmp(tests[i].name, L"UserApcReserve"))
2409 {
2410 skip("%s not implemented before Win7\n", tests[i].name);
2411 break;
2412 }
2413 }
2414#endif
2415 for (j = 0; j < ARRAY_SIZE(all_types); j++)
2416 {
2417 if (!all_types[j].TypeName.Buffer) continue;
2418 if (wcscmp( tests[i].name, all_types[j].TypeName.Buffer )) continue;
2420 ok( !memcmp( &map, &tests[i].mapping, sizeof(GENERIC_MAPPING) ) ||
2421 broken( !((map.GenericRead ^ tests[i].mapping.GenericRead) & ~tests[i].broken) &&
2422 !((map.GenericWrite ^ tests[i].mapping.GenericWrite) & ~tests[i].broken) &&
2423 !((map.GenericExecute ^ tests[i].mapping.GenericExecute) & ~tests[i].broken) &&
2424 !((map.GenericAll ^ tests[i].mapping.GenericAll) & ~tests[i].broken) ),
2425 "%s: mismatched mappings %08lx,%08lx,%08lx,%08lx / %08lx,%08lx,%08lx,%08lx\n",
2426 debugstr_w( tests[i].name ),
2429 tests[i].mapping.GenericRead, tests[i].mapping.GenericWrite,
2430 tests[i].mapping.GenericExecute, tests[i].mapping.GenericAll );
2431 ok( all_types[j].ValidAccessMask == tests[i].mask ||
2432 broken( !((all_types[j].ValidAccessMask ^ tests[i].mask) & ~tests[i].broken) ),
2433 "%s: mismatched access mask %08lx / %08lx\n", debugstr_w( tests[i].name ),
2434 all_types[j].ValidAccessMask, tests[i].mask );
2435 tested[j] = TRUE;
2436 break;
2437 }
2438
2439 ok( j < ARRAY_SIZE(all_types), "type %s not found\n", debugstr_w(tests[i].name) );
2440 }
2441 for (j = 0; j < ARRAY_SIZE(all_types); j++)
2442 {
2443 if (!all_types[j].TypeName.Buffer) continue;
2444 if (tested[j]) continue;
2445 trace( "not tested: %s\n", debugstr_w(all_types[j].TypeName.Buffer ));
2446 }
2447}
#define DEBUG(args)
Definition: rdesktop.h:129
Definition: _map.h:48
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
TYPE
Definition: eventcreate.c:652
GLenum GLint GLuint mask
Definition: glext.h:6028
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
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 GLint GLint j
Definition: glfuncs.h:250
@ EVENT
Definition: msgtrace.h:9
#define THREAD(work, arg, cleanup)
static void * align_ptr(void *ptr)
Definition: om.c:2284
#define TYPE(name, gen, extra, broken)
Definition: btrfs.h:143
Definition: timer.h:4
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
@ ObjectTypesInformation
Definition: winternl.h:1875
#define JOB_OBJECT_IMPERSONATE
Definition: winnt_old.h:3995
#define TOKEN_QUERY_SOURCE
Definition: setypes.h:941
#define TOKEN_ASSIGN_PRIMARY
Definition: setypes.h:937

Referenced by START_TEST().

◆ test_process()

static void test_process ( void  )
static

Definition at line 2110 of file om.c.

2111{
2113 CLIENT_ID cid;
2116
2117 if (!pNtOpenProcess)
2118 {
2119 win_skip( "NtOpenProcess not supported, skipping test\n" );
2120 return;
2121 }
2122
2124
2125 cid.UniqueProcess = 0;
2126 cid.UniqueThread = 0;
2127 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, NULL, &cid );
2128 todo_wine ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcess returned %lx\n", status );
2129 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, NULL );
2130 todo_wine ok( status == STATUS_INVALID_PARAMETER_MIX, "NtOpenProcess returned %lx\n", status );
2131
2132 cid.UniqueProcess = 0;
2133 cid.UniqueThread = 0;
2134 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2135 ok( status == STATUS_INVALID_CID || broken(/* __REACTOS__ */ (GetNTVersion() < _WIN32_WINNT_VISTA) && (status == STATUS_INVALID_PARAMETER)), "NtOpenProcess returned %lx\n", status );
2136
2137 cid.UniqueProcess = ULongToHandle( 0xdeadbeef );
2138 cid.UniqueThread = ULongToHandle( 0xdeadbeef );
2139 process = (HANDLE)0xdeadbeef;
2140 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2141 ok( status == STATUS_INVALID_CID, "NtOpenProcess returned %lx\n", status );
2142 ok( !process || broken(process == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", process );
2143
2144 cid.UniqueProcess = ULongToHandle( GetCurrentThreadId() );
2145 cid.UniqueThread = 0;
2146 process = (HANDLE)0xdeadbeef;
2147 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2148 ok( status == STATUS_INVALID_CID || broken(/* __REACTOS__ */ (GetNTVersion() < _WIN32_WINNT_VISTA) && (status == STATUS_INVALID_PARAMETER)), "NtOpenProcess returned %lx\n", status );
2149 ok( !process || broken(process == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", process );
2150
2151 cid.UniqueProcess = ULongToHandle( GetCurrentProcessId() );
2152 cid.UniqueThread = 0;
2153 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2154 ok( !status, "NtOpenProcess returned %lx\n", status );
2155 pNtClose( process );
2156
2157 cid.UniqueProcess = ULongToHandle( GetCurrentProcessId() );
2158 cid.UniqueThread = ULongToHandle( GetCurrentThreadId() );
2159 status = pNtOpenProcess( &process, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2160 ok( !status, "NtOpenProcess returned %lx\n", status );
2161 pNtClose( process );
2162 status = pNtOpenProcess( (HANDLE *)0xdeadbee0, PROCESS_QUERY_LIMITED_INFORMATION, &attr, &cid );
2163 ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcess returned %lx\n", status );
2164}
#define ULongToHandle(h)
Definition: basetsd.h:75
static TfClientId cid
#define STATUS_INVALID_CID
Definition: ntstatus.h:341
#define STATUS_INVALID_PARAMETER_MIX
Definition: ntstatus.h:378
DWORD WINAPI GetCurrentProcessId(void)
Definition: proc.c:1156

Referenced by START_TEST().

◆ test_query_directory()

static void test_query_directory ( void  )
static

Definition at line 2649 of file om.c.

2650{
2651 static const DIRECTORY_BASIC_INFORMATION empty_info;
2652 char buffer[200];
2654 ULONG context, size, needed_size;
2655 const WCHAR *name1, *name2;
2656 HANDLE dir, child1, child2;
2661
2662#ifndef _WIN64
2664#endif
2665
2666 RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest" );
2667 InitializeObjectAttributes( &attr, &string, 0, 0, NULL );
2668 status = pNtCreateDirectoryObject( &dir, DIRECTORY_QUERY, &attr );
2669 ok( !status, "got %#lx\n", status );
2670
2671 context = 0xdeadbeef;
2672 size = 0xdeadbeef;
2674 ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
2675 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2676 ok( size == sizeof(*info) || (is_wow64 && !size), "got size %lu\n", size );
2677
2678 context = 0xdeadbeef;
2679 size = 0xdeadbeef;
2681 ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
2682 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2683 ok( size == sizeof(*info) || (is_wow64 && !size), "got size %lu\n", size );
2684
2685 context = 0xdeadbeef;
2686 size = 0xdeadbeef;
2687 memset( buffer, 0xcc, sizeof(buffer) );
2689 ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
2690 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2691 ok( size == sizeof(*info) || (is_wow64 && !size), "got size %lu\n", size );
2692 if (size == sizeof(*info))
2693 ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2694
2695 context = 0xdeadbeef;
2696 size = 0xdeadbeef;
2697 memset( buffer, 0xcc, sizeof(buffer) );
2699 ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
2700 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2701 ok( size == sizeof(*info) || (is_wow64 && !size), "got size %lu\n", size );
2702 if (size == sizeof(*info))
2703 ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2704
2705 RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest\\Telamon" );
2706 status = NtCreateMutant( &child1, GENERIC_ALL, &attr, FALSE );
2707 ok( !status, "got %#lx\n", status );
2708
2709 RtlInitUnicodeString( &string, L"\\BaseNamedObjects\\winetest\\Oileus" );
2710 status = NtCreateMutant( &child2, GENERIC_ALL, &attr, FALSE );
2711 ok( !status, "got %#lx\n", status );
2712
2713 context = 0xdeadbeef;
2714 size = 0xdeadbeef;
2716 ok( status == STATUS_INVALID_HANDLE, "got %#lx\n", status );
2717 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2718 ok( size == 0xdeadbeef || broken(!size) /* WoW64 */, "got size %lu\n", size);
2719
2720 size = 0xdeadbeef;
2722 ok( status == STATUS_ACCESS_VIOLATION, "got %#lx\n", status );
2723 ok( size == 0xdeadbeef, "got size %lu\n", size);
2724
2725 context = 0xdeadbeef;
2726 size = 0xdeadbeef;
2727 memset( buffer, 0xcc, sizeof(buffer) );
2729 ok( !status, "got %#lx\n", status );
2730 ok( context == 1, "got context %#lx\n", context );
2731 ok( size && size < sizeof(buffer), "got size %lu\n", size );
2732 if (!wcscmp( info[0].ObjectName.Buffer, L"Oileus" ))
2733 {
2734 name1 = L"Oileus";
2735 name2 = L"Telamon";
2736 }
2737 else
2738 {
2739 name1 = L"Telamon";
2740 name2 = L"Oileus";
2741 }
2743 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2744 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2745
2746 memset( buffer, 0xcc, sizeof(buffer) );
2748 ok( !status, "got %#lx\n", status );
2749 ok( context == 2, "got context %#lx\n", context );
2751 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2752 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2753
2754 size = 0xdeadbeef;
2756 ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx\n", status );
2757 ok( context == 2, "got context %#lx\n", context );
2758 ok( size == sizeof(*info) || (is_wow64 && !size), "got size %lu\n", size );
2759
2760 memset( buffer, 0xcc, sizeof(buffer) );
2762 ok( !status, "got %#lx\n", status );
2763 ok( context == 1, "got context %#lx\n", context );
2765 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2766 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2767
2768 needed_size = size;
2769
2770 size = 0xdeadbeef;
2771 context = 0xdeadbeef;
2773 ok( status == STATUS_BUFFER_TOO_SMALL, "got %#lx\n", status );
2774 ok( context == 0xdeadbeef, "got context %#lx\n", context );
2775 ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
2776
2777 size = 0xdeadbeef;
2778 memset( buffer, 0xcc, sizeof(buffer) );
2779 status = NtQueryDirectoryObject( dir, info, needed_size - 1, TRUE, TRUE, &context, &size );
2780 ok( status == STATUS_BUFFER_TOO_SMALL, "got %#lx\n", status );
2781 ok( size == needed_size, "expected size %lu, got %lu\n", needed_size, size );
2782
2784 ok( !status, "got %#lx\n", status );
2785
2786 context = 0;
2787 memset( buffer, 0xcc, sizeof(buffer) );
2789 ok( !status, "got %#lx\n", status );
2790 ok( context == 1, "got context %#lx\n", context );
2792 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2793 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2794
2795 memset( buffer, 0xcc, sizeof(buffer) );
2797 ok( !status, "got %#lx\n", status );
2798 ok( context == 2, "got context %#lx\n", context );
2800 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2802 check_unicode_string( &info[1].ObjectTypeName, L"Mutant" );
2803 ok( !memcmp( &info[2], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2804
2805 needed_size = size;
2806 size = 0xdeadbeef;
2807 context = 0xdeadbeef;
2808 memset( buffer, 0xcc, sizeof(buffer) );
2809 status = NtQueryDirectoryObject( dir, info, needed_size - 1, FALSE, TRUE, &context, &size );
2810 ok( status == STATUS_MORE_ENTRIES, "got %#lx\n", status );
2811 ok( context == 1, "got context %#lx\n", context );
2812 ok( size > 0 && size < needed_size, "got size %lu\n", size );
2814 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2815 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2816
2817 size = 0xdeadbeef;
2818 context = 0xdeadbeef;
2819 memset( buffer, 0xcc, sizeof(buffer) );
2822 || broken(status == STATUS_BUFFER_TOO_SMALL) /* wow64 */, "got %#lx\n", status );
2824 {
2825 ok( !context, "got context %#lx\n", context );
2826 ok( size == sizeof(*info), "got size %lu\n", size );
2827 ok( !memcmp( &info[0], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2828 }
2829
2830 size = 0xdeadbeef;
2831 context = 0xdeadbeef;
2834 || broken(status == STATUS_BUFFER_TOO_SMALL) /* wow64 */, "got %#lx\n", status );
2836 {
2837 ok( !context, "got context %#lx\n", context );
2838 ok( size == sizeof(*info), "got size %lu\n", size );
2839 }
2840
2841 context = 1;
2842 memset( buffer, 0xcc, sizeof(buffer) );
2844 ok( !status, "got %#lx\n", status );
2845 ok( context == 2, "got context %#lx\n", context );
2847 check_unicode_string( &info[0].ObjectTypeName, L"Mutant" );
2848 ok( !memcmp( &info[1], &empty_info, sizeof(*info) ), "entry was not cleared\n" );
2849
2850 pNtClose( child1 );
2851 pNtClose( child2 );
2852 pNtClose( dir );
2853}
char string[160]
Definition: util.h:11
static POBJECTS_AND_NAME_A SE_OBJECT_TYPE LPSTR ObjectTypeName
Definition: security.c:120
static WCHAR name1[]
Definition: record.c:34
static WCHAR name2[]
Definition: record.c:35
NTSTATUS NTAPI NtCreateMutant(OUT PHANDLE MutantHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN BOOLEAN InitialOwner)
Definition: mutant.c:79
NTSTATUS NTAPI NtQueryDirectoryObject(IN HANDLE DirectoryHandle, OUT PVOID Buffer, IN ULONG BufferLength, IN BOOLEAN ReturnSingleEntry, IN BOOLEAN RestartScan, IN OUT PULONG Context, OUT PULONG ReturnLength OPTIONAL)
Definition: obdir.c:490
#define check_unicode_string(a, b)
Definition: om.c:108
Definition: http.c:7252
#define STATUS_MORE_ENTRIES
Definition: udferr_usr.h:124
_In_ PVOID _Out_opt_ PULONG_PTR _Outptr_opt_ PCUNICODE_STRING * ObjectName
Definition: cmfuncs.h:64

Referenced by START_TEST().

◆ test_query_object()

static void test_query_object ( void  )
static

Definition at line 1683 of file om.c.

1684{
1685 static const WCHAR name[] = L"\\BaseNamedObjects\\test_event";
1687 char buffer[1024];
1689 ULONG len, expected_len;
1693 char dir[MAX_PATH], tmp_path[MAX_PATH], file1[MAX_PATH + 16];
1694 WCHAR expect[100];
1696
1697 InitializeObjectAttributes( &attr, &path, 0, 0, 0 );
1698
1699 handle = CreateEventA( NULL, FALSE, FALSE, "test_event" );
1700
1701 status = pNtQueryObject( handle, ObjectBasicInformation, NULL, 0, NULL );
1702 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1703
1704 status = pNtQueryObject( handle, ObjectBasicInformation, &info, 0, NULL );
1705 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1706
1707 status = pNtQueryObject( handle, ObjectBasicInformation, NULL, 0, &len );
1708 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1709
1710 len = 0;
1711 status = pNtQueryObject( handle, ObjectBasicInformation, &info, sizeof(OBJECT_BASIC_INFORMATION), &len );
1712 ok( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1713 ok( len >= sizeof(OBJECT_BASIC_INFORMATION), "unexpected len %lu\n", len );
1714
1715 len = 0;
1716 status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
1717 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1718 ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %lu\n", len );
1719
1720 len = 0;
1721 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, 0, &len );
1722 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1723 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %lu\n", len );
1724
1725 len = 0;
1726 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len );
1727 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1728 ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %lu\n", len );
1729
1730 len = 0;
1731 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, sizeof(OBJECT_TYPE_INFORMATION), &len );
1732 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1733 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %lu\n", len );
1734
1735 len = 0;
1736 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1737 ok( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1738 ok( len > sizeof(UNICODE_STRING), "unexpected len %lu\n", len );
1740 ok( sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR) == len, "unexpected len %lu\n", len );
1741 ok( str->Length >= sizeof(name) - sizeof(WCHAR), "unexpected len %u\n", str->Length );
1742 ok( len > sizeof(UNICODE_STRING) + sizeof("\\test_event") * sizeof(WCHAR),
1743 "name too short %s\n", wine_dbgstr_w(str->Buffer) );
1744 /* check for \\Sessions prefix in the name */
1745 swprintf( expect, ARRAY_SIZE(expect), L"\\Sessions\\%u%s", NtCurrentTeb()->Peb->SessionId, name );
1746 ok( (str->Length == wcslen( expect ) * sizeof(WCHAR) && !wcscmp( str->Buffer, expect )) || broken(/* __REACTOS__ */ (GetNTVersion() < _WIN32_WINNT_VISTA) && (str->Length == wcslen( name ) * sizeof(WCHAR)) && !wcscmp( str->Buffer, name )),
1747 "wrong name %s\n", wine_dbgstr_w(str->Buffer) );
1748 trace( "got %s len %lu\n", wine_dbgstr_w(str->Buffer), len );
1749
1750 len -= sizeof(WCHAR);
1751 status = pNtQueryObject( handle, ObjectNameInformation, buffer, len, &len );
1752 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1753 ok( len >= sizeof(UNICODE_STRING) + sizeof(name), "unexpected len %lu\n", len );
1754
1755 test_object_type( handle, L"Event" );
1756
1757 len -= sizeof(WCHAR);
1758 status = pNtQueryObject( handle, ObjectTypeInformation, buffer, len, &len );
1759 ok( status == STATUS_INFO_LENGTH_MISMATCH, "NtQueryObject failed %lx\n", status );
1760 ok( len >= sizeof(OBJECT_TYPE_INFORMATION) + sizeof(L"Event"), "unexpected len %lu\n", len );
1761
1763 pNtClose( handle );
1764
1766 len = 0;
1767 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1768 ok( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1769 ok( len == sizeof(UNICODE_STRING), "unexpected len %lu\n", len );
1771 ok( str->Length == 0, "unexpected len %lu\n", len );
1772 ok( str->Buffer == NULL, "unexpected ptr %p\n", str->Buffer );
1774 pNtClose( handle );
1775
1779 len = 0;
1780 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(buffer), &len );
1781 ok( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1782 ok( len > sizeof(UNICODE_STRING), "unexpected len %lu\n", len );
1784 expected_len = sizeof(UNICODE_STRING) + str->Length + sizeof(WCHAR);
1785 ok( len == expected_len, "unexpected len %lu\n", len );
1786 trace( "got %s len %lu\n", wine_dbgstr_w(str->Buffer), len );
1787
1788 len = 0;
1789 status = pNtQueryObject( handle, ObjectNameInformation, buffer, 0, &len );
1790 ok( status == STATUS_INFO_LENGTH_MISMATCH, "got %#lx\n", status );
1791 ok( len == expected_len || broken(/* __REACTOS__ */ (GetNTVersion() < _WIN32_WINNT_VISTA) && (len == sizeof(UNICODE_STRING))), "unexpected len %lu\n", len);
1792
1793 len = 0;
1794 status = pNtQueryObject( handle, ObjectNameInformation, buffer, sizeof(UNICODE_STRING), &len );
1795 ok( status == STATUS_BUFFER_OVERFLOW, "got %#lx\n", status);
1796 ok( len == expected_len, "unexpected len %lu\n", len );
1797
1798 test_object_type( handle, L"File" );
1799
1800 pNtClose( handle );
1801
1802 GetTempPathA(MAX_PATH, tmp_path);
1803 GetTempFileNameA(tmp_path, "foo", 0, file1);
1805 test_object_type(handle, L"File");
1807 pNtClose( handle );
1808 DeleteFileA( file1 );
1809
1810 status = pNtCreateIoCompletion( &handle, IO_COMPLETION_ALL_ACCESS, NULL, 0 );
1811 ok( status == STATUS_SUCCESS, "NtCreateIoCompletion failed %lx\n", status);
1812
1813 test_object_type( handle, L"IoCompletion" );
1815
1816 pNtClose( handle );
1817
1818 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_debug" );
1819 status = pNtCreateDebugObject( &handle, DEBUG_ALL_ACCESS, &attr, 0 );
1820 ok(!status, "NtCreateDebugObject failed: %lx\n", status);
1821 test_object_name( handle, L"\\BaseNamedObjects\\test_debug" );
1822 test_object_type( handle, L"DebugObject" );
1824 pNtClose(handle);
1825
1826 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_mutant" );
1827 status = pNtCreateMutant( &handle, MUTANT_ALL_ACCESS, &attr, 0 );
1828 ok(!status, "NtCreateMutant failed: %lx\n", status);
1829 test_object_name( handle, L"\\BaseNamedObjects\\test_mutant" );
1830 test_object_type( handle, L"Mutant" );
1832 pNtClose(handle);
1833
1834 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_sem" );
1835 status = pNtCreateSemaphore( &handle, SEMAPHORE_ALL_ACCESS, &attr, 1, 2 );
1836 ok(!status, "NtCreateSemaphore failed: %lx\n", status);
1837 test_object_name( handle, L"\\BaseNamedObjects\\test_sem" );
1838 test_object_type( handle, L"Semaphore" );
1840 pNtClose(handle);
1841
1842 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_keyed" );
1843 status = pNtCreateKeyedEvent( &handle, KEYEDEVENT_ALL_ACCESS, &attr, 0 );
1844 ok(!status, "NtCreateKeyedEvent failed: %lx\n", status);
1845 test_object_name( handle, L"\\BaseNamedObjects\\test_keyed" );
1846 test_object_type( handle, L"KeyedEvent" );
1848 pNtClose(handle);
1849
1850 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_compl" );
1851 status = pNtCreateIoCompletion( &handle, IO_COMPLETION_ALL_ACCESS, &attr, 0 );
1852 ok(!status, "NtCreateIoCompletion failed: %lx\n", status);
1853 test_object_name( handle, L"\\BaseNamedObjects\\test_compl" );
1854 test_object_type( handle, L"IoCompletion" );
1856 pNtClose(handle);
1857
1858 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_job" );
1859 status = pNtCreateJobObject( &handle, JOB_OBJECT_ALL_ACCESS, &attr );
1860 ok(!status, "NtCreateJobObject failed: %lx\n", status);
1861 test_object_name( handle, L"\\BaseNamedObjects\\test_job" );
1862 test_object_type( handle, L"Job" );
1864 pNtClose(handle);
1865
1866 RtlInitUnicodeString( &path, L"\\BaseNamedObjects\\test_timer" );
1867 status = pNtCreateTimer( &handle, TIMER_ALL_ACCESS, &attr, NotificationTimer );
1868 ok(!status, "NtCreateTimer failed: %lx\n", status);
1869 test_object_type( handle, L"Timer" );
1871 pNtClose(handle);
1872
1873 RtlInitUnicodeString( &path, L"\\DosDevices\\test_link" );
1874 RtlInitUnicodeString( &target, L"\\DosDevices" );
1875 status = pNtCreateSymbolicLinkObject( &handle, SYMBOLIC_LINK_ALL_ACCESS, &attr, &target );
1876 ok(!status, "NtCreateSymbolicLinkObject failed: %lx\n", status);
1877 test_object_type( handle, L"SymbolicLink" );
1879 pNtClose(handle);
1880
1882 swprintf( expect, ARRAY_SIZE(expect), L"\\Sessions\\%u\\Windows\\WindowStations\\WinSta0", NtCurrentTeb()->Peb->SessionId );
1884 test_object_type( handle, L"WindowStation" );
1886
1888 test_object_name( handle, L"\\Default" );
1889 test_object_type( handle, L"Desktop" );
1891
1892 status = pNtCreateDirectoryObject( &handle, DIRECTORY_QUERY, NULL );
1893 ok(status == STATUS_SUCCESS, "Failed to create Directory %08lx\n", status);
1894
1895 test_object_type( handle, L"Directory" );
1897
1898 pNtClose( handle );
1899
1900 size.u.LowPart = 256;
1901 size.u.HighPart = 0;
1902 status = pNtCreateSection( &handle, SECTION_MAP_WRITE, NULL, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
1903 ok( status == STATUS_SUCCESS , "NtCreateSection returned %lx\n", status );
1904
1905 test_object_type( handle, L"Section" );
1907
1908 pNtClose( handle );
1909
1910 handle = CreateMailslotA( "\\\\.\\mailslot\\test_mailslot", 100, 1000, NULL );
1911 ok( handle != INVALID_HANDLE_VALUE, "CreateMailslot failed err %lu\n", GetLastError() );
1912
1913 test_object_name( handle, L"\\Device\\Mailslot\\test_mailslot" );
1914 test_object_type( handle, L"File" );
1916
1917 client = CreateFileA( "\\\\.\\mailslot\\test_mailslot", 0, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
1918 ok( client != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
1919
1920 len = 0;
1921 status = pNtQueryObject( client, ObjectNameInformation, buffer, sizeof(buffer), &len );
1922 ok( status == STATUS_SUCCESS, "NtQueryObject failed %lx\n", status );
1924 ok( len == sizeof(UNICODE_STRING) + str->MaximumLength, "unexpected len %lu\n", len );
1925 todo_wine
1926 ok( compare_unicode_string( str, L"\\Device\\Mailslot" ) ||
1927 compare_unicode_string( str, L"\\Device\\Mailslot\\test_mailslot" ) /* win8+ */,
1928 "wrong name %s\n", debugstr_w( str->Buffer ));
1929
1930 test_object_type( client, L"File" );
1932
1933 pNtClose( client );
1934 pNtClose( handle );
1935
1936 handle = CreateFileA( "\\\\.\\mailslot", 0, 0, NULL, OPEN_EXISTING, 0, 0 );
1937 ok( handle != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
1938
1939 test_object_name( handle, L"\\Device\\Mailslot" );
1940 test_object_type( handle, L"File" );
1942
1943 pNtClose( handle );
1944
1945 handle = CreateNamedPipeA( "\\\\.\\pipe\\test_pipe", PIPE_ACCESS_DUPLEX, PIPE_READMODE_BYTE,
1946 1, 1000, 1000, 1000, NULL );
1947 ok( handle != INVALID_HANDLE_VALUE, "CreateNamedPipe failed err %lu\n", GetLastError() );
1948
1949 test_object_name( handle, L"\\Device\\NamedPipe\\test_pipe" );
1950 test_object_type( handle, L"File" );
1952
1953 client = CreateFileA( "\\\\.\\pipe\\test_pipe", GENERIC_READ | GENERIC_WRITE,
1954 0, NULL, OPEN_EXISTING, 0, 0 );
1955 ok( client != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
1956
1957 test_object_type( client, L"File" );
1959
1960 pNtClose( client );
1961 pNtClose( handle );
1962
1963 handle = CreateFileA( "\\\\.\\pipe", 0, 0, NULL, OPEN_EXISTING, 0, 0 );
1964 ok( handle != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
1965
1966 test_object_name( handle, L"\\Device\\NamedPipe" );
1967 test_object_type( handle, L"File" );
1969
1970 pNtClose( handle );
1971
1972 handle = CreateFileA( "\\\\.\\pipe\\", 0, 0, NULL, OPEN_EXISTING, 0, 0 );
1973 ok( handle != INVALID_HANDLE_VALUE, "CreateFile failed (%lu)\n", GetLastError() );
1974
1975 test_object_name( handle, L"\\Device\\NamedPipe\\" );
1976 test_object_type( handle, L"File" );
1978
1979 pNtClose( handle );
1980
1981 RtlInitUnicodeString( &path, L"\\REGISTRY\\Machine" );
1982 status = pNtCreateKey( &handle, KEY_READ, &attr, 0, 0, 0, 0 );
1983 ok( status == STATUS_SUCCESS, "NtCreateKey failed status %lx\n", status );
1984
1985 test_object_name( handle, L"\\REGISTRY\\MACHINE" );
1986 test_object_type( handle, L"Key" );
1987
1988 pNtClose( handle );
1989
1991 test_object_type( GetCurrentProcess(), L"Process" );
1993
1995 test_object_type( GetCurrentThread(), L"Thread" );
1997
1998 status = pNtOpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &handle);
1999 ok(!status, "OpenProcessToken failed: %lx\n", status);
2000
2002 test_object_type( handle, L"Token" );
2004
2005 pNtClose(handle);
2006
2007 handle = CreateFileA( "nul", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0 );
2008 ok( handle != INVALID_HANDLE_VALUE, "CreateFile failed (%ld)\n", GetLastError() );
2009 test_object_name( handle, L"\\Device\\Null" );
2010 test_object_type( handle, L"File" );
2012 pNtClose( handle );
2013}
#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:2256
DWORD WINAPI GetTempPathA(IN DWORD nBufferLength, OUT LPSTR lpBuffer)
Definition: path.c:1973
UINT WINAPI GetTempFileNameA(IN LPCSTR lpPathName, IN LPCSTR lpPrefixString, IN UINT uUnique, OUT LPSTR lpTempFileName)
Definition: filename.c:26
#define JOB_OBJECT_ALL_ACCESS
Definition: pstypes.h:201
#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:43
#define MUTANT_ALL_ACCESS
Definition: extypes.h:110
#define TIMER_ALL_ACCESS
Definition: extypes.h:116
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1270
#define test_no_file_info(a)
Definition: om.c:1579
#define KEYEDEVENT_ALL_ACCESS
Definition: om.c:105
#define test_file_info(a)
Definition: om.c:1559
static FILE * client
Definition: client.c:37
HWINSTA WINAPI GetProcessWindowStation(void)
Definition: ntwrapper.h:124
#define SEMAPHORE_ALL_ACCESS
Definition: winbase.h:162
HDESK WINAPI GetThreadDesktop(_In_ DWORD)
#define TOKEN_ALL_ACCESS
Definition: setypes.h:958

Referenced by START_TEST().

◆ test_symboliclink()

static void test_symboliclink ( void  )
static

Definition at line 1377 of file om.c.

1378{
1382 HANDLE dir, link, h, h2;
1384
1385 /* No name and/or no attributes */
1387 RtlInitUnicodeString(&target, L"\\DosDevices");
1388 status = pNtCreateSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr, &target );
1389 ok(status == STATUS_ACCESS_VIOLATION, "got %#lx\n", status);
1390 status = pNtOpenSymbolicLinkObject( NULL, SYMBOLIC_LINK_QUERY, &attr );
1391 ok(status == STATUS_ACCESS_VIOLATION, "got %#lx\n", status);
1392
1393 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, NULL);
1395 "NtCreateSymbolicLinkObject should have failed with STATUS_ACCESS_VIOLATION got(%08lx)\n", status);
1396 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL);
1398 "NtOpenSymbolicLinkObject should have failed with STATUS_INVALID_PARAMETER got(%08lx)\n", status);
1399
1400 /* No attributes */
1401 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, NULL, &target);
1403 "NtCreateSymbolicLinkObject failed(%08lx)\n", status);
1404
1406 memset(&target, 0, sizeof(target));
1407 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1408 ok(status == STATUS_INVALID_PARAMETER, "got %#lx\n", status);
1409 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr);
1411 "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
1412
1413 /* Bad name */
1414 RtlInitUnicodeString(&target, L"anywhere");
1416
1418 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1419 ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08lx)\n", status);
1420 status = pNtOpenSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr);
1422 "NtOpenSymbolicLinkObject should have failed with STATUS_OBJECT_PATH_SYNTAX_BAD got(%08lx)\n", status);
1423 pNtClose(link);
1424
1425 RtlInitUnicodeString(&str, L"\\");
1426 attr.Attributes = OBJ_OPENIF;
1427 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr, &target);
1429 "NtCreateSymbolicLinkObject should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
1430 attr.Attributes = 0;
1431 status = pNtCreateSymbolicLinkObject(&h, SYMBOLIC_LINK_QUERY, &attr, &target);
1432 todo_wine
1434 "NtCreateSymbolicLinkObject should have failed with STATUS_OBJECT_TYPE_MISMATCH got(%08lx)\n", status);
1435
1436 RtlInitUnicodeString( &target, L"->Somewhere");
1437
1438 RtlInitUnicodeString( &str, L"BaseNamedObjects" );
1439 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1440 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtCreateSymbolicLinkObject got %08lx\n", status );
1441 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1442 ok( status == STATUS_OBJECT_PATH_SYNTAX_BAD, "NtOpenSymbolicLinkObject got %08lx\n", status );
1443
1444 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\" );
1445 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1446 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08lx\n", status );
1447 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1448 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08lx\n", status );
1449
1450 RtlInitUnicodeString( &str, L"\\\\BaseNamedObjects" );
1451 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1452 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08lx\n", status );
1453 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1454 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08lx\n", status );
1455
1456 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\\\om.c-test" );
1457 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1458 ok( status == STATUS_OBJECT_NAME_INVALID, "NtCreateSymbolicLinkObject got %08lx\n", status );
1459 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1460 ok( status == STATUS_OBJECT_NAME_INVALID, "NtOpenSymbolicLinkObject got %08lx\n", status );
1461
1462 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\om.c-test\\" );
1463 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1464 ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#lx\n", status );
1465 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1466 ok( status == STATUS_OBJECT_PATH_NOT_FOUND, "got %#lx\n", status );
1467
1468 /* Compound test */
1469 dir = get_base_dir();
1471 RtlInitUnicodeString(&str, L"test-link");
1472 RtlInitUnicodeString(&target, L"\\DosDevices");
1473 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1474 ok(status == STATUS_SUCCESS, "Failed to create SymbolicLink(%08lx)\n", status);
1475
1476 RtlInitUnicodeString(&str, L"test-link\\NUL");
1478 ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08lx)\n", status);
1480 ok(status == STATUS_SUCCESS, "Failed to open NUL device(%08lx)\n", status);
1481
1482 pNtClose(h);
1483 pNtClose(link);
1484 pNtClose(dir);
1485
1487 RtlInitUnicodeString(&str, L"\\BaseNamedObjects\\om.c-test");
1488 status = pNtCreateDirectoryObject(&dir, DIRECTORY_QUERY, &attr);
1489 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1490
1491 RtlInitUnicodeString(&str, L"\\DosDevices\\test_link");
1492 RtlInitUnicodeString(&target, L"\\BaseNamedObjects");
1493 status = pNtCreateSymbolicLinkObject(&link, SYMBOLIC_LINK_QUERY, &attr, &target);
1494 ok(status == STATUS_SUCCESS && !!link, "Got unexpected status %#lx.\n", status);
1495
1498 ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Got unexpected status %#lx.\n", status);
1499
1500 status = pNtOpenSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr );
1501 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1502 pNtClose(h);
1503
1504 attr.Attributes = OBJ_OPENIF;
1505 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1506 ok(status == STATUS_SUCCESS || broken( status == STATUS_OBJECT_NAME_EXISTS ), /* <= win10 1507 */
1507 "Got unexpected status %#lx.\n", status);
1508 pNtClose(h);
1509 attr.Attributes = 0;
1510 status = pNtCreateSymbolicLinkObject( &h, SYMBOLIC_LINK_QUERY, &attr, &target );
1511 ok(status == STATUS_OBJECT_NAME_COLLISION, "Got unexpected status %#lx.\n", status);
1512 pNtClose(h);
1513
1515 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\om.c-test\\" );
1518 ok(status == STATUS_OBJECT_NAME_INVALID, "Got unexpected status %#lx.\n", status);
1519
1521 RtlInitUnicodeString( &str, L"om.c-test\\test_object" );
1522 status = pNtCreateMutant( &h, GENERIC_ALL, &attr, FALSE );
1523 ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Got unexpected status %#lx.\n", status);
1524
1526 RtlInitUnicodeString( &str, L"\\DosDevices\\test_link\\om.c-test\\test_object" );
1527 status = pNtCreateMutant( &h, GENERIC_ALL, &attr, FALSE );
1528 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1529 status = pNtOpenMutant( &h2, GENERIC_ALL, &attr );
1530 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1531 pNtClose(h2);
1532 RtlInitUnicodeString( &str, L"\\BaseNamedObjects\\om.c-test\\test_object" );
1533 status = pNtCreateMutant( &h2, GENERIC_ALL, &attr, FALSE );
1534 ok(status == STATUS_OBJECT_NAME_COLLISION, "Got unexpected status %#lx.\n", status);
1535
1537 RtlInitUnicodeString( &str, L"om.c-test\\test_object" );
1538 status = pNtOpenMutant( &h2, GENERIC_ALL, &attr );
1539 ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Got unexpected status %#lx.\n", status);
1540
1541 pNtClose(h);
1542
1543 status = pNtOpenMutant( &h, GENERIC_ALL, &attr );
1544 ok(status == STATUS_OBJECT_TYPE_MISMATCH, "Got unexpected status %#lx.\n", status);
1545
1547 RtlInitUnicodeString( &str, L"test_object" );
1548 status = pNtCreateMutant( &h, GENERIC_ALL, &attr, FALSE );
1549 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1550 status = pNtOpenMutant( &h2, GENERIC_ALL, &attr );
1551 ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status);
1552 pNtClose(h);
1553 pNtClose(h2);
1554
1555 pNtClose(link);
1556 pNtClose(dir);
1557}
#define FILE_DIRECTORY_FILE
Definition: constants.h:491
const WCHAR * link
Definition: db.cpp:998
NTSTATUS NTAPI NtCreateFile(OUT PHANDLE FileHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK IoStatusBlock, IN PLARGE_INTEGER AllocationSize OPTIONAL, IN ULONG FileAttributes, IN ULONG ShareAccess, IN ULONG CreateDisposition, IN ULONG CreateOptions, IN PVOID EaBuffer OPTIONAL, IN ULONG EaLength)

Referenced by START_TEST().

◆ test_token()

static void test_token ( void  )
static

Definition at line 2166 of file om.c.

2167{
2169 HANDLE handle, handle2;
2170
2171 status = pNtOpenProcessToken( GetCurrentProcess(), TOKEN_ALL_ACCESS, (HANDLE *)0xdeadbee0 );
2172 ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcessToken failed: %lx\n", status);
2173 status = pNtOpenThreadToken( GetCurrentThread(), TOKEN_ALL_ACCESS, TRUE, (HANDLE *)0xdeadbee0 );
2174 ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcessToken failed: %lx\n", status);
2175 handle = (HANDLE)0xdeadbeef;
2176 status = pNtOpenProcessToken( (HANDLE)0xdead, TOKEN_ALL_ACCESS, &handle );
2177 ok( status == STATUS_INVALID_HANDLE, "NtOpenProcessToken failed: %lx\n", status);
2178 ok( !handle || broken(handle == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", handle );
2179 handle = (HANDLE)0xdeadbeef;
2180 status = pNtOpenThreadToken( (HANDLE)0xdead, TOKEN_ALL_ACCESS, TRUE, &handle );
2181 ok( status == STATUS_INVALID_HANDLE, "NtOpenThreadToken failed: %lx\n", status);
2182 ok( !handle || broken(handle == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", handle );
2183
2184 status = pNtOpenProcessToken( GetCurrentProcess(), TOKEN_ALL_ACCESS, &handle );
2185 ok( status == STATUS_SUCCESS, "NtOpenProcessToken failed: %lx\n", status);
2186 status = pNtDuplicateToken( handle, TOKEN_ALL_ACCESS, NULL, FALSE, TokenPrimary, &handle2 );
2187 ok( status == STATUS_SUCCESS, "NtOpenProcessToken failed: %lx\n", status);
2188 pNtClose( handle2 );
2189 status = pNtDuplicateToken( handle, TOKEN_ALL_ACCESS, NULL, FALSE, TokenPrimary, (HANDLE *)0xdeadbee0 );
2190 ok( status == STATUS_ACCESS_VIOLATION, "NtOpenProcessToken failed: %lx\n", status);
2191 handle2 = (HANDLE)0xdeadbeef;
2192 status = pNtDuplicateToken( (HANDLE)0xdead, TOKEN_ALL_ACCESS, NULL, FALSE, TokenPrimary, &handle2 );
2193 ok( status == STATUS_INVALID_HANDLE, "NtOpenProcessToken failed: %lx\n", status);
2194 ok( !handle2 || broken(handle2 == (HANDLE)0xdeadbeef) /* vista */, "handle set %p\n", handle2 );
2195 pNtClose( handle );
2196}
@ TokenPrimary
Definition: imports.h:273

Referenced by START_TEST().

◆ test_type_mismatch()

static void test_type_mismatch ( void  )
static

Definition at line 2015 of file om.c.

2016{
2017 HANDLE h;
2018 NTSTATUS res;
2020
2021 attr.Length = sizeof(attr);
2022 attr.RootDirectory = 0;
2023 attr.ObjectName = NULL;
2024 attr.Attributes = 0;
2025 attr.SecurityDescriptor = NULL;
2026 attr.SecurityQualityOfService = NULL;
2027
2028 res = pNtCreateEvent( &h, 0, &attr, NotificationEvent, 0 );
2029 ok(!res, "can't create event: %lx\n", res);
2030
2031 res = pNtReleaseSemaphore( h, 30, NULL );
2032 ok(res == STATUS_OBJECT_TYPE_MISMATCH, "expected 0xc0000024, got %lx\n", res);
2033
2034 pNtClose( h );
2035}
GLuint res
Definition: glext.h:9613

Referenced by START_TEST().

◆ test_zero_access()

static void test_zero_access ( void  )
static

Definition at line 3429 of file om.c.

3430{
3431 UNICODE_STRING target = RTL_CONSTANT_STRING( L"\\DosDevices" );
3432 OBJECT_BASIC_INFORMATION obj_info;
3437 NTSTATUS status, status2;
3438 WCHAR name[256];
3439 CLIENT_ID cid;
3440 HANDLE h1, h2;
3441 DWORD err;
3442
3443#ifdef __REACTOS__
3445 {
3446 skip("Zero access tests don't work on Windows 2003\n");
3447 return;
3448 }
3449#endif
3450
3451 size.QuadPart = 4096;
3452 timeout.QuadPart = -10000;
3453 swprintf( name, ARRAY_SIZE(name), L"\\Sessions\\%u\\BaseNamedObjects\\test_object", NtCurrentTeb()->Peb->SessionId );
3454 pRtlInitUnicodeString( &str, name );
3456
3457 status = pNtCreateEvent( &h1, 0, &attr, NotificationEvent, FALSE );
3458 ok( !status, "got %#lx.\n", status );
3459 CloseHandle( h1 );
3460 status = pNtOpenEvent( &h1, 0, &attr );
3461 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3462 status = pNtCreateEvent( &h1, EVENT_ALL_ACCESS, &attr, NotificationEvent, FALSE );
3463 ok( !status, "got %#lx.\n", status );
3464 status = pNtCreateEvent( &h2, EVENT_ALL_ACCESS, &attr, NotificationEvent, FALSE );
3465 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3466 CloseHandle( h2 );
3467 status = pNtCreateEvent( &h2, 0, &attr, NotificationEvent, FALSE );
3468 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3469 if (NT_SUCCESS(status)) CloseHandle( h2 );
3470 status = pNtOpenEvent( &h2, EVENT_ALL_ACCESS, &attr );
3471 ok( !status, "got %#lx.\n", status );
3472 CloseHandle( h2 );
3473 status = pNtOpenEvent( &h2, 0, &attr );
3474 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3475 if (NT_SUCCESS(status)) CloseHandle( h2 );
3477 status = pNtOpenEvent( &h2, 0, &attr );
3478 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3479 if (NT_SUCCESS(status)) CloseHandle( h2 );
3480
3481 status = pNtDuplicateObject( GetCurrentProcess(), h1, GetCurrentProcess(), &h2, 0, 0, 0 );
3482 ok( !status, "got %#lx.\n", status );
3483 CloseHandle( h2 );
3484 status = pNtDuplicateObject( GetCurrentProcess(), h1, GetCurrentProcess(), &h2, EVENT_ALL_ACCESS, 0, 0 );
3485 ok( !status, "got %#lx.\n", status );
3486 CloseHandle( h2 );
3487 CloseHandle( h1 );
3488
3490 status = pNtCreateMutant( &h1, 0, &attr, FALSE );
3491 ok( !status, "got %#lx.\n", status );
3492 CloseHandle( h1 );
3493 status = pNtOpenMutant( &h1, 0, &attr );
3494 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3495 status = pNtCreateMutant( &h1, MUTANT_ALL_ACCESS, &attr, FALSE );
3496 ok( !status, "got %#lx.\n", status );
3497 status = pNtCreateMutant( &h2, MUTANT_ALL_ACCESS, &attr, FALSE );
3498 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3499 CloseHandle( h2 );
3500 status = pNtCreateMutant( &h2, 0, &attr, FALSE );
3501 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3502 if (NT_SUCCESS(status)) CloseHandle( h2 );
3503 status = pNtOpenMutant( &h2, 0, &attr );
3504 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3505 if (NT_SUCCESS(status)) CloseHandle( h2 );
3506 CloseHandle( h1 );
3507
3508 status = pNtCreateSemaphore( &h1, 0, &attr, 1, 2 );
3509 ok( !status, "got %#lx.\n", status );
3510 CloseHandle( h1 );
3511 status = pNtOpenSemaphore( &h1, 0, &attr );
3512 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3513 status = pNtCreateSemaphore( &h1, SEMAPHORE_ALL_ACCESS, &attr, 1, 2 );
3514 ok( !status, "got %#lx.\n", status );
3515 status = pNtCreateSemaphore( &h2, SEMAPHORE_ALL_ACCESS, &attr, 1, 2 );
3516 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3517 CloseHandle( h2 );
3518 status = pNtCreateSemaphore( &h2, 0, &attr, 1, 2 );
3519 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3520 if (NT_SUCCESS(status)) CloseHandle( h2 );
3521 status = pNtOpenSemaphore( &h2, 0, &attr );
3522 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3523 if (NT_SUCCESS(status)) CloseHandle( h2 );
3524 CloseHandle( h1 );
3525
3526 status = pNtCreateKeyedEvent( &h1, 0, &attr, 0 );
3527 ok( !status, "got %#lx.\n", status );
3528 CloseHandle( h1 );
3529 status = pNtOpenKeyedEvent( &h1, 0, &attr );
3530 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3531 status = pNtCreateKeyedEvent( &h1, KEYEDEVENT_ALL_ACCESS, &attr, 0 );
3532 ok( !status, "got %#lx.\n", status );
3533 status = pNtCreateKeyedEvent( &h2, KEYEDEVENT_ALL_ACCESS, &attr, 0 );
3534 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3535 CloseHandle( h2 );
3536 status = pNtCreateKeyedEvent( &h2, 0, &attr, 0 );
3537 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3538 if (NT_SUCCESS(status)) CloseHandle( h2 );
3539 status = pNtOpenKeyedEvent( &h2, 0, &attr );
3540 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3541 if (NT_SUCCESS(status)) CloseHandle( h2 );
3542 CloseHandle( h1 );
3543
3544 status = pNtCreateIoCompletion( &h1, 0, &attr, 0 );
3545 ok( !status, "got %#lx.\n", status );
3546 CloseHandle( h1 );
3547 status = pNtOpenIoCompletion( &h1, 0, &attr );
3548 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3549 status = pNtCreateIoCompletion( &h1, IO_COMPLETION_ALL_ACCESS, &attr, 0 );
3550 ok( !status, "got %#lx.\n", status );
3552 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3553 CloseHandle( h2 );
3554 status = pNtCreateIoCompletion( &h2, 0, &attr, 0 );
3555 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3556 if (NT_SUCCESS(status)) CloseHandle( h2 );
3557 status = pNtOpenIoCompletion( &h2, 0, &attr );
3558 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3559 if (NT_SUCCESS(status)) CloseHandle( h2 );
3560 CloseHandle( h1 );
3561
3562 status = pNtCreateJobObject( &h1, 0, &attr );
3563 ok( !status, "got %#lx.\n", status );
3564 CloseHandle( h1 );
3565 status = pNtOpenJobObject( &h1, 0, &attr );
3566 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3567 status = pNtCreateJobObject( &h1, JOB_OBJECT_ALL_ACCESS, &attr );
3568 ok( !status, "got %#lx.\n", status );
3569 status = pNtCreateJobObject( &h2, JOB_OBJECT_ALL_ACCESS, &attr );
3570 ok( status == STATUS_OBJECT_NAME_EXISTS || broken( status == STATUS_ACCESS_DENIED), /* <= win10 1507 */
3571 "got %#lx.\n", status );
3572 if (NT_SUCCESS(status)) CloseHandle( h2 );
3573 status = pNtCreateJobObject( &h2, 0, &attr );
3574 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3575 if (NT_SUCCESS(status)) CloseHandle( h2 );
3576 status = pNtOpenJobObject( &h2, 0, &attr );
3577 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3578 if (NT_SUCCESS(status)) CloseHandle( h2 );
3579 CloseHandle( h1 );
3580
3581 status = pNtCreateDirectoryObject( &h1, 0, &attr );
3582 ok( !status, "got %#lx.\n", status );
3583 CloseHandle( h1 );
3584 status = pNtOpenDirectoryObject( &h1, 0, &attr );
3585 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3586 status = pNtCreateDirectoryObject( &h1, DIRECTORY_ALL_ACCESS, &attr );
3587 ok( !status, "got %#lx.\n", status );
3588 status = pNtCreateDirectoryObject( &h2, DIRECTORY_ALL_ACCESS, &attr );
3589 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3590 CloseHandle( h2 );
3591 status = pNtCreateDirectoryObject( &h2, 0, &attr );
3592 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3593 if (NT_SUCCESS(status)) CloseHandle( h2 );
3594 status = pNtOpenDirectoryObject( &h2, 0, &attr );
3595 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3596 if (NT_SUCCESS(status)) CloseHandle( h2 );
3597 CloseHandle( h1 );
3598
3599 status = pNtCreateTimer( &h1, 0, &attr, NotificationTimer );
3600 ok( !status, "got %#lx.\n", status );
3601 CloseHandle( h1 );
3602 status = pNtOpenTimer( &h1, 0, &attr );
3603 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3604 status = pNtCreateTimer( &h1, TIMER_ALL_ACCESS, &attr, NotificationTimer );
3605 ok( !status, "got %#lx.\n", status );
3606 status = pNtCreateTimer( &h2, TIMER_ALL_ACCESS, &attr, NotificationTimer );
3607 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3608 CloseHandle( h2 );
3609 status = pNtCreateTimer( &h2, 0, &attr, NotificationTimer );
3610 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3611 if (NT_SUCCESS(status)) CloseHandle( h2 );
3612 status = pNtOpenTimer( &h2, 0, &attr );
3613 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3614 if (NT_SUCCESS(status)) CloseHandle( h2 );
3615 CloseHandle( h1 );
3616
3617 status = pNtCreateSymbolicLinkObject( &h1, 0, &attr, &target );
3618 ok( !status, "got %#lx.\n", status );
3619 CloseHandle( h1 );
3620 status = pNtOpenSymbolicLinkObject( &h1, 0, &attr );
3621 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3622 status = pNtCreateSymbolicLinkObject( &h1, SYMBOLIC_LINK_ALL_ACCESS, &attr, &target );
3623 ok( !status, "got %#lx.\n", status );
3624 status = pNtCreateSymbolicLinkObject( &h2, SYMBOLIC_LINK_ALL_ACCESS, &attr, &target );
3625 ok( !status || broken( status == STATUS_OBJECT_NAME_EXISTS ), /* <= win10 1507 */
3626 "got %#lx.\n", status );
3627 CloseHandle( h2 );
3628 status = pNtCreateSymbolicLinkObject( &h2, 0, &attr, &target );
3629 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3630 if (NT_SUCCESS(status)) CloseHandle( h2 );
3631 status = pNtOpenSymbolicLinkObject( &h2, 0, &attr );
3632 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3633 if (NT_SUCCESS(status)) CloseHandle( h2 );
3634 CloseHandle( h1 );
3635
3636 status = pNtCreateSection( &h1, 0, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
3637 ok( !status, "got %#lx.\n", status );
3638 CloseHandle( h1 );
3639 status = pNtOpenSection( &h1, 0, &attr );
3640 ok( status == STATUS_OBJECT_NAME_NOT_FOUND, "got %#lx.\n", status );
3641 status = pNtCreateSection( &h1, SECTION_ALL_ACCESS, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
3642 ok( !status, "got %#lx.\n", status );
3643 status = pNtCreateSection( &h2, SECTION_ALL_ACCESS, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
3644 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3645 CloseHandle( h2 );
3646 status = pNtCreateSection( &h2, 0, &attr, &size, PAGE_READWRITE, SEC_COMMIT, 0 );
3647 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3648 if (NT_SUCCESS(status)) CloseHandle( h2 );
3649 status = pNtOpenSection( &h2, 0, &attr );
3650 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3651 if (NT_SUCCESS(status)) CloseHandle( h2 );
3652 CloseHandle( h1 );
3653
3654 status = pNtCreateDebugObject( &h1, 0, &attr, 0 );
3655 ok( !status, "got %#lx.\n", status );
3656 CloseHandle( h1 );
3657 status = pNtCreateDebugObject( &h1, DEBUG_ALL_ACCESS, &attr, 0 );
3658 ok( !status, "got %#lx.\n", status );
3659 status = pNtCreateDebugObject( &h2, DEBUG_ALL_ACCESS, &attr, 0 );
3660 ok( status == STATUS_OBJECT_NAME_EXISTS, "got %#lx.\n", status );
3661 CloseHandle( h2 );
3662 status = pNtCreateDebugObject( &h2, 0, &attr, 0 );
3663 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3664 if (NT_SUCCESS(status)) CloseHandle( h2 );
3665 CloseHandle( h1 );
3666
3667 pRtlInitUnicodeString( &str, L"\\Device\\Null" );
3670 ok( !status, "got %#lx.\n", status );
3671 CloseHandle( h1 );
3672 status = NtCreateFile( &h1, 0, &attr, &iosb, NULL, 0,
3674 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3675 if (NT_SUCCESS(status)) CloseHandle( h1 );
3676
3677 pRtlInitUnicodeString( &str, L"\\??\\c:\\windows\\system32\\ntdll.dll" );
3680 ok( !status, "got %#lx.\n", status );
3681 CloseHandle( h1 );
3682 status = NtCreateFile( &h1, 0, &attr, &iosb, NULL, 0,
3684 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3685 if (NT_SUCCESS(status)) CloseHandle( h1 );
3686
3687 pRtlInitUnicodeString( &str, L"\\Device\\MailSlot\\abc" );
3688 status = pNtCreateMailslotFile( &h1, 0, &attr, &iosb, 0, 0, 0, NULL );
3689 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3690 if (NT_SUCCESS(status)) CloseHandle( h1 );
3691 status = pNtCreateMailslotFile( &h1, GENERIC_ALL, &attr, &iosb, 0, 0, 0, NULL );
3692 ok( !status, "got %#lx.\n", status );
3693 status = pNtCreateMailslotFile( &h2, GENERIC_READ, &attr, &iosb, 0, 0, 0, NULL );
3694 ok( status == STATUS_OBJECT_NAME_COLLISION, "got %#lx.\n", status );
3695 status = pNtCreateMailslotFile( &h2, 0, &attr, &iosb, 0, 0, 0, NULL );
3696 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3697 CloseHandle( h1 );
3698
3699 pRtlInitUnicodeString( &str, L"\\??\\PIPE\\test\\pipe" );
3700 status = pNtCreateNamedPipeFile( &h1, 0, &attr, &iosb,
3702 FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout );
3703 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3704 if (NT_SUCCESS(status)) CloseHandle( h1 );
3705 status = pNtCreateNamedPipeFile( &h1, GENERIC_READ | GENERIC_WRITE, &attr, &iosb,
3707 FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout );
3708 ok( !status, "got %#lx.\n", status );
3709 status = pNtCreateNamedPipeFile( &h2, GENERIC_READ, &attr, &iosb,
3711 FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout );
3712 ok( status == STATUS_INSTANCE_NOT_AVAILABLE, "got %#lx.\n", status );
3713 status = pNtCreateNamedPipeFile( &h2, 0, &attr, &iosb,
3715 FILE_PIPE_FULL_DUPLEX, FALSE, FALSE, FALSE, 1, 256, 256, &timeout );
3716 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3717 if (NT_SUCCESS(status)) CloseHandle( h2 );
3718 CloseHandle( h1 );
3719
3720 pRtlInitUnicodeString( &str, L"\\REGISTRY\\Machine" );
3721 status = pNtCreateKey( &h1, 0, &attr, 0, 0, 0, 0 );
3722 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3723 if (NT_SUCCESS(status)) CloseHandle( h1 );
3724 status = pNtCreateKey( &h1, KEY_READ, &attr, 0, 0, 0, 0 );
3725 ok( !status, "got %#lx.\n", status );
3726 CloseHandle( h1 );
3727 status = pNtOpenKey( &h1, KEY_READ, &attr );
3728 ok( !status, "got %#lx.\n", status );
3729 CloseHandle( h1 );
3730 status = pNtOpenKey( &h1, 0, &attr );
3731 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3732 if (NT_SUCCESS(status)) CloseHandle( h1 );
3733
3734 pRtlInitUnicodeString( &str, L"\\REGISTRY\\Machine\\Software\\foobar-test" );
3735 status = pNtCreateKey( &h1, KEY_ALL_ACCESS, &attr, 0, 0, 0, 0 );
3737 "got %#lx.\n", status );
3738 if (!status)
3739 {
3740 pNtDeleteKey( h1 );
3741 CloseHandle( h1 );
3742 }
3743 status2 = pNtCreateKey( &h1, 0, &attr, 0, 0, 0, 0 );
3744 ok( status2 == status, "got %#lx / %#lx.\n", status2, status );
3745 if (!status2)
3746 {
3747 pNtDeleteKey( h1 );
3748 CloseHandle( h1 );
3749 }
3750
3751 status = pNtOpenProcessToken( GetCurrentProcess(), TOKEN_ALL_ACCESS, &h1 );
3752 ok( !status, "got %#lx.\n", status );
3753 CloseHandle( h1 );
3754 status = pNtOpenProcessToken( GetCurrentProcess(), 0, &h1 );
3755 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3756 if (NT_SUCCESS(status)) CloseHandle( h1 );
3757
3758#if !defined(__REACTOS__) || DLL_EXPORT_VERSION >= 0x600
3759 status = NtGetNextThread(GetCurrentProcess(), NULL, 0, 0, 0, &h1);
3760 todo_wine ok( status == STATUS_NO_MORE_ENTRIES, "got %#lx.\n", status );
3761 if (NT_SUCCESS(status)) CloseHandle( h1 );
3762#endif
3763
3765 cid.UniqueProcess = ULongToHandle( GetCurrentProcessId() );
3766 cid.UniqueThread = 0;
3767 status = pNtOpenProcess( &h1, 0, &attr, &cid );
3768 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3769 if (NT_SUCCESS(status)) CloseHandle( h1 );
3770
3772 cid.UniqueProcess = 0;
3773 cid.UniqueThread = ULongToHandle( GetCurrentThreadId() );
3774 status = pNtOpenThread( &h1, 0, &attr, &cid );
3775 todo_wine ok( status == STATUS_ACCESS_DENIED, "got %#lx.\n", status );
3776 if (NT_SUCCESS(status)) CloseHandle( h1 );
3777
3778 h1 = CreateWindowStationA( "WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
3779 err = GetLastError();
3780 if (h1)
3781 {
3782 CloseWindowStation( h1 );
3783 h1 = CreateWindowStationA( "WinSta0", 0, WINSTA_ALL_ACCESS, NULL );
3784 ok( h1 != 0, "CreateWindowStationA failed err %lu\n", GetLastError());
3785 CloseWindowStation( h1 );
3786 h1 = CreateWindowStationA( "WinSta0", 0, 0, NULL );
3787 err = GetLastError();
3788 todo_wine ok( !h1, "CreateWindowStationA succeeded\n" );
3789 todo_wine ok( err == ERROR_ACCESS_DENIED, "CreateWindowStationA failed %lu\n", err );
3790 if (h1) CloseWindowStation( h1 );
3791 }
3792 else if (err == ERROR_ACCESS_DENIED) win_skip( "Not enough privileges for CreateWindowStation\n" );
3793
3794 h1 = OpenWindowStationA( "WinSta0", TRUE, WINSTA_ALL_ACCESS );
3795 ok( h1 != 0, "OpenWindowStation failed\n" );
3796 CloseWindowStation( h1 );
3797 h1 = OpenWindowStationA( "WinSta0", TRUE, 0 );
3798 err = GetLastError();
3799 todo_wine ok( !h1, "OpenWindowStation succeeeded\n" );
3800 todo_wine ok( err == ERROR_ACCESS_DENIED, "OpenWindowStation failed %lu\n", err );
3801 if (h1) CloseWindowStation( h1 );
3802
3803 h1 = CreateDesktopA( "default", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
3804 ok( h1 != 0, "CreateDesktopA failed %lu\n", GetLastError() );
3805 CloseDesktop( h1 );
3806 SetLastError( 0xdeadbeef );
3807 h1 = CreateDesktopA( "default", NULL, NULL, 0, 0, NULL );
3808 err = GetLastError();
3809 todo_wine ok( !h1, "CreateDesktopA succeeded\n" );
3810 todo_wine ok( err == ERROR_ACCESS_DENIED, "CreateDesktopA failed %lu\n", err );
3811 if (h1) CloseDesktop( h1 );
3812
3813 h1 = OpenDesktopA( "default", 0, TRUE, DESKTOP_ALL_ACCESS );
3814 ok( h1 != 0, "OpenDesktopA failed %lu\n", GetLastError() );
3815 CloseDesktop( h1 );
3816 h1 = OpenDesktopA( "default", 0, TRUE, 0 );
3817 ok( h1 != 0, "OpenDesktopA failed %lu\n", GetLastError() );
3818 NtQueryObject( h1, ObjectBasicInformation, &obj_info, sizeof(obj_info), NULL );
3820 "wrong access %lx\n", obj_info.GrantedAccess );
3821 CloseDesktop( h1 );
3822 h1 = OpenDesktopA( "default", 0, TRUE, DESKTOP_CREATEWINDOW );
3823 ok( h1 != 0, "OpenDesktopA failed %lu\n", GetLastError() );
3824 NtQueryObject( h1, ObjectBasicInformation, &obj_info, sizeof(obj_info), NULL );
3826 "wrong access %lx\n", obj_info.GrantedAccess );
3827 CloseDesktop( h1 );
3828
3830 ok( h1 != 0, "OpenInputDesktop failed %lu\n", GetLastError() );
3831 CloseDesktop( h1 );
3832 h1 = OpenInputDesktop( 0, FALSE, 0 );
3833 ok( h1 != 0, "OpenInputDesktop failed %lu\n", GetLastError() );
3834 NtQueryObject( h1, ObjectBasicInformation, &obj_info, sizeof(obj_info), NULL );
3836 "wrong access %lx\n", obj_info.GrantedAccess );
3837 CloseDesktop( h1 );
3839 ok( h1 != 0, "OpenInputDesktop failed %lu\n", GetLastError() );
3840 NtQueryObject( h1, ObjectBasicInformation, &obj_info, sizeof(obj_info), NULL );
3842 "wrong access %lx\n", obj_info.GrantedAccess );
3843 CloseDesktop( h1 );
3844}
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
NTSTATUS NTAPI NtCreateIoCompletion(OUT PHANDLE IoCompletionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG NumberOfConcurrentThreads)
Definition: iocomp.c:253
#define KEY_ALL_ACCESS
Definition: nt_native.h:1044
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1296
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1262
#define WINSTA_ALL_ACCESS
Definition: om.c:2279
#define DESKTOP_ALL_ACCESS
Definition: om.c:2280
#define err(...)
HDESK WINAPI CreateDesktopA(LPCSTR lpszDesktop, LPCSTR lpszDevice, LPDEVMODEA pDevmode, DWORD dwFlags, ACCESS_MASK dwDesiredAccess, LPSECURITY_ATTRIBUTES lpsa)
Definition: desktop.c:431
NTSYSAPI NTSTATUS WINAPI NtGetNextThread(HANDLE, HANDLE, ACCESS_MASK, ULONG, ULONG, HANDLE *)
HWINSTA WINAPI OpenWindowStationA(_In_ LPCSTR, _In_ BOOL, _In_ DWORD)
HDESK WINAPI OpenInputDesktop(_In_ DWORD, _In_ BOOL, _In_ DWORD)
HDESK WINAPI OpenDesktopA(_In_ LPCSTR, _In_ DWORD, _In_ BOOL, _In_ DWORD)
#define DESKTOP_ENUMERATE
Definition: winuser.h:218
HWINSTA WINAPI CreateWindowStationA(_In_opt_ LPCSTR lpwinsta, _In_ DWORD dwFlags, _In_ ACCESS_MASK dwDesiredAccess, _In_opt_ LPSECURITY_ATTRIBUTES lpsa)
BOOL WINAPI CloseWindowStation(_In_ HWINSTA)
#define DESKTOP_READOBJECTS
Definition: winuser.h:222
BOOL WINAPI CloseDesktop(_In_ HDESK)

Referenced by START_TEST().

◆ VOID()

static VOID ( WINAPI pRtlInitUnicodeString)
static

Variable Documentation

◆ access

Definition at line 94 of file om.c.

◆ ACCESS_MASK

Definition at line 57 of file om.c.

◆ all_types

◆ attributes

HANDLE ACCESS_MASK ULONG attributes

Definition at line 94 of file om.c.

Referenced by _IRQL_requires_max_(), _waccess_s(), _wchmod(), AddEventHooksWdfDeviceCreate(), AddEventHooksWdfIoQueueCreate(), apply_image_attributes(), check_language(), CheckTestFile(), FxUsbPipeContinuousReader::Config(), convert_to_stat_mode(), CreateFile2(), CreateFileA(), CreateFileW(), CreateRemoteThreadEx(), CreateTestFile(), CRYPT_AsnEncodePKCSAttributes(), D3DXWeldVertices(), DeviceErrorHandlerForMmc(), DeviceSendStartUnit(), dialog_add_control(), dialog_bitmap_control(), dialog_button_control(), dialog_combo_control(), dialog_icon_control(), dialog_list_box(), dialog_listview(), dialog_progress_bar(), DriverEntry(), DriverEvtDeviceAdd(), Fdo_Create(), find_mono_dll(), GdipCreateTexture(), GdipCreateTexture2(), get_nt_file_options(), GetSOFTplg(), HDA_TransferCodecVerbs(), HDAGraphicsPowerInterfaceAdd(), HDAGraphicsPowerInterfaceCallback(), headerinfo_GetAttributeCount(), headerinfo_GetAttributeCountEx(), idmap_lookup_group(), idmap_lookup_user(), idmap_query_attrs(), init_test_mesh(), FxInterrupt::InitializeWorker(), ITERATE_FindRelatedProducts(), ITERATE_MigrateFeatureStates(), libxmlStartElementNS(), load_icon(), METAFILE_PlaybackObject(), MsiEnableLogA(), MsiEnableLogW(), nfs41_name_cache_delegreturn(), nfs41_name_cache_insert(), nfs41_name_cache_remove(), OLEFontImpl_Load(), OLEFontImpl_Save(), on_default_action(), FxPkgGeneral::OnCreate(), ParaNdis5_Initialize(), CAddressEditBox::ParseNow(), patch_offset_get_files(), FxPkgGeneral::PostCreateDeviceInitialize(), ReOpenFile(), resample_bitmap_pixel(), resample_bitmap_pixel_premult(), sample_bitmap_pixel(), SetFileAttributesA(), SetFileAttributesW(), shell_item_exists(), SHGetFolderLocation(), SHILCreateFromPathA(), SHILCreateFromPathAW(), SHILCreateFromPathW(), test_AttributesRegistration(), test_catalog_properties(), test_clone_mesh(), test_convert_adjacency_to_point_reps(), test_convert_point_reps_to_adjacency(), test_decodePKCSAttributes(), test_device_info(), test_domnode(), test_encodePKCSAttributes(), test_FindFirstChangeNotification(), test_profile_directory_readonly(), test_rtti(), test_update_semantics(), test_weld_vertices(), UACPI_PACKED(), VfdOpenImage(), WdfLdrDiagnosticsValueByNameAsULONG(), and xmlSAX2StartElementNs().

◆ BOOLEAN

Definition at line 57 of file om.c.

◆ DWORD

Definition at line 96 of file om.c.

◆ EVENT_TYPE

Definition at line 57 of file om.c.

◆ FILE_INFORMATION_CLASS

Definition at line 91 of file om.c.

◆ flags

Definition at line 95 of file om.c.

◆ HANDLE

◆ handle

◆ LONG

Definition at line 69 of file om.c.

◆ LPCWSTR

Definition at line 55 of file om.c.

◆ MEMORY_RESERVE_OBJECT_TYPE

◆ OBJECT_INFORMATION_CLASS

Definition at line 85 of file om.c.

◆ PIO_STATUS_BLOCK

Definition at line 65 of file om.c.

◆ PLARGE_INTEGER

Definition at line 66 of file om.c.

◆ POBJECT_ATTRIBUTES

Definition at line 57 of file om.c.

◆ PULONG

Definition at line 62 of file om.c.

◆ PUNICODE_STRING

Definition at line 83 of file om.c.

◆ PVOID

Definition at line 85 of file om.c.

◆ thread

HANDLE thread

Definition at line 94 of file om.c.

Referenced by test_get_next_thread().

◆ TIMER_TYPE

Definition at line 71 of file om.c.

◆ TOKEN_TYPE

Definition at line 99 of file om.c.

◆ ULONG

Definition at line 61 of file om.c.