Coverage Report

Created: 2026-09-03 07:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/FreeRDP/winpr/libwinpr/handle/handle.h
Line
Count
Source
1
/**
2
 * WinPR: Windows Portable Runtime
3
 * Handle Management
4
 *
5
 * Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
20
#ifndef WINPR_HANDLE_PRIVATE_H
21
#define WINPR_HANDLE_PRIVATE_H
22
23
#include <stdlib.h>
24
25
#include <winpr/handle.h>
26
#include <winpr/file.h>
27
#include <winpr/interlocked.h>
28
#include <winpr/synch.h>
29
#include <winpr/winsock.h>
30
31
0
#define HANDLE_TYPE_NONE 0
32
68.8k
#define HANDLE_TYPE_PROCESS 1
33
274k
#define HANDLE_TYPE_THREAD 2
34
463k
#define HANDLE_TYPE_EVENT 3
35
34.4k
#define HANDLE_TYPE_MUTEX 4
36
#define HANDLE_TYPE_SEMAPHORE 5
37
#define HANDLE_TYPE_TIMER 6
38
0
#define HANDLE_TYPE_NAMED_PIPE 7
39
0
#define HANDLE_TYPE_ANONYMOUS_PIPE 8
40
0
#define HANDLE_TYPE_ACCESS_TOKEN 9
41
0
#define HANDLE_TYPE_FILE 10
42
#define HANDLE_TYPE_TIMER_QUEUE 11
43
#define HANDLE_TYPE_TIMER_QUEUE_TIMER 12
44
0
#define HANDLE_TYPE_COMM 13
45
46
typedef BOOL (*pcIsHandled)(HANDLE handle);
47
typedef BOOL (*pcCloseHandle)(HANDLE handle);
48
typedef int (*pcGetFd)(HANDLE handle);
49
typedef DWORD (*pcCleanupHandle)(HANDLE handle);
50
typedef BOOL (*pcReadFile)(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
51
                           LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
52
typedef BOOL (*pcReadFileEx)(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
53
                             LPOVERLAPPED lpOverlapped,
54
                             LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
55
typedef BOOL (*pcReadFileScatter)(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[],
56
                                  DWORD nNumberOfBytesToRead, LPDWORD lpReserved,
57
                                  LPOVERLAPPED lpOverlapped);
58
typedef BOOL (*pcWriteFile)(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
59
                            LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
60
typedef BOOL (*pcWriteFileEx)(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite,
61
                              LPOVERLAPPED lpOverlapped,
62
                              LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
63
typedef BOOL (*pcWriteFileGather)(HANDLE hFile, FILE_SEGMENT_ELEMENT aSegmentArray[],
64
                                  DWORD nNumberOfBytesToWrite, LPDWORD lpReserved,
65
                                  LPOVERLAPPED lpOverlapped);
66
typedef DWORD (*pcGetFileSize)(HANDLE handle, LPDWORD lpFileSizeHigh);
67
typedef BOOL (*pcGetFileInformationByHandle)(HANDLE handle,
68
                                             LPBY_HANDLE_FILE_INFORMATION lpFileInformation);
69
typedef BOOL (*pcFlushFileBuffers)(HANDLE hFile);
70
typedef BOOL (*pcSetEndOfFile)(HANDLE handle);
71
typedef DWORD (*pcSetFilePointer)(HANDLE handle, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh,
72
                                  DWORD dwMoveMethod);
73
typedef BOOL (*pcSetFilePointerEx)(HANDLE hFile, LARGE_INTEGER liDistanceToMove,
74
                                   PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod);
75
typedef BOOL (*pcLockFile)(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
76
                           DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh);
77
typedef BOOL (*pcLockFileEx)(HANDLE hFile, DWORD dwFlags, DWORD dwReserved,
78
                             DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
79
                             LPOVERLAPPED lpOverlapped);
80
typedef BOOL (*pcUnlockFile)(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
81
                             DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh);
82
typedef BOOL (*pcUnlockFileEx)(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow,
83
                               DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped);
84
typedef BOOL (*pcSetFileTime)(HANDLE hFile, const FILETIME* lpCreationTime,
85
                              const FILETIME* lpLastAccessTime, const FILETIME* lpLastWriteTime);
86
87
typedef struct
88
{
89
  pcIsHandled IsHandled;
90
  pcCloseHandle CloseHandle;
91
  pcGetFd GetFd;
92
  pcCleanupHandle CleanupHandle;
93
  pcReadFile ReadFile;
94
  pcReadFileEx ReadFileEx;
95
  pcReadFileScatter ReadFileScatter;
96
  pcWriteFile WriteFile;
97
  pcWriteFileEx WriteFileEx;
98
  pcWriteFileGather WriteFileGather;
99
  pcGetFileSize GetFileSize;
100
  pcFlushFileBuffers FlushFileBuffers;
101
  pcSetEndOfFile SetEndOfFile;
102
  pcSetFilePointer SetFilePointer;
103
  pcSetFilePointerEx SetFilePointerEx;
104
  pcLockFile LockFile;
105
  pcLockFileEx LockFileEx;
106
  pcUnlockFile UnlockFile;
107
  pcUnlockFileEx UnlockFileEx;
108
  pcSetFileTime SetFileTime;
109
  pcGetFileInformationByHandle GetFileInformationByHandle;
110
} HANDLE_OPS;
111
112
typedef struct
113
{
114
  ULONG Type;
115
  ULONG Mode;
116
  HANDLE_OPS* ops;
117
  volatile LONG refCount;
118
} WINPR_HANDLE;
119
120
WINPR_ATTR_NODISCARD
121
static inline BOOL WINPR_HANDLE_IS_HANDLED(HANDLE handle, ULONG type, BOOL invalidValue)
122
274k
{
123
274k
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
274k
  BOOL invalid = !pWinprHandle;
125
126
274k
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
274k
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
274k
  return TRUE;
139
274k
}
Unexecuted instantiation: process.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: critical.c:WINPR_HANDLE_IS_HANDLED
event.c:WINPR_HANDLE_IS_HANDLED
Line
Count
Source
122
206k
{
123
206k
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
206k
  BOOL invalid = !pWinprHandle;
125
126
206k
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
206k
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
206k
  return TRUE;
139
206k
}
Unexecuted instantiation: sleep.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: wait.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: generic.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: namedPipeClient.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: file.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_ioctl.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_serial_sys.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_sercx_sys.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_sercx2_sys.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: pipe.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: shell.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: handle.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: nonehandle.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: apc.c:WINPR_HANDLE_IS_HANDLED
thread.c:WINPR_HANDLE_IS_HANDLED
Line
Count
Source
122
68.6k
{
123
68.6k
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
68.6k
  BOOL invalid = !pWinprHandle;
125
126
68.6k
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
68.6k
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
68.6k
  return TRUE;
139
68.6k
}
Unexecuted instantiation: nt.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_io.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: io.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: sspicli.c:WINPR_HANDLE_IS_HANDLED
140
141
static inline void WINPR_HANDLE_SET_TYPE_AND_MODE(void* _handle, ULONG _type, ULONG _mode)
142
188k
{
143
188k
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
188k
  hdl->Type = _type;
146
188k
  hdl->Mode = _mode;
147
188k
  hdl->refCount = 1;
148
188k
}
Unexecuted instantiation: process.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: critical.c:WINPR_HANDLE_SET_TYPE_AND_MODE
event.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Line
Count
Source
142
171k
{
143
171k
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
171k
  hdl->Type = _type;
146
171k
  hdl->Mode = _mode;
147
171k
  hdl->refCount = 1;
148
171k
}
Unexecuted instantiation: sleep.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: wait.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: generic.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: namedPipeClient.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: file.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_ioctl.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_serial_sys.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_sercx_sys.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_sercx2_sys.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: pipe.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: shell.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: handle.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: nonehandle.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: apc.c:WINPR_HANDLE_SET_TYPE_AND_MODE
thread.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Line
Count
Source
142
17.1k
{
143
17.1k
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
17.1k
  hdl->Type = _type;
146
17.1k
  hdl->Mode = _mode;
147
17.1k
  hdl->refCount = 1;
148
17.1k
}
Unexecuted instantiation: nt.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_io.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: io.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: sspicli.c:WINPR_HANDLE_SET_TYPE_AND_MODE
149
150
WINPR_ATTR_NODISCARD
151
static inline BOOL winpr_Handle_GetInfo(HANDLE handle, ULONG* pType, WINPR_HANDLE** pObject)
152
635k
{
153
635k
  WINPR_HANDLE* wHandle = nullptr;
154
155
635k
  if (handle == nullptr)
156
0
    return FALSE;
157
158
  /* INVALID_HANDLE_VALUE is an invalid value for every handle, but it
159
   * confuses the clang scanbuild analyzer. */
160
635k
#ifndef __clang_analyzer__
161
635k
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
635k
#endif
164
165
635k
  wHandle = (WINPR_HANDLE*)handle;
166
167
635k
  *pType = wHandle->Type;
168
635k
  *pObject = wHandle;
169
170
635k
  return TRUE;
171
635k
}
Unexecuted instantiation: process.c:winpr_Handle_GetInfo
Unexecuted instantiation: critical.c:winpr_Handle_GetInfo
event.c:winpr_Handle_GetInfo
Line
Count
Source
152
85.8k
{
153
85.8k
  WINPR_HANDLE* wHandle = nullptr;
154
155
85.8k
  if (handle == nullptr)
156
0
    return FALSE;
157
158
  /* INVALID_HANDLE_VALUE is an invalid value for every handle, but it
159
   * confuses the clang scanbuild analyzer. */
160
85.8k
#ifndef __clang_analyzer__
161
85.8k
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
85.8k
#endif
164
165
85.8k
  wHandle = (WINPR_HANDLE*)handle;
166
167
85.8k
  *pType = wHandle->Type;
168
85.8k
  *pObject = wHandle;
169
170
85.8k
  return TRUE;
171
85.8k
}
Unexecuted instantiation: sleep.c:winpr_Handle_GetInfo
wait.c:winpr_Handle_GetInfo
Line
Count
Source
152
189k
{
153
189k
  WINPR_HANDLE* wHandle = nullptr;
154
155
189k
  if (handle == nullptr)
156
0
    return FALSE;
157
158
  /* INVALID_HANDLE_VALUE is an invalid value for every handle, but it
159
   * confuses the clang scanbuild analyzer. */
160
189k
#ifndef __clang_analyzer__
161
189k
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
189k
#endif
164
165
189k
  wHandle = (WINPR_HANDLE*)handle;
166
167
189k
  *pType = wHandle->Type;
168
189k
  *pObject = wHandle;
169
170
189k
  return TRUE;
171
189k
}
Unexecuted instantiation: generic.c:winpr_Handle_GetInfo
Unexecuted instantiation: namedPipeClient.c:winpr_Handle_GetInfo
Unexecuted instantiation: file.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm_ioctl.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm_serial_sys.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm_sercx_sys.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm_sercx2_sys.c:winpr_Handle_GetInfo
Unexecuted instantiation: pipe.c:winpr_Handle_GetInfo
Unexecuted instantiation: shell.c:winpr_Handle_GetInfo
handle.c:winpr_Handle_GetInfo
Line
Count
Source
152
360k
{
153
360k
  WINPR_HANDLE* wHandle = nullptr;
154
155
360k
  if (handle == nullptr)
156
0
    return FALSE;
157
158
  /* INVALID_HANDLE_VALUE is an invalid value for every handle, but it
159
   * confuses the clang scanbuild analyzer. */
160
360k
#ifndef __clang_analyzer__
161
360k
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
360k
#endif
164
165
360k
  wHandle = (WINPR_HANDLE*)handle;
166
167
360k
  *pType = wHandle->Type;
168
360k
  *pObject = wHandle;
169
170
360k
  return TRUE;
171
360k
}
Unexecuted instantiation: nonehandle.c:winpr_Handle_GetInfo
Unexecuted instantiation: apc.c:winpr_Handle_GetInfo
Unexecuted instantiation: thread.c:winpr_Handle_GetInfo
Unexecuted instantiation: nt.c:winpr_Handle_GetInfo
Unexecuted instantiation: comm_io.c:winpr_Handle_GetInfo
Unexecuted instantiation: io.c:winpr_Handle_GetInfo
Unexecuted instantiation: sspicli.c:winpr_Handle_GetInfo
172
173
static inline void winpr_Handle_AddRef(HANDLE handle)
174
0
{
175
0
  ULONG type = 0;
176
0
  WINPR_HANDLE* hdl = nullptr;
177
0
178
0
  if (!winpr_Handle_GetInfo(handle, &type, &hdl) || !hdl)
179
0
    return;
180
0
181
0
  InterlockedIncrement(&hdl->refCount);
182
0
}
Unexecuted instantiation: process.c:winpr_Handle_AddRef
Unexecuted instantiation: critical.c:winpr_Handle_AddRef
Unexecuted instantiation: event.c:winpr_Handle_AddRef
Unexecuted instantiation: sleep.c:winpr_Handle_AddRef
Unexecuted instantiation: wait.c:winpr_Handle_AddRef
Unexecuted instantiation: generic.c:winpr_Handle_AddRef
Unexecuted instantiation: namedPipeClient.c:winpr_Handle_AddRef
Unexecuted instantiation: file.c:winpr_Handle_AddRef
Unexecuted instantiation: comm.c:winpr_Handle_AddRef
Unexecuted instantiation: comm_ioctl.c:winpr_Handle_AddRef
Unexecuted instantiation: comm_serial_sys.c:winpr_Handle_AddRef
Unexecuted instantiation: comm_sercx_sys.c:winpr_Handle_AddRef
Unexecuted instantiation: comm_sercx2_sys.c:winpr_Handle_AddRef
Unexecuted instantiation: pipe.c:winpr_Handle_AddRef
Unexecuted instantiation: shell.c:winpr_Handle_AddRef
Unexecuted instantiation: handle.c:winpr_Handle_AddRef
Unexecuted instantiation: nonehandle.c:winpr_Handle_AddRef
Unexecuted instantiation: apc.c:winpr_Handle_AddRef
Unexecuted instantiation: thread.c:winpr_Handle_AddRef
Unexecuted instantiation: nt.c:winpr_Handle_AddRef
Unexecuted instantiation: comm_io.c:winpr_Handle_AddRef
Unexecuted instantiation: io.c:winpr_Handle_AddRef
Unexecuted instantiation: sspicli.c:winpr_Handle_AddRef
183
184
/* implemented in nonehandle.c: turns an already-released handle (see CloseHandle() in handle.c)
185
 * into a harmless placeholder, for as long as other references to the same struct remain. */
186
void winpr_Handle_ConvertToNone(HANDLE handle);
187
188
/* decrements refCount and frees the struct once it reaches zero - does not touch the underlying
189
 * OS resource, that's the type's real CloseHandle op's job (see CloseHandle() in handle.c).
190
 * Returns TRUE if this was the last reference (the handle has been freed). */
191
static inline BOOL winpr_Handle_Release(HANDLE handle)
192
171k
{
193
171k
  ULONG type = 0;
194
171k
  WINPR_HANDLE* hdl = nullptr;
195
196
171k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl) || !hdl)
197
0
    return FALSE;
198
199
171k
  if (InterlockedDecrement(&hdl->refCount) > 0)
200
0
    return FALSE;
201
202
171k
  free(hdl);
203
171k
  return TRUE;
204
171k
}
Unexecuted instantiation: process.c:winpr_Handle_Release
Unexecuted instantiation: critical.c:winpr_Handle_Release
Unexecuted instantiation: event.c:winpr_Handle_Release
Unexecuted instantiation: sleep.c:winpr_Handle_Release
Unexecuted instantiation: wait.c:winpr_Handle_Release
Unexecuted instantiation: generic.c:winpr_Handle_Release
Unexecuted instantiation: namedPipeClient.c:winpr_Handle_Release
Unexecuted instantiation: file.c:winpr_Handle_Release
Unexecuted instantiation: comm.c:winpr_Handle_Release
Unexecuted instantiation: comm_ioctl.c:winpr_Handle_Release
Unexecuted instantiation: comm_serial_sys.c:winpr_Handle_Release
Unexecuted instantiation: comm_sercx_sys.c:winpr_Handle_Release
Unexecuted instantiation: comm_sercx2_sys.c:winpr_Handle_Release
Unexecuted instantiation: pipe.c:winpr_Handle_Release
Unexecuted instantiation: shell.c:winpr_Handle_Release
handle.c:winpr_Handle_Release
Line
Count
Source
192
171k
{
193
171k
  ULONG type = 0;
194
171k
  WINPR_HANDLE* hdl = nullptr;
195
196
171k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl) || !hdl)
197
0
    return FALSE;
198
199
171k
  if (InterlockedDecrement(&hdl->refCount) > 0)
200
0
    return FALSE;
201
202
171k
  free(hdl);
203
171k
  return TRUE;
204
171k
}
Unexecuted instantiation: nonehandle.c:winpr_Handle_Release
Unexecuted instantiation: apc.c:winpr_Handle_Release
Unexecuted instantiation: thread.c:winpr_Handle_Release
Unexecuted instantiation: nt.c:winpr_Handle_Release
Unexecuted instantiation: comm_io.c:winpr_Handle_Release
Unexecuted instantiation: io.c:winpr_Handle_Release
Unexecuted instantiation: sspicli.c:winpr_Handle_Release
205
206
WINPR_ATTR_NODISCARD
207
static inline int winpr_Handle_getFd(HANDLE handle)
208
68.7k
{
209
68.7k
  WINPR_HANDLE* hdl = nullptr;
210
68.7k
  ULONG type = 0;
211
212
68.7k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
213
0
    return -1;
214
215
68.7k
  if (!hdl || !hdl->ops || !hdl->ops->GetFd)
216
0
    return -1;
217
218
68.7k
  return hdl->ops->GetFd(handle);
219
68.7k
}
Unexecuted instantiation: process.c:winpr_Handle_getFd
Unexecuted instantiation: critical.c:winpr_Handle_getFd
Unexecuted instantiation: event.c:winpr_Handle_getFd
Unexecuted instantiation: sleep.c:winpr_Handle_getFd
wait.c:winpr_Handle_getFd
Line
Count
Source
208
68.7k
{
209
68.7k
  WINPR_HANDLE* hdl = nullptr;
210
68.7k
  ULONG type = 0;
211
212
68.7k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
213
0
    return -1;
214
215
68.7k
  if (!hdl || !hdl->ops || !hdl->ops->GetFd)
216
0
    return -1;
217
218
68.7k
  return hdl->ops->GetFd(handle);
219
68.7k
}
Unexecuted instantiation: generic.c:winpr_Handle_getFd
Unexecuted instantiation: namedPipeClient.c:winpr_Handle_getFd
Unexecuted instantiation: file.c:winpr_Handle_getFd
Unexecuted instantiation: comm.c:winpr_Handle_getFd
Unexecuted instantiation: comm_ioctl.c:winpr_Handle_getFd
Unexecuted instantiation: comm_serial_sys.c:winpr_Handle_getFd
Unexecuted instantiation: comm_sercx_sys.c:winpr_Handle_getFd
Unexecuted instantiation: comm_sercx2_sys.c:winpr_Handle_getFd
Unexecuted instantiation: pipe.c:winpr_Handle_getFd
Unexecuted instantiation: shell.c:winpr_Handle_getFd
Unexecuted instantiation: handle.c:winpr_Handle_getFd
Unexecuted instantiation: nonehandle.c:winpr_Handle_getFd
Unexecuted instantiation: apc.c:winpr_Handle_getFd
Unexecuted instantiation: thread.c:winpr_Handle_getFd
Unexecuted instantiation: nt.c:winpr_Handle_getFd
Unexecuted instantiation: comm_io.c:winpr_Handle_getFd
Unexecuted instantiation: io.c:winpr_Handle_getFd
Unexecuted instantiation: sspicli.c:winpr_Handle_getFd
220
221
WINPR_ATTR_NODISCARD
222
static inline DWORD winpr_Handle_cleanup(HANDLE handle)
223
51.5k
{
224
51.5k
  WINPR_HANDLE* hdl = nullptr;
225
51.5k
  ULONG type = 0;
226
227
51.5k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
228
0
    return WAIT_FAILED;
229
230
51.5k
  if (!hdl || !hdl->ops)
231
0
    return WAIT_FAILED;
232
233
  /* If there is no cleanup function, assume all ok. */
234
51.5k
  if (!hdl->ops->CleanupHandle)
235
17.2k
    return WAIT_OBJECT_0;
236
237
34.3k
  return hdl->ops->CleanupHandle(handle);
238
51.5k
}
Unexecuted instantiation: process.c:winpr_Handle_cleanup
Unexecuted instantiation: critical.c:winpr_Handle_cleanup
Unexecuted instantiation: event.c:winpr_Handle_cleanup
Unexecuted instantiation: sleep.c:winpr_Handle_cleanup
wait.c:winpr_Handle_cleanup
Line
Count
Source
223
51.5k
{
224
51.5k
  WINPR_HANDLE* hdl = nullptr;
225
51.5k
  ULONG type = 0;
226
227
51.5k
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
228
0
    return WAIT_FAILED;
229
230
51.5k
  if (!hdl || !hdl->ops)
231
0
    return WAIT_FAILED;
232
233
  /* If there is no cleanup function, assume all ok. */
234
51.5k
  if (!hdl->ops->CleanupHandle)
235
17.2k
    return WAIT_OBJECT_0;
236
237
34.3k
  return hdl->ops->CleanupHandle(handle);
238
51.5k
}
Unexecuted instantiation: generic.c:winpr_Handle_cleanup
Unexecuted instantiation: namedPipeClient.c:winpr_Handle_cleanup
Unexecuted instantiation: file.c:winpr_Handle_cleanup
Unexecuted instantiation: comm.c:winpr_Handle_cleanup
Unexecuted instantiation: comm_ioctl.c:winpr_Handle_cleanup
Unexecuted instantiation: comm_serial_sys.c:winpr_Handle_cleanup
Unexecuted instantiation: comm_sercx_sys.c:winpr_Handle_cleanup
Unexecuted instantiation: comm_sercx2_sys.c:winpr_Handle_cleanup
Unexecuted instantiation: pipe.c:winpr_Handle_cleanup
Unexecuted instantiation: shell.c:winpr_Handle_cleanup
Unexecuted instantiation: handle.c:winpr_Handle_cleanup
Unexecuted instantiation: nonehandle.c:winpr_Handle_cleanup
Unexecuted instantiation: apc.c:winpr_Handle_cleanup
Unexecuted instantiation: thread.c:winpr_Handle_cleanup
Unexecuted instantiation: nt.c:winpr_Handle_cleanup
Unexecuted instantiation: comm_io.c:winpr_Handle_cleanup
Unexecuted instantiation: io.c:winpr_Handle_cleanup
Unexecuted instantiation: sspicli.c:winpr_Handle_cleanup
239
240
WINPR_ATTR_NODISCARD
241
BOOL winpr_set_cloexec(int fd, BOOL cloexec);
242
243
#endif /* WINPR_HANDLE_PRIVATE_H */