2012-05-29 22:14:26 +04:00
|
|
|
/**
|
|
|
|
* WinPR: Windows Portable Runtime
|
|
|
|
* Handle Management
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
2014-12-02 11:08:10 +03:00
|
|
|
* Copyright 2014 DI (FH) Martin Haimberger <martin.haimberger@thincast.com>
|
2012-05-29 22: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.
|
|
|
|
*/
|
|
|
|
|
2012-08-15 01:20:53 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2012-05-29 22:14:26 +04:00
|
|
|
#include <winpr/handle.h>
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
2014-06-19 21:07:45 +04:00
|
|
|
#include <assert.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
2012-09-19 01:33:52 +04:00
|
|
|
#include "../synch/synch.h"
|
2012-12-13 07:03:40 +04:00
|
|
|
#include "../thread/thread.h"
|
2013-05-17 01:32:58 +04:00
|
|
|
#include "../pipe/pipe.h"
|
2014-04-02 23:51:28 +04:00
|
|
|
#include "../comm/comm.h"
|
2013-09-24 08:07:48 +04:00
|
|
|
#include "../security/security.h"
|
2012-05-29 22:14:26 +04:00
|
|
|
|
2012-09-19 02:36:13 +04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-26 23:24:34 +04:00
|
|
|
#include <assert.h>
|
|
|
|
|
2013-05-17 01:32:58 +04:00
|
|
|
#include "../handle/handle.h"
|
|
|
|
|
2012-05-29 22:14:26 +04:00
|
|
|
BOOL CloseHandle(HANDLE hObject)
|
|
|
|
{
|
2012-09-19 01:33:52 +04:00
|
|
|
ULONG Type;
|
2015-03-11 19:57:01 +03:00
|
|
|
WINPR_HANDLE *Object;
|
2012-09-19 01:33:52 +04:00
|
|
|
|
2015-03-17 23:54:45 +03:00
|
|
|
if (!winpr_Handle_GetInfo(hObject, &Type, (PVOID*) &Object))
|
2012-09-19 01:33:52 +04:00
|
|
|
return FALSE;
|
2012-05-29 22:14:26 +04:00
|
|
|
|
2015-03-16 02:29:37 +03:00
|
|
|
if (!Object)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (!Object->ops)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-03-17 23:54:45 +03:00
|
|
|
if (Object->ops->CloseHandle)
|
2015-03-16 02:29:37 +03:00
|
|
|
return Object->ops->CloseHandle(hObject);
|
2014-07-03 13:24:37 +04:00
|
|
|
|
2012-09-19 01:33:52 +04:00
|
|
|
return FALSE;
|
2012-05-29 22:14:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL DuplicateHandle(HANDLE hSourceProcessHandle, HANDLE hSourceHandle, HANDLE hTargetProcessHandle,
|
2014-10-11 20:34:45 +04:00
|
|
|
LPHANDLE lpTargetHandle, DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwOptions)
|
2012-05-29 22:14:26 +04:00
|
|
|
{
|
2014-10-17 02:07:44 +04:00
|
|
|
*((ULONG_PTR*) lpTargetHandle) = (ULONG_PTR) hSourceHandle;
|
2012-09-19 01:33:52 +04:00
|
|
|
return TRUE;
|
2012-05-29 22:14:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL GetHandleInformation(HANDLE hObject, LPDWORD lpdwFlags)
|
|
|
|
{
|
2012-09-19 01:33:52 +04:00
|
|
|
return TRUE;
|
2012-05-29 22:14:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
BOOL SetHandleInformation(HANDLE hObject, DWORD dwMask, DWORD dwFlags)
|
|
|
|
{
|
2012-09-19 01:33:52 +04:00
|
|
|
return TRUE;
|
2012-05-29 22:14:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|