HANDLER_ROUTINE is in fact PHANDLER_ROUTINE.
[wine] / win32 / init.c
1 /*
2  * Win32 kernel functions
3  *
4  * Copyright 1995 Martin von Loewis and Cameron Heide
5  * 1999 Peter Ganten
6  */
7
8 #include <string.h>
9 #include <unistd.h>
10 #include <stdlib.h>
11 #include "winnls.h"
12 #include "winbase.h"
13 #include "winerror.h"
14 #include "wine/exception.h"
15 #include "debugtools.h"
16
17 DEFAULT_DEBUG_CHANNEL(win32);
18   
19 /* filter for page-fault exceptions */
20 static WINE_EXCEPTION_FILTER(page_fault)
21 {
22     if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION)
23         return EXCEPTION_EXECUTE_HANDLER;
24     return EXCEPTION_CONTINUE_SEARCH;
25 }
26
27 /***********************************************************************
28  *              GetComputerNameA         (KERNEL32.@)
29  */
30 BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size)
31 {
32     /* At least Win95OSR2 survives if size is not a pointer (NT crashes though) */
33     BOOL ret;
34     __TRY
35     {
36       ret = (-1!=gethostname(name,*size));
37       if (ret)
38         *size = strlen(name);
39     }
40     __EXCEPT(page_fault)
41     {
42       SetLastError( ERROR_INVALID_PARAMETER );
43       return FALSE;
44     }
45     __ENDTRY
46      
47     return ret;
48 }
49
50 /***********************************************************************
51  *              GetComputerNameW         (KERNEL32.@)
52  */
53 BOOL WINAPI GetComputerNameW(LPWSTR name,LPDWORD size)
54 {
55     LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
56     BOOL ret = GetComputerNameA(nameA,size);
57     /* FIXME: should set *size in Unicode chars */
58     if (ret) MultiByteToWideChar( CP_ACP, 0, nameA, -1, name, *size+1 );
59     HeapFree( GetProcessHeap(), 0, nameA );
60     return ret;
61 }
62