diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index f1fc07a2ec7..0f601d8ade7 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -217,6 +217,8 @@ @ stdcall CreateDirectoryExW(wstr wstr ptr) @ stdcall CreateDirectoryW(wstr ptr) @ stdcall CreateEventA(ptr long long str) +@ stdcall CreateEventExA(ptr str long long) +@ stdcall CreateEventExW(ptr wstr long long) @ stdcall CreateEventW(ptr long long wstr) @ stdcall CreateFiber(long ptr ptr) @ stdcall CreateFiberEx(long long long ptr ptr) @@ -235,6 +237,8 @@ @ stdcall CreateMailslotW(ptr long long ptr) # @ stub CreateMemoryResourceNotification @ stdcall CreateMutexA(ptr long str) +@ stdcall CreateMutexExA(ptr str long long) +@ stdcall CreateMutexExW(ptr wstr long long) @ stdcall CreateMutexW(ptr long wstr) @ stdcall CreateNamedPipeA(str long long long long long long ptr) @ stdcall CreateNamedPipeW(wstr long long long long long long ptr) @@ -247,6 +251,8 @@ @ stdcall CreateProcessW(wstr wstr ptr ptr long long ptr wstr ptr ptr) @ stdcall CreateRemoteThread(long ptr long ptr long long ptr) @ stdcall CreateSemaphoreA(ptr long long str) +@ stdcall CreateSemaphoreExA(ptr long long str long long) +@ stdcall CreateSemaphoreExW(ptr long long wstr long long) @ stdcall CreateSemaphoreW(ptr long long wstr) @ stdcall CreateSocketHandle() @ stdcall CreateTapePartition(long long long long) @@ -256,6 +262,8 @@ @ stdcall CreateToolhelp32Snapshot(long long) @ stub CreateVirtualBuffer @ stdcall CreateWaitableTimerA(ptr long str) +@ stdcall CreateWaitableTimerExA(ptr str long long) +@ stdcall CreateWaitableTimerExW(ptr wstr long long) @ stdcall CreateWaitableTimerW(ptr long wstr) @ stdcall DeactivateActCtx(long ptr) @ stdcall DebugActiveProcess(long) diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c index e92679aafef..2318c918273 100644 --- a/dlls/kernel32/sync.c +++ b/dlls/kernel32/sync.c @@ -458,16 +458,11 @@ void WINAPI UninitializeCriticalSection( CRITICAL_SECTION *crit ) HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, BOOL initial_state, LPCSTR name ) { - WCHAR buffer[MAX_PATH]; + DWORD flags = 0; - if (!name) return CreateEventW( sa, manual_reset, initial_state, NULL ); - - if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) - { - SetLastError( ERROR_FILENAME_EXCED_RANGE ); - return 0; - } - return CreateEventW( sa, manual_reset, initial_state, buffer ); + if (manual_reset) flags |= CREATE_EVENT_MANUAL_RESET; + if (initial_state) flags |= CREATE_EVENT_INITIAL_SET; + return CreateEventExA( sa, name, flags, EVENT_ALL_ACCESS ); } @@ -476,6 +471,37 @@ HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, */ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, BOOL initial_state, LPCWSTR name ) +{ + DWORD flags = 0; + + if (manual_reset) flags |= CREATE_EVENT_MANUAL_RESET; + if (initial_state) flags |= CREATE_EVENT_INITIAL_SET; + return CreateEventExW( sa, name, flags, EVENT_ALL_ACCESS ); +} + + +/*********************************************************************** + * CreateEventExA (KERNEL32.@) + */ +HANDLE WINAPI CreateEventExA( SECURITY_ATTRIBUTES *sa, LPCSTR name, DWORD flags, DWORD access ) +{ + WCHAR buffer[MAX_PATH]; + + if (!name) return CreateEventExW( sa, NULL, flags, access ); + + if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return 0; + } + return CreateEventExW( sa, buffer, flags, access ); +} + + +/*********************************************************************** + * CreateEventExW (KERNEL32.@) + */ +HANDLE WINAPI CreateEventExW( SECURITY_ATTRIBUTES *sa, LPCWSTR name, DWORD flags, DWORD access ) { HANDLE ret; UNICODE_STRING nameW; @@ -505,7 +531,8 @@ HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset, attr.RootDirectory = get_BaseNamedObjects_handle(); } - status = NtCreateEvent( &ret, EVENT_ALL_ACCESS, &attr, manual_reset, initial_state ); + status = NtCreateEvent( &ret, access, &attr, (flags & CREATE_EVENT_MANUAL_RESET) != 0, + (flags & CREATE_EVENT_INITIAL_SET) != 0 ); if (status == STATUS_OBJECT_NAME_EXISTS) SetLastError( ERROR_ALREADY_EXISTS ); else @@ -668,16 +695,7 @@ VOID WINAPI VWin32_EventSet(HANDLE event) */ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) { - WCHAR buffer[MAX_PATH]; - - if (!name) return CreateMutexW( sa, owner, NULL ); - - if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) - { - SetLastError( ERROR_FILENAME_EXCED_RANGE ); - return 0; - } - return CreateMutexW( sa, owner, buffer ); + return CreateMutexExA( sa, name, owner ? CREATE_MUTEX_INITIAL_OWNER : 0, MUTEX_ALL_ACCESS ); } @@ -685,6 +703,33 @@ HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name ) * CreateMutexW (KERNEL32.@) */ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) +{ + return CreateMutexExW( sa, name, owner ? CREATE_MUTEX_INITIAL_OWNER : 0, MUTEX_ALL_ACCESS ); +} + + +/*********************************************************************** + * CreateMutexExA (KERNEL32.@) + */ +HANDLE WINAPI CreateMutexExA( SECURITY_ATTRIBUTES *sa, LPCSTR name, DWORD flags, DWORD access ) +{ + WCHAR buffer[MAX_PATH]; + + if (!name) return CreateMutexExW( sa, NULL, flags, access ); + + if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return 0; + } + return CreateMutexExW( sa, buffer, flags, access ); +} + + +/*********************************************************************** + * CreateMutexExW (KERNEL32.@) + */ +HANDLE WINAPI CreateMutexExW( SECURITY_ATTRIBUTES *sa, LPCWSTR name, DWORD flags, DWORD access ) { HANDLE ret; UNICODE_STRING nameW; @@ -704,7 +749,7 @@ HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name ) attr.RootDirectory = get_BaseNamedObjects_handle(); } - status = NtCreateMutant( &ret, MUTEX_ALL_ACCESS, &attr, owner ); + status = NtCreateMutant( &ret, access, &attr, (flags & CREATE_MUTEX_INITIAL_OWNER) != 0 ); if (status == STATUS_OBJECT_NAME_EXISTS) SetLastError( ERROR_ALREADY_EXISTS ); else @@ -793,16 +838,7 @@ BOOL WINAPI ReleaseMutex( HANDLE handle ) */ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name ) { - WCHAR buffer[MAX_PATH]; - - if (!name) return CreateSemaphoreW( sa, initial, max, NULL ); - - if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) - { - SetLastError( ERROR_FILENAME_EXCED_RANGE ); - return 0; - } - return CreateSemaphoreW( sa, initial, max, buffer ); + return CreateSemaphoreExA( sa, initial, max, name, 0, SEMAPHORE_ALL_ACCESS ); } @@ -811,6 +847,35 @@ HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, */ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCWSTR name ) +{ + return CreateSemaphoreExW( sa, initial, max, name, 0, SEMAPHORE_ALL_ACCESS ); +} + + +/*********************************************************************** + * CreateSemaphoreExA (KERNEL32.@) + */ +HANDLE WINAPI CreateSemaphoreExA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name, + DWORD flags, DWORD access ) +{ + WCHAR buffer[MAX_PATH]; + + if (!name) return CreateSemaphoreExW( sa, initial, max, NULL, flags, access ); + + if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return 0; + } + return CreateSemaphoreExW( sa, initial, max, buffer, flags, access ); +} + + +/*********************************************************************** + * CreateSemaphoreExW (KERNEL32.@) + */ +HANDLE WINAPI CreateSemaphoreExW( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCWSTR name, + DWORD flags, DWORD access ) { HANDLE ret; UNICODE_STRING nameW; @@ -830,7 +895,7 @@ HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial, attr.RootDirectory = get_BaseNamedObjects_handle(); } - status = NtCreateSemaphore( &ret, SEMAPHORE_ALL_ACCESS, &attr, initial, max ); + status = NtCreateSemaphore( &ret, access, &attr, initial, max ); if (status == STATUS_OBJECT_NAME_EXISTS) SetLastError( ERROR_ALREADY_EXISTS ); else @@ -1076,16 +1141,8 @@ BOOL WINAPI IsProcessInJob( HANDLE process, HANDLE job, PBOOL result ) */ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name ) { - WCHAR buffer[MAX_PATH]; - - if (!name) return CreateWaitableTimerW( sa, manual, NULL ); - - if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) - { - SetLastError( ERROR_FILENAME_EXCED_RANGE ); - return 0; - } - return CreateWaitableTimerW( sa, manual, buffer ); + return CreateWaitableTimerExA( sa, name, manual ? CREATE_WAITABLE_TIMER_MANUAL_RESET : 0, + TIMER_ALL_ACCESS ); } @@ -1093,6 +1150,34 @@ HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR * CreateWaitableTimerW (KERNEL32.@) */ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name ) +{ + return CreateWaitableTimerExW( sa, name, manual ? CREATE_WAITABLE_TIMER_MANUAL_RESET : 0, + TIMER_ALL_ACCESS ); +} + + +/*********************************************************************** + * CreateWaitableTimerExA (KERNEL32.@) + */ +HANDLE WINAPI CreateWaitableTimerExA( SECURITY_ATTRIBUTES *sa, LPCSTR name, DWORD flags, DWORD access ) +{ + WCHAR buffer[MAX_PATH]; + + if (!name) return CreateWaitableTimerExW( sa, NULL, flags, access ); + + if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH )) + { + SetLastError( ERROR_FILENAME_EXCED_RANGE ); + return 0; + } + return CreateWaitableTimerExW( sa, buffer, flags, access ); +} + + +/*********************************************************************** + * CreateWaitableTimerExW (KERNEL32.@) + */ +HANDLE WINAPI CreateWaitableTimerExW( SECURITY_ATTRIBUTES *sa, LPCWSTR name, DWORD flags, DWORD access ) { HANDLE handle; NTSTATUS status; @@ -1112,8 +1197,8 @@ HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWST attr.RootDirectory = get_BaseNamedObjects_handle(); } - status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &attr, - manual ? NotificationTimer : SynchronizationTimer); + status = NtCreateTimer( &handle, access, &attr, + (flags & CREATE_WAITABLE_TIMER_MANUAL_RESET) ? NotificationTimer : SynchronizationTimer ); if (status == STATUS_OBJECT_NAME_EXISTS) SetLastError( ERROR_ALREADY_EXISTS ); else diff --git a/include/winbase.h b/include/winbase.h index 0b637f56492..a7733b02734 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -827,6 +827,12 @@ typedef DWORD (CALLBACK *LPPROGRESS_ROUTINE)(LARGE_INTEGER, LARGE_INTEGER, LARGE LARGE_INTEGER, DWORD, DWORD, HANDLE, HANDLE, LPVOID); +#define CREATE_EVENT_MANUAL_RESET 1 +#define CREATE_EVENT_INITIAL_SET 2 + +#define CREATE_MUTEX_INITIAL_OWNER 1 + +#define CREATE_WAITABLE_TIMER_MANUAL_RESET 1 #define WAIT_FAILED 0xffffffff #define WAIT_OBJECT_0 0 @@ -1351,6 +1357,9 @@ WINBASEAPI BOOL WINAPI CreateDirectoryExW(LPCWSTR,LPCWSTR,LPSECURITY_ATTR WINBASEAPI HANDLE WINAPI CreateEventA(LPSECURITY_ATTRIBUTES,BOOL,BOOL,LPCSTR); WINBASEAPI HANDLE WINAPI CreateEventW(LPSECURITY_ATTRIBUTES,BOOL,BOOL,LPCWSTR); #define CreateEvent WINELIB_NAME_AW(CreateEvent) +WINBASEAPI HANDLE WINAPI CreateEventExA(SECURITY_ATTRIBUTES*,LPCSTR,DWORD,DWORD); +WINBASEAPI HANDLE WINAPI CreateEventExW(SECURITY_ATTRIBUTES*,LPCWSTR,DWORD,DWORD); +#define CreateEventEx WINELIB_NAME_AW(CreateEventEx) WINBASEAPI LPVOID WINAPI CreateFiber(SIZE_T,LPFIBER_START_ROUTINE,LPVOID); WINBASEAPI LPVOID WINAPI CreateFiberEx(SIZE_T,SIZE_T,DWORD,LPFIBER_START_ROUTINE,LPVOID); WINBASEAPI HANDLE WINAPI CreateFileA(LPCSTR,DWORD,DWORD,LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE); @@ -1369,6 +1378,9 @@ WINBASEAPI HANDLE WINAPI CreateMailslotW(LPCWSTR,DWORD,DWORD,LPSECURITY_ATT WINBASEAPI HANDLE WINAPI CreateMutexA(LPSECURITY_ATTRIBUTES,BOOL,LPCSTR); WINBASEAPI HANDLE WINAPI CreateMutexW(LPSECURITY_ATTRIBUTES,BOOL,LPCWSTR); #define CreateMutex WINELIB_NAME_AW(CreateMutex) +WINBASEAPI HANDLE WINAPI CreateMutexExA(SECURITY_ATTRIBUTES*,LPCSTR,DWORD,DWORD); +WINBASEAPI HANDLE WINAPI CreateMutexExW(SECURITY_ATTRIBUTES*,LPCWSTR,DWORD,DWORD); +#define CreateMutexEx WINELIB_NAME_AW(CreateMutexEx) WINBASEAPI HANDLE WINAPI CreateNamedPipeA(LPCSTR,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,LPSECURITY_ATTRIBUTES); WINBASEAPI HANDLE WINAPI CreateNamedPipeW(LPCWSTR,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,LPSECURITY_ATTRIBUTES); #define CreateNamedPipe WINELIB_NAME_AW(CreateNamedPipe) @@ -1385,6 +1397,9 @@ WINADVAPI BOOL WINAPI CreateRestrictedToken(HANDLE,DWORD,DWORD,PSID_AND_ WINBASEAPI HANDLE WINAPI CreateSemaphoreA(LPSECURITY_ATTRIBUTES,LONG,LONG,LPCSTR); WINBASEAPI HANDLE WINAPI CreateSemaphoreW(LPSECURITY_ATTRIBUTES,LONG,LONG,LPCWSTR); #define CreateSemaphore WINELIB_NAME_AW(CreateSemaphore) +WINBASEAPI HANDLE WINAPI CreateSemaphoreExA(SECURITY_ATTRIBUTES*,LONG,LONG,LPCSTR,DWORD,DWORD); +WINBASEAPI HANDLE WINAPI CreateSemaphoreExW(SECURITY_ATTRIBUTES*,LONG,LONG,LPCWSTR,DWORD,DWORD); +#define CreateSemaphoreEx WINELIB_NAME_AW(CreateSemaphoreEx) WINBASEAPI DWORD WINAPI CreateTapePartition(HANDLE,DWORD,DWORD,DWORD); WINBASEAPI HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES,SIZE_T,LPTHREAD_START_ROUTINE,LPVOID,DWORD,LPDWORD); WINBASEAPI HANDLE WINAPI CreateTimerQueue(void); @@ -1392,6 +1407,9 @@ WINBASEAPI BOOL WINAPI CreateTimerQueueTimer(PHANDLE,HANDLE,WAITORTIMERCA WINBASEAPI HANDLE WINAPI CreateWaitableTimerA(LPSECURITY_ATTRIBUTES,BOOL,LPCSTR); WINBASEAPI HANDLE WINAPI CreateWaitableTimerW(LPSECURITY_ATTRIBUTES,BOOL,LPCWSTR); #define CreateWaitableTimer WINELIB_NAME_AW(CreateWaitableTimer) +WINBASEAPI HANDLE WINAPI CreateWaitableTimerExA(SECURITY_ATTRIBUTES*,LPCSTR,DWORD,DWORD); +WINBASEAPI HANDLE WINAPI CreateWaitableTimerExW(SECURITY_ATTRIBUTES*,LPCWSTR,DWORD,DWORD); +#define CreateWaitableTimerEx WINELIB_NAME_AW(CreateWaitableTimerEx) WINADVAPI BOOL WINAPI CreateWellKnownSid(WELL_KNOWN_SID_TYPE,PSID,PSID,DWORD*); WINBASEAPI BOOL WINAPI DeactivateActCtx(DWORD,ULONG_PTR); WINBASEAPI BOOL WINAPI DebugActiveProcess(DWORD);