Add support for specific EOI PIC command.
[wine] / dlls / kernel / computername.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  * Copyright 1999 Peter Ganten
6  * Copyright 2002 Martin Wilck
7  *
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.
12  *
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.
17  *
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "config.h"
24
25 #include <string.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29 #include <stdlib.h>
30 #include <errno.h>
31 #ifdef HAVE_NETDB_H
32 #include <netdb.h>
33 #endif
34
35 #include "winbase.h"
36 #include "winerror.h"
37 #include "winnls.h"
38 #include "winternl.h"
39 #include "wine/unicode.h"
40 #include "wine/exception.h"
41 #include "excpt.h"
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(computername);
45
46 /* Registry key and value names */
47 static const WCHAR ComputerW[] = {'M','a','c','h','i','n','e','\\',
48                                   'S','y','s','t','e','m','\\',
49                                   'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
50                                   'C','o','n','t','r','o','l','\\',
51                                   'C','o','m','p','u','t','e','r','N','a','m','e',0};
52 static const WCHAR ActiveComputerNameW[] =   {'A','c','t','i','v','e','C','o','m','p','u','t','e','r','N','a','m','e',0};
53 static const WCHAR ComputerNameW[] = {'C','o','m','p','u','t','e','r','N','a','m','e',0};
54
55 static const char default_ComputerName[] = "WINE";
56
57 #define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
58
59 /* filter for page-fault exceptions */
60 static WINE_EXCEPTION_FILTER(page_fault)
61 {
62     if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
63         return EXCEPTION_EXECUTE_HANDLER;
64     return EXCEPTION_CONTINUE_SEARCH;
65 }
66
67 /*********************************************************************** 
68  *                    dns_gethostbyname (INTERNAL)
69  *
70  *  From hostname(1):
71  *  "The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2)."
72  *
73  *  Wine can use this technique only if the thread-safe gethostbyname_r is available.
74  */
75 #ifdef  HAVE_LINUX_GETHOSTBYNAME_R_6
76 static BOOL dns_gethostbyname ( char *name, int *size )
77 {
78     struct hostent* host = NULL;
79     char *extrabuf;
80     int ebufsize = 1024;
81     struct hostent hostentry;
82     int locerr = ENOBUFS, res = ENOMEM;
83
84     extrabuf = HeapAlloc( GetProcessHeap(), 0, ebufsize ) ;
85
86     while( extrabuf ) 
87     {
88         res = gethostbyname_r ( name, &hostentry, extrabuf, ebufsize, &host, &locerr );
89         if( res != ERANGE ) break;
90         ebufsize *= 2;
91         extrabuf = HeapReAlloc( GetProcessHeap(), 0, extrabuf, ebufsize ) ;
92     }
93     
94     if ( res )
95         WARN ("Error in gethostbyname_r %d (%d)\n", res, locerr);
96     else
97     {
98         size_t len = strlen ( host->h_name );
99         if ( len < *size )
100         {
101             strcpy ( name, host->h_name );
102             *size = len;
103         }
104         else
105         {
106             memcpy ( name, host->h_name, *size );
107             name[*size] = 0;
108             SetLastError ( ERROR_MORE_DATA );
109             res = 1;
110         }
111     }
112
113     HeapFree( GetProcessHeap(), 0, extrabuf );
114     return !res;
115 }
116 #else
117 #  define dns_gethostbyname(name,size) 0
118 #endif
119
120 /*********************************************************************** 
121  *                     dns_fqdn (INTERNAL)
122  */
123 static BOOL dns_fqdn ( char *name, int *size )
124 {
125     if ( gethostname ( name, *size + 1 ) ) 
126     {
127         switch( errno )
128         {
129         case ENAMETOOLONG:
130             SetLastError ( ERROR_MORE_DATA );
131         default:
132             SetLastError ( ERROR_INVALID_PARAMETER );
133         }
134         return FALSE;
135     }
136
137     if ( !dns_gethostbyname ( name, size ) )
138         *size = strlen ( name );
139
140     return TRUE;
141 }
142
143 /*********************************************************************** 
144  *                     dns_hostname (INTERNAL)
145  */
146 static BOOL dns_hostname ( char *name, int *size )
147 {
148     char *c;
149     if ( ! dns_fqdn ( name, size ) ) return FALSE;
150     c = strchr ( name, '.' );
151     if (c)
152     {
153         *c = 0;
154         *size = (c - name);
155     }
156     return TRUE;
157 }
158
159 /*********************************************************************** 
160  *                     dns_domainname (INTERNAL)
161  */
162 static BOOL dns_domainname ( char *name, int *size )
163 {
164     char *c;
165     if ( ! dns_fqdn ( name, size ) ) return FALSE;
166     c = strchr ( name, '.' );
167     if (c)
168     {
169         c += 1;
170         *size -= (c - name);
171         memmove ( name, c, *size + 1 );
172     }
173     return TRUE;
174 }
175
176 /*********************************************************************** 
177  *                      _init_attr    (INTERNAL)
178  */
179 inline static void _init_attr ( OBJECT_ATTRIBUTES *attr, UNICODE_STRING *name )
180 {
181     attr->Length = sizeof (OBJECT_ATTRIBUTES);
182     attr->RootDirectory = 0;
183     attr->ObjectName = name;
184     attr->Attributes = 0;
185     attr->SecurityDescriptor = NULL;
186     attr->SecurityQualityOfService = NULL;
187 }
188
189 /***********************************************************************
190  *           get_use_dns_option
191  */
192 static BOOL get_use_dns_option(void)
193 {
194     static const WCHAR NetworkW[] = {'M','a','c','h','i','n','e','\\',
195                                   'S','o','f','t','w','a','r','e','\\',
196                                   'W','i','n','e','\\','W','i','n','e','\\',
197                                   'C','o','n','f','i','g','\\','N','e','t','w','o','r','k',0};
198     static const WCHAR UseDNSW[] = {'U','s','e','D','n','s','C','o','m','p','u','t','e','r','N','a','m','e',0};
199
200     char tmp[80];
201     HKEY hkey;
202     DWORD dummy;
203     OBJECT_ATTRIBUTES attr;
204     UNICODE_STRING nameW;
205     BOOL ret = TRUE;
206
207     _init_attr( &attr, &nameW );
208     RtlInitUnicodeString( &nameW, NetworkW );
209
210     if (!NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ))
211     {
212         RtlInitUnicodeString( &nameW, UseDNSW );
213         if (!NtQueryValueKey( hkey, &nameW, KeyValuePartialInformation, tmp, sizeof(tmp), &dummy ))
214         {
215             WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)tmp)->Data;
216             ret = IS_OPTION_TRUE( str[0] );
217         }
218         NtClose( hkey );
219     }
220     return ret;
221 }
222
223
224 /*********************************************************************** 
225  *                      COMPUTERNAME_Init    (INTERNAL)
226  */
227 void COMPUTERNAME_Init (void)
228 {
229     HKEY hkey = INVALID_HANDLE_VALUE, hsubkey = INVALID_HANDLE_VALUE;
230     OBJECT_ATTRIBUTES attr;
231     UNICODE_STRING nameW;
232     char buf[offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ) + (MAX_COMPUTERNAME_LENGTH + 1) * sizeof( WCHAR )];
233     DWORD len = sizeof( buf );
234     LPWSTR computer_name = (LPWSTR) (buf + offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ));
235     NTSTATUS st = STATUS_INTERNAL_ERROR;
236
237     TRACE("(void)\n");
238     _init_attr ( &attr, &nameW );
239     
240     RtlInitUnicodeString( &nameW, ComputerW );
241     if ( ( st = NtCreateKey( &hkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) ) != STATUS_SUCCESS )
242         goto out;
243     
244     attr.RootDirectory = hkey;
245     RtlInitUnicodeString( &nameW, ComputerNameW );
246     if ( (st = NtCreateKey( &hsubkey, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) ) != STATUS_SUCCESS )
247         goto out;
248     
249     st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len );
250
251     if ( st == STATUS_OBJECT_NAME_NOT_FOUND || ( st == STATUS_SUCCESS && get_use_dns_option()))
252     {
253         char hbuf[256];
254         int hlen = sizeof (hbuf);
255         char *dot;
256         TRACE( "retrieving Unix host name\n" );
257         if ( gethostname ( hbuf, hlen ) )
258         {
259             strcpy ( hbuf, default_ComputerName );
260             WARN( "gethostname() error: %d, using host name %s\n", errno, hbuf );
261         }
262         hbuf[MAX_COMPUTERNAME_LENGTH] = 0;
263         dot = strchr ( hbuf, '.' );
264         if ( dot ) *dot = 0;
265         hlen = strlen ( hbuf );
266         len = MultiByteToWideChar( CP_ACP, 0, hbuf, hlen + 1, computer_name, MAX_COMPUTERNAME_LENGTH + 1 )
267             * sizeof( WCHAR );
268         if ( NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, computer_name, len ) != STATUS_SUCCESS )
269             WARN ( "failed to set ComputerName" );
270     }
271     else if ( st == STATUS_SUCCESS)
272     {
273         len = (len - offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data ));
274         TRACE( "found in registry\n" );
275     }
276     else goto out;
277     
278     NtClose( hsubkey );
279     TRACE(" ComputerName: %s (%lu)\n", debugstr_w ( computer_name ), len / sizeof(WCHAR));
280
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;
285     
286     RtlInitUnicodeString( &nameW, ComputerNameW );
287     st = NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, computer_name, len );
288
289 out:
290     NtClose( hsubkey );
291     NtClose( hkey );
292
293     if ( st == STATUS_SUCCESS )
294         TRACE( "success\n" );
295     else
296     {
297         WARN( "status trying to set ComputerName: %lx\n", st );
298         SetLastError ( RtlNtStatusToDosError ( st ) );
299     }
300 }
301
302
303 /***********************************************************************
304  *              GetComputerNameW         (KERNEL32.@)
305  */
306 BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
307 {
308     UNICODE_STRING nameW;
309     OBJECT_ATTRIBUTES attr;
310     HKEY 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;
315     
316     TRACE ("%p %p\n", name, size);
317
318     _init_attr ( &attr, &nameW );
319     RtlInitUnicodeString( &nameW, ComputerW );
320     if ( ( st = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
321         goto out;
322          
323     attr.RootDirectory = hkey;
324     RtlInitUnicodeString( &nameW, ActiveComputerNameW );
325     if ( ( st = NtOpenKey( &hsubkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
326         goto out;
327     
328     RtlInitUnicodeString( &nameW, ComputerNameW );
329     if ( ( st = NtQueryValueKey( hsubkey, &nameW, KeyValuePartialInformation, buf, len, &len ) )
330          != STATUS_SUCCESS )
331         goto out;
332
333     len = (len -offsetof( KEY_VALUE_PARTIAL_INFORMATION, Data )) / sizeof (WCHAR) - 1;
334     TRACE ("ComputerName is %s (length %lu)\n", debugstr_w ( theName ), len);
335
336     __TRY
337     {
338         if ( *size < len )
339         {
340             memcpy ( name, theName, *size * sizeof (WCHAR) );
341             name[*size] = 0;
342             *size = len;
343             st = STATUS_MORE_ENTRIES;
344         }
345         else
346         {
347             memcpy ( name, theName, len * sizeof (WCHAR) );
348             name[len] = 0;
349             *size = len;
350             st = STATUS_SUCCESS;
351         }
352     }
353     __EXCEPT(page_fault)
354     {
355         st = STATUS_INVALID_PARAMETER;
356     }
357     __ENDTRY
358
359 out:
360     NtClose ( hsubkey );
361     NtClose ( hkey );
362
363     if ( st == STATUS_SUCCESS )
364         return TRUE;
365     else
366     {
367         SetLastError ( RtlNtStatusToDosError ( st ) );
368         WARN ( "Status %lu reading computer name from registry\n", st );
369         return FALSE;
370     }
371 }
372
373 /***********************************************************************
374  *              GetComputerNameA         (KERNEL32.@)
375  */
376 BOOL WINAPI GetComputerNameA(LPSTR name, LPDWORD size)
377 {
378     WCHAR nameW[ MAX_COMPUTERNAME_LENGTH + 1 ];
379     DWORD sizeW = MAX_COMPUTERNAME_LENGTH;
380     int len;
381     BOOL ret;
382
383     if ( !GetComputerNameW (nameW, &sizeW) ) return FALSE;
384
385     len = WideCharToMultiByte ( CP_ACP, 0, nameW, sizeW, NULL, 0, NULL, 0 );
386     __TRY
387     {
388         if ( *size < len )
389         {
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;
395         }
396         else 
397         {
398             WideCharToMultiByte ( CP_ACP, 0, nameW, sizeW, name, len, NULL, 0 );
399             name[len] = 0;
400             *size = len;
401             ret = TRUE;
402         }
403     }
404     __EXCEPT(page_fault)
405     {
406         SetLastError( ERROR_INVALID_PARAMETER );
407         ret = FALSE;
408     }
409     __ENDTRY
410
411     return ret;
412 }
413
414 /***********************************************************************
415  *              GetComputerNameExA         (KERNEL32.@)
416  */
417 BOOL WINAPI GetComputerNameExA(COMPUTER_NAME_FORMAT type, LPSTR name, LPDWORD size)
418 {
419     char buf[256];
420     int len = sizeof (buf), ret;
421     TRACE("%d, %p, %p\n", type, name, size);
422     switch( type )
423     {
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;
442     }
443
444     if ( ret )
445     {
446         TRACE ("-> %s (%d)\n", debugstr_a (buf), len);
447         __TRY
448         {
449             if ( *size < len )
450             {
451                 memcpy( name, buf, *size );
452                 name[*size] = 0;
453                 *size = len;
454                 SetLastError( ERROR_MORE_DATA );
455                 ret = FALSE;
456             }
457             else
458             {
459                 memcpy( name, buf, len );
460                 name[len] = 0;
461                 *size = len;
462                 ret = TRUE;
463             }
464         }
465         __EXCEPT(page_fault)
466         {
467             SetLastError( ERROR_INVALID_PARAMETER );
468             return FALSE;
469         }
470         __ENDTRY
471     }
472
473     return ret;
474 }
475
476
477 /***********************************************************************
478  *              GetComputerNameExW         (KERNEL32.@)
479  */
480 BOOL WINAPI GetComputerNameExW( COMPUTER_NAME_FORMAT type, LPWSTR name, LPDWORD size )
481 {
482     char buf[256];
483     int len = sizeof (buf), ret;
484
485     TRACE("%d, %p, %p\n", type, name, size);
486     switch( type )
487     {
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;
506     }
507
508     if ( ret )
509     {
510         TRACE ("-> %s (%d)\n", debugstr_a (buf), len);
511         __TRY
512         {
513             int lenW = MultiByteToWideChar( CP_ACP, 0, buf, len, NULL, 0 );
514             if ( *size < lenW )
515             {
516                 MultiByteToWideChar( CP_ACP, 0, buf, len, name, *size );
517                 name[*size] = 0;
518                 *size = lenW;
519                 SetLastError( ERROR_MORE_DATA );
520                 ret = FALSE;
521             }
522             else
523             {
524                 MultiByteToWideChar( CP_ACP, 0, buf, len, name, lenW );
525                 name[lenW] = 0;
526                 *size = lenW;
527                 ret = TRUE;
528             }
529         }
530         __EXCEPT(page_fault)
531         {
532             SetLastError( ERROR_INVALID_PARAMETER );
533             return FALSE;
534         }
535         __ENDTRY
536     }
537
538     return ret;
539 }
540
541 /******************************************************************************
542  * netbios_char (INTERNAL)
543  */
544 static WCHAR netbios_char ( WCHAR wc )
545 {
546     static const WCHAR special[] = {'!','@','#','$','%','^','&','\'',')','(','-','_','{','}','~'};
547     static const WCHAR deflt = '_';
548     int i;
549     
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;
554 }
555
556 /******************************************************************************
557  * SetComputerNameW [KERNEL32.@]
558  *
559  * PARAMS
560  *    lpComputerName [I] Address of new computer name
561  *
562  * RETURNS STD
563  */
564 BOOL WINAPI SetComputerNameW( LPCWSTR lpComputerName )
565 {
566     UNICODE_STRING nameW;
567     OBJECT_ATTRIBUTES attr;
568     HKEY hkey = INVALID_HANDLE_VALUE, hsubkey = INVALID_HANDLE_VALUE;
569     int plen = strlenW ( lpComputerName );
570     int i;
571     NTSTATUS st = STATUS_INTERNAL_ERROR;
572
573     if (get_use_dns_option())
574     {
575         /* This check isn't necessary, but may help debugging problems. */
576         WARN( "Disabled by Wine Configuration.\n" );
577         WARN( "Set \"UseDnsComputerName\" = \"N\" in category [Network] to enable.\n" );
578         SetLastError ( ERROR_ACCESS_DENIED );
579         return FALSE;
580     }
581
582     TRACE( "%s\n", debugstr_w (lpComputerName) );
583
584     /* Check parameter */
585     if ( plen > MAX_COMPUTERNAME_LENGTH ) 
586         goto out;
587
588     /* This is NT behaviour. Win 95/98 would coerce characters. */
589     for ( i = 0; i < plen; i++ )
590     {
591         WCHAR wc = lpComputerName[i];
592         if ( wc != netbios_char( wc ) )
593             goto out;
594     }
595     
596     _init_attr ( &attr, &nameW );
597     
598     RtlInitUnicodeString (&nameW, ComputerW);
599     if ( ( st = NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
600         goto out;
601     attr.RootDirectory = hkey;
602     RtlInitUnicodeString( &nameW, ComputerNameW );
603     if ( ( st = NtOpenKey( &hsubkey, KEY_ALL_ACCESS, &attr ) ) != STATUS_SUCCESS )
604         goto out;
605     if ( ( st = NtSetValueKey( hsubkey, &nameW, 0, REG_SZ, lpComputerName, ( plen + 1) * sizeof(WCHAR) ) )
606          != STATUS_SUCCESS )
607         goto out;
608
609 out:
610     NtClose( hsubkey );
611     NtClose( hkey );
612     
613     if ( st == STATUS_SUCCESS )
614     {
615         TRACE( "ComputerName changed\n" );
616         return TRUE;
617     }
618
619     else
620     {
621         SetLastError ( RtlNtStatusToDosError ( st ) );
622         WARN ( "status %lu\n", st );
623         return FALSE;
624     }
625 }
626
627 /******************************************************************************
628  * SetComputerNameA [KERNEL32.@]
629  */
630 BOOL WINAPI SetComputerNameA( LPCSTR lpComputerName )
631 {
632     BOOL ret;
633     DWORD len = MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, NULL, 0 );
634     LPWSTR nameW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
635
636     MultiByteToWideChar( CP_ACP, 0, lpComputerName, -1, nameW, len );
637     ret = SetComputerNameW( nameW );
638     HeapFree( GetProcessHeap(), 0, nameW );
639     return ret;
640 }
641
642 /******************************************************************************
643  * SetComputerNameExW [KERNEL32.@]
644  *
645  */
646 BOOL WINAPI SetComputerNameExW( COMPUTER_NAME_FORMAT type, LPCWSTR lpComputerName )
647 {
648     TRACE("%d, %s\n", type, debugstr_w (lpComputerName));
649     switch( type )
650     {
651     case ComputerNameNetBIOS:
652     case ComputerNamePhysicalNetBIOS:
653         return SetComputerNameW( lpComputerName );
654     default:
655         SetLastError( ERROR_ACCESS_DENIED );
656         return FALSE;
657     }
658 }
659
660 /******************************************************************************
661  * SetComputerNameExA [KERNEL32.@]
662  *
663  */
664 BOOL WINAPI SetComputerNameExA( COMPUTER_NAME_FORMAT type, LPCSTR lpComputerName )
665 {
666     TRACE( "%d, %s\n", type, debugstr_a (lpComputerName) );
667     switch( type )
668     {
669     case ComputerNameNetBIOS:
670     case ComputerNamePhysicalNetBIOS:
671         return SetComputerNameA( lpComputerName );
672     default:
673         SetLastError( ERROR_ACCESS_DENIED );
674         return FALSE;
675     }
676 }
677
678 /***********************************************************************
679  *              DnsHostnameToComputerNameA         (KERNEL32.@)
680  */
681 BOOL WINAPI DnsHostnameToComputerNameA(LPCSTR Hostname, LPSTR ComputerName,
682                               LPDWORD nSize)
683 {
684     FIXME("(%s, %s, %08lx): stub\n", debugstr_a(Hostname),
685           debugstr_a(ComputerName), *nSize);
686     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
687     return FALSE;
688 }
689
690 /***********************************************************************
691  *              DnsHostnameToComputerNameW         (KERNEL32.@)
692  */
693 BOOL WINAPI DnsHostnameToComputerNameW(LPCWSTR Hostname, LPWSTR ComputerName,
694                               LPDWORD nSize)
695 {
696     FIXME("(%s, %s, %08lx): stub\n", debugstr_w(Hostname),
697           debugstr_w(ComputerName), *nSize);
698     SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
699     return FALSE;
700 }