1 | /* $Id: KERNEL32.CPP,v 1.44 2000-05-02 20:53:11 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 compatibility file functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | * Copyright 1998 Peter Fitzsimmons
|
---|
9 | * Copyright 1998 Knut St. Osmundsen
|
---|
10 | *
|
---|
11 | * @(#) KERNEL32.CPP 1.0.1 1998/06/12 PH added HandleManager support
|
---|
12 | *
|
---|
13 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
14 | *
|
---|
15 | */
|
---|
16 |
|
---|
17 |
|
---|
18 | /*****************************************************************************
|
---|
19 | * Includes *
|
---|
20 | *****************************************************************************/
|
---|
21 |
|
---|
22 | #include <odin.h>
|
---|
23 | #include <odinwrap.h>
|
---|
24 | #include <os2sel.h>
|
---|
25 |
|
---|
26 | #include <os2win.h>
|
---|
27 | #include <winnt.h>
|
---|
28 | #include <winnls.h>
|
---|
29 | #include <stdlib.h>
|
---|
30 | #include <string.h>
|
---|
31 |
|
---|
32 | #include "misc.h"
|
---|
33 | #include <builtin.h>
|
---|
34 | #include "heap.h"
|
---|
35 | #include "handlemanager.h"
|
---|
36 | #include "wprocess.h"
|
---|
37 | #include <versionos2.h>
|
---|
38 |
|
---|
39 | #define DBG_LOCALLOG DBG_kernel32
|
---|
40 | #include "dbglocal.h"
|
---|
41 |
|
---|
42 | /*****************************************************************************
|
---|
43 | * Defines *
|
---|
44 | *****************************************************************************/
|
---|
45 |
|
---|
46 | ODINDEBUGCHANNEL(KERNEL32-KERNEL32)
|
---|
47 |
|
---|
48 | /* this define enables certain less important debug messages */
|
---|
49 | //#define DEBUG_LOCAL 1
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 | /*****************************************************************************
|
---|
54 | * Name : BOOL WIN32API CloseHandle
|
---|
55 | * Purpose : forward call to Open32
|
---|
56 | * Parameters:
|
---|
57 | * Variables :
|
---|
58 | * Result :
|
---|
59 | * Remark :
|
---|
60 | * Status :
|
---|
61 | *
|
---|
62 | * Author : Patrick Haller [Fri, 1998/06/12 03:44]
|
---|
63 | *****************************************************************************/
|
---|
64 | BOOL WIN32API CloseHandle(HANDLE hHandle)
|
---|
65 | {
|
---|
66 | dprintf(("KERNEL32: CloseHandle(%08xh)\n",
|
---|
67 | hHandle));
|
---|
68 |
|
---|
69 | return HMCloseHandle(hHandle);
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | //******************************************************************************
|
---|
74 | HANDLE WIN32API GetStdHandle(DWORD fdwDevice)
|
---|
75 | {
|
---|
76 | HANDLE handle;
|
---|
77 |
|
---|
78 | /* @@@PH 1998/02/12 Handle Manager Support */
|
---|
79 | handle = HMGetStdHandle(fdwDevice);
|
---|
80 |
|
---|
81 | //@@@PH translate handle
|
---|
82 |
|
---|
83 | /* handle = GetStdHandle(fdwDevice); */
|
---|
84 | dprintf(("KERNEL32: GetStdHandle for device %X returned %X\n", fdwDevice, handle));
|
---|
85 | return(handle);
|
---|
86 | }
|
---|
87 | //******************************************************************************
|
---|
88 | //******************************************************************************
|
---|
89 | BOOL WIN32API SetStdHandle(DWORD IDStdHandle,
|
---|
90 | HANDLE hHandle)
|
---|
91 | {
|
---|
92 | dprintf(("KERNEL32: SetStdHandle\n"));
|
---|
93 |
|
---|
94 | ///@@@PH translate handle
|
---|
95 |
|
---|
96 | return (HMSetStdHandle(IDStdHandle,
|
---|
97 | hHandle));
|
---|
98 | }
|
---|
99 | //******************************************************************************
|
---|
100 | //******************************************************************************
|
---|
101 | BOOL WIN32API IsBadWritePtr(LPVOID lpvPtr, UINT cbBytes)
|
---|
102 | {
|
---|
103 | #ifdef DEBUG
|
---|
104 | BOOL rc;
|
---|
105 |
|
---|
106 | rc = O32_IsBadWritePtr(lpvPtr, cbBytes);
|
---|
107 | dprintf(("KERNEL32: IsBadWritePtr: 0x%X size %d rc = %d\n", (int)lpvPtr, cbBytes, rc));
|
---|
108 | return(rc);
|
---|
109 | #else
|
---|
110 | return(O32_IsBadWritePtr(lpvPtr, cbBytes));
|
---|
111 | #endif
|
---|
112 | }
|
---|
113 | //******************************************************************************
|
---|
114 | //******************************************************************************
|
---|
115 | BOOL WIN32API IsBadReadPtr(CONST VOID *lpvPtr, UINT cbBytes)
|
---|
116 | {
|
---|
117 | #ifdef DEBUG
|
---|
118 | BOOL rc;
|
---|
119 |
|
---|
120 | rc = O32_IsBadReadPtr(lpvPtr, cbBytes);
|
---|
121 | dprintf(("KERNEL32: IsBadWritePtr: 0x%X size %d rc = %d\n", (int)lpvPtr, cbBytes, rc));
|
---|
122 | return(rc);
|
---|
123 | #else
|
---|
124 | return(O32_IsBadReadPtr(lpvPtr, cbBytes));
|
---|
125 | #endif
|
---|
126 | }
|
---|
127 | //******************************************************************************
|
---|
128 | //******************************************************************************
|
---|
129 | BOOL WIN32API IsBadCodePtr( FARPROC arg1)
|
---|
130 | {
|
---|
131 | dprintf(("KERNEL32: IsBadCodePtr\n"));
|
---|
132 | return O32_IsBadCodePtr(arg1);
|
---|
133 | }
|
---|
134 | //******************************************************************************
|
---|
135 | //******************************************************************************
|
---|
136 | BOOL WIN32API IsBadStringPtrA( LPCSTR arg1, UINT arg2)
|
---|
137 | {
|
---|
138 | dprintf(("KERNEL32: IsBadStringPtr"));
|
---|
139 | return O32_IsBadStringPtr(arg1, arg2);
|
---|
140 | }
|
---|
141 | //******************************************************************************
|
---|
142 | //******************************************************************************
|
---|
143 | BOOL WIN32API IsBadStringPtrW(LPCWSTR arg1, UINT arg2)
|
---|
144 | {
|
---|
145 | dprintf(("KERNEL32: OS2IsBadStringPtrW"));
|
---|
146 | return O32_IsBadReadPtr((CONST VOID *)arg1, arg2*2+2);
|
---|
147 | }
|
---|
148 | //******************************************************************************
|
---|
149 | //******************************************************************************
|
---|
150 | DWORD WIN32API GetLastError()
|
---|
151 | {
|
---|
152 | DWORD rc;
|
---|
153 |
|
---|
154 | rc = O32_GetLastError();
|
---|
155 | #ifdef DEBUG_LOCAL
|
---|
156 | dprintf(("KERNEL32: GetLastError returned %d\n", rc));
|
---|
157 | #endif
|
---|
158 | return(rc);
|
---|
159 | }
|
---|
160 | //******************************************************************************
|
---|
161 | //******************************************************************************
|
---|
162 | VOID WIN32API SetLastError( DWORD dwError)
|
---|
163 | {
|
---|
164 | if(dwError != 0) {
|
---|
165 | dprintf2(("KERNEL32: SetLastError to %d\n", dwError));
|
---|
166 | }
|
---|
167 | O32_SetLastError(dwError);
|
---|
168 | }
|
---|
169 | //******************************************************************************
|
---|
170 | //******************************************************************************
|
---|
171 | UINT WIN32API GetOEMCP(VOID)
|
---|
172 | {
|
---|
173 | dprintf(("KERNEL32: GetOEMCP\n"));
|
---|
174 | return(O32_GetOEMCP());
|
---|
175 | }
|
---|
176 | //******************************************************************************
|
---|
177 | //******************************************************************************
|
---|
178 | UINT WIN32API GetACP(VOID)
|
---|
179 | {
|
---|
180 | dprintf(("KERNEL32: GetACP\n"));
|
---|
181 | return(O32_GetACP());
|
---|
182 | }
|
---|
183 | //******************************************************************************
|
---|
184 | //******************************************************************************
|
---|
185 | BOOL WIN32API GetStringTypeW(DWORD fdwInfoType, LPCWSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
---|
186 | {
|
---|
187 | int i;
|
---|
188 |
|
---|
189 | dprintf(("KERNEL32: GetStringTypeW, not properly implemented\n"));
|
---|
190 | if((DWORD)lpSrcStr == (DWORD)lpCharType || !lpSrcStr || !lpCharType) {
|
---|
191 | O32_SetLastError(ERROR_INVALID_PARAMETER);
|
---|
192 | return(FALSE);
|
---|
193 | }
|
---|
194 | if(cchSrc == -1)
|
---|
195 | cchSrc = UniStrlen((UniChar*)lpSrcStr);
|
---|
196 |
|
---|
197 | memset(lpCharType, 0, cchSrc*sizeof(WORD));
|
---|
198 | switch(fdwInfoType) {
|
---|
199 | case CT_CTYPE1:
|
---|
200 | for(i=0;i<cchSrc;i++) {
|
---|
201 | if(lpSrcStr[i] >= (WCHAR)'a' && lpSrcStr[i] <= (WCHAR)'z')
|
---|
202 | lpCharType[i] |= C1_LOWER | C1_ALPHA;
|
---|
203 | else
|
---|
204 | if(lpSrcStr[i] >= (WCHAR)'A' && lpSrcStr[i] <= (WCHAR)'A')
|
---|
205 | lpCharType[i] |= C1_UPPER | C1_ALPHA;
|
---|
206 | else
|
---|
207 | if(lpSrcStr[i] >= (WCHAR)'0' && lpSrcStr[i] <= (WCHAR)'9')
|
---|
208 | lpCharType[i] |= C1_DIGIT;
|
---|
209 | else
|
---|
210 | if(lpSrcStr[i] >= (WCHAR)' ')
|
---|
211 | lpCharType[i] |= C1_SPACE;
|
---|
212 | }
|
---|
213 | break;
|
---|
214 | case CT_CTYPE2:
|
---|
215 | case CT_CTYPE3: //not supported right now
|
---|
216 | break;
|
---|
217 | }
|
---|
218 | return(TRUE);
|
---|
219 | }
|
---|
220 | //******************************************************************************
|
---|
221 | //NOTE: This has one parameter more than the W version! (@#$@#$)
|
---|
222 | //******************************************************************************
|
---|
223 | BOOL WIN32API GetStringTypeA(LCID Locale, DWORD fdwInfoType, LPCSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
---|
224 | {
|
---|
225 | int i;
|
---|
226 |
|
---|
227 | dprintf(("KERNEL32: GetStringTypeA, not properly implemented\n"));
|
---|
228 | if(lpSrcStr == (LPCSTR)lpCharType || !lpSrcStr || !lpCharType) {
|
---|
229 | O32_SetLastError(ERROR_INVALID_PARAMETER);
|
---|
230 | return(FALSE);
|
---|
231 | }
|
---|
232 | if(cchSrc == -1)
|
---|
233 | cchSrc = strlen(lpSrcStr);
|
---|
234 |
|
---|
235 | memset(lpCharType, 0, cchSrc*sizeof(WORD));
|
---|
236 | switch(fdwInfoType) {
|
---|
237 | case CT_CTYPE1:
|
---|
238 | for(i=0;i<cchSrc;i++) {
|
---|
239 | if(lpSrcStr[i] >= 'a' && lpSrcStr[i] <= 'z')
|
---|
240 | lpCharType[i] |= C1_LOWER | C1_ALPHA;
|
---|
241 | else
|
---|
242 | if(lpSrcStr[i] >= 'A' && lpSrcStr[i] <= 'A')
|
---|
243 | lpCharType[i] |= C1_UPPER | C1_ALPHA;
|
---|
244 | else
|
---|
245 | if(lpSrcStr[i] >= '0' && lpSrcStr[i] <= '9')
|
---|
246 | lpCharType[i] |= C1_DIGIT;
|
---|
247 | else
|
---|
248 | if(lpSrcStr[i] >= ' ')
|
---|
249 | lpCharType[i] |= C1_SPACE;
|
---|
250 | }
|
---|
251 | break;
|
---|
252 | case CT_CTYPE2:
|
---|
253 | case CT_CTYPE3: //not supported right now
|
---|
254 | break;
|
---|
255 | }
|
---|
256 | return(TRUE);
|
---|
257 | }
|
---|
258 | //******************************************************************************
|
---|
259 | //******************************************************************************
|
---|
260 | BOOL WIN32API GetStringTypeExW(LCID Locale, DWORD fdwInfoType, LPCWSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
---|
261 | {
|
---|
262 | dprintf(("KERNEL32: GetStringTypeExW, not properly implemented\n"));
|
---|
263 | return(GetStringTypeW(fdwInfoType, lpSrcStr, cchSrc, lpCharType));
|
---|
264 | }
|
---|
265 | //******************************************************************************
|
---|
266 | //******************************************************************************
|
---|
267 | BOOL WIN32API GetStringTypeExA(LCID Locale, DWORD fdwInfoType, LPCSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
---|
268 | {
|
---|
269 | dprintf(("KERNEL32: GetStringTypeExA, not properly implemented\n"));
|
---|
270 | return(GetStringTypeA(Locale, fdwInfoType, lpSrcStr, cchSrc, lpCharType));
|
---|
271 | }
|
---|
272 | //******************************************************************************
|
---|
273 | VOID WIN32API GlobalMemoryStatus( MEMORYSTATUS *arg1)
|
---|
274 | {
|
---|
275 | dprintf(("KERNEL32: GlobalMemoryStatus\n"));
|
---|
276 | O32_GlobalMemoryStatus(arg1);
|
---|
277 | dprintf(("dwMemoryLoad %X\n", arg1->dwMemoryLoad));
|
---|
278 | dprintf(("dwTotalPhys %X\n", arg1->dwTotalPhys));
|
---|
279 | dprintf(("dwAvailPhys %X\n", arg1->dwAvailPhys));
|
---|
280 | dprintf(("dwTotalPageFile %X\n", arg1->dwTotalPageFile));
|
---|
281 | dprintf(("dwAvailPageFile %X\n", arg1->dwAvailPageFile));
|
---|
282 | dprintf(("dwTotalVirtual %X\n", arg1->dwTotalVirtual));
|
---|
283 | dprintf(("dwAvailVirtual %X\n", arg1->dwAvailVirtual));
|
---|
284 | }
|
---|
285 | VOID WIN32API Sleep(DWORD arg1)
|
---|
286 | {
|
---|
287 | dprintf2(("KERNEL32: Sleep %d\n", arg1));
|
---|
288 | O32_Sleep(arg1);
|
---|
289 | }
|
---|
290 | //******************************************************************************
|
---|
291 | //******************************************************************************
|
---|
292 | DWORD WIN32API GetPriorityClass(HANDLE arg1)
|
---|
293 | {
|
---|
294 | dprintf(("KERNEL32: GetPriorityClass\n"));
|
---|
295 | return O32_GetPriorityClass(arg1);
|
---|
296 | }
|
---|
297 | //******************************************************************************
|
---|
298 | //******************************************************************************
|
---|
299 | BOOL WIN32API SetPriorityClass(HANDLE arg1, DWORD arg2)
|
---|
300 | {
|
---|
301 | dprintf(("KERNEL32: SetPriorityClass\n"));
|
---|
302 | return O32_SetPriorityClass(arg1, arg2);
|
---|
303 | }
|
---|
304 | //******************************************************************************
|
---|
305 | //TODO!
|
---|
306 | //******************************************************************************
|
---|
307 | int WIN32API LCMapStringW(
|
---|
308 | DWORD /*LCID*/ Locale,
|
---|
309 | DWORD dwMapFlags,
|
---|
310 | LPCWSTR lpSrcStr,
|
---|
311 | int cchSrc,
|
---|
312 | LPWSTR lpDestStr,
|
---|
313 | int cchDest)
|
---|
314 | {
|
---|
315 | // quick hack! this code is not done!
|
---|
316 | if(cchSrc == -1)
|
---|
317 | cchSrc = strlen((const char *)lpSrcStr);
|
---|
318 | if(!cchDest)
|
---|
319 | return cchSrc;
|
---|
320 | strncpy((char *)lpDestStr, (const char *)lpSrcStr, max(cchSrc, cchDest));
|
---|
321 | return max(cchSrc, cchDest);
|
---|
322 | }
|
---|
323 | //******************************************************************************
|
---|
324 | //TODO!
|
---|
325 | //******************************************************************************
|
---|
326 | int WIN32API LCMapStringA(
|
---|
327 | DWORD /*LCID*/ Locale,
|
---|
328 | DWORD dwMapFlags,
|
---|
329 | LPCSTR lpSrcStr,
|
---|
330 | int cchSrc,
|
---|
331 | LPSTR lpDestStr,
|
---|
332 | int cchDest)
|
---|
333 | {
|
---|
334 | dprintf(("KERNEL32: LCMapStringA not implemented\n"));
|
---|
335 | if(cchSrc == -1)
|
---|
336 | cchSrc = strlen((const char *)lpSrcStr);
|
---|
337 | if(!cchDest)
|
---|
338 | return cchSrc;
|
---|
339 | strncpy((char *)lpDestStr, (const char *)lpSrcStr, max(cchSrc, cchDest));
|
---|
340 | return max(cchSrc, cchDest);
|
---|
341 | }
|
---|
342 | //******************************************************************************
|
---|
343 | //SvL: 24-6-'97 - Added
|
---|
344 | //******************************************************************************
|
---|
345 | BOOL WIN32API Beep( DWORD arg1, DWORD arg2)
|
---|
346 | {
|
---|
347 | dprintf(("KERNEL32: OS2Beep\n"));
|
---|
348 | return O32_Beep(arg1, arg2);
|
---|
349 | }
|
---|
350 | //******************************************************************************
|
---|
351 | //******************************************************************************
|
---|
352 | VOID WIN32API FatalAppExitA( UINT arg1, LPCSTR arg2)
|
---|
353 | {
|
---|
354 | dprintf(("KERNEL32: OS2FatalAppExitA\n"));
|
---|
355 | O32_FatalAppExit(arg1, arg2);
|
---|
356 | }
|
---|
357 | //******************************************************************************
|
---|
358 | //******************************************************************************
|
---|
359 | VOID WIN32API FatalAppExitW(UINT arg1, LPCWSTR arg2)
|
---|
360 | {
|
---|
361 | char *astring;
|
---|
362 |
|
---|
363 | dprintf(("KERNEL32: OS2FatalAppExitW\n"));
|
---|
364 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
365 | O32_FatalAppExit(arg1, astring);
|
---|
366 | //probably won't return, but who cares..
|
---|
367 | FreeAsciiString(astring);
|
---|
368 | }
|
---|
369 | //******************************************************************************
|
---|
370 | //******************************************************************************
|
---|
371 | VOID WIN32API FatalExit( UINT arg1)
|
---|
372 | {
|
---|
373 | dprintf(("KERNEL32: OS2FatalExit\n"));
|
---|
374 | O32_FatalExit(arg1);
|
---|
375 | }
|
---|
376 | //******************************************************************************
|
---|
377 | //******************************************************************************
|
---|
378 | BOOL WIN32API IsBadHugeReadPtr( const void * arg1, UINT arg2)
|
---|
379 | {
|
---|
380 | dprintf(("KERNEL32: OS2IsBadHugeReadPtr\n"));
|
---|
381 | return O32_IsBadHugeReadPtr(arg1, arg2);
|
---|
382 | }
|
---|
383 | //******************************************************************************
|
---|
384 | //******************************************************************************
|
---|
385 | BOOL WIN32API IsBadHugeWritePtr( PVOID arg1, UINT arg2)
|
---|
386 | {
|
---|
387 | dprintf(("KERNEL32: OS2IsBadHugeWritePtr\n"));
|
---|
388 | return O32_IsBadHugeWritePtr(arg1, arg2);
|
---|
389 | }
|
---|
390 | //******************************************************************************
|
---|
391 | //******************************************************************************
|
---|
392 | BOOL WIN32API IsDBCSLeadByte(BYTE arg1)
|
---|
393 | {
|
---|
394 | dprintf2(("KERNEL32: OS2IsDBCSLeadByte\n"));
|
---|
395 | return O32_IsDBCSLeadByte(arg1);
|
---|
396 | }
|
---|
397 | //******************************************************************************
|
---|
398 | //******************************************************************************
|
---|
399 | DWORD WIN32API LoadModule( LPCSTR arg1, PVOID arg2)
|
---|
400 | {
|
---|
401 | dprintf(("KERNEL32: OS2LoadModule\n"));
|
---|
402 | return O32_LoadModule(arg1, arg2);
|
---|
403 | }
|
---|
404 | //******************************************************************************
|
---|
405 | //******************************************************************************
|
---|
406 | int WIN32API MulDiv(int arg1, int arg2, int arg3)
|
---|
407 | {
|
---|
408 | dprintf2(("KERNEL32: MulDiv %d*%d/%d\n", arg1, arg2, arg3));
|
---|
409 | if(arg3 == 0)
|
---|
410 | return 0;
|
---|
411 |
|
---|
412 | return O32_MulDiv(arg1, arg2, arg3);
|
---|
413 | }
|
---|
414 | //******************************************************************************
|
---|
415 | UINT WIN32API CompareStringA(LCID lcid, DWORD fdwStyle, LPCSTR lpString1,
|
---|
416 | DWORD cch1, LPCSTR lpString2, DWORD cch2)
|
---|
417 | {
|
---|
418 | int i;
|
---|
419 | int fEqual = TRUE;
|
---|
420 | char *string1 = (char *)lpString1, *string2 = (char *)lpString2;
|
---|
421 |
|
---|
422 | SetLastError(0);
|
---|
423 |
|
---|
424 | #ifdef DEBUG
|
---|
425 | if(fdwStyle & SORT_STRINGSORT)
|
---|
426 | dprintf(("KERNEL32: SORT_STRINGSORT not supported!\n"));
|
---|
427 | if(fdwStyle & NORM_IGNORENONSPACE)
|
---|
428 | dprintf(("KERNEL32: NORM_IGNORENONSPACE not supported!\n"));
|
---|
429 | if(fdwStyle & NORM_IGNORESYMBOLS)
|
---|
430 | dprintf(("KERNEL32: NORM_IGNORESYMBOLS not supported!\n"));
|
---|
431 | #endif
|
---|
432 |
|
---|
433 | if(lpString1 == NULL || lpString2 == NULL)
|
---|
434 | {
|
---|
435 | dprintf(("CompareStringA: (s1=%s,s2=%s): Invalid NULL string\n", lpString1, lpString2));
|
---|
436 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
437 | return 0;
|
---|
438 | }
|
---|
439 |
|
---|
440 | if(cch1 == -1) cch1 = strlen(string1);
|
---|
441 | if(cch2 == -1) cch2 = strlen(string2);
|
---|
442 |
|
---|
443 | if(fdwStyle) {
|
---|
444 | //TODO!
|
---|
445 | if(fdwStyle != 0 && fdwStyle != NORM_IGNORECASE)
|
---|
446 | return(0); /*PLF Fri 98-03-13 04:09:32 was return 1 */
|
---|
447 | }
|
---|
448 | if(fdwStyle & NORM_IGNORECASE)
|
---|
449 | fEqual = strnicmp(string1, string2, min(cch1, cch2));
|
---|
450 | else
|
---|
451 | fEqual = strncmp(string1, string2, min(cch1, cch2));
|
---|
452 |
|
---|
453 | if (fEqual < 0 ) fEqual = 1;
|
---|
454 | else if(fEqual == 0) fEqual = 2;
|
---|
455 | else if(fEqual > 0) fEqual = 3;
|
---|
456 |
|
---|
457 | //If equal, but different length, largest one is the greatest in lexical value
|
---|
458 | if(fEqual == 2 && cch1 != cch2){
|
---|
459 | if(cch1 < cch2)
|
---|
460 | fEqual = 1;
|
---|
461 | else
|
---|
462 | fEqual = 3;
|
---|
463 | }
|
---|
464 | dprintf2(("KERNEL32: OS2CompareStringA '%s' - '%s' returned %d\n", lpString1, lpString2, fEqual));
|
---|
465 | return(fEqual);
|
---|
466 | }
|
---|
467 |
|
---|
468 | //******************************************************************************
|
---|
469 | //TODO: Not complete (fdwStyle flags specify compare method)
|
---|
470 | //******************************************************************************
|
---|
471 | UINT WIN32API CompareStringW(LCID lcid, DWORD fdwStyle, LPCWSTR lpString1,
|
---|
472 | DWORD cch1, LPCWSTR lpString2, DWORD cch2)
|
---|
473 | {
|
---|
474 | int i;
|
---|
475 | int fEqual = TRUE;
|
---|
476 | char *string1;
|
---|
477 | char *string2;
|
---|
478 |
|
---|
479 | dprintf2(("KERNEL32: OS2CompareStringW '%s' - '%s'\n", string1, string2));
|
---|
480 |
|
---|
481 | if(lpString1 == NULL || lpString2 == NULL)
|
---|
482 | {
|
---|
483 | dprintf(("CompareStringW: (s1=%s,s2=%s): Invalid NULL string\n", lpString1, lpString2));
|
---|
484 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
485 | return 0;
|
---|
486 | }
|
---|
487 |
|
---|
488 | if(cch1 == -1) cch1 = lstrlenW(lpString1);
|
---|
489 | if(cch2 == -1) cch2 = lstrlenW(lpString2);
|
---|
490 |
|
---|
491 | string1 = UnicodeToAsciiStringN((LPWSTR)lpString1, cch1);
|
---|
492 | string2 = UnicodeToAsciiStringN((LPWSTR)lpString2, cch2);
|
---|
493 |
|
---|
494 | fEqual = CompareStringA(lcid, fdwStyle, string1, cch1, string2, cch2);
|
---|
495 | FreeAsciiString(string1);
|
---|
496 | FreeAsciiString(string2);
|
---|
497 |
|
---|
498 | return(fEqual);
|
---|
499 | }
|
---|
500 | //******************************************************************************
|
---|
501 | //Borrowed from Wine
|
---|
502 | //******************************************************************************
|
---|
503 | ODINPROCEDURE1(GetStartupInfoA,LPSTARTUPINFOA,lpStartupInfo)
|
---|
504 | {
|
---|
505 | lpStartupInfo->cb = sizeof(STARTUPINFOA);
|
---|
506 | lpStartupInfo->lpReserved = "<Reserved>";
|
---|
507 | lpStartupInfo->lpDesktop = "Desktop";
|
---|
508 | lpStartupInfo->lpTitle = "Title";
|
---|
509 | lpStartupInfo->dwX = 0;
|
---|
510 | lpStartupInfo->dwY = 0;
|
---|
511 | lpStartupInfo->dwXSize = 640;
|
---|
512 | lpStartupInfo->dwYSize = 480;
|
---|
513 | lpStartupInfo->dwXCountChars = 80; // for console
|
---|
514 | lpStartupInfo->dwYCountChars = 25;
|
---|
515 | lpStartupInfo->dwFillAttribute = 0x0720;
|
---|
516 | lpStartupInfo->dwFlags = STARTF_USESHOWWINDOW |
|
---|
517 | STARTF_USEPOSITION |
|
---|
518 | STARTF_USESIZE |
|
---|
519 | STARTF_USECOUNTCHARS |
|
---|
520 | STARTF_USEFILLATTRIBUTE|
|
---|
521 | STARTF_USESTDHANDLES;
|
---|
522 | lpStartupInfo->wShowWindow = SW_SHOWDEFAULT;
|
---|
523 | lpStartupInfo->cbReserved2 = 0;
|
---|
524 | lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
|
---|
525 | /* @@@PH 98/07/13 Handlemanager support */
|
---|
526 | lpStartupInfo->hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
---|
527 | lpStartupInfo->hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
---|
528 | lpStartupInfo->hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
---|
529 | return;
|
---|
530 | }
|
---|
531 | //******************************************************************************
|
---|
532 | //Borrowed from Wine
|
---|
533 | //******************************************************************************
|
---|
534 | ODINPROCEDURE1(GetStartupInfoW,LPSTARTUPINFOW,lpStartupInfo)
|
---|
535 | {
|
---|
536 | static WCHAR lpReserved[] = {'<', 'R','e','s','e','r','v','e','d','>', 0};
|
---|
537 | static WCHAR lpDesktop[] = {'D', 'e','s','k','t','o','p', 0};
|
---|
538 | static WCHAR lpTitle[] = {'T', 'i','t','l','e', 0};
|
---|
539 |
|
---|
540 | // forward call to ascii variant
|
---|
541 | GetStartupInfoA((LPSTARTUPINFOA)lpStartupInfo);
|
---|
542 | lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
---|
543 | lpStartupInfo->lpReserved = lpReserved;
|
---|
544 | lpStartupInfo->lpDesktop = lpDesktop;
|
---|
545 | lpStartupInfo->lpTitle = lpTitle;
|
---|
546 | return;
|
---|
547 | }
|
---|
548 | //******************************************************************************
|
---|
549 | //TODO: Not complete or correct, but sufficient for now
|
---|
550 | //******************************************************************************
|
---|
551 | BOOL WIN32API GetBinaryTypeA(LPCTSTR lpApplicationName, LPDWORD lpBinaryType)
|
---|
552 | {
|
---|
553 | dprintf(("KERNEL32: OS2GetBinaryTypeA %s\n", lpApplicationName));
|
---|
554 | if(strstr(lpApplicationName, ".EXE") || strstr(lpApplicationName, ".exe"))
|
---|
555 | *lpBinaryType = SCS_32BIT_BINARY;
|
---|
556 | else
|
---|
557 | if(strstr(lpApplicationName, ".COM") || strstr(lpApplicationName, ".com"))
|
---|
558 | *lpBinaryType = SCS_DOS_BINARY;
|
---|
559 | else
|
---|
560 | if(strstr(lpApplicationName, ".PIF") || strstr(lpApplicationName, ".pif"))
|
---|
561 | *lpBinaryType = SCS_PIF_BINARY;
|
---|
562 | else return(FALSE);
|
---|
563 | return(TRUE);
|
---|
564 | }
|
---|
565 | //******************************************************************************
|
---|
566 | //******************************************************************************
|
---|
567 | BOOL WIN32API GetBinaryTypeW(LPCWSTR lpApplicationName, LPDWORD lpBinaryType)
|
---|
568 | {
|
---|
569 | BOOL rc;
|
---|
570 | char *astring;
|
---|
571 |
|
---|
572 | dprintf(("KERNEL32: OS2GetBinaryTypeW\n"));
|
---|
573 | astring = UnicodeToAsciiString((LPWSTR)lpApplicationName);
|
---|
574 | rc = GetBinaryTypeA(astring, lpBinaryType);
|
---|
575 | FreeAsciiString(astring);
|
---|
576 | return(rc);
|
---|
577 | }
|
---|
578 | //******************************************************************************
|
---|
579 | //TODO: SetLastError
|
---|
580 | //******************************************************************************
|
---|
581 | BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
|
---|
582 | {
|
---|
583 | dprintf(("KERNEL32: OS2GetVersionExA\n"));
|
---|
584 |
|
---|
585 | if(lpVersionInformation == NULL || lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA))
|
---|
586 | return(FALSE);
|
---|
587 |
|
---|
588 | lpVersionInformation->dwMajorVersion = ODINNT_MAJOR_VERSION; //pretend we're NT 4.0
|
---|
589 | lpVersionInformation->dwMinorVersion = ODINNT_MINOR_VERSION;
|
---|
590 | lpVersionInformation->dwBuildNumber = ODINNT_BUILD_NR;
|
---|
591 | lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
---|
592 | strcpy(lpVersionInformation->szCSDVersion, ODINNT_CSDVERSION);
|
---|
593 | return(TRUE);
|
---|
594 | }
|
---|
595 | //******************************************************************************
|
---|
596 | //******************************************************************************
|
---|
597 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
---|
598 | {
|
---|
599 | dprintf(("KERNEL32: OS2GetVersionExW\n"));
|
---|
600 |
|
---|
601 | if(lpVersionInformation == NULL || lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW))
|
---|
602 | return(FALSE);
|
---|
603 |
|
---|
604 | lpVersionInformation->dwMajorVersion = ODINNT_MAJOR_VERSION; //pretend we're NT 4.0
|
---|
605 | lpVersionInformation->dwMinorVersion = ODINNT_MINOR_VERSION;
|
---|
606 | lpVersionInformation->dwBuildNumber = ODINNT_BUILD_NR;
|
---|
607 | lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
---|
608 | lstrcpyW(lpVersionInformation->szCSDVersion, ODINNT_CSDVERSION_W);
|
---|
609 | return(TRUE);
|
---|
610 | }
|
---|
611 | //******************************************************************************
|
---|
612 | //******************************************************************************
|
---|
613 | LONG WIN32API GetVersion()
|
---|
614 | {
|
---|
615 | dprintf(("KERNEL32: GetVersion\n"));
|
---|
616 | // highword 0 = NT, lowword high byte major ver, low byte minor ver
|
---|
617 | /* @@@PH 98/04/04 MFC30 makes assumptions about process control block */
|
---|
618 | /* structures that lead to crashes if we don't identify as NT */
|
---|
619 |
|
---|
620 | return ODINNT_VERSION;
|
---|
621 | }
|
---|
622 | //******************************************************************************
|
---|
623 | //SvL: 26-6-'97 - Added
|
---|
624 | //******************************************************************************
|
---|
625 | VOID WIN32API OutputDebugStringW(LPCWSTR arg1)
|
---|
626 | {
|
---|
627 | char *astring;
|
---|
628 |
|
---|
629 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
630 | dprintf(("KERNEL32: OS2OutputDebugStringW %s\n", astring));
|
---|
631 | FreeAsciiString(astring);
|
---|
632 | }
|
---|
633 | //******************************************************************************
|
---|
634 | //******************************************************************************
|
---|
635 | VOID WIN32API OutputDebugStringA(LPCSTR lpszOutputString)
|
---|
636 | {
|
---|
637 | dprintf(("KERNEL32: OutputDebugStringA: %s\n", lpszOutputString));
|
---|
638 | return;
|
---|
639 | }
|
---|
640 | //******************************************************************************
|
---|
641 | //******************************************************************************
|
---|
642 | BOOL WIN32API FlushInstructionCache( /*PLF Mon 98-02-09 23:56:49 : STUB STUB STUB STUB STUB */
|
---|
643 | HANDLE hProcess, /* process with cache to flush */
|
---|
644 | LPCVOID lpvBase, /* address of region to flush */
|
---|
645 | DWORD cbFlush) /* length of region to flush */
|
---|
646 |
|
---|
647 | {
|
---|
648 | dprintf(("FlushInstructionCache() - NIY\n"));
|
---|
649 | return TRUE;
|
---|
650 | }
|
---|
651 |
|
---|
652 |
|
---|
653 | int WIN32API GetNumberFormatA(LCID Locale,
|
---|
654 | DWORD dwFlags,
|
---|
655 | LPCSTR lpValue,
|
---|
656 | CONST NUMBERFMTA *lpFormat,
|
---|
657 | LPSTR lpNumberStr,
|
---|
658 | int cchNumber)
|
---|
659 | {
|
---|
660 | dprintf(("KERNEL32::OS2GetNumberFormatA(%08x,%08x,%s,%08x,%s,%08x) not implemented.\n",
|
---|
661 | Locale,
|
---|
662 | dwFlags,
|
---|
663 | lpValue,
|
---|
664 | lpFormat,
|
---|
665 | lpNumberStr,
|
---|
666 | cchNumber));
|
---|
667 |
|
---|
668 | return 0;
|
---|
669 | }
|
---|
670 |
|
---|
671 | int WIN32API GetNumberFormatW(LCID Locale,
|
---|
672 | DWORD dwFlags,
|
---|
673 | LPCWSTR lpValue,
|
---|
674 | CONST NUMBERFMTW *lpFormat,
|
---|
675 | LPWSTR lpNumberStr,
|
---|
676 | int cchNumber)
|
---|
677 | {
|
---|
678 | dprintf(("KERNEL32::OS2GetNumberFormatW(%08x,%08x,%s,%08x,%s,%08x) not implemented.\n",
|
---|
679 | Locale,
|
---|
680 | dwFlags,
|
---|
681 | lpValue,
|
---|
682 | lpFormat,
|
---|
683 | lpNumberStr,
|
---|
684 | cchNumber));
|
---|
685 |
|
---|
686 | return 0;
|
---|
687 | }
|
---|
688 |
|
---|
689 | //******************************************************************************
|
---|
690 | //******************************************************************************
|
---|
691 | void WIN32API WrongComctl32()
|
---|
692 | {
|
---|
693 | O32_MessageBox(NULL,
|
---|
694 | "KERNEL32.36 not implemented",
|
---|
695 | "Win32 for OS/2 Error",
|
---|
696 | MB_OK);
|
---|
697 | ExitProcess(987);
|
---|
698 | }
|
---|
699 | //******************************************************************************
|
---|
700 |
|
---|
701 | /***********************************************************************
|
---|
702 | * RtlFillMemory (KERNEL32.441)
|
---|
703 | */
|
---|
704 | VOID WIN32API RtlFillMemory(LPVOID ptr,
|
---|
705 | UINT len,
|
---|
706 | UINT fill )
|
---|
707 | {
|
---|
708 | #ifdef DEBUG_LOCAL
|
---|
709 | dprintf(("KERNEL32: RtlFillMemory(%08x,%08x,%08x)\n",
|
---|
710 | ptr,
|
---|
711 | len,
|
---|
712 | fill));
|
---|
713 | #endif
|
---|
714 |
|
---|
715 | memset(ptr,
|
---|
716 | fill,
|
---|
717 | len );
|
---|
718 | }
|
---|
719 |
|
---|
720 |
|
---|
721 | /***********************************************************************
|
---|
722 | * RtlMoveMemory (KERNEL32.442)
|
---|
723 | */
|
---|
724 | VOID WIN32API RtlMoveMemory(LPVOID dst,
|
---|
725 | LPCVOID src,
|
---|
726 | UINT len )
|
---|
727 | {
|
---|
728 | dprintf2(("KERNEL32: RtlMoveMemory(%08x,%08x,%08x)\n",
|
---|
729 | dst,
|
---|
730 | src,
|
---|
731 | len));
|
---|
732 |
|
---|
733 | memmove(dst,
|
---|
734 | src,
|
---|
735 | len );
|
---|
736 | }
|
---|
737 |
|
---|
738 |
|
---|
739 | /***********************************************************************
|
---|
740 | * RtlZeroMemory (KERNEL32.444)
|
---|
741 | */
|
---|
742 | VOID WIN32API RtlZeroMemory(LPVOID ptr,
|
---|
743 | UINT len)
|
---|
744 | {
|
---|
745 | dprintf2(("KERNEL32: RtlZeroMemory(%08x,%08x)\n",
|
---|
746 | ptr,
|
---|
747 | len));
|
---|
748 |
|
---|
749 | memset(ptr,
|
---|
750 | 0,
|
---|
751 | len);
|
---|
752 | }
|
---|
753 |
|
---|
754 | //******************************************************************************
|
---|
755 | /*KSO Thu 21.05.1998*/
|
---|
756 | BOOL WIN32API IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar)
|
---|
757 | {
|
---|
758 | dprintf(("KERNEL32: OS2IsDBCSLeadByteEx - not correctly implemented\n"));
|
---|
759 | return O32_IsDBCSLeadByte(TestChar);
|
---|
760 | }
|
---|
761 | //******************************************************************************
|
---|
762 |
|
---|
763 |
|
---|
764 |
|
---|
765 |
|
---|
766 |
|
---|
767 |
|
---|
768 |
|
---|
769 |
|
---|
770 | /*****************************************************************************
|
---|
771 | * Name : BOOL GetSystemPowerStatus
|
---|
772 | * Purpose : The GetSystemPowerStatus function retrieves the power status of
|
---|
773 | * the system. The status indicates whether the system is running
|
---|
774 | * on AC or DC power, whether the battery is currently charging,
|
---|
775 | * and how much battery life currently remains.
|
---|
776 | * Parameters: LPSYSTEM_POWER_STATUS lpSystemPowerStatus
|
---|
777 | * Variables :
|
---|
778 | * Result : TRUE / FALSE
|
---|
779 | * Remark :
|
---|
780 | * Status : UNTESTED STUB
|
---|
781 | *
|
---|
782 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
783 | *****************************************************************************/
|
---|
784 |
|
---|
785 | BOOL WIN32API GetSystemPowerStatus(LPSYSTEM_POWER_STATUS lpSystemPowerStatus)
|
---|
786 | {
|
---|
787 | dprintf(("Kernel32: GetSystemPowerStatus(%08xh) not properly implemented.\n",
|
---|
788 | lpSystemPowerStatus));
|
---|
789 |
|
---|
790 | if(lpSystemPowerStatus == NULL) {
|
---|
791 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
792 | return FALSE;
|
---|
793 | }
|
---|
794 | lpSystemPowerStatus->ACLineStatus = 1; //online
|
---|
795 | lpSystemPowerStatus->BatteryFlag = 128; //no system battery
|
---|
796 | lpSystemPowerStatus->BatteryLifePercent = 255; //unknown
|
---|
797 | lpSystemPowerStatus->reserved = 0;
|
---|
798 | lpSystemPowerStatus->BatteryLifeTime = -1; //unknown
|
---|
799 | lpSystemPowerStatus->BatteryFullLifeTime= -1; //unknown
|
---|
800 |
|
---|
801 | return TRUE;
|
---|
802 | }
|
---|