source: trunk/src/kernel32/KERNEL32.CPP@ 1889

Last change on this file since 1889 was 1885, checked in by sandervl, 26 years ago

Added process api + virtualprotect fix

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