ReactOS  0.4.14-dev-49-gfb4591c
compname.c
Go to the documentation of this file.
1 /*
2  * ReactOS kernel
3  * Copyright (C) 2003 ReactOS Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /*
20  * COPYRIGHT: See COPYING in the top level directory
21  * PROJECT: ReactOS system libraries
22  * PURPOSE: Computer name functions
23  * FILE: dll/win32/kernel32/client/compname.c
24  * PROGRAMER: Eric Kohl
25  */
26 
27 /* INCLUDES ******************************************************************/
28 
29 #include <k32.h>
30 
31 #define NDEBUG
32 #include <debug.h>
33 
34 
35 /* FUNCTIONS *****************************************************************/
36 
37 static
38 BOOL
40  LPWSTR ValueNameStr,
42  LPDWORD nSize)
43 {
49  ULONG KeyInfoSize;
50  ULONG ReturnSize;
52 
53  if (lpBuffer != NULL && *nSize > 0)
54  lpBuffer[0] = 0;
55 
56  RtlInitUnicodeString(&KeyName, RegistryKey);
58  &KeyName,
60  NULL,
61  NULL);
62 
64  KEY_READ,
66  if (!NT_SUCCESS(Status))
67  {
69  return FALSE;
70  }
71 
72  KeyInfoSize = sizeof(KEY_VALUE_PARTIAL_INFORMATION) + *nSize * sizeof(WCHAR);
73  KeyInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, KeyInfoSize);
74  if (KeyInfo == NULL)
75  {
78  return FALSE;
79  }
80 
81  RtlInitUnicodeString(&ValueName, ValueNameStr);
82 
84  &ValueName,
86  KeyInfo,
87  KeyInfoSize,
88  &ReturnSize);
89 
91 
92  if (!NT_SUCCESS(Status))
93  {
94  *nSize = (ReturnSize - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data)) / sizeof(WCHAR);
95  goto failed;
96  }
97 
98  if (KeyInfo->Type != REG_SZ)
99  {
101  goto failed;
102  }
103 
104  if (!lpBuffer || *nSize < (KeyInfo->DataLength / sizeof(WCHAR)))
105  {
106  *nSize = (ReturnSize - FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data)) / sizeof(WCHAR);
108  goto failed;
109  }
110 
111  *nSize = KeyInfo->DataLength / sizeof(WCHAR) - 1;
112  RtlCopyMemory(lpBuffer, KeyInfo->Data, KeyInfo->DataLength);
113  lpBuffer[*nSize] = 0;
114 
115  RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
116 
117  return TRUE;
118 
119 failed:
120  RtlFreeHeap(RtlGetProcessHeap(), 0, KeyInfo);
122  return FALSE;
123 }
124 
125 
126 static
127 BOOL
129  LPCWSTR SubKey,
130  LPCWSTR ValueNameStr,
132 {
137  SIZE_T StringLength;
140 
141  StringLength = wcslen(lpBuffer);
142  if (StringLength > ((MAXULONG / sizeof(WCHAR)) - 1))
143  {
144  return FALSE;
145  }
146 
147  RtlInitUnicodeString(&KeyName, RegistryKey);
149  &KeyName,
151  NULL,
152  NULL);
153 
155  KEY_WRITE,
157  if (!NT_SUCCESS(Status))
158  {
160  return FALSE;
161  }
162 
163  RtlInitUnicodeString(&KeyName, SubKey);
165  &KeyName,
167  KeyHandle,
168  NULL);
169 
171  KEY_WRITE,
173  0,
174  NULL,
176  &Disposition);
177  if (!NT_SUCCESS(Status))
178  {
181  return FALSE;
182  }
183 
184  RtlInitUnicodeString(&ValueName, ValueNameStr);
185 
187  &ValueName,
188  0,
189  REG_SZ,
190  (PVOID)lpBuffer,
191  (StringLength + 1) * sizeof(WCHAR));
192  if (!NT_SUCCESS(Status))
193  {
197  return FALSE;
198  }
199 
203 
204  return TRUE;
205 }
206 
207 
208 /*
209  * @implemented
210  */
211 BOOL
212 WINAPI
213 GetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
215  LPDWORD nSize)
216 {
217  UNICODE_STRING ResultString;
218  UNICODE_STRING DomainPart;
221  BOOL ret = TRUE;
222  DWORD HostSize;
223 
224  if ((nSize == NULL) ||
225  (lpBuffer == NULL && *nSize > 0))
226  {
228  return FALSE;
229  }
230 
231  switch (NameType)
232  {
233  case ComputerNameNetBIOS:
234  ret = GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
235  L"\\Control\\ComputerName\\ActiveComputerName",
236  L"ComputerName",
237  lpBuffer,
238  nSize);
239  if ((ret == FALSE) &&
241  {
242  ret = GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
243  L"\\Control\\ComputerName\\ComputerName",
244  L"ComputerName",
245  lpBuffer,
246  nSize);
247  if (ret)
248  {
249  ret = SetActiveComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
250  L"\\Control\\ComputerName",
251  L"ActiveComputerName",
252  L"ComputerName",
253  lpBuffer);
254  }
255  }
256  return ret;
257 
258  case ComputerNameDnsDomain:
259  return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
260  L"\\Services\\Tcpip\\Parameters",
261  L"Domain",
262  lpBuffer,
263  nSize);
264 
265  case ComputerNameDnsFullyQualified:
266  ResultString.Length = 0;
267  ResultString.MaximumLength = (USHORT)*nSize * sizeof(WCHAR);
268  ResultString.Buffer = lpBuffer;
269 
271  RtlInitUnicodeString(&DomainPart, NULL);
272 
273  QueryTable[0].Name = L"HostName";
275  QueryTable[0].EntryContext = &DomainPart;
276 
278  L"\\Registry\\Machine\\System"
279  L"\\CurrentControlSet\\Services\\Tcpip"
280  L"\\Parameters",
281  QueryTable,
282  NULL,
283  NULL);
284 
285  if (NT_SUCCESS(Status))
286  {
287  Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart);
288  HostSize = DomainPart.Length;
289 
290  if (!NT_SUCCESS(Status))
291  {
292  ret = FALSE;
293  }
294 
295  RtlAppendUnicodeToString(&ResultString, L".");
296  RtlFreeUnicodeString(&DomainPart);
297 
298  RtlInitUnicodeString(&DomainPart, NULL);
299  QueryTable[0].Name = L"Domain";
301  QueryTable[0].EntryContext = &DomainPart;
302 
304  L"\\Registry\\Machine\\System"
305  L"\\CurrentControlSet\\Services\\Tcpip"
306  L"\\Parameters",
307  QueryTable,
308  NULL,
309  NULL);
310 
311  if (NT_SUCCESS(Status))
312  {
313  Status = RtlAppendUnicodeStringToString(&ResultString, &DomainPart);
314  if ((!NT_SUCCESS(Status)) || (!ret))
315  {
316  *nSize = HostSize + DomainPart.Length;
318  RtlFreeUnicodeString(&DomainPart);
319  return FALSE;
320  }
321  RtlFreeUnicodeString(&DomainPart);
322  *nSize = ResultString.Length / sizeof(WCHAR) - 1;
323  return TRUE;
324  }
325  }
326  return FALSE;
327 
328  case ComputerNameDnsHostname:
329  return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
330  L"\\Services\\Tcpip\\Parameters",
331  L"Hostname",
332  lpBuffer,
333  nSize);
334 
335  case ComputerNamePhysicalDnsDomain:
336  return GetComputerNameFromRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
337  L"\\Services\\Tcpip\\Parameters",
338  L"Domain",
339  lpBuffer,
340  nSize);
341 
342  /* XXX Redo these */
343  case ComputerNamePhysicalDnsFullyQualified:
344  return GetComputerNameExW(ComputerNameDnsFullyQualified,
345  lpBuffer,
346  nSize);
347 
348  case ComputerNamePhysicalDnsHostname:
349  return GetComputerNameExW(ComputerNameDnsHostname,
350  lpBuffer,
351  nSize);
352 
353  case ComputerNamePhysicalNetBIOS:
354  return GetComputerNameExW(ComputerNameNetBIOS,
355  lpBuffer,
356  nSize);
357 
358  case ComputerNameMax:
359  return FALSE;
360  }
361 
362  return FALSE;
363 }
364 
365 /*
366  * @implemented
367  */
368 BOOL
369 WINAPI
370 GetComputerNameExA(COMPUTER_NAME_FORMAT NameType,
371  LPSTR lpBuffer,
372  LPDWORD nSize)
373 {
376  BOOL Result;
377  PWCHAR TempBuffer = NULL;
378 
379  if ((nSize == NULL) ||
380  (lpBuffer == NULL && *nSize > 0))
381  {
383  return FALSE;
384  }
385 
386  if (*nSize > 0)
387  {
388  TempBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, *nSize * sizeof(WCHAR));
389  if (!TempBuffer)
390  {
392  return FALSE;
393  }
394  }
395 
396  AnsiString.MaximumLength = (USHORT)*nSize;
397  AnsiString.Length = 0;
398  AnsiString.Buffer = lpBuffer;
399 
400  Result = GetComputerNameExW(NameType, TempBuffer, nSize);
401 
402  if (Result)
403  {
404  UnicodeString.MaximumLength = (USHORT)*nSize * sizeof(WCHAR) + sizeof(WCHAR);
405  UnicodeString.Length = (USHORT)*nSize * sizeof(WCHAR);
406  UnicodeString.Buffer = TempBuffer;
407 
409  &UnicodeString,
410  FALSE);
411  }
412 
413  RtlFreeHeap(RtlGetProcessHeap(), 0, TempBuffer);
414 
415  return Result;
416 }
417 
418 /*
419  * @implemented
420  */
421 BOOL
422 WINAPI
424 {
425  BOOL ret;
426 
427  ret = GetComputerNameExA(ComputerNameNetBIOS, lpBuffer, lpnSize);
428  if (!ret && GetLastError() == ERROR_MORE_DATA)
430 
431  return ret;
432 }
433 
434 
435 /*
436  * @implemented
437  */
438 BOOL
439 WINAPI
441 {
442  BOOL ret;
443 
444  ret = GetComputerNameExW(ComputerNameNetBIOS, lpBuffer, lpnSize);
445  if (!ret && GetLastError() == ERROR_MORE_DATA)
447 
448  return ret;
449 }
450 
451 
452 /*
453  * @implemented
454  */
455 static
456 BOOL
457 IsValidComputerName(COMPUTER_NAME_FORMAT NameType,
459 {
460  PWCHAR p;
461  ULONG Length;
462 
463  /* FIXME: do verification according to NameType */
464 
465  Length = 0;
467 
468  while (*p != 0)
469  {
470  if (!(iswctype(*p, _ALPHA | _DIGIT) || *p == L'!' || *p == L'@' || *p == L'#' ||
471  *p == L'$' || *p == L'%' || *p == L'^' || *p == L'&' || *p == L'\'' ||
472  *p == L')' || *p == L'(' || *p == L'.' || *p == L'-' || *p == L'_' ||
473  *p == L'{' || *p == L'}' || *p == L'~'))
474  return FALSE;
475 
476  Length++;
477  p++;
478  }
479 
480  if (Length == 0 || Length > MAX_COMPUTERNAME_LENGTH)
481  return FALSE;
482 
483  return TRUE;
484 }
485 
486 
487 static
488 BOOL
490  LPCWSTR ValueNameStr,
492 {
497  SIZE_T StringLength;
499 
500  StringLength = wcslen(lpBuffer);
501  if (StringLength > ((MAXULONG / sizeof(WCHAR)) - 1))
502  {
503  return FALSE;
504  }
505 
506  RtlInitUnicodeString(&KeyName, RegistryKey);
508  &KeyName,
510  NULL,
511  NULL);
512 
514  KEY_WRITE,
516  if (!NT_SUCCESS(Status))
517  {
519  return FALSE;
520  }
521 
522  RtlInitUnicodeString(&ValueName, ValueNameStr);
523 
525  &ValueName,
526  0,
527  REG_SZ,
528  (PVOID)lpBuffer,
529  (StringLength + 1) * sizeof(WCHAR));
530  if (!NT_SUCCESS(Status))
531  {
534  return FALSE;
535  }
536 
539 
540  return TRUE;
541 }
542 
543 
544 /*
545  * @implemented
546  */
547 BOOL
548 WINAPI
550 {
551  return SetComputerNameExA(ComputerNamePhysicalNetBIOS, lpComputerName);
552 }
553 
554 
555 /*
556  * @implemented
557  */
558 BOOL
559 WINAPI
561 {
562  return SetComputerNameExW(ComputerNamePhysicalNetBIOS, lpComputerName);
563 }
564 
565 
566 /*
567  * @implemented
568  */
569 BOOL
570 WINAPI
571 SetComputerNameExA(COMPUTER_NAME_FORMAT NameType,
573 {
575  BOOL bResult;
576 
578 
579  bResult = SetComputerNameExW(NameType, Buffer.Buffer);
580 
582 
583  return bResult;
584 }
585 
586 
587 /*
588  * @implemented
589  */
590 BOOL
591 WINAPI
592 SetComputerNameExW(COMPUTER_NAME_FORMAT NameType,
594 {
595  BOOL ret1, ret2;
596 
598  {
600  return FALSE;
601  }
602 
603  switch( NameType )
604  {
605  case ComputerNamePhysicalDnsDomain:
606  return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
607  L"\\Services\\Tcpip\\Parameters",
608  L"Domain",
609  lpBuffer);
610 
611  case ComputerNamePhysicalDnsHostname:
612  ret1 = SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
613  L"\\Services\\Tcpip\\Parameters",
614  L"NV Hostname",
615  lpBuffer);
616 
617  ret2 = SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
618  L"\\Control\\ComputerName\\ComputerName",
619  L"ComputerName",
620  lpBuffer);
621  return (ret1 && ret2);
622 
623  case ComputerNamePhysicalNetBIOS:
624  return SetComputerNameToRegistry(L"\\Registry\\Machine\\System\\CurrentControlSet"
625  L"\\Control\\ComputerName\\ComputerName",
626  L"ComputerName",
627  lpBuffer);
628 
629  default:
631  return FALSE;
632  }
633 }
634 
635 
636 /*
637  * @implemented
638  */
639 BOOL
640 WINAPI
642  LPSTR ComputerName,
643  LPDWORD nSize)
644 {
645  DWORD len;
646 
647  DPRINT("(%s, %p, %p)\n", Hostname, ComputerName, nSize);
648 
649  if (!Hostname || !nSize)
650  return FALSE;
651 
652  len = lstrlenA(Hostname);
653 
656 
657  if (*nSize < len)
658  {
659  *nSize = len;
660  return FALSE;
661  }
662 
663  if (!ComputerName) return FALSE;
664 
665  memcpy(ComputerName, Hostname, len);
666  ComputerName[len + 1] = 0;
667  return TRUE;
668 }
669 
670 
671 /*
672  * @implemented
673  */
674 BOOL
675 WINAPI
677  LPWSTR computername,
678  LPDWORD size)
679 {
680  DWORD len;
681 
682  DPRINT("(%s, %p, %p): stub\n", hostname, computername, size);
683 
684  if (!hostname || !size) return FALSE;
685  len = lstrlenW(hostname);
686 
689 
690  if (*size < len)
691  {
692  *size = len;
693  return FALSE;
694  }
695  if (!computername) return FALSE;
696 
697  memcpy(computername, hostname, len * sizeof(WCHAR));
698  computername[len + 1] = 0;
699  return TRUE;
700 }
701 
702 DWORD
703 WINAPI
705 {
706  STUB;
707  return 0;
708 }
709 
710 DWORD
711 WINAPI
713 {
714  STUB;
715  return 0;
716 }
717 
718 DWORD
719 WINAPI
721 {
722  STUB;
724 }
725 
726 DWORD
727 WINAPI
729 {
730  STUB;
732 }
733 
734 DWORD
735 WINAPI
737 {
738  STUB;
740 }
741 
742 DWORD
743 WINAPI
745 {
746  STUB;
748 }
749 
750 /*
751  * @unimplemented
752  */
753 BOOL
754 WINAPI
756  IN DWORD Unknown2)
757 {
758  STUB;
759  return FALSE;
760 }
761 
762 /*
763  * @unimplemented
764  */
765 BOOL
766 WINAPI
768  IN DWORD Unknown2)
769 {
770  STUB;
771  return FALSE;
772 }
773 
774 
775 /* EOF */
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
* PNTSTATUS
Definition: strlen.c:14
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
Definition: rtlfuncs.h:4004
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
BOOL WINAPI SetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPCSTR lpBuffer)
Definition: compname.c:571
*BytesInUnicodeString PWCH UnicodeString
Definition: rtlfuncs.h:1980
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
BOOL WINAPI SetComputerNameW(LPCWSTR lpComputerName)
Definition: compname.c:560
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
LONG NTSTATUS
Definition: precomp.h:26
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2024
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
_In_ LPCSTR lpName
Definition: winbase.h:2729
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD WINAPI AddLocalAlternateComputerNameW(LPWSTR lpName, PNTSTATUS Status)
Definition: compname.c:712
uint16_t * PWCHAR
Definition: typedefs.h:54
BOOL WINAPI SetLocalPrimaryComputerNameA(IN DWORD Unknown1, IN DWORD Unknown2)
Definition: compname.c:755
BOOL WINAPI GetComputerNameA(LPSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:423
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:440
char * LPSTR
Definition: xmlstorage.h:182
#define lstrlenW
Definition: compat.h:407
_In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Reserved_ ULONG _In_opt_ PUNICODE_STRING _In_ ULONG _Out_opt_ PULONG Disposition
Definition: cmfuncs.h:50
BOOL WINAPI GetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPWSTR lpBuffer, LPDWORD nSize)
Definition: compname.c:213
char * hostname
Definition: ftp.c:88
DWORD WINAPI RemoveLocalAlternateComputerNameA(LPSTR lpName, DWORD Unknown)
Definition: compname.c:736
DWORD WINAPI EnumerateLocalComputerNamesW(PVOID pUnknown, DWORD Size, LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:728
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
unsigned int BOOL
Definition: ntddk_ex.h:94
static LPSTR PULONG lpnSize
Definition: secur32.c:50
static BOOL IsValidComputerName(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpComputerName)
Definition: compname.c:457
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
Definition: bufpool.h:45
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
const char * LPCSTR
Definition: xmlstorage.h:183
DWORD WINAPI EnumerateLocalComputerNamesA(PVOID pUnknown, DWORD Size, LPSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:720
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname, LPWSTR computername, LPDWORD size)
Definition: compname.c:676
_In_ PUNKNOWN pUnknown
Definition: drmk.h:76
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
NTSYSAPI NTSTATUS NTAPI NtQueryValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
BOOL WINAPI SetComputerNameA(LPCSTR lpComputerName)
Definition: compname.c:549
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:97
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ PNDIS_STRING _Out_ PNDIS_HANDLE SubKeyHandle
Definition: ndis.h:4723
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static BOOL SetActiveComputerNameToRegistry(LPCWSTR RegistryKey, LPCWSTR SubKey, LPCWSTR ValueNameStr, LPCWSTR lpBuffer)
Definition: compname.c:128
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
static BOOL SetComputerNameToRegistry(LPCWSTR RegistryKey, LPCWSTR ValueNameStr, LPCWSTR lpBuffer)
Definition: compname.c:489
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define RTL_REGISTRY_ABSOLUTE
Definition: nt_native.h:161
#define ERROR_MORE_DATA
Definition: dderror.h:13
LPWSTR lpComputerName
Definition: eventvwr.c:91
Status
Definition: gdiplustypes.h:24
#define MAXULONG
Definition: typedefs.h:250
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:240
ULONG_PTR SIZE_T
Definition: typedefs.h:78
DWORD WINAPI RemoveLocalAlternateComputerNameW(LPWSTR lpName, DWORD Unknown)
Definition: compname.c:744
#define _DIGIT
Definition: ctype.h:67
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
#define STUB
Definition: kernel32.h:27
unsigned short USHORT
Definition: pedump.c:61
struct _KEY_VALUE_PARTIAL_INFORMATION KEY_VALUE_PARTIAL_INFORMATION
NTSTATUS NTAPI NtFlushKey(IN HANDLE KeyHandle)
Definition: ntapi.c:1065
BOOL WINAPI SetLocalPrimaryComputerNameW(IN DWORD Unknown1, IN DWORD Unknown2)
Definition: compname.c:767
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
Definition: ntapi.c:859
DWORD WINAPI AddLocalAlternateComputerNameA(LPSTR lpName, PNTSTATUS Status)
Definition: compname.c:704
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
uint32_t * LPDWORD
Definition: typedefs.h:57
BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT NameType, LPSTR lpBuffer, LPDWORD nSize)
Definition: compname.c:370
unsigned int ULONG
Definition: retypes.h:1
#define _ALPHA
Definition: ctype.h:76
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 NameType
Definition: acpixf.h:648
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
static BOOL GetComputerNameFromRegistry(LPWSTR RegistryKey, LPWSTR ValueNameStr, LPWSTR lpBuffer, LPDWORD nSize)
Definition: compname.c:39
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
BOOL WINAPI SetComputerNameExW(COMPUTER_NAME_FORMAT NameType, LPCWSTR lpBuffer)
Definition: compname.c:592
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR Hostname, LPSTR ComputerName, LPDWORD nSize)
Definition: compname.c:641
#define REG_SZ
Definition: layer.c:22