winedump: Larger usage of symbol demangling while dumping.
[wine/wine64.git] / dlls / kernel32 / computername.c
blob4683f1135ac3f88343ecf34f2b1c09b7bd5fc89f
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 * Copyright 1999 Peter Ganten
6 * Copyright 2002 Martin Wilck
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "config.h"
24 #include "wine/port.h"
26 #include <stdarg.h>
27 #include <string.h>
28 #ifdef HAVE_UNISTD_H
29 # include <unistd.h>
30 #endif
31 #include <stdlib.h>
32 #include <errno.h>
33 #ifdef HAVE_NETDB_H
34 #include <netdb.h>
35 #endif
37 #include "ntstatus.h"
38 #define WIN32_NO_STATUS
39 #include "windef.h"
40 #include "winbase.h"
41 #include "winerror.h"
42 #include "winnls.h"
43 #include "winternl.h"
44 #include "wine/unicode.h"
45 #include "wine/exception.h"
46 #include "excpt.h"
47 #include "wine/debug.h"
49 #include "kernel_private.h"
51 WINE_DEFAULT_DEBUG_CHANNEL(computername);
53 /* Registry key and value names */
54 static const WCHAR ComputerW[] = {'M','a','c','h','i','n','e','\\',
55 'S','y','s','t','e','m','\\',
56 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
57 'C','o','n','t','r','o','l','\\',
58 'C','o','m','p','u','t','e','r','N','a','m','e',0};
59 static const WCHAR ActiveComputerNameW[] = {'A','c','t','i','v','e','C','o','m','p','u','t','e','r','N','a','m','e',0};
60 static const WCHAR ComputerNameW[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
62 static const char default_ComputerName[] = "WINE";
64 #define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
66 /***********************************************************************
67 * dns_gethostbyname (INTERNAL)
69 * From hostname(1):
70 * "The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2)."
72 * Wine can use this technique only if the thread-safe gethostbyname_r is available.
74 #ifdef HAVE_LINUX_GETHOSTBYNAME_R_6
75 static BOOL dns_gethostbyname ( char *name, int *size )
77 struct hostent* host = NULL;
78 char *extrabuf;
79 int ebufsize = 1024;
80 struct hostent hostentry;
81 int locerr = ENOBUFS, res = ENOMEM;
83 extrabuf = HeapAlloc( GetProcessHeap(), 0, ebufsize ) ;
85 while( extrabuf )
87 res = gethostbyname_r ( name, &hostentry, extrabuf, ebufsize, &host, &locerr );
88 if( res != ERANGE ) break;
89 ebufsize *= 2;
90 extrabuf = HeapReAlloc( GetProcessHeap(), 0, extrabuf, ebufsize ) ;
93 if ( res )
94 WARN ("Error in gethostbyname_r %d (%d)\n", res, locerr);
95 else
97 int len = strlen ( host->h_name );
98 if ( len < *size )
100 strcpy ( name, host->h_name );
101 *size = len;
103 else
105 memcpy ( name, host->h_name, *size );
106 name[*size] = 0;
107 SetLastError ( ERROR_MORE_DATA );
108 res = 1;
112 HeapFree( GetProcessHeap(), 0, extrabuf );
113 return !res;
115 #else
116 # define dns_gethostbyname(name,size) 0
117 #endif
119 /***********************************************************************
120 * dns_fqdn (INTERNAL)
122 static BOOL dns_fqdn ( char *name, int *size )
124 if ( gethostname ( name, *size + 1 ) )
126 switch( errno )
128 case ENAMETOOLONG:
129 SetLastError ( ERROR_MORE_DATA );
130 default:
131 SetLastError ( ERROR_INVALID_PARAMETER );
133 return FALSE;
136 if ( !dns_gethostbyname ( name, size ) )
137 *size = strlen ( name );
139 return TRUE;
142 /***********************************************************************
143 * dns_hostname (INTERNAL)
145 static BOOL dns_hostname ( char *name, int *size )
147 char *c;
148 if ( ! dns_fqdn ( name, size ) ) return FALSE;
149 c = strchr ( name, '.' );
150 if (c)
152 *c = 0;
153 *size = (c - name);
155 return TRUE;
158 /***********************************************************************
159 * dns_domainname (INTERNAL)
161 static BOOL dns_domainname ( char *name, int *size )
163 char *c;
164 if ( ! dns_fqdn ( name, size ) ) return FALSE;
165 c = strchr ( name, '.' );
166 if (c)
168 c += 1;
169 *size -= (c - name);
170 memmove ( name, c, *size + 1 );
172 return TRUE;
175 /***********************************************************************
176 * _init_attr (INTERNAL)
178 inline static void _init_attr ( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *name )
180 attr->Length = sizeof (OBJECT_ATTRIBUTES);
181 attr->RootDirectory = 0;
182 attr->ObjectName = name;
183 attr->Attributes = 0;
184 attr->SecurityDescriptor = NULL;
185 attr->SecurityQualityOfService = NULL;
188 /***********************************************************************
189 * get_use_dns_option
191 static BOOL get_use_dns_option(void)
193 static const WCHAR NetworkW[] = {'S','o','f','t','w','a','r','e','\\',
194 'W','i','n','e','\\','N','e','t','w','o','r','k',0};
195 static const WCHAR UseDNSW[] = {'U','s','e','D','n','s','C','o','m','p','u','t','e','r','N','a','m','e',0};
197 char tmp[80];
198 HANDLE root, hkey;
199 DWORD dummy;
200 OBJECT_ATTRIBUTES attr;
201 UNICODE_STRING nameW;
202 BOOL ret = TRUE;
204 _init_attr( &attr, &nameW );
205 RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
206 attr.RootDirectory = root;
207 RtlInitUnicodeString( &nameW, NetworkW );
209 /* @@ Wine registry key: HKCU\Software\Wine\Network */
210 if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
212 RtlInitUnicodeString( &nameW, UseDNSW );
213 if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
215 WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
216 ret = IS_OPTION_TRUE( str[0] );
218 NtClose( hkey );
220 NtClose( root );
221 return ret;
225 /***********************************************************************
226 * COMPUTERNAME_Init (INTERNAL)
228 void COMPUTERNAME_Init (void)
230 HANDLE hkey = INVALID_HANDLE_VALUE, hsubkey = INVALID_HANDLE_VALUE;
231 OBJECT_ATTRIBUTES attr;
232 UNICODE_STRING nameW;
233 char buf[offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ) + (MAX_COMPUTERNAME_LENGTH + 1) * sizeof( WCHAR )];
234 DWORD len = sizeof( buf );
235 LPWSTR computer_name = (LPWSTR) (buf + offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ));
236 NTSTATUS st = STATUS_INTERNAL_ERROR;
238 TRACE("(void)\n");
239 _init_attr ( &attr, &nameW );
241 RtlInitUnicodeString( &nameW, ComputerW );
242 if ( ( st = NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) ) != STATUS_SUCCESS )
243 goto out;
245 attr.RootDirectory = hkey;
246 RtlInitUnicodeString( &nameW, ComputerNameW );
247 if ( (st = NtCreateKey( &hsubkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) ) != STATUS_SUCCESS )
248 goto out;
250 st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len );
252 if ( st != STATUS_SUCCESS || get_use_dns_option() )
254 char hbuf[256];
255 int hlen = sizeof (hbuf);
256 char *dot;
257 TRACE( "retrieving Unix host name\n" );
258 if ( gethostname ( hbuf, hlen ) )
260 strcpy ( hbuf, default_ComputerName );
261 WARN( "gethostname() error: %d, using host name %s\n", errno, hbuf );
263 hbuf[MAX_COMPUTERNAME_LENGTH] = 0;
264 dot = strchr ( hbuf, '.' );
265 if ( dot ) *dot = 0;
266 hlen = strlen ( hbuf );
267 len = MultiByteToWideChar( CP_ACP, 0, hbuf, hlen + 1, computer_name, MAX_COMPUTERNAME_LENGTH + 1 )
268 * sizeof( WCHAR );
269 if ( NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, computer_name, len ) != STATUS_SUCCESS )
270 WARN ( "failed to set ComputerName\n" );
272 else
274 len = (len - offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ));
275 TRACE( "found in registry\n" );
278 NtClose( hsubkey );
279 TRACE(" ComputerName: %s (%u)\n", debugstr_w (computer_name), len);
281 RtlInitUnicodeString( &nameW, ActiveComputerNameW );
282 if ( ( st = NtCreateKey( &hsubkey, KEY_ALL_ACCESS, &attr, 0, NULL, REG_OPTION_VOLATILE, NULL ) )
283 != STATUS_SUCCESS )
284 goto out;
286 RtlInitUnicodeString( &nameW, ComputerNameW );
287 st = NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, computer_name, len );
289 out:
290 NtClose( hsubkey );
291 NtClose( hkey );
293 if ( st == STATUS_SUCCESS )
294 TRACE( "success\n" );
295 else
297 WARN( "status trying to set ComputerName: %x\n", st );
298 SetLastError ( RtlNtStatusToDosError ( st ) );
303 /***********************************************************************
304 * GetComputerNameW (KERNEL32.@)
306 BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
308 UNICODE_STRING nameW;
309 OBJECT_ATTRIBUTES attr;
310 HANDLE hkey = INVALID_HANDLE_VALUE, hsubkey = INVALID_HANDLE_VALUE;
311 char buf[offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ) + (MAX_COMPUTERNAME_LENGTH + 1) * sizeof( WCHAR )];
312 DWORD len = sizeof( buf );
313 LPWSTR theName = (LPWSTR) (buf + offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ));
314 NTSTATUS st = STATUS_INVALID_PARAMETER;
316 TRACE ("%p %p\n", name, size);
318 _init_attr ( &attr, &nameW );
319 RtlInitUnicodeString( &nameW, ComputerW );
320 if ( ( st = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
321 goto out;
323 attr.RootDirectory = hkey;
324 RtlInitUnicodeString( &nameW, ActiveComputerNameW );
325 if ( ( st = NtOpenKey( &hsubkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
326 goto out;
328 RtlInitUnicodeString( &nameW, ComputerNameW );
329 if ( ( st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len ) )
330 != STATUS_SUCCESS )
331 goto out;
333 len = (len -offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data )) / sizeof (WCHAR) - 1;
334 TRACE ("ComputerName is %s (length %u)\n", debugstr_w ( theName ), len);
336 __TRY
338 if ( *size < len )
340 memcpy ( name, theName, *size * sizeof (WCHAR) );
341 name[*size] = 0;
342 *size = len;
343 st = STATUS_MORE_ENTRIES;
345 else
347 memcpy ( name, theName, len * sizeof (WCHAR) );
348 name[len] = 0;
349 *size = len;
350 st = STATUS_SUCCESS;
353 __EXCEPT_PAGE_FAULT
355 st = STATUS_INVALID_PARAMETER;
357 __ENDTRY
359 out:
360 NtClose ( hsubkey );
361 NtClose ( hkey );
363 if ( st == STATUS_SUCCESS )
364 return TRUE;
365 else
367 SetLastError ( RtlNtStatusToDosError ( st ) );
368 WARN ( "Status %u reading computer name from registry\n", st );
369 return FALSE;
373 /***********************************************************************
374 * GetComputerNameA (KERNEL32.@)
376 BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
378 WCHAR nameW[ MAX_COMPUTERNAME_LENGTH + 1 ];
379 DWORD sizeW = MAX_COMPUTERNAME_LENGTH;
380 unsigned int len;
381 BOOL ret;
383 if ( !GetComputerNameW (nameW, &sizeW) ) return FALSE;
385 len = WideCharToMultiByte ( CP_ACP, 0, nameW, sizeW, NULL, 0, NULL, 0 );
386 __TRY
388 if ( *size < len )
390 WideCharToMultiByte ( CP_ACP, 0, nameW, sizeW, name, *size, NULL, 0 );
391 name[*size] = 0;
392 *size = len;
393 SetLastError( ERROR_MORE_DATA );
394 ret = FALSE;
396 else
398 WideCharToMultiByte ( CP_ACP, 0, nameW, sizeW, name, len, NULL, 0 );
399 name[len] = 0;
400 *size = len;
401 ret = TRUE;
404 __EXCEPT_PAGE_FAULT
406 SetLastError( ERROR_INVALID_PARAMETER );
407 ret = FALSE;
409 __ENDTRY
411 return ret;
414 /***********************************************************************
415 * GetComputerNameExA (KERNEL32.@)
417 BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD size)
419 char buf[256];
420 int len = sizeof (buf), ret;
421 TRACE("%d, %p, %p\n", type, name, size);
422 switch( type )
424 case ComputerNameNetBIOS:
425 case ComputerNamePhysicalNetBIOS:
426 return GetComputerNameA (name, size);
427 case ComputerNameDnsHostname:
428 case ComputerNamePhysicalDnsHostname:
429 ret = dns_hostname (buf, &len);
430 break;
431 case ComputerNameDnsDomain:
432 case ComputerNamePhysicalDnsDomain:
433 ret = dns_domainname (buf, &len);
434 break;
435 case ComputerNameDnsFullyQualified:
436 case ComputerNamePhysicalDnsFullyQualified:
437 ret = dns_fqdn (buf, &len);
438 break;
439 default:
440 SetLastError (ERROR_INVALID_PARAMETER);
441 return FALSE;
444 if ( ret )
446 TRACE ("-> %s (%d)\n", debugstr_a (buf), len);
447 __TRY
449 if ( *size < len )
451 memcpy( name, buf, *size );
452 name[*size] = 0;
453 *size = len;
454 SetLastError( ERROR_MORE_DATA );
455 ret = FALSE;
457 else
459 memcpy( name, buf, len );
460 name[len] = 0;
461 *size = len;
462 ret = TRUE;
465 __EXCEPT_PAGE_FAULT
467 SetLastError( ERROR_INVALID_PARAMETER );
468 return FALSE;
470 __ENDTRY
473 return ret;
477 /***********************************************************************
478 * GetComputerNameExW (KERNEL32.@)
480 BOOL WINAPI GetComputerNameExW( COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD size )
482 char buf[256];
483 int len = sizeof (buf), ret;
485 TRACE("%d, %p, %p\n", type, name, size);
486 switch( type )
488 case ComputerNameNetBIOS:
489 case ComputerNamePhysicalNetBIOS:
490 return GetComputerNameW (name, size);
491 case ComputerNameDnsHostname:
492 case ComputerNamePhysicalDnsHostname:
493 ret = dns_hostname (buf, &len);
494 break;
495 case ComputerNameDnsDomain:
496 case ComputerNamePhysicalDnsDomain:
497 ret = dns_domainname (buf, &len);
498 break;
499 case ComputerNameDnsFullyQualified:
500 case ComputerNamePhysicalDnsFullyQualified:
501 ret = dns_fqdn (buf, &len);
502 break;
503 default:
504 SetLastError (ERROR_INVALID_PARAMETER);
505 return FALSE;
508 if ( ret )
510 TRACE ("-> %s (%d)\n", debugstr_a (buf), len);
511 __TRY
513 unsigned int lenW = MultiByteToWideChar( CP_ACP, 0, buf, len, NULL, 0 );
514 if ( *size < lenW )
516 MultiByteToWideChar( CP_ACP, 0, buf, len, name, *size );
517 name[*size] = 0;
518 *size = lenW;
519 SetLastError( ERROR_MORE_DATA );
520 ret = FALSE;
522 else
524 MultiByteToWideChar( CP_ACP, 0, buf, len, name, lenW );
525 name[lenW] = 0;
526 *size = lenW;
527 ret = TRUE;
530 __EXCEPT_PAGE_FAULT
532 SetLastError( ERROR_INVALID_PARAMETER );
533 return FALSE;
535 __ENDTRY
538 return ret;
541 /******************************************************************************
542 * netbios_char (INTERNAL)
544 static WCHAR netbios_char ( WCHAR wc )
546 static const WCHAR special[] = {'!','@','#','$','%','^','&','\'',')','(','-','_','{','}','~'};
547 static const WCHAR deflt = '_';
548 unsigned int i;
550 if ( isalnumW ( wc ) ) return wc;
551 for ( i = 0; i < sizeof (special) / sizeof (WCHAR); i++ )
552 if ( wc == special[i] ) return wc;
553 return deflt;
556 /******************************************************************************
557 * SetComputerNameW [KERNEL32.@]
559 * Set a new NetBIOS name for the local computer.
561 * PARAMS
562 * lpComputerName [I] Address of new computer name
564 * RETURNS
565 * Success: TRUE
566 * Failure: FALSE
568 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
570 UNICODE_STRING nameW;
571 OBJECT_ATTRIBUTES attr;
572 HANDLE hkey = INVALID_HANDLE_VALUE, hsubkey = INVALID_HANDLE_VALUE;
573 int plen = strlenW ( lpComputerName );
574 int i;
575 NTSTATUS st = STATUS_INTERNAL_ERROR;
577 if (get_use_dns_option())
579 /* This check isn't necessary, but may help debugging problems. */
580 WARN( "Disabled by Wine Configuration.\n" );
581 WARN( "Set \"UseDnsComputerName\" = \"N\" in category [Network] to enable.\n" );
582 SetLastError ( ERROR_ACCESS_DENIED );
583 return FALSE;
586 TRACE( "%s\n", debugstr_w (lpComputerName) );
588 /* Check parameter */
589 if ( plen > MAX_COMPUTERNAME_LENGTH )
590 goto out;
592 /* This is NT behaviour. Win 95/98 would coerce characters. */
593 for ( i = 0; i < plen; i++ )
595 WCHAR wc = lpComputerName[i];
596 if ( wc != netbios_char( wc ) )
597 goto out;
600 _init_attr ( &attr, &nameW );
602 RtlInitUnicodeString (&nameW, ComputerW);
603 if ( ( st = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
604 goto out;
605 attr.RootDirectory = hkey;
606 RtlInitUnicodeString( &nameW, ComputerNameW );
607 if ( ( st = NtOpenKey( &hsubkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
608 goto out;
609 if ( ( st = NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, lpComputerName, ( plen + 1) * sizeof(WCHAR) ) )
610 != STATUS_SUCCESS )
611 goto out;
613 out:
614 NtClose( hsubkey );
615 NtClose( hkey );
617 if ( st == STATUS_SUCCESS )
619 TRACE( "ComputerName changed\n" );
620 return TRUE;
623 else
625 SetLastError ( RtlNtStatusToDosError ( st ) );
626 WARN ( "status %u\n", st );
627 return FALSE;
631 /******************************************************************************
632 * SetComputerNameA [KERNEL32.@]
634 * See SetComputerNameW.
636 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
638 BOOL ret;
639 DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
640 LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
642 MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
643 ret = SetComputerNameW( nameW );
644 HeapFree( GetProcessHeap(), 0, nameW );
645 return ret;
648 /******************************************************************************
649 * SetComputerNameExW [KERNEL32.@]
652 BOOL WINAPI SetComputerNameExW( COMPUTER_NAME_FORMAT type, LPCWSTR lpComputerName )
654 TRACE("%d, %s\n", type, debugstr_w (lpComputerName));
655 switch( type )
657 case ComputerNameNetBIOS:
658 case ComputerNamePhysicalNetBIOS:
659 return SetComputerNameW( lpComputerName );
660 default:
661 SetLastError( ERROR_ACCESS_DENIED );
662 return FALSE;
666 /******************************************************************************
667 * SetComputerNameExA [KERNEL32.@]
670 BOOL WINAPI SetComputerNameExA( COMPUTER_NAME_FORMAT type, LPCSTR lpComputerName )
672 TRACE( "%d, %s\n", type, debugstr_a (lpComputerName) );
673 switch( type )
675 case ComputerNameNetBIOS:
676 case ComputerNamePhysicalNetBIOS:
677 return SetComputerNameA( lpComputerName );
678 default:
679 SetLastError( ERROR_ACCESS_DENIED );
680 return FALSE;
684 /***********************************************************************
685 * DnsHostnameToComputerNameA (KERNEL32.@)
687 BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR hostname,
688 LPSTR computername, LPDWORD size)
690 DWORD len;
692 FIXME("(%s, %p, %p): stub\n", debugstr_a(hostname), computername, size);
694 if (!hostname || !size) return FALSE;
695 len = lstrlenA(hostname);
697 if (len > MAX_COMPUTERNAME_LENGTH)
698 len = MAX_COMPUTERNAME_LENGTH;
700 if (*size < len)
702 *size = len;
703 return FALSE;
705 if (!computername) return FALSE;
707 memcpy( computername, hostname, len );
708 computername[len + 1] = 0;
709 return TRUE;
712 /***********************************************************************
713 * DnsHostnameToComputerNameW (KERNEL32.@)
715 BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR hostname,
716 LPWSTR computername, LPDWORD size)
718 DWORD len;
720 FIXME("(%s, %p, %p): stub\n", debugstr_w(hostname), computername, size);
722 if (!hostname || !size) return FALSE;
723 len = lstrlenW(hostname);
725 if (len > MAX_COMPUTERNAME_LENGTH)
726 len = MAX_COMPUTERNAME_LENGTH;
728 if (*size < len)
730 *size = len;
731 return FALSE;
733 if (!computername) return FALSE;
735 memcpy( computername, hostname, len * sizeof(WCHAR) );
736 computername[len + 1] = 0;
737 return TRUE;