ReactOS  0.4.15-dev-1033-gd7d716a
xcv.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Local Port Monitor
3  * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4  * PURPOSE: Implementation of Xcv* and support functions
5  * COPYRIGHT: Copyright 2015 Colin Finck (colin@reactos.org)
6  */
7 
8 #include "precomp.h"
9 
10 static DWORD
11 _HandleAddPort(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
12 {
13  DWORD res, cbPortName;
14  HKEY hroot;
15  HKEY hToken = NULL;
16  PLOCALMON_PORT pPort;
17  PLOCALMON_HANDLE pLocalmon = pXcv->pLocalmon;
18  PWSTR PortName = (PWSTR)pInputData;
19 
20  FIXME("LcmXcvAddPort : %s\n", debugstr_w( (LPWSTR) PortName ) );
21 
22  if (!pLocalmon )
23  {
25  goto Cleanup;
26  }
27 
28  // This action can only happen at SERVER_ACCESS_ADMINISTER access level.
30  {
32  goto Cleanup;
33  }
34 
35  // Switch to the SYSTEM context for modifying the registry.
36  hToken = RevertToPrinterSelf();
37  if (!hToken)
38  {
39  res = GetLastError();
40  ERR("RevertToPrinterSelf failed with error %lu!\n", res);
41  goto Cleanup;
42  }
43 
44  res = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Ports", &hroot);
45  if (res == ERROR_SUCCESS)
46  {
47  if ( DoesPortExist( PortName ) )
48  {
49  RegCloseKey(hroot);
50  FIXME("=> %u\n", ERROR_ALREADY_EXISTS);
52  goto Cleanup;
53  }
54 
55  cbPortName = (wcslen( PortName ) + 1) * sizeof(WCHAR);
56 
57  // Create a new LOCALMON_PORT structure for it.
58  pPort = DllAllocSplMem(sizeof(LOCALMON_PORT) + cbPortName);
59  if (!pPort)
60  {
62  RegCloseKey( hroot );
63  goto Cleanup;
64  }
65  memset( pPort, 0, sizeof(LOCALMON_PORT) + cbPortName );
66 
67  pPort->hFile = INVALID_HANDLE_VALUE;
68  pPort->pLocalmon = pLocalmon;
69  pPort->pwszPortName = wcscpy( (PWSTR)(pPort+1), PortName );
70 
71  // Insert it into the Registry list.
72  InsertTailList(&pLocalmon->RegistryPorts, &pPort->Entry);
73 
74  res = RegSetValueExW(hroot, PortName, 0, REG_SZ, (const BYTE *) L"", sizeof(L""));
75  RegCloseKey(hroot);
76  }
77 
78  FIXME("=> %u\n", res);
79 
80 Cleanup:
81  if (hToken) ImpersonatePrinterClient(hToken);
83  return res;
84 }
85 
104 static DWORD
105 _HandleConfigureLPTPortCommandOK(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
106 {
107  DWORD cbBuffer;
108  DWORD dwErrorCode;
109  HKEY hKey = NULL;
110  HKEY hToken = NULL;
111 
112  // Sanity checks
113  if (!pXcv || !pInputData || !pcbOutputNeeded)
114  {
115  dwErrorCode = ERROR_INVALID_PARAMETER;
116  goto Cleanup;
117  }
118 
119  *pcbOutputNeeded = 0;
120 
121  // This action can only happen at SERVER_ACCESS_ADMINISTER access level.
123  {
124  dwErrorCode = ERROR_ACCESS_DENIED;
125  goto Cleanup;
126  }
127 
128  // Switch to the SYSTEM context for modifying the registry.
129  hToken = RevertToPrinterSelf();
130  if (!hToken)
131  {
132  dwErrorCode = GetLastError();
133  ERR("RevertToPrinterSelf failed with error %lu!\n", dwErrorCode);
134  goto Cleanup;
135  }
136 
137  // Open the key where our value is stored.
138  dwErrorCode = (DWORD)RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Windows", 0, KEY_SET_VALUE, &hKey);
139  if (dwErrorCode != ERROR_SUCCESS)
140  {
141  ERR("RegOpenKeyExW failed with status %lu!\n", dwErrorCode);
142  goto Cleanup;
143  }
144 
145  // We don't use cbInputData here, because the buffer pInputData could be bigger than the data it contains.
146  cbBuffer = (wcslen((PWSTR)pInputData) + 1) * sizeof(WCHAR);
147 
148  // Write the value to the registry.
149  dwErrorCode = (DWORD)RegSetValueExW(hKey, L"TransmissionRetryTimeout", 0, REG_SZ, pInputData, cbBuffer);
150  if (dwErrorCode != ERROR_SUCCESS)
151  {
152  ERR("RegSetValueExW failed with status %lu!\n", dwErrorCode);
153  goto Cleanup;
154  }
155 
156 Cleanup:
157  if (hKey)
158  RegCloseKey(hKey);
159 
160  if (hToken)
161  ImpersonatePrinterClient(hToken);
162 
163  return dwErrorCode;
164 }
165 
166 static DWORD
167 _HandleDeletePort(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
168 {
169  DWORD res;
170  HKEY hroot;
171  HKEY hToken = NULL;
172  PLOCALMON_HANDLE pLocalmon = pXcv->pLocalmon;
173  PLOCALMON_PORT pPort = NULL;
174  PLIST_ENTRY pEntry;
175  PWSTR pPortName = (PWSTR)pInputData;
176 
177  FIXME("LcmXcvDeletePort : %s\n", debugstr_w( pPortName ) );
178 
179  if (!pLocalmon )
180  {
182  goto Cleanup;
183  }
184 
185  // This action can only happen at SERVER_ACCESS_ADMINISTER access level.
187  {
189  goto Cleanup;
190  }
191 
192  // Switch to the SYSTEM context for modifying the registry.
193  hToken = RevertToPrinterSelf();
194  if (!hToken)
195  {
196  res = GetLastError();
197  ERR("RevertToPrinterSelf failed with error %lu!\n", res);
198  goto Cleanup;
199  }
200 
201  res = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Ports", &hroot);
202  if ( res == ERROR_SUCCESS )
203  {
204  res = RegDeleteValueW(hroot, pPortName );
205 
206  RegCloseKey(hroot);
207 
208  if ( res == ERROR_SUCCESS )
209  {
210  EnterCriticalSection(&pLocalmon->Section);
211 
212  if (!IsListEmpty(&pLocalmon->RegistryPorts) )
213  {
214  for (pEntry = pLocalmon->RegistryPorts.Flink; pEntry != &pLocalmon->RegistryPorts; pEntry = pEntry->Flink)
215  {
216  pPort = CONTAINING_RECORD(pEntry, LOCALMON_PORT, Entry);
217 
218  if (wcscmp(pPort->pwszPortName, pPortName) == 0)
219  break;
220  }
221  }
222 
223  LeaveCriticalSection(&pLocalmon->Section);
224 
225  if ( pPort )
226  {
227  FIXME("LcmXcvDeletePort removed Port Entry\n");
229  RemoveEntryList(&pPort->Entry);
231 
232  DllFreeSplMem(pPort);
233  }
234  }
235  FIXME("LcmXcvDeletePort => %u with %u\n", res, GetLastError() );
236  }
237 
238 Cleanup:
239  if (hToken) ImpersonatePrinterClient(hToken);
240  SetLastError(res);
241  return res;
242 }
243 
265 static DWORD
266 _HandleGetDefaultCommConfig(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
267 {
268  // Sanity checks
269  if (!pInputData || !pcbOutputNeeded)
271 
272  *pcbOutputNeeded = sizeof(COMMCONFIG);
273 
274  // Check if the supplied buffer is large enough.
275  if (cbOutputData < *pcbOutputNeeded)
277 
278  // Finally get the port configuration.
279  if (!GetDefaultCommConfigW((PCWSTR)pInputData, (LPCOMMCONFIG)pOutputData, pcbOutputNeeded))
280  return GetLastError();
281 
282  return ERROR_SUCCESS;
283 }
284 
303 static DWORD
304 _HandleGetTransmissionRetryTimeout(PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
305 {
307 
308  // Sanity checks
309  if (!pOutputData || !pcbOutputNeeded)
311 
312  *pcbOutputNeeded = sizeof(DWORD);
313 
314  // Check if the supplied buffer is large enough.
315  if (cbOutputData < *pcbOutputNeeded)
317 
318  // Retrieve and copy the number.
320  CopyMemory(pOutputData, &dwTimeout, sizeof(DWORD));
321  return ERROR_SUCCESS;
322 }
323 
341 static DWORD
342 _HandleMonitorUI(PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
343 {
344  const WCHAR wszMonitorUI[] = L"LocalUI.dll";
345 
346  // Sanity checks
347  if (!pcbOutputNeeded)
349 
350  *pcbOutputNeeded = sizeof(wszMonitorUI);
351 
352  // Check if the supplied buffer is large enough.
353  if (cbOutputData < *pcbOutputNeeded)
355 
356  if (!pOutputData)
358 
359  // Copy the string.
360  CopyMemory(pOutputData, wszMonitorUI, sizeof(wszMonitorUI));
361  return ERROR_SUCCESS;
362 }
363 
384 static DWORD
385 _HandlePortExists(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
386 {
387  // Sanity checks
388  if (!pInputData || !pOutputData || !pcbOutputNeeded)
390 
391  *pcbOutputNeeded = sizeof(BOOL);
392 
393  // Check if the supplied buffer is large enough.
394  if (cbOutputData < *pcbOutputNeeded)
396 
397  // Return the check result and error code.
398  *(PBOOL)pOutputData = DoesPortExist((PCWSTR)pInputData);
399  return GetLastError();
400 }
401 
402 static DWORD
403 _HandlePortIsValid(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
404 {
405  DWORD res;
406 
407  TRACE("HandlePortIsValid : pInputData %s\n", debugstr_w( (LPWSTR) pInputData));
408 
409  res = GetTypeFromName((LPCWSTR) pInputData);
410 
411  TRACE("HandlePortIsValid : detected as %u\n", res);
412 
413  /* names, that we have recognized, are valid */
414  if (res) return ERROR_SUCCESS;
415 
416  TRACE("=> %u\n", GetLastError());
417 
418  /* ERROR_ACCESS_DENIED, ERROR_PATH_NOT_FOUND or something else */
419  return GetLastError();
420 }
421 
441 static DWORD
442 _HandleSetDefaultCommConfig(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
443 {
444  DWORD dwErrorCode;
445  HANDLE hToken = NULL;
446  LPCOMMCONFIG pCommConfig;
447  PWSTR pwszPortNameWithoutColon = NULL;
448 
449  // Sanity checks
450  // pwszObject needs to be at least 2 characters long to be a port name with a trailing colon.
451  if (!pXcv || !pXcv->pwszObject || !pXcv->pwszObject[0] || !pXcv->pwszObject[1] || !pInputData || !pcbOutputNeeded)
452  {
453  dwErrorCode = ERROR_INVALID_PARAMETER;
454  goto Cleanup;
455  }
456 
457  *pcbOutputNeeded = 0;
458 
459  // This action can only happen at SERVER_ACCESS_ADMINISTER access level.
461  {
462  dwErrorCode = ERROR_ACCESS_DENIED;
463  goto Cleanup;
464  }
465 
466  // SetDefaultCommConfigW needs the port name without colon.
467  dwErrorCode = GetPortNameWithoutColon(pXcv->pwszObject, &pwszPortNameWithoutColon);
468  if (dwErrorCode != ERROR_SUCCESS)
469  goto Cleanup;
470 
471  // Switch to the SYSTEM context for setting the port configuration.
472  hToken = RevertToPrinterSelf();
473  if (!hToken)
474  {
475  dwErrorCode = GetLastError();
476  ERR("RevertToPrinterSelf failed with error %lu!\n", dwErrorCode);
477  goto Cleanup;
478  }
479 
480  // Finally pass the parameters to SetDefaultCommConfigW.
481  pCommConfig = (LPCOMMCONFIG)pInputData;
482  if (!SetDefaultCommConfigW(pwszPortNameWithoutColon, pCommConfig, pCommConfig->dwSize))
483  {
484  dwErrorCode = GetLastError();
485  ERR("SetDefaultCommConfigW failed with error %lu!\n", dwErrorCode);
486  goto Cleanup;
487  }
488 
489  dwErrorCode = ERROR_SUCCESS;
490 
491 Cleanup:
492  if (hToken)
493  ImpersonatePrinterClient(hToken);
494 
495  if (pwszPortNameWithoutColon)
496  DllFreeSplMem(pwszPortNameWithoutColon);
497 
498  return dwErrorCode;
499 }
500 
501 BOOL WINAPI
503 {
505 
506  TRACE("LocalmonXcvClosePort(%p)\n", hXcv);
507 
508  // Sanity checks
509  if (!pXcv)
510  {
512  return FALSE;
513  }
514 
515  // Remove it from the list and free the memory.
517  RemoveEntryList(&pXcv->Entry);
519  DllFreeSplMem(pXcv);
520 
522  return TRUE;
523 }
524 
526 LocalmonXcvDataPort(HANDLE hXcv, PCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
527 {
528  FIXME("LocalmonXcvDataPort(%p, %S, %p, %lu, %p, %lu, %p)\n", hXcv, pszDataName, pInputData, cbInputData, pOutputData, cbOutputData, pcbOutputNeeded);
529 
530  // Sanity checks
531  if (!pszDataName)
533 
534  // Call the appropriate handler for the requested data name.
535  if (wcscmp(pszDataName, L"AddPort") == 0)
536  return _HandleAddPort((PLOCALMON_XCV)hXcv, pInputData, pcbOutputNeeded);
537 
538  if (wcscmp(pszDataName, L"ConfigureLPTPortCommandOK") == 0)
539  return _HandleConfigureLPTPortCommandOK((PLOCALMON_XCV)hXcv, pInputData, pcbOutputNeeded);
540 
541  if (wcscmp(pszDataName, L"DeletePort") == 0)
542  return _HandleDeletePort((PLOCALMON_XCV)hXcv, pInputData, pcbOutputNeeded);
543 
544  if (wcscmp(pszDataName, L"GetDefaultCommConfig") == 0)
545  return _HandleGetDefaultCommConfig(pInputData, pOutputData, cbOutputData, pcbOutputNeeded);
546 
547  if (wcscmp(pszDataName, L"GetTransmissionRetryTimeout") == 0)
548  return _HandleGetTransmissionRetryTimeout(pOutputData, cbOutputData, pcbOutputNeeded);
549 
550  if (wcscmp(pszDataName, L"MonitorUI") == 0)
551  return _HandleMonitorUI(pOutputData, cbOutputData, pcbOutputNeeded);
552 
553  if (wcscmp(pszDataName, L"PortExists") == 0)
554  return _HandlePortExists(pInputData, pOutputData, cbOutputData, pcbOutputNeeded);
555 
556  if (wcscmp(pszDataName, L"PortIsValid") == 0)
557  return _HandlePortIsValid(pInputData, pOutputData, cbOutputData, pcbOutputNeeded);
558 
559  if (wcscmp(pszDataName, L"SetDefaultCommConfig") == 0)
560  return _HandleSetDefaultCommConfig((PLOCALMON_XCV)hXcv, pInputData, pcbOutputNeeded);
561 
563 }
564 
565 BOOL WINAPI
567 {
568  DWORD cbObject = 0;
569  DWORD dwErrorCode;
570  PLOCALMON_HANDLE pLocalmon = (PLOCALMON_HANDLE)hMonitor;
571  PLOCALMON_XCV pXcv;
572 
573  FIXME("LocalmonXcvOpenPort(%p, %S, %lu, %p)\n", hMonitor, pwszObject, GrantedAccess, phXcv);
574 
575  // Sanity checks
576  if (!pLocalmon || !phXcv)
577  {
578  dwErrorCode = ERROR_INVALID_PARAMETER;
579  goto Cleanup;
580  }
581 
582  if (pwszObject)
583  cbObject = (wcslen(pwszObject) + 1) * sizeof(WCHAR);
584 
585  // Create a new LOCALMON_XCV structure and fill the relevant fields.
586  pXcv = DllAllocSplMem(sizeof(LOCALMON_XCV) + cbObject);
587  if (!pXcv)
588  {
589  dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
590  ERR("DllAllocSplMem failed with error %lu!\n", GetLastError());
591  goto Cleanup;
592  }
593 
594  pXcv->pLocalmon = pLocalmon;
596 
597  if (cbObject)
598  {
599  pXcv->pwszObject = (PWSTR)((PBYTE)pXcv + sizeof(LOCALMON_XCV));
600  CopyMemory(pXcv->pwszObject, pwszObject, cbObject);
601  }
602 
603  InsertTailList(&pLocalmon->XcvHandles, &pXcv->Entry);
604 
605  // Return it as the Xcv handle.
606  *phXcv = (HANDLE)pXcv;
607  dwErrorCode = ERROR_SUCCESS;
608 
609 Cleanup:
610  SetLastError(dwErrorCode);
611  return (dwErrorCode == ERROR_SUCCESS);
612 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
struct _COMM_CONFIG COMMCONFIG
const uint16_t * PCWSTR
Definition: typedefs.h:57
struct _COMM_CONFIG * LPCOMMCONFIG
Definition: confdlg.c:35
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_SET_VALUE
Definition: nt_native.h:1017
LIST_ENTRY Entry
Definition: precomp.h:54
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI SetDefaultCommConfigW(LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, DWORD dwSize)
Definition: comm.c:1338
struct _LOCALMON_XCV LOCALMON_XCV
static DWORD _HandleMonitorUI(PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:342
#define TRUE
Definition: types.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI DllFreeSplMem(PVOID pMem)
Definition: memory.c:112
LIST_ENTRY XcvHandles
Definition: precomp.h:44
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:479
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI LocalmonXcvDataPort(HANDLE hXcv, PCWSTR pszDataName, PBYTE pInputData, DWORD cbInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:526
static DWORD _HandleConfigureLPTPortCommandOK(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:105
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define InsertTailList(ListHead, Entry)
#define BOOL
Definition: nt_native.h:43
#define DWORD
Definition: nt_native.h:44
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct _LOCALMON_XCV * PLOCALMON_XCV
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
DWORD GetLPTTransmissionRetryTimeout(VOID)
Definition: tools.c:85
LIST_ENTRY Entry
Definition: precomp.h:79
static DWORD _HandleGetDefaultCommConfig(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:266
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define ERROR_ACCESS_DENIED
Definition: compat.h:97
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
static DWORD _HandleDeletePort(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:167
BOOL * PBOOL
Definition: windef.h:161
HANDLE WINAPI RevertToPrinterSelf(VOID)
Definition: context.c:64
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
static DWORD _HandleGetTransmissionRetryTimeout(PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:304
BOOL WINAPI LocalmonXcvOpenPort(HANDLE hMonitor, PCWSTR pwszObject, ACCESS_MASK GrantedAccess, PHANDLE phXcv)
Definition: xcv.c:566
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
BOOL DoesPortExist(PCWSTR pwszPortName)
Definition: tools.c:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
DWORD GetTypeFromName(LPCWSTR name)
Definition: tools.c:215
LIST_ENTRY RegistryPorts
Definition: precomp.h:43
#define TRACE(s)
Definition: solgame.cpp:4
PWSTR pwszPortName
Definition: precomp.h:55
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI GetDefaultCommConfigW(LPCWSTR lpszName, LPCOMMCONFIG lpCC, LPDWORD lpdwSize)
Definition: comm.c:1398
PLOCALMON_HANDLE pLocalmon
Definition: precomp.h:56
#define WINAPI
Definition: msvc.h:6
#define CopyMemory
Definition: winbase.h:1646
static DWORD _HandlePortIsValid(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:403
PVOID HANDLE
Definition: typedefs.h:73
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:500
CRITICAL_SECTION Section
Definition: precomp.h:40
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
DWORD dwSize
Definition: winbase.h:655
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:454
Definition: typedefs.h:119
static const WCHAR Cleanup[]
Definition: register.c:80
HANDLE hFile
Definition: precomp.h:67
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD dwTimeout
Definition: wincrypt.h:6077
BOOL WINAPI LocalmonXcvClosePort(HANDLE hXcv)
Definition: xcv.c:502
PWSTR pwszObject
Definition: precomp.h:82
static DWORD _HandleAddPort(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:11
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PLOCALMON_HANDLE pLocalmon
Definition: precomp.h:81
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2355
#define SERVER_ACCESS_ADMINISTER
Definition: winspool.h:1366
DWORD * PDWORD
Definition: pedump.c:68
GLuint res
Definition: glext.h:9613
static DWORD _HandlePortExists(PBYTE pInputData, PBYTE pOutputData, DWORD cbOutputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:385
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
BOOL WINAPI ImpersonatePrinterClient(_In_ HANDLE hToken)
PVOID WINAPI DllAllocSplMem(DWORD dwBytes)
Definition: memory.c:95
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
static HANDLE hXcv
Definition: localmon.c:73
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_In_ PSECURITY_SUBJECT_CONTEXT _In_ BOOLEAN _In_ ACCESS_MASK _In_ ACCESS_MASK _Outptr_opt_ PPRIVILEGE_SET _In_ PGENERIC_MAPPING _In_ KPROCESSOR_MODE _Out_ PACCESS_MASK GrantedAccess
Definition: sefuncs.h:13
#define memset(x, y, z)
Definition: compat.h:39
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
ULONG ACCESS_MASK
Definition: nt_native.h:40
base of all file and directory entries
Definition: entries.h:82
struct _LOCALMON_HANDLE * PLOCALMON_HANDLE
DWORD GetPortNameWithoutColon(PCWSTR pwszPortName, PWSTR *ppwszPortNameWithoutColon)
Definition: tools.c:142
static DWORD _HandleSetDefaultCommConfig(PLOCALMON_XCV pXcv, PBYTE pInputData, PDWORD pcbOutputNeeded)
Definition: xcv.c:442
IN PUNICODE_STRING PortName
Definition: conport.c:35
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22
ACCESS_MASK GrantedAccess
Definition: precomp.h:80