2012-05-29 14:14:26 -04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Handle Management
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2014-12-02 00:08:10 -08:00
|
|
|
* Copyright 2014 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2012-05-29 14:14:26 -04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 10:08:00 +01:00
|
|
|
#include <winpr/config.h>
|
2012-08-14 17:20:53 -04:00
|
|
|
|
2012-05-29 14:14:26 -04:00
|
|
|
#include <winpr/handle.h>
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
2014-06-19 19:07:45 +02:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2012-09-18 17:33:52 -04:00
|
|
|
#include "../synch/synch.h"
|
2012-12-12 22:03:40 -05:00
|
|
|
#include "../thread/thread.h"
|
2013-05-16 17:32:58 -04:00
|
|
|
#include "../pipe/pipe.h"
|
2014-04-02 15:51:28 -04:00
|
|
|
#include "../comm/comm.h"
|
2013-09-24 00:07:48 -04:00
|
|
|
#include "../security/security.h"
|
2012-05-29 14:14:26 -04:00
|
|
|
|
2012-09-18 18:36:13 -04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2021-06-09 14:03:34 +02:00
|
|
|
#include <winpr/assert.h>
|
2014-05-26 21:24:34 +02:00
|
|
|
|
2013-05-16 17:32:58 -04:00
|
|
|
#include "../handle/handle.h"
|
|
|
|
|
2012-05-29 14:14:26 -04:00
|
|
|
BOOL CloseHandle(HANDLE hObject)
|
|
|
|
{
|
2012-09-18 17:33:52 -04:00
|
|
|
ULONG Type;
|
2019-11-06 15:24:51 +01:00
|
|
|
WINPR_HANDLE* Object;
|
2012-09-18 17:33:52 -04:00
|
|
|
|
2015-07-03 09:25:41 +02:00
|
|
|
if (!winpr_Handle_GetInfo(hObject, &Type, &Object))
|
2012-09-18 17:33:52 -04:00
|
|
|
return FALSE;
|
2012-05-29 14:14:26 -04:00
|
|
|
|
2015-03-16 00:29:37 +01:00
|
|
|
if (!Object)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!Object->ops)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-03-17 16:54:45 -04:00
|
|
|
if (Object->ops->CloseHandle)
|
2015-03-16 00:29:37 +01:00
|
|
|
return Object->ops->CloseHandle(hObject);
|
2014-07-03 11:24:37 +02:00
|
|
|
|
2012-09-18 17:33:52 -04:00
|
|
|
return FALSE;
|
2012-05-29 14:14:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, HANDLE hTargetProcessHandle,
|
2019-11-06 15:24:51 +01:00
|
|
|
LPHANDLE lpTargetHandle, DWORD dwDesiredAccess, BOOL bInheritHandle,
|
|
|
|
DWORD dwOptions)
|
2012-05-29 14:14:26 -04:00
|
|
|
{
|
2019-11-06 15:24:51 +01:00
|
|
|
*((ULONG_PTR*)lpTargetHandle) = (ULONG_PTR)hSourceHandle;
|
2012-09-18 17:33:52 -04:00
|
|
|
return TRUE;
|
2012-05-29 14:14:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
|
|
|
|
{
|
2012-09-18 17:33:52 -04:00
|
|
|
return TRUE;
|
2012-05-29 14:14:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags)
|
|
|
|
{
|
2012-09-18 17:33:52 -04:00
|
|
|
return TRUE;
|
2012-05-29 14:14:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|