Coverage Report

Created: 2026-08-31 06:25

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
92
#define HANDLE_TYPE_PROCESS 1
33
392
#define HANDLE_TYPE_THREAD 2
34
690
#define HANDLE_TYPE_EVENT 3
35
46
#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
#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
391
{
123
391
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
391
  BOOL invalid = !pWinprHandle;
125
126
391
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
391
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
391
  return TRUE;
139
391
}
Unexecuted instantiation: critical.c:WINPR_HANDLE_IS_HANDLED
event.c:WINPR_HANDLE_IS_HANDLED
Line
Count
Source
122
299
{
123
299
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
299
  BOOL invalid = !pWinprHandle;
125
126
299
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
299
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
299
  return TRUE;
139
299
}
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: io.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
Unexecuted instantiation: process.c:WINPR_HANDLE_IS_HANDLED
thread.c:WINPR_HANDLE_IS_HANDLED
Line
Count
Source
122
92
{
123
92
  WINPR_HANDLE* pWinprHandle = (WINPR_HANDLE*)handle;
124
92
  BOOL invalid = !pWinprHandle;
125
126
92
  if (invalidValue)
127
0
  {
128
0
    if (INVALID_HANDLE_VALUE == pWinprHandle)
129
0
      invalid = TRUE;
130
0
  }
131
132
92
  if (invalid || (pWinprHandle->Type != type))
133
0
  {
134
0
    SetLastError(ERROR_INVALID_HANDLE);
135
0
    return FALSE;
136
0
  }
137
138
92
  return TRUE;
139
92
}
Unexecuted instantiation: nt.c:WINPR_HANDLE_IS_HANDLED
Unexecuted instantiation: comm_io.c:WINPR_HANDLE_IS_HANDLED
140
141
static inline void WINPR_HANDLE_SET_TYPE_AND_MODE(void* _handle, ULONG _type, ULONG _mode)
142
276
{
143
276
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
276
  hdl->Type = _type;
146
276
  hdl->Mode = _mode;
147
276
  hdl->refCount = 1;
148
276
}
Unexecuted instantiation: critical.c:WINPR_HANDLE_SET_TYPE_AND_MODE
event.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Line
Count
Source
142
253
{
143
253
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
253
  hdl->Type = _type;
146
253
  hdl->Mode = _mode;
147
253
  hdl->refCount = 1;
148
253
}
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: io.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
Unexecuted instantiation: process.c:WINPR_HANDLE_SET_TYPE_AND_MODE
thread.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Line
Count
Source
142
23
{
143
23
  WINPR_HANDLE* hdl = (WINPR_HANDLE*)_handle;
144
145
23
  hdl->Type = _type;
146
23
  hdl->Mode = _mode;
147
23
  hdl->refCount = 1;
148
23
}
Unexecuted instantiation: nt.c:WINPR_HANDLE_SET_TYPE_AND_MODE
Unexecuted instantiation: comm_io.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
920
{
153
920
  WINPR_HANDLE* wHandle = nullptr;
154
155
920
  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
920
#ifndef __clang_analyzer__
161
920
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
920
#endif
164
165
920
  wHandle = (WINPR_HANDLE*)handle;
166
167
920
  *pType = wHandle->Type;
168
920
  *pObject = wHandle;
169
170
920
  return TRUE;
171
920
}
Unexecuted instantiation: critical.c:winpr_Handle_GetInfo
event.c:winpr_Handle_GetInfo
Line
Count
Source
152
138
{
153
138
  WINPR_HANDLE* wHandle = nullptr;
154
155
138
  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
138
#ifndef __clang_analyzer__
161
138
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
138
#endif
164
165
138
  wHandle = (WINPR_HANDLE*)handle;
166
167
138
  *pType = wHandle->Type;
168
138
  *pObject = wHandle;
169
170
138
  return TRUE;
171
138
}
Unexecuted instantiation: sleep.c:winpr_Handle_GetInfo
wait.c:winpr_Handle_GetInfo
Line
Count
Source
152
253
{
153
253
  WINPR_HANDLE* wHandle = nullptr;
154
155
253
  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
253
#ifndef __clang_analyzer__
161
253
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
253
#endif
164
165
253
  wHandle = (WINPR_HANDLE*)handle;
166
167
253
  *pType = wHandle->Type;
168
253
  *pObject = wHandle;
169
170
253
  return TRUE;
171
253
}
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
Unexecuted instantiation: io.c:winpr_Handle_GetInfo
handle.c:winpr_Handle_GetInfo
Line
Count
Source
152
529
{
153
529
  WINPR_HANDLE* wHandle = nullptr;
154
155
529
  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
529
#ifndef __clang_analyzer__
161
529
  if (handle == INVALID_HANDLE_VALUE)
162
0
    return FALSE;
163
529
#endif
164
165
529
  wHandle = (WINPR_HANDLE*)handle;
166
167
529
  *pType = wHandle->Type;
168
529
  *pObject = wHandle;
169
170
529
  return TRUE;
171
529
}
Unexecuted instantiation: nonehandle.c:winpr_Handle_GetInfo
Unexecuted instantiation: apc.c:winpr_Handle_GetInfo
Unexecuted instantiation: process.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
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: 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: io.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: process.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
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
253
{
193
253
  ULONG type = 0;
194
253
  WINPR_HANDLE* hdl = nullptr;
195
196
253
  if (!winpr_Handle_GetInfo(handle, &type, &hdl) || !hdl)
197
0
    return FALSE;
198
199
253
  if (InterlockedDecrement(&hdl->refCount) > 0)
200
0
    return FALSE;
201
202
253
  free(hdl);
203
253
  return TRUE;
204
253
}
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
Unexecuted instantiation: io.c:winpr_Handle_Release
handle.c:winpr_Handle_Release
Line
Count
Source
192
253
{
193
253
  ULONG type = 0;
194
253
  WINPR_HANDLE* hdl = nullptr;
195
196
253
  if (!winpr_Handle_GetInfo(handle, &type, &hdl) || !hdl)
197
0
    return FALSE;
198
199
253
  if (InterlockedDecrement(&hdl->refCount) > 0)
200
0
    return FALSE;
201
202
253
  free(hdl);
203
253
  return TRUE;
204
253
}
Unexecuted instantiation: nonehandle.c:winpr_Handle_Release
Unexecuted instantiation: apc.c:winpr_Handle_Release
Unexecuted instantiation: process.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
205
206
WINPR_ATTR_NODISCARD
207
static inline int winpr_Handle_getFd(HANDLE handle)
208
92
{
209
92
  WINPR_HANDLE* hdl = nullptr;
210
92
  ULONG type = 0;
211
212
92
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
213
0
    return -1;
214
215
92
  if (!hdl || !hdl->ops || !hdl->ops->GetFd)
216
0
    return -1;
217
218
92
  return hdl->ops->GetFd(handle);
219
92
}
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
92
{
209
92
  WINPR_HANDLE* hdl = nullptr;
210
92
  ULONG type = 0;
211
212
92
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
213
0
    return -1;
214
215
92
  if (!hdl || !hdl->ops || !hdl->ops->GetFd)
216
0
    return -1;
217
218
92
  return hdl->ops->GetFd(handle);
219
92
}
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: io.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: process.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
220
221
WINPR_ATTR_NODISCARD
222
static inline DWORD winpr_Handle_cleanup(HANDLE handle)
223
69
{
224
69
  WINPR_HANDLE* hdl = nullptr;
225
69
  ULONG type = 0;
226
227
69
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
228
0
    return WAIT_FAILED;
229
230
69
  if (!hdl || !hdl->ops)
231
0
    return WAIT_FAILED;
232
233
  /* If there is no cleanup function, assume all ok. */
234
69
  if (!hdl->ops->CleanupHandle)
235
23
    return WAIT_OBJECT_0;
236
237
46
  return hdl->ops->CleanupHandle(handle);
238
69
}
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
69
{
224
69
  WINPR_HANDLE* hdl = nullptr;
225
69
  ULONG type = 0;
226
227
69
  if (!winpr_Handle_GetInfo(handle, &type, &hdl))
228
0
    return WAIT_FAILED;
229
230
69
  if (!hdl || !hdl->ops)
231
0
    return WAIT_FAILED;
232
233
  /* If there is no cleanup function, assume all ok. */
234
69
  if (!hdl->ops->CleanupHandle)
235
23
    return WAIT_OBJECT_0;
236
237
46
  return hdl->ops->CleanupHandle(handle);
238
69
}
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: io.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: process.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
239
240
WINPR_ATTR_NODISCARD
241
BOOL winpr_set_cloexec(int fd, BOOL cloexec);
242
243
#endif /* WINPR_HANDLE_PRIVATE_H */