Coverage Report

Created: 2025-07-01 06:46

/src/FreeRDP/winpr/libwinpr/nt/nt.c
Line
Count
Source (jump to first uncovered line)
1
/**
2
 * WinPR: Windows Portable Runtime
3
 * Windows Native System Services
4
 *
5
 * Copyright 2013 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6
 * Copyright 2013 Thincast Technologies GmbH
7
 * Copyright 2013 Norbert Federa <norbert.federa@thincast.com>
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 *     http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21
22
#include <winpr/assert.h>
23
#include <winpr/config.h>
24
25
#include <winpr/crt.h>
26
#include <winpr/library.h>
27
#include <winpr/nt.h>
28
#include <winpr/endian.h>
29
30
#ifndef _WIN32
31
32
#include <pthread.h>
33
34
#include "../handle/handle.h"
35
36
static pthread_once_t sTebOnceControl = PTHREAD_ONCE_INIT;
37
static pthread_key_t sTebKey;
38
39
static void sTebDestruct(void* teb)
40
0
{
41
0
  free(teb);
42
0
}
43
44
static void sTebInitOnce(void)
45
0
{
46
0
  pthread_key_create(&sTebKey, sTebDestruct);
47
0
}
48
49
PTEB NtCurrentTeb(void)
50
0
{
51
0
  PTEB teb = NULL;
52
53
0
  if (pthread_once(&sTebOnceControl, sTebInitOnce) == 0)
54
0
  {
55
0
    if ((teb = pthread_getspecific(sTebKey)) == NULL)
56
0
    {
57
0
      teb = calloc(1, sizeof(TEB));
58
0
      if (teb)
59
0
        pthread_setspecific(sTebKey, teb);
60
0
    }
61
0
  }
62
0
  return teb;
63
0
}
64
#endif
65
66
const char* FSInformationClass2Tag(FILE_INFORMATION_CLASS value)
67
0
{
68
0
  switch (value)
69
0
  {
70
0
    case FileDirectoryInformation:
71
0
      return "FileDirectoryInformation";
72
0
    case FileFullDirectoryInformation:
73
0
      return "FileFullDirectoryInformation";
74
0
    case FileBothDirectoryInformation:
75
0
      return "FileBothDirectoryInformation";
76
0
    case FileBasicInformation:
77
0
      return "FileBasicInformation";
78
0
    case FileStandardInformation:
79
0
      return "FileStandardInformation";
80
0
    case FileInternalInformation:
81
0
      return "FileInternalInformation";
82
0
    case FileEaInformation:
83
0
      return "FileEaInformation";
84
0
    case FileAccessInformation:
85
0
      return "FileAccessInformation";
86
0
    case FileNameInformation:
87
0
      return "FileNameInformation";
88
0
    case FileRenameInformation:
89
0
      return "FileRenameInformation";
90
0
    case FileLinkInformation:
91
0
      return "FileLinkInformation";
92
0
    case FileNamesInformation:
93
0
      return "FileNamesInformation";
94
0
    case FileDispositionInformation:
95
0
      return "FileDispositionInformation";
96
0
    case FilePositionInformation:
97
0
      return "FilePositionInformation";
98
0
    case FileFullEaInformation:
99
0
      return "FileFullEaInformation";
100
0
    case FileModeInformation:
101
0
      return "FileModeInformation";
102
0
    case FileAlignmentInformation:
103
0
      return "FileAlignmentInformation";
104
0
    case FileAllInformation:
105
0
      return "FileAllInformation";
106
0
    case FileAllocationInformation:
107
0
      return "FileAllocationInformation";
108
0
    case FileEndOfFileInformation:
109
0
      return "FileEndOfFileInformation";
110
0
    case FileAlternateNameInformation:
111
0
      return "FileAlternateNameInformation";
112
0
    case FileStreamInformation:
113
0
      return "FileStreamInformation";
114
0
    case FilePipeInformation:
115
0
      return "FilePipeInformation";
116
0
    case FilePipeLocalInformation:
117
0
      return "FilePipeLocalInformation";
118
0
    case FilePipeRemoteInformation:
119
0
      return "FilePipeRemoteInformation";
120
0
    case FileMailslotQueryInformation:
121
0
      return "FileMailslotQueryInformation";
122
0
    case FileMailslotSetInformation:
123
0
      return "FileMailslotSetInformation";
124
0
    case FileCompressionInformation:
125
0
      return "FileCompressionInformation";
126
0
    case FileObjectIdInformation:
127
0
      return "FileObjectIdInformation";
128
0
    case FileCompletionInformation:
129
0
      return "FileCompletionInformation";
130
0
    case FileMoveClusterInformation:
131
0
      return "FileMoveClusterInformation";
132
0
    case FileQuotaInformation:
133
0
      return "FileQuotaInformation";
134
0
    case FileReparsePointInformation:
135
0
      return "FileReparsePointInformation";
136
0
    case FileNetworkOpenInformation:
137
0
      return "FileNetworkOpenInformation";
138
0
    case FileAttributeTagInformation:
139
0
      return "FileAttributeTagInformation";
140
0
    case FileTrackingInformation:
141
0
      return "FileTrackingInformation";
142
0
    case FileIdBothDirectoryInformation:
143
0
      return "FileIdBothDirectoryInformation";
144
0
    case FileIdFullDirectoryInformation:
145
0
      return "FileIdFullDirectoryInformation";
146
0
    case FileValidDataLengthInformation:
147
0
      return "FileValidDataLengthInformation";
148
0
    case FileShortNameInformation:
149
0
      return "FileShortNameInformation";
150
0
    default:
151
0
      return "UNKNOWN";
152
0
  }
153
0
}