2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
20 /* The global error value
24 /***********************************************************************
25 * GetModuleHandle (KERNEL32.237)
27 HMODULE32 WIN32_GetModuleHandleA(char *module)
31 dprintf_win32(stddeb, "GetModuleHandleA: %s\n", module ? module : "NULL");
32 /* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
33 all calls to e.g. CreateWindowEx. */
35 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
36 hModule = pTask->hInstance;
38 hModule = GetModuleHandle(module);
39 dprintf_win32(stddeb, "GetModuleHandleA: returning %d\n", hModule );
43 HMODULE32 WIN32_GetModuleHandleW(LPCWSTR module)
46 LPSTR modulea = HEAP_strdupWtoA( GetProcessHeap(), 0, module );
47 hModule = WIN32_GetModuleHandleA( modulea );
48 HeapFree( GetProcessHeap(), 0, modulea );
53 /***********************************************************************
54 * GetStartupInfoA (KERNEL32.273)
56 VOID GetStartupInfo32A(LPSTARTUPINFO32A lpStartupInfo)
58 lpStartupInfo->cb = sizeof(STARTUPINFO32A);
59 lpStartupInfo->lpReserved = "<Reserved>";
60 lpStartupInfo->lpDesktop = "Desktop";
61 lpStartupInfo->lpTitle = "Title";
63 lpStartupInfo->cbReserved2 = 0;
64 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
65 lpStartupInfo->hStdInput = (HANDLE32)0;
66 lpStartupInfo->hStdOutput = (HANDLE32)1;
67 lpStartupInfo->hStdError = (HANDLE32)2;
70 /***********************************************************************
71 * GetStartupInfoW (KERNEL32.274)
73 VOID GetStartupInfo32W(LPSTARTUPINFO32W lpStartupInfo)
75 lpStartupInfo->cb = sizeof(STARTUPINFO32W);
76 lpStartupInfo->lpReserved = HEAP_strdupAtoW(GetProcessHeap(),0,"<Reserved>");
77 lpStartupInfo->lpDesktop = HEAP_strdupAtoW(GetProcessHeap(), 0, "Desktop");
78 lpStartupInfo->lpTitle = HEAP_strdupAtoW(GetProcessHeap(), 0, "Title");
80 lpStartupInfo->cbReserved2 = 0;
81 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
82 lpStartupInfo->hStdInput = (HANDLE32)0;
83 lpStartupInfo->hStdOutput = (HANDLE32)1;
84 lpStartupInfo->hStdError = (HANDLE32)2;
87 /***********************************************************************
88 * GetStartupInfoA (KERNEL32.284)
89 * FIXME: perhaps supply better values.
90 * add other architectures for WINELIB.
93 GetSystemInfo(LPSYSTEM_INFO si) {
96 si->u.x.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
98 si->dwPageSize = 4096; /* 4K */
99 si->lpMinimumApplicationAddress = (void *)0x40000000;
100 si->lpMaximumApplicationAddress = (void *)0x80000000;
101 si->dwActiveProcessorMask = 1;
102 si->dwNumberOfProcessors = 1;
104 /* FIXME: perhaps check compilation defines ... */
105 si->dwProcessorType = PROCESSOR_INTEL_386;
110 case 4: si->dwProcessorType = PROCESSOR_INTEL_486;
112 case 5: si->dwProcessorType = PROCESSOR_INTEL_PENTIUM;
115 default: si->dwProcessorType = PROCESSOR_INTEL_386;
119 si->dwAllocationGranularity = 8; /* hmm? */
120 si->wProcessorLevel = cpu;
121 si->wProcessorRevision = 0; /* FIXME, see SDK */
124 /* Initialize whatever internal data structures we need.
126 * Returns 1 on success, 0 on failure.
128 int KERN32_Init(void)
131 /* Initialize exception handling */
137 /***********************************************************************
138 * GetComputerNameA (KERNEL32.165)
141 GetComputerName32A(LPSTR name,LPDWORD size) {
142 if (-1==gethostname(name,*size))
144 *size = lstrlen32A(name);
148 /***********************************************************************
149 * GetComputerNameW (KERNEL32.166)
152 GetComputerName32W(LPWSTR name,LPDWORD size) {
153 LPSTR nameA = (LPSTR)xmalloc(*size);
155 if (!GetComputerName32A(nameA,size)) {
159 lstrcpynAtoW(name,nameA,*size);
161 /* FIXME : size correct? */
165 /***********************************************************************
166 * GetUserNameA [ADVAPI32.67]
168 BOOL32 GetUserName32A(LPSTR lpszName, LPDWORD lpSize)
174 len = name ? strlen(name) : 0;
175 if (!len || !lpSize || len > *lpSize) {
176 if (lpszName) *lpszName = 0;
180 strcpy(lpszName, name);
184 /***********************************************************************
185 * GetUserNameW [ADVAPI32.68]
187 BOOL32 GetUserName32W(LPWSTR lpszName, LPDWORD lpSize)
189 LPSTR name = (LPSTR)xmalloc(*lpSize);
190 DWORD size = *lpSize;
191 BOOL32 res = GetUserName32A(name,lpSize);
193 lstrcpynAtoW(lpszName,name,size);