2000-09-29 22:48:04 +02:00
|
|
|
/*
|
|
|
|
* Kernel synchronization objects
|
|
|
|
*
|
|
|
|
* Copyright 1998 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
2002-07-25 02:22:03 +02:00
|
|
|
#include <errno.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-05-20 06:32:53 +02:00
|
|
|
#include <stdio.h>
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "ntstatus.h"
|
2005-11-28 17:32:54 +01:00
|
|
|
#define WIN32_NO_STATUS
|
2015-03-12 10:39:31 +01:00
|
|
|
#define NONAMELESSUNION
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "winbase.h"
|
2019-07-01 17:44:38 +02:00
|
|
|
#include "wincon.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "winnls.h"
|
2004-03-18 02:36:09 +01:00
|
|
|
#include "winternl.h"
|
2005-08-18 12:59:26 +02:00
|
|
|
#include "winioctl.h"
|
2005-12-02 15:55:48 +01:00
|
|
|
#include "ddk/wdm.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2003-09-18 06:39:13 +02:00
|
|
|
#include "kernel_private.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2004-02-26 06:30:54 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(sync);
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2020-05-26 14:51:16 +02:00
|
|
|
static const struct _KUSER_SHARED_DATA *user_shared_data = (struct _KUSER_SHARED_DATA *)0x7ffe0000;
|
|
|
|
|
|
|
|
|
2018-03-02 10:41:12 +01:00
|
|
|
static void get_create_object_attributes( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *nameW,
|
|
|
|
SECURITY_ATTRIBUTES *sa, const WCHAR *name )
|
|
|
|
{
|
|
|
|
attr->Length = sizeof(*attr);
|
|
|
|
attr->RootDirectory = 0;
|
|
|
|
attr->ObjectName = NULL;
|
|
|
|
attr->Attributes = OBJ_OPENIF | ((sa && sa->bInheritHandle) ? OBJ_INHERIT : 0);
|
|
|
|
attr->SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
|
|
|
|
attr->SecurityQualityOfService = NULL;
|
|
|
|
if (name)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString( nameW, name );
|
|
|
|
attr->ObjectName = nameW;
|
2019-06-27 15:53:28 +02:00
|
|
|
BaseGetNamedObjectDirectory( &attr->RootDirectory );
|
2018-03-02 10:41:12 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-02 10:40:41 +01:00
|
|
|
static BOOL get_open_object_attributes( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *nameW,
|
|
|
|
BOOL inherit, const WCHAR *name )
|
|
|
|
{
|
2019-06-27 15:53:28 +02:00
|
|
|
HANDLE dir;
|
|
|
|
|
2018-03-02 10:40:41 +01:00
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
RtlInitUnicodeString( nameW, name );
|
2019-06-27 15:53:28 +02:00
|
|
|
BaseGetNamedObjectDirectory( &dir );
|
|
|
|
InitializeObjectAttributes( attr, nameW, inherit ? OBJ_INHERIT : 0, dir, NULL );
|
2018-03-02 10:40:41 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2020-05-26 14:51:16 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* GetTickCount64 (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
|
|
|
|
{
|
|
|
|
ULONG high, low;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
high = user_shared_data->u.TickCount.High1Time;
|
|
|
|
low = user_shared_data->u.TickCount.LowPart;
|
|
|
|
}
|
|
|
|
while (high != user_shared_data->u.TickCount.High2Time);
|
|
|
|
/* note: we ignore TickCountMultiplier */
|
|
|
|
return (ULONGLONG)high << 32 | low;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetTickCount (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI DECLSPEC_HOTPATCH GetTickCount(void)
|
|
|
|
{
|
|
|
|
/* note: we ignore TickCountMultiplier */
|
|
|
|
return user_shared_data->u.TickCount.LowPart;
|
|
|
|
}
|
|
|
|
|
2003-10-09 21:46:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* RegisterWaitForSingleObject (KERNEL32.@)
|
|
|
|
*/
|
2020-05-26 12:29:06 +02:00
|
|
|
BOOL WINAPI RegisterWaitForSingleObject( HANDLE *wait, HANDLE object, WAITORTIMERCALLBACK callback,
|
|
|
|
void *context, ULONG timeout, ULONG flags )
|
2003-10-09 21:46:43 +02:00
|
|
|
{
|
2021-02-11 10:53:50 +01:00
|
|
|
if (!set_ntstatus( RtlRegisterWait( wait, object, callback, context, timeout, flags ))) return FALSE;
|
|
|
|
return TRUE;
|
2003-10-09 21:46:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UnregisterWait (KERNEL32.@)
|
|
|
|
*/
|
2020-05-26 12:29:06 +02:00
|
|
|
BOOL WINAPI UnregisterWait( HANDLE handle )
|
2003-10-09 21:46:43 +02:00
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( RtlDeregisterWait( handle ));
|
2003-10-09 21:46:43 +02:00
|
|
|
}
|
|
|
|
|
2003-06-24 05:34:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* MakeCriticalSectionGlobal (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
/* let's assume that only one thread at a time will try to do this */
|
|
|
|
HANDLE sem = crit->LockSemaphore;
|
|
|
|
if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
|
|
|
|
crit->LockSemaphore = ConvertToGlobalHandle( sem );
|
2019-04-30 12:19:22 +02:00
|
|
|
if (crit->DebugInfo != (void *)(ULONG_PTR)-1)
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, crit->DebugInfo );
|
2006-05-01 22:44:43 +02:00
|
|
|
crit->DebugInfo = NULL;
|
2003-06-24 05:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ReinitializeCriticalSection (KERNEL32.@)
|
2003-09-17 22:05:03 +02:00
|
|
|
*
|
|
|
|
* Initialise an already used critical section.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* crit [O] Critical section to initialise.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2003-06-24 05:34:15 +02:00
|
|
|
*/
|
|
|
|
void WINAPI ReinitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
if ( !crit->LockSemaphore )
|
|
|
|
RtlInitializeCriticalSection( crit );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UninitializeCriticalSection (KERNEL32.@)
|
2003-09-17 22:05:03 +02:00
|
|
|
*
|
|
|
|
* UnInitialise a critical section after use.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* crit [O] Critical section to uninitialise (destroy).
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
2003-06-24 05:34:15 +02:00
|
|
|
*/
|
|
|
|
void WINAPI UninitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
RtlDeleteCriticalSection( crit );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenMutexA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2013-04-10 23:54:08 +02:00
|
|
|
HANDLE WINAPI DECLSPEC_HOTPATCH OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenMutexW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return OpenMutexW( access, inherit, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Semaphores
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateSemaphoreA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2013-04-10 23:54:08 +02:00
|
|
|
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
|
2008-11-11 12:17:05 +01:00
|
|
|
{
|
|
|
|
return CreateSemaphoreExA( sa, initial, max, name, 0, SEMAPHORE_ALL_ACCESS );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateSemaphoreExA (KERNEL32.@)
|
|
|
|
*/
|
2013-04-10 23:54:08 +02:00
|
|
|
HANDLE WINAPI DECLSPEC_HOTPATCH CreateSemaphoreExA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max,
|
|
|
|
LPCSTR name, DWORD flags, DWORD access )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2008-11-11 12:17:05 +01:00
|
|
|
if (!name) return CreateSemaphoreExW( sa, initial, max, NULL, flags, access );
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-11 12:17:05 +01:00
|
|
|
return CreateSemaphoreExW( sa, initial, max, buffer, flags, access );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenSemaphoreA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2013-04-10 23:54:08 +02:00
|
|
|
HANDLE WINAPI DECLSPEC_HOTPATCH OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenSemaphoreW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return OpenSemaphoreW( access, inherit, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-04 22:51:02 +02:00
|
|
|
/*
|
|
|
|
* Jobs
|
|
|
|
*/
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CreateJobObjectW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateJobObjectW( LPSECURITY_ATTRIBUTES sa, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret = 0;
|
|
|
|
UNICODE_STRING nameW;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
NTSTATUS status;
|
|
|
|
|
2018-03-02 10:41:12 +01:00
|
|
|
get_create_object_attributes( &attr, &nameW, sa, name );
|
2008-09-04 22:51:02 +02:00
|
|
|
|
|
|
|
status = NtCreateJobObject( &ret, JOB_OBJECT_ALL_ACCESS, &attr );
|
|
|
|
if (status == STATUS_OBJECT_NAME_EXISTS)
|
|
|
|
SetLastError( ERROR_ALREADY_EXISTS );
|
|
|
|
else
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CreateJobObjectA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateJobObjectA( LPSECURITY_ATTRIBUTES attr, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return CreateJobObjectW( attr, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return CreateJobObjectW( attr, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenJobObjectW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenJobObjectW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
UNICODE_STRING nameW;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
|
2018-03-02 10:40:41 +01:00
|
|
|
if (!get_open_object_attributes( &attr, &nameW, inherit, name )) return 0;
|
2008-09-04 22:51:02 +02:00
|
|
|
|
2020-05-26 12:29:06 +02:00
|
|
|
if (!set_ntstatus( NtOpenJobObject( &ret, access, &attr ))) return 0;
|
2008-09-04 22:51:02 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* OpenJobObjectA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenJobObjectA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenJobObjectW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenJobObjectW( access, inherit, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* TerminateJobObject (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI TerminateJobObject( HANDLE job, UINT exit_code )
|
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtTerminateJobObject( job, exit_code ));
|
2008-09-04 22:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* QueryInformationJobObject (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI QueryInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info,
|
|
|
|
DWORD len, DWORD *ret_len )
|
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtQueryInformationJobObject( job, class, info, len, ret_len ));
|
2008-09-04 22:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* SetInformationJobObject (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetInformationJobObject( HANDLE job, JOBOBJECTINFOCLASS class, LPVOID info, DWORD len )
|
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtSetInformationJobObject( job, class, info, len ));
|
2008-09-04 22:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* AssignProcessToJobObject (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AssignProcessToJobObject( HANDLE job, HANDLE process )
|
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtAssignProcessToJobObject( job, process ));
|
2008-09-04 22:51:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-20 06:14:45 +02:00
|
|
|
/*
|
|
|
|
* Timers
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateWaitableTimerA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name )
|
2008-11-11 12:17:05 +01:00
|
|
|
{
|
|
|
|
return CreateWaitableTimerExA( 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 )
|
2003-05-20 06:14:45 +02:00
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
2008-11-11 12:17:05 +01:00
|
|
|
if (!name) return CreateWaitableTimerExW( sa, NULL, flags, access );
|
2003-05-20 06:14:45 +02:00
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2008-11-11 12:17:05 +01:00
|
|
|
return CreateWaitableTimerExW( sa, buffer, flags, access );
|
2003-05-20 06:14:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenWaitableTimerA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenWaitableTimerW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenWaitableTimerW( access, inherit, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-22 18:55:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DeleteTimerQueue (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteTimerQueue(HANDLE TimerQueue)
|
|
|
|
{
|
|
|
|
return DeleteTimerQueueEx(TimerQueue, NULL);
|
|
|
|
}
|
|
|
|
|
2014-10-25 08:03:01 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CancelTimerQueueTimer (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CancelTimerQueueTimer(HANDLE queue, HANDLE timer)
|
|
|
|
{
|
2019-06-27 16:42:17 +02:00
|
|
|
return DeleteTimerQueueTimer( queue, timer, NULL );
|
2014-10-25 08:03:01 +02:00
|
|
|
}
|
|
|
|
|
2003-05-20 06:14:45 +02:00
|
|
|
|
|
|
|
|
2018-03-02 10:51:31 +01:00
|
|
|
/*
|
|
|
|
* Mappings
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateFileMappingA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateFileMappingA( HANDLE file, SECURITY_ATTRIBUTES *sa, DWORD protect,
|
|
|
|
DWORD size_high, DWORD size_low, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return CreateFileMappingW( file, sa, protect, size_high, size_low, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return CreateFileMappingW( file, sa, protect, size_high, size_low, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenFileMappingA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenFileMappingA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenFileMappingW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenFileMappingW( access, inherit, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/*
|
|
|
|
* Pipes
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateNamedPipeA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateNamedPipeA( LPCSTR name, DWORD dwOpenMode,
|
|
|
|
DWORD dwPipeMode, DWORD nMaxInstances,
|
|
|
|
DWORD nOutBufferSize, DWORD nInBufferSize,
|
|
|
|
DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!name) return CreateNamedPipeW( NULL, dwOpenMode, dwPipeMode, nMaxInstances,
|
|
|
|
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
2003-05-06 02:19:59 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return CreateNamedPipeW( buffer, dwOpenMode, dwPipeMode, nMaxInstances,
|
|
|
|
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* WaitNamedPipeA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WaitNamedPipeA (LPCSTR name, DWORD nTimeOut)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2001-11-07 21:14:45 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!name) return WaitNamedPipeW( NULL, nTimeOut );
|
2001-08-24 01:29:20 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2001-11-07 21:14:45 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
2013-10-24 00:40:22 +02:00
|
|
|
return FALSE;
|
2001-11-07 21:14:45 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return WaitNamedPipeW( buffer, nTimeOut );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-04-11 14:32:56 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeClientProcessId (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeClientProcessId( HANDLE pipe, ULONG *id )
|
|
|
|
{
|
|
|
|
IO_STATUS_BLOCK iosb;
|
|
|
|
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtFsControlFile( pipe, NULL, NULL, NULL, &iosb,
|
|
|
|
FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ClientProcessId",
|
|
|
|
sizeof("ClientProcessId"), id, sizeof(*id) ));
|
2018-04-11 14:32:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeServerProcessId (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeServerProcessId( HANDLE pipe, ULONG *id )
|
|
|
|
{
|
|
|
|
IO_STATUS_BLOCK iosb;
|
|
|
|
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtFsControlFile( pipe, NULL, NULL, NULL, &iosb,
|
|
|
|
FSCTL_PIPE_GET_CONNECTION_ATTRIBUTE, (void *)"ServerProcessId",
|
|
|
|
sizeof("ServerProcessId"), id, sizeof(*id) ));
|
2018-04-11 14:32:56 +02:00
|
|
|
}
|
|
|
|
|
2018-04-11 14:32:57 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeClientSessionId (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeClientSessionId( HANDLE pipe, ULONG *id )
|
|
|
|
{
|
|
|
|
FIXME( "%p, %p\n", pipe, id );
|
|
|
|
|
|
|
|
if (!id) return FALSE;
|
|
|
|
*id = NtCurrentTeb()->Peb->SessionId;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeServerSessionId (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeServerSessionId( HANDLE pipe, ULONG *id )
|
|
|
|
{
|
|
|
|
FIXME( "%p, %p\n", pipe, id );
|
|
|
|
|
|
|
|
if (!id) return FALSE;
|
|
|
|
*id = NtCurrentTeb()->Peb->SessionId;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-08-24 21:15:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeHandleStateA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeHandleStateA(
|
|
|
|
HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
|
|
|
|
LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
|
|
|
|
LPSTR lpUsername, DWORD nUsernameMaxSize)
|
|
|
|
{
|
2018-03-07 16:59:39 +01:00
|
|
|
WCHAR *username = NULL;
|
|
|
|
BOOL ret;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2018-03-07 16:59:39 +01:00
|
|
|
WARN("%p %p %p %p %p %p %d: semi-stub\n", hNamedPipe, lpState, lpCurInstances,
|
|
|
|
lpMaxCollectionCount, lpCollectDataTimeout, lpUsername, nUsernameMaxSize);
|
|
|
|
|
|
|
|
if (lpUsername && nUsernameMaxSize &&
|
|
|
|
!(username = HeapAlloc(GetProcessHeap(), 0, nUsernameMaxSize * sizeof(WCHAR)))) return FALSE;
|
|
|
|
|
|
|
|
ret = GetNamedPipeHandleStateW(hNamedPipe, lpState, lpCurInstances, lpMaxCollectionCount,
|
|
|
|
lpCollectDataTimeout, username, nUsernameMaxSize);
|
|
|
|
if (ret && username)
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, username, -1, lpUsername, nUsernameMaxSize, NULL, NULL);
|
2014-08-11 17:26:18 +02:00
|
|
|
|
2018-03-07 16:59:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, username);
|
|
|
|
return ret;
|
2001-08-24 21:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CallNamedPipeA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CallNamedPipeA(
|
2004-10-19 23:08:58 +02:00
|
|
|
LPCSTR lpNamedPipeName, LPVOID lpInput, DWORD dwInputSize,
|
|
|
|
LPVOID lpOutput, DWORD dwOutputSize,
|
2001-08-24 21:15:35 +02:00
|
|
|
LPDWORD lpBytesRead, DWORD nTimeout)
|
|
|
|
{
|
2004-10-19 23:08:58 +02:00
|
|
|
DWORD len;
|
|
|
|
LPWSTR str = NULL;
|
|
|
|
BOOL ret;
|
|
|
|
|
2006-10-12 22:56:29 +02:00
|
|
|
TRACE("%s %p %d %p %d %p %d\n",
|
2004-10-19 23:08:58 +02:00
|
|
|
debugstr_a(lpNamedPipeName), lpInput, dwInputSize,
|
|
|
|
lpOutput, dwOutputSize, lpBytesRead, nTimeout);
|
|
|
|
|
|
|
|
if( lpNamedPipeName )
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpNamedPipeName, -1, NULL, 0 );
|
|
|
|
str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpNamedPipeName, -1, str, len );
|
|
|
|
}
|
|
|
|
ret = CallNamedPipeW( str, lpInput, dwInputSize, lpOutput,
|
|
|
|
dwOutputSize, lpBytesRead, nTimeout );
|
|
|
|
if( lpNamedPipeName )
|
|
|
|
HeapFree( GetProcessHeap(), 0, str );
|
|
|
|
|
|
|
|
return ret;
|
2001-08-24 21:15:35 +02:00
|
|
|
}
|
|
|
|
|
2003-09-16 00:07:50 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* CreateMailslotA [KERNEL32.@]
|
2005-11-08 12:01:03 +01:00
|
|
|
*
|
2007-12-18 14:15:23 +01:00
|
|
|
* See CreateMailslotW.
|
2003-09-16 00:07:50 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
|
|
|
|
DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
HANDLE handle;
|
|
|
|
LPWSTR name = NULL;
|
|
|
|
|
2006-10-12 22:56:29 +02:00
|
|
|
TRACE("%s %d %d %p\n", debugstr_a(lpName),
|
2003-09-16 00:07:50 +02:00
|
|
|
nMaxMessageSize, lReadTimeout, sa);
|
|
|
|
|
|
|
|
if( lpName )
|
|
|
|
{
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpName, -1, NULL, 0 );
|
|
|
|
name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpName, -1, name, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
handle = CreateMailslotW( name, nMaxMessageSize, lReadTimeout, sa );
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, name );
|
2003-09-16 00:07:50 +02:00
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-17 22:05:03 +02:00
|
|
|
* CreateMailslotW [KERNEL32.@]
|
|
|
|
*
|
|
|
|
* Create a mailslot with specified name.
|
2003-09-16 00:07:50 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpName [I] Pointer to string for mailslot name
|
|
|
|
* nMaxMessageSize [I] Maximum message size
|
|
|
|
* lReadTimeout [I] Milliseconds before read time-out
|
|
|
|
* sa [I] Pointer to security structure
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Handle to mailslot
|
|
|
|
* Failure: INVALID_HANDLE_VALUE
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
|
|
|
|
DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
|
|
|
|
{
|
2005-03-28 12:03:56 +02:00
|
|
|
HANDLE handle = INVALID_HANDLE_VALUE;
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING nameW;
|
|
|
|
LARGE_INTEGER timeout;
|
|
|
|
IO_STATUS_BLOCK iosb;
|
|
|
|
|
2006-10-12 22:56:29 +02:00
|
|
|
TRACE("%s %d %d %p\n", debugstr_w(lpName),
|
2003-09-16 00:07:50 +02:00
|
|
|
nMaxMessageSize, lReadTimeout, sa);
|
2005-03-28 12:03:56 +02:00
|
|
|
|
|
|
|
if (!RtlDosPathNameToNtPathName_U( lpName, &nameW, NULL, NULL ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_PATH_NOT_FOUND );
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nameW.Length >= MAX_PATH * sizeof(WCHAR) )
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
RtlFreeUnicodeString( &nameW );
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
attr.Length = sizeof(attr);
|
|
|
|
attr.RootDirectory = 0;
|
|
|
|
attr.Attributes = OBJ_CASE_INSENSITIVE;
|
|
|
|
attr.ObjectName = &nameW;
|
|
|
|
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
|
|
|
|
attr.SecurityQualityOfService = NULL;
|
|
|
|
|
2005-11-21 16:23:49 +01:00
|
|
|
if (lReadTimeout != MAILSLOT_WAIT_FOREVER)
|
|
|
|
timeout.QuadPart = (ULONGLONG) lReadTimeout * -10000;
|
|
|
|
else
|
|
|
|
timeout.QuadPart = ((LONGLONG)0x7fffffff << 32) | 0xffffffff;
|
2005-03-28 12:03:56 +02:00
|
|
|
|
2020-05-26 12:29:06 +02:00
|
|
|
if (!set_ntstatus( NtCreateMailslotFile( &handle, GENERIC_READ | SYNCHRONIZE, &attr,
|
|
|
|
&iosb, 0, 0, nMaxMessageSize, &timeout )))
|
2005-03-28 12:03:56 +02:00
|
|
|
handle = INVALID_HANDLE_VALUE;
|
|
|
|
|
|
|
|
RtlFreeUnicodeString( &nameW );
|
|
|
|
return handle;
|
2003-09-16 00:07:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-17 22:05:03 +02:00
|
|
|
* GetMailslotInfo [KERNEL32.@]
|
|
|
|
*
|
|
|
|
* Retrieve information about a mailslot.
|
2003-09-16 00:07:50 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hMailslot [I] Mailslot handle
|
|
|
|
* lpMaxMessageSize [O] Address of maximum message size
|
|
|
|
* lpNextSize [O] Address of size of next message
|
|
|
|
* lpMessageCount [O] Address of number of messages
|
|
|
|
* lpReadTimeout [O] Address of read time-out
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
|
|
|
|
LPDWORD lpNextSize, LPDWORD lpMessageCount,
|
|
|
|
LPDWORD lpReadTimeout )
|
|
|
|
{
|
2005-04-11 16:20:49 +02:00
|
|
|
FILE_MAILSLOT_QUERY_INFORMATION info;
|
|
|
|
IO_STATUS_BLOCK iosb;
|
2005-03-30 21:02:15 +02:00
|
|
|
|
2005-04-11 16:20:49 +02:00
|
|
|
TRACE("%p %p %p %p %p\n",hMailslot, lpMaxMessageSize,
|
|
|
|
lpNextSize, lpMessageCount, lpReadTimeout);
|
2005-03-30 21:02:15 +02:00
|
|
|
|
2020-05-26 12:29:06 +02:00
|
|
|
if (!set_ntstatus( NtQueryInformationFile( hMailslot, &iosb, &info, sizeof info,
|
|
|
|
FileMailslotQueryInformation )))
|
2005-04-11 16:20:49 +02:00
|
|
|
return FALSE;
|
2005-03-30 21:02:15 +02:00
|
|
|
|
2005-04-11 16:20:49 +02:00
|
|
|
if( lpMaxMessageSize )
|
|
|
|
*lpMaxMessageSize = info.MaximumMessageSize;
|
|
|
|
if( lpNextSize )
|
|
|
|
*lpNextSize = info.NextMessageSize;
|
|
|
|
if( lpMessageCount )
|
|
|
|
*lpMessageCount = info.MessagesAvailable;
|
|
|
|
if( lpReadTimeout )
|
2007-04-17 20:08:59 +02:00
|
|
|
{
|
|
|
|
if (info.ReadTimeout.QuadPart == (((LONGLONG)0x7fffffff << 32) | 0xffffffff))
|
|
|
|
*lpReadTimeout = MAILSLOT_WAIT_FOREVER;
|
|
|
|
else
|
|
|
|
*lpReadTimeout = info.ReadTimeout.QuadPart / -10000;
|
|
|
|
}
|
2005-04-11 16:20:49 +02:00
|
|
|
return TRUE;
|
2003-09-16 00:07:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
2003-09-17 22:05:03 +02:00
|
|
|
* SetMailslotInfo [KERNEL32.@]
|
|
|
|
*
|
|
|
|
* Set the read timeout of a mailslot.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hMailslot [I] Mailslot handle
|
|
|
|
* dwReadTimeout [I] Timeout in milliseconds.
|
2003-09-16 00:07:50 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetMailslotInfo( HANDLE hMailslot, DWORD dwReadTimeout)
|
|
|
|
{
|
2005-04-11 16:20:49 +02:00
|
|
|
FILE_MAILSLOT_SET_INFORMATION info;
|
|
|
|
IO_STATUS_BLOCK iosb;
|
2005-03-30 21:02:15 +02:00
|
|
|
|
2006-10-12 22:56:29 +02:00
|
|
|
TRACE("%p %d\n", hMailslot, dwReadTimeout);
|
2005-03-30 21:02:15 +02:00
|
|
|
|
2007-04-17 20:08:59 +02:00
|
|
|
if (dwReadTimeout != MAILSLOT_WAIT_FOREVER)
|
|
|
|
info.ReadTimeout.QuadPart = (ULONGLONG)dwReadTimeout * -10000;
|
|
|
|
else
|
|
|
|
info.ReadTimeout.QuadPart = ((LONGLONG)0x7fffffff << 32) | 0xffffffff;
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( NtSetInformationFile( hMailslot, &iosb, &info, sizeof info,
|
|
|
|
FileMailslotSetInformation ));
|
2003-09-16 00:07:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-30 22:29:18 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* BindIoCompletionCallback (KERNEL32.@)
|
|
|
|
*/
|
2020-05-26 12:29:06 +02:00
|
|
|
BOOL WINAPI BindIoCompletionCallback( HANDLE handle, LPOVERLAPPED_COMPLETION_ROUTINE func, ULONG flags )
|
2007-04-30 22:29:18 +02:00
|
|
|
{
|
2020-05-26 12:29:06 +02:00
|
|
|
return set_ntstatus( RtlSetIoCompletionCallback( handle, (PRTL_OVERLAPPED_COMPLETION_ROUTINE)func, flags ));
|
2007-04-30 22:29:18 +02:00
|
|
|
}
|
|
|
|
|
2009-11-14 09:58:47 +01:00
|
|
|
|
2003-06-24 05:34:15 +02:00
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare ); */
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC(InterlockedCompareExchange, 12,
|
2003-06-24 05:34:15 +02:00
|
|
|
"movl 12(%esp),%eax\n\t"
|
|
|
|
"movl 8(%esp),%ecx\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; cmpxchgl %ecx,(%edx)\n\t"
|
2004-06-14 19:00:21 +02:00
|
|
|
"ret $12")
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedExchange( PLONG dest, LONG val ); */
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC(InterlockedExchange, 8,
|
2003-06-24 05:34:15 +02:00
|
|
|
"movl 8(%esp),%eax\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; xchgl %eax,(%edx)\n\t"
|
2004-06-14 19:00:21 +02:00
|
|
|
"ret $8")
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr ); */
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC(InterlockedExchangeAdd, 8,
|
2003-06-24 05:34:15 +02:00
|
|
|
"movl 8(%esp),%eax\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
2004-06-14 19:00:21 +02:00
|
|
|
"ret $8")
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedIncrement( PLONG dest ); */
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC(InterlockedIncrement, 4,
|
2003-06-24 05:34:15 +02:00
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"movl $1,%eax\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
|
|
|
"incl %eax\n\t"
|
2004-06-14 19:00:21 +02:00
|
|
|
"ret $4")
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (KERNEL32.@)
|
|
|
|
*/
|
2009-06-14 15:34:09 +02:00
|
|
|
__ASM_STDCALL_FUNC(InterlockedDecrement, 4,
|
2003-06-24 05:34:15 +02:00
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"movl $-1,%eax\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
|
|
|
"decl %eax\n\t"
|
2004-06-14 19:00:21 +02:00
|
|
|
"ret $4")
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
#endif /* __i386__ */
|