| 1 | /* $Id: KERNEL32.CPP,v 1.17 1999-08-22 11:11:09 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 compatibility file functions for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright 1998 Sander van Leeuven
|
|---|
| 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 | #include <os2win.h>
|
|---|
| 22 | #include <winnt.h>
|
|---|
| 23 | #include <winnls.h>
|
|---|
| 24 | #include <stdlib.h>
|
|---|
| 25 | #include <string.h>
|
|---|
| 26 |
|
|---|
| 27 | #include "misc.h"
|
|---|
| 28 | #include "devio.h"
|
|---|
| 29 | #include "except.h"
|
|---|
| 30 | #include <builtin.h>
|
|---|
| 31 | #include "heap.h"
|
|---|
| 32 | #include "handlemanager.h"
|
|---|
| 33 | #include "os2util.h"
|
|---|
| 34 | #include "wprocess.h"
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 | /*****************************************************************************
|
|---|
| 38 | * Defines *
|
|---|
| 39 | *****************************************************************************/
|
|---|
| 40 |
|
|---|
| 41 | /* this define enables certain less important debug messages */
|
|---|
| 42 | //#define DEBUG_LOCAL 1
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | /*****************************************************************************
|
|---|
| 47 | * Name : BOOL WIN32API CloseHandle
|
|---|
| 48 | * Purpose : forward call to Open32
|
|---|
| 49 | * Parameters:
|
|---|
| 50 | * Variables :
|
|---|
| 51 | * Result :
|
|---|
| 52 | * Remark :
|
|---|
| 53 | * Status :
|
|---|
| 54 | *
|
|---|
| 55 | * Author : Patrick Haller [Fri, 1998/06/12 03:44]
|
|---|
| 56 | *****************************************************************************/
|
|---|
| 57 | BOOL WIN32API CloseHandle(HANDLE hHandle)
|
|---|
| 58 | {
|
|---|
| 59 | dprintf(("KERNEL32: CloseHandle(%08xh)\n",
|
|---|
| 60 | hHandle));
|
|---|
| 61 |
|
|---|
| 62 | return HMCloseHandle(hHandle);
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 |
|
|---|
| 66 | //******************************************************************************
|
|---|
| 67 | HANDLE WIN32API GetStdHandle(DWORD fdwDevice)
|
|---|
| 68 | {
|
|---|
| 69 | HANDLE handle;
|
|---|
| 70 |
|
|---|
| 71 | /* @@@PH 1998/02/12 Handle Manager Support */
|
|---|
| 72 | handle = HMGetStdHandle(fdwDevice);
|
|---|
| 73 |
|
|---|
| 74 | //@@@PH translate handle
|
|---|
| 75 |
|
|---|
| 76 | /* handle = GetStdHandle(fdwDevice); */
|
|---|
| 77 | dprintf(("KERNEL32: GetStdHandle for device %X returned %X\n", fdwDevice, handle));
|
|---|
| 78 | return(handle);
|
|---|
| 79 | }
|
|---|
| 80 | //******************************************************************************
|
|---|
| 81 | //******************************************************************************
|
|---|
| 82 | BOOL WIN32API SetStdHandle(DWORD IDStdHandle,
|
|---|
| 83 | HANDLE hHandle)
|
|---|
| 84 | {
|
|---|
| 85 | dprintf(("KERNEL32: SetStdHandle\n"));
|
|---|
| 86 |
|
|---|
| 87 | ///@@@PH translate handle
|
|---|
| 88 |
|
|---|
| 89 | return (HMSetStdHandle(IDStdHandle,
|
|---|
| 90 | hHandle));
|
|---|
| 91 | }
|
|---|
| 92 | //******************************************************************************
|
|---|
| 93 | //******************************************************************************
|
|---|
| 94 | BOOL WIN32API IsBadWritePtr(LPVOID lpvPtr, UINT cbBytes)
|
|---|
| 95 | {
|
|---|
| 96 | #ifdef DEBUG
|
|---|
| 97 | BOOL rc;
|
|---|
| 98 |
|
|---|
| 99 | rc = O32_IsBadWritePtr(lpvPtr, cbBytes);
|
|---|
| 100 | dprintf(("KERNEL32: IsBadWritePtr: 0x%X size %d rc = %d\n", (int)lpvPtr, cbBytes, rc));
|
|---|
| 101 | return(rc);
|
|---|
| 102 | #else
|
|---|
| 103 | return(O32_IsBadWritePtr(lpvPtr, cbBytes));
|
|---|
| 104 | #endif
|
|---|
| 105 | }
|
|---|
| 106 | //******************************************************************************
|
|---|
| 107 | //******************************************************************************
|
|---|
| 108 | BOOL WIN32API IsBadReadPtr(CONST VOID *lpvPtr, UINT cbBytes)
|
|---|
| 109 | {
|
|---|
| 110 | #ifdef DEBUG
|
|---|
| 111 | BOOL rc;
|
|---|
| 112 |
|
|---|
| 113 | rc = O32_IsBadReadPtr(lpvPtr, cbBytes);
|
|---|
| 114 | dprintf(("KERNEL32: IsBadWritePtr: 0x%X size %d rc = %d\n", (int)lpvPtr, cbBytes, rc));
|
|---|
| 115 | return(rc);
|
|---|
| 116 | #else
|
|---|
| 117 | return(O32_IsBadReadPtr(lpvPtr, cbBytes));
|
|---|
| 118 | #endif
|
|---|
| 119 | }
|
|---|
| 120 | //******************************************************************************
|
|---|
| 121 | //******************************************************************************
|
|---|
| 122 | BOOL WIN32API IsBadCodePtr( FARPROC arg1)
|
|---|
| 123 | {
|
|---|
| 124 | dprintf(("KERNEL32: IsBadCodePtr\n"));
|
|---|
| 125 | return O32_IsBadCodePtr(arg1);
|
|---|
| 126 | }
|
|---|
| 127 | //******************************************************************************
|
|---|
| 128 | //******************************************************************************
|
|---|
| 129 | BOOL WIN32API IsBadStringPtrA( LPCSTR arg1, UINT arg2)
|
|---|
| 130 | {
|
|---|
| 131 | dprintf(("KERNEL32: IsBadStringPtr"));
|
|---|
| 132 | return O32_IsBadStringPtr(arg1, arg2);
|
|---|
| 133 | }
|
|---|
| 134 | //******************************************************************************
|
|---|
| 135 | //******************************************************************************
|
|---|
| 136 | BOOL WIN32API IsBadStringPtrW(LPCWSTR arg1, UINT arg2)
|
|---|
| 137 | {
|
|---|
| 138 | dprintf(("KERNEL32: OS2IsBadStringPtrW"));
|
|---|
| 139 | return O32_IsBadReadPtr((CONST VOID *)arg1, arg2*2+2);
|
|---|
| 140 | }
|
|---|
| 141 | //******************************************************************************
|
|---|
| 142 | //******************************************************************************
|
|---|
| 143 | DWORD WIN32API GetLastError()
|
|---|
| 144 | {
|
|---|
| 145 | DWORD rc;
|
|---|
| 146 |
|
|---|
| 147 | rc = O32_GetLastError();
|
|---|
| 148 | #ifdef DEBUG_LOCAL
|
|---|
| 149 | dprintf(("KERNEL32: GetLastError returned %d\n", rc));
|
|---|
| 150 | #endif
|
|---|
| 151 | return(rc);
|
|---|
| 152 | }
|
|---|
| 153 | //******************************************************************************
|
|---|
| 154 | //******************************************************************************
|
|---|
| 155 | VOID WIN32API SetLastError( DWORD arg1)
|
|---|
| 156 | {
|
|---|
| 157 | // dprintf(("KERNEL32: SetLastError to %d\n", arg1));
|
|---|
| 158 | O32_SetLastError(arg1);
|
|---|
| 159 | }
|
|---|
| 160 | //******************************************************************************
|
|---|
| 161 | //******************************************************************************
|
|---|
| 162 | UINT WIN32API GetOEMCP(VOID)
|
|---|
| 163 | {
|
|---|
| 164 | dprintf(("KERNEL32: GetOEMCP\n"));
|
|---|
| 165 | return(O32_GetOEMCP());
|
|---|
| 166 | }
|
|---|
| 167 | //******************************************************************************
|
|---|
| 168 | //******************************************************************************
|
|---|
| 169 | UINT WIN32API GetACP(VOID)
|
|---|
| 170 | {
|
|---|
| 171 | dprintf(("KERNEL32: GetACP\n"));
|
|---|
| 172 | return(O32_GetACP());
|
|---|
| 173 | }
|
|---|
| 174 | //******************************************************************************
|
|---|
| 175 | //******************************************************************************
|
|---|
| 176 | LONG WIN32API InterlockedDecrement(LPLONG lplVal)
|
|---|
| 177 | {
|
|---|
| 178 | dprintf(("KERNEL32: InterlockedDecrement\n"));
|
|---|
| 179 | return(O32_InterlockedDecrement(lplVal));
|
|---|
| 180 | }
|
|---|
| 181 | //******************************************************************************
|
|---|
| 182 | //******************************************************************************
|
|---|
| 183 | LONG WIN32API InterlockedIncrement(LPLONG lplVal)
|
|---|
| 184 | {
|
|---|
| 185 | dprintf(("KERNEL32: InterlockedIncrement\n"));
|
|---|
| 186 | return(O32_InterlockedIncrement(lplVal));
|
|---|
| 187 | }
|
|---|
| 188 | //******************************************************************************
|
|---|
| 189 | //******************************************************************************
|
|---|
| 190 | LONG WIN32API InterlockedExchange( PLONG arg1, LONG arg2)
|
|---|
| 191 | {
|
|---|
| 192 | dprintf(("KERNEL32: InterlockedExchange\n"));
|
|---|
| 193 | return O32_InterlockedExchange(arg1, arg2);
|
|---|
| 194 | }
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | /************************************************************************
|
|---|
| 198 | * InterlockedCompareExchange [KERNEL32.879]
|
|---|
| 199 | *
|
|---|
| 200 | * Atomically compares Destination and Comperand, and if found equal exchanges
|
|---|
| 201 | * the value of Destination with Exchange
|
|---|
| 202 | *
|
|---|
| 203 | * RETURNS
|
|---|
| 204 | * Prior value of value pointed to by Destination
|
|---|
| 205 | */
|
|---|
| 206 | PVOID WIN32API InterlockedCompareExchange(
|
|---|
| 207 | PVOID *Destination, /* Address of 32-bit value to exchange */
|
|---|
| 208 | PVOID Exchange, /* change value, 32 bits */
|
|---|
| 209 | PVOID Comperand /* value to compare, 32 bits */
|
|---|
| 210 | ) {
|
|---|
| 211 | PVOID ret;
|
|---|
| 212 | /* StopAllThreadsAndProcesses() */
|
|---|
| 213 |
|
|---|
| 214 | ret=*Destination;
|
|---|
| 215 | if(*Destination==Comperand) *Destination=Exchange;
|
|---|
| 216 |
|
|---|
| 217 | /* ResumeAllThreadsAndProcesses() */
|
|---|
| 218 | return ret;
|
|---|
| 219 | }
|
|---|
| 220 |
|
|---|
| 221 | /************************************************************************
|
|---|
| 222 | * InterlockedExchangeAdd [KERNEL32.880]
|
|---|
| 223 | *
|
|---|
| 224 | * Atomically adds Increment to Addend and returns the previous value of
|
|---|
| 225 | * Addend
|
|---|
| 226 | *
|
|---|
| 227 | * RETURNS
|
|---|
| 228 | * Prior value of value pointed to by cwAddendTarget
|
|---|
| 229 | */
|
|---|
| 230 | LONG WIN32API InterlockedExchangeAdd(
|
|---|
| 231 | PLONG Addend, /* Address of 32-bit value to exchange */
|
|---|
| 232 | LONG Increment /* Value to add */
|
|---|
| 233 | ) {
|
|---|
| 234 | LONG ret;
|
|---|
| 235 | /* StopAllThreadsAndProcesses() */
|
|---|
| 236 |
|
|---|
| 237 | ret = *Addend;
|
|---|
| 238 | *Addend += Increment;
|
|---|
| 239 |
|
|---|
| 240 | /* ResumeAllThreadsAndProcesses() */
|
|---|
| 241 | return ret;
|
|---|
| 242 | }
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 | //******************************************************************************
|
|---|
| 246 | //******************************************************************************
|
|---|
| 247 | LPWSTR WIN32API GetEnvironmentStringsW(VOID)
|
|---|
| 248 | {
|
|---|
| 249 | char *envstrings = (char *)O32_GetEnvironmentStrings();
|
|---|
| 250 | char *tmp;
|
|---|
| 251 | LPWSTR wenvstrings;
|
|---|
| 252 | int len, i;
|
|---|
| 253 |
|
|---|
| 254 | dprintf(("KERNEL32: GetEnvironmentStringsW\n"));
|
|---|
| 255 |
|
|---|
| 256 | if(envstrings == NULL)
|
|---|
| 257 | return(NULL);
|
|---|
| 258 |
|
|---|
| 259 | tmp = envstrings;
|
|---|
| 260 | len = 0;
|
|---|
| 261 | while(*tmp != 0)
|
|---|
| 262 | {
|
|---|
| 263 | len += strlen(tmp)+1;
|
|---|
| 264 | tmp = envstrings + len;
|
|---|
| 265 | }
|
|---|
| 266 | len++; //terminating 0
|
|---|
| 267 | wenvstrings = (LPWSTR)malloc(len*sizeof(WCHAR));
|
|---|
| 268 | for(i=0;
|
|---|
| 269 | i<len;
|
|---|
| 270 | i++)
|
|---|
| 271 | {
|
|---|
| 272 | wenvstrings[i] = envstrings[i];
|
|---|
| 273 | }
|
|---|
| 274 | return(wenvstrings);
|
|---|
| 275 | }
|
|---|
| 276 | //******************************************************************************
|
|---|
| 277 | //******************************************************************************
|
|---|
| 278 | BOOL WIN32API FreeEnvironmentStringsA(LPSTR envstrings)
|
|---|
| 279 | {
|
|---|
| 280 | dprintf(("KERNEL32: FreeEnvironmentStringsA\n"));
|
|---|
| 281 | return(TRUE);
|
|---|
| 282 | }
|
|---|
| 283 | //******************************************************************************
|
|---|
| 284 | //******************************************************************************
|
|---|
| 285 | BOOL WIN32API FreeEnvironmentStringsW(LPWSTR envstrings)
|
|---|
| 286 | {
|
|---|
| 287 | dprintf(("KERNEL32: FreeEnvironmentStringsW\n"));
|
|---|
| 288 | free(envstrings);
|
|---|
| 289 | return(TRUE);
|
|---|
| 290 | }
|
|---|
| 291 | //******************************************************************************
|
|---|
| 292 | //******************************************************************************
|
|---|
| 293 | BOOL WIN32API GetStringTypeW(DWORD fdwInfoType, LPCWSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
|---|
| 294 | {
|
|---|
| 295 | int i;
|
|---|
| 296 |
|
|---|
| 297 | dprintf(("KERNEL32: GetStringTypeW, not properly implemented\n"));
|
|---|
| 298 | if((DWORD)lpSrcStr == (DWORD)lpCharType || !lpSrcStr || !lpCharType) {
|
|---|
| 299 | O32_SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 300 | return(FALSE);
|
|---|
| 301 | }
|
|---|
| 302 | if(cchSrc == -1)
|
|---|
| 303 | cchSrc = UniStrlen((UniChar*)lpSrcStr);
|
|---|
| 304 |
|
|---|
| 305 | memset(lpCharType, 0, cchSrc*sizeof(WORD));
|
|---|
| 306 | switch(fdwInfoType) {
|
|---|
| 307 | case CT_CTYPE1:
|
|---|
| 308 | for(i=0;i<cchSrc;i++) {
|
|---|
| 309 | if(lpSrcStr[i] >= (WCHAR)'a' && lpSrcStr[i] <= (WCHAR)'z')
|
|---|
| 310 | lpCharType[i] |= C1_LOWER | C1_ALPHA;
|
|---|
| 311 | else
|
|---|
| 312 | if(lpSrcStr[i] >= (WCHAR)'A' && lpSrcStr[i] <= (WCHAR)'A')
|
|---|
| 313 | lpCharType[i] |= C1_UPPER | C1_ALPHA;
|
|---|
| 314 | else
|
|---|
| 315 | if(lpSrcStr[i] >= (WCHAR)'0' && lpSrcStr[i] <= (WCHAR)'9')
|
|---|
| 316 | lpCharType[i] |= C1_DIGIT;
|
|---|
| 317 | else
|
|---|
| 318 | if(lpSrcStr[i] >= (WCHAR)' ')
|
|---|
| 319 | lpCharType[i] |= C1_SPACE;
|
|---|
| 320 | }
|
|---|
| 321 | break;
|
|---|
| 322 | case CT_CTYPE2:
|
|---|
| 323 | case CT_CTYPE3: //not supported right now
|
|---|
| 324 | break;
|
|---|
| 325 | }
|
|---|
| 326 | return(TRUE);
|
|---|
| 327 | }
|
|---|
| 328 | //******************************************************************************
|
|---|
| 329 | //NOTE: This has one parameter more than the W version! (@#$@#$)
|
|---|
| 330 | //******************************************************************************
|
|---|
| 331 | BOOL WIN32API GetStringTypeA(LCID Locale, DWORD fdwInfoType, LPCSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
|---|
| 332 | {
|
|---|
| 333 | int i;
|
|---|
| 334 |
|
|---|
| 335 | dprintf(("KERNEL32: GetStringTypeA, not properly implemented\n"));
|
|---|
| 336 | if(lpSrcStr == (LPCSTR)lpCharType || !lpSrcStr || !lpCharType) {
|
|---|
| 337 | O32_SetLastError(ERROR_INVALID_PARAMETER);
|
|---|
| 338 | return(FALSE);
|
|---|
| 339 | }
|
|---|
| 340 | if(cchSrc == -1)
|
|---|
| 341 | cchSrc = strlen(lpSrcStr);
|
|---|
| 342 |
|
|---|
| 343 | memset(lpCharType, 0, cchSrc*sizeof(WORD));
|
|---|
| 344 | switch(fdwInfoType) {
|
|---|
| 345 | case CT_CTYPE1:
|
|---|
| 346 | for(i=0;i<cchSrc;i++) {
|
|---|
| 347 | if(lpSrcStr[i] >= 'a' && lpSrcStr[i] <= 'z')
|
|---|
| 348 | lpCharType[i] |= C1_LOWER | C1_ALPHA;
|
|---|
| 349 | else
|
|---|
| 350 | if(lpSrcStr[i] >= 'A' && lpSrcStr[i] <= 'A')
|
|---|
| 351 | lpCharType[i] |= C1_UPPER | C1_ALPHA;
|
|---|
| 352 | else
|
|---|
| 353 | if(lpSrcStr[i] >= '0' && lpSrcStr[i] <= '9')
|
|---|
| 354 | lpCharType[i] |= C1_DIGIT;
|
|---|
| 355 | else
|
|---|
| 356 | if(lpSrcStr[i] >= ' ')
|
|---|
| 357 | lpCharType[i] |= C1_SPACE;
|
|---|
| 358 | }
|
|---|
| 359 | break;
|
|---|
| 360 | case CT_CTYPE2:
|
|---|
| 361 | case CT_CTYPE3: //not supported right now
|
|---|
| 362 | break;
|
|---|
| 363 | }
|
|---|
| 364 | return(TRUE);
|
|---|
| 365 | }
|
|---|
| 366 | //******************************************************************************
|
|---|
| 367 | //******************************************************************************
|
|---|
| 368 | BOOL WIN32API GetStringTypeExW(LCID Locale, DWORD fdwInfoType, LPCWSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
|---|
| 369 | {
|
|---|
| 370 | dprintf(("KERNEL32: GetStringTypeExW, not properly implemented\n"));
|
|---|
| 371 | return(GetStringTypeW(fdwInfoType, lpSrcStr, cchSrc, lpCharType));
|
|---|
| 372 | }
|
|---|
| 373 | //******************************************************************************
|
|---|
| 374 | //******************************************************************************
|
|---|
| 375 | BOOL WIN32API GetStringTypeExA(LCID Locale, DWORD fdwInfoType, LPCSTR lpSrcStr, int cchSrc, LPWORD lpCharType)
|
|---|
| 376 | {
|
|---|
| 377 | dprintf(("KERNEL32: GetStringTypeExA, not properly implemented\n"));
|
|---|
| 378 | return(GetStringTypeA(Locale, fdwInfoType, lpSrcStr, cchSrc, lpCharType));
|
|---|
| 379 | }
|
|---|
| 380 | //******************************************************************************
|
|---|
| 381 | //******************************************************************************
|
|---|
| 382 | VOID WIN32API EnterCriticalSection(CRITICAL_SECTION * lpcsCriticalSection)
|
|---|
| 383 | {
|
|---|
| 384 | //// dprintf(("KERNEL32: EnterCriticalSection\n"));
|
|---|
| 385 | O32_EnterCriticalSection(lpcsCriticalSection);
|
|---|
| 386 | }
|
|---|
| 387 | //******************************************************************************
|
|---|
| 388 | //******************************************************************************
|
|---|
| 389 | VOID WIN32API LeaveCriticalSection(CRITICAL_SECTION * arg1)
|
|---|
| 390 | {
|
|---|
| 391 | //// dprintf(("KERNEL32: LeaveCriticalSection\n"));
|
|---|
| 392 | O32_LeaveCriticalSection(arg1);
|
|---|
| 393 | }
|
|---|
| 394 | //******************************************************************************
|
|---|
| 395 | //******************************************************************************
|
|---|
| 396 | VOID WIN32API InitializeCriticalSection(CRITICAL_SECTION * arg1)
|
|---|
| 397 | {
|
|---|
| 398 | dprintf(("KERNEL32: InitializeCriticalSection\n"));
|
|---|
| 399 | O32_InitializeCriticalSection(arg1);
|
|---|
| 400 | }
|
|---|
| 401 | //******************************************************************************
|
|---|
| 402 | //******************************************************************************
|
|---|
| 403 | void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *arg1 )
|
|---|
| 404 | {
|
|---|
| 405 | dprintf(("KERNEL32: MakeCriticalSectionGlobal not implemented correctly\n"));
|
|---|
| 406 | }
|
|---|
| 407 | //******************************************************************************
|
|---|
| 408 | //******************************************************************************
|
|---|
| 409 | BOOL WIN32API SetEnvironmentVariableA(LPCSTR arg1, LPCSTR arg2)
|
|---|
| 410 | {
|
|---|
| 411 | dprintf(("KERNEL32: SetEnvironmentVariable %s to %s\n", arg1, arg2));
|
|---|
| 412 | return O32_SetEnvironmentVariable(arg1, arg2);
|
|---|
| 413 | }
|
|---|
| 414 | //******************************************************************************
|
|---|
| 415 | //******************************************************************************
|
|---|
| 416 | BOOL WIN32API SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue)
|
|---|
| 417 | {
|
|---|
| 418 | char *asciiname, *asciivalue;
|
|---|
| 419 | BOOL rc;
|
|---|
| 420 |
|
|---|
| 421 | dprintf(("KERNEL32: OS2SetEnvironmentVariableW\n"));
|
|---|
| 422 | asciiname = UnicodeToAsciiString((LPWSTR)lpName);
|
|---|
| 423 | asciivalue = UnicodeToAsciiString((LPWSTR)lpValue);
|
|---|
| 424 | rc = O32_SetEnvironmentVariable(asciiname, asciivalue);
|
|---|
| 425 | FreeAsciiString(asciivalue);
|
|---|
| 426 | FreeAsciiString(asciiname);
|
|---|
| 427 | return(rc);
|
|---|
| 428 | }
|
|---|
| 429 | //******************************************************************************
|
|---|
| 430 | VOID WIN32API GlobalMemoryStatus( MEMORYSTATUS *arg1)
|
|---|
| 431 | {
|
|---|
| 432 | dprintf(("KERNEL32: GlobalMemoryStatus\n"));
|
|---|
| 433 | O32_GlobalMemoryStatus(arg1);
|
|---|
| 434 | dprintf(("dwMemoryLoad %X\n", arg1->dwMemoryLoad));
|
|---|
| 435 | dprintf(("dwTotalPhys %X\n", arg1->dwTotalPhys));
|
|---|
| 436 | dprintf(("dwAvailPhys %X\n", arg1->dwAvailPhys));
|
|---|
| 437 | dprintf(("dwTotalPageFile %X\n", arg1->dwTotalPageFile));
|
|---|
| 438 | dprintf(("dwAvailPageFile %X\n", arg1->dwAvailPageFile));
|
|---|
| 439 | dprintf(("dwTotalVirtual %X\n", arg1->dwTotalVirtual));
|
|---|
| 440 | dprintf(("dwAvailVirtual %X\n", arg1->dwAvailVirtual));
|
|---|
| 441 | }
|
|---|
| 442 | //******************************************************************************
|
|---|
| 443 | //******************************************************************************
|
|---|
| 444 | DWORD WIN32API GetEnvironmentVariableA(LPCSTR arg1, LPSTR arg2, DWORD arg3)
|
|---|
| 445 | {
|
|---|
| 446 | dprintf(("KERNEL32: GetEnvironmentVariable %s\n", arg1));
|
|---|
| 447 | return O32_GetEnvironmentVariable(arg1, arg2, arg3);
|
|---|
| 448 | }
|
|---|
| 449 | //******************************************************************************
|
|---|
| 450 | //******************************************************************************
|
|---|
| 451 | DWORD WIN32API GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer,
|
|---|
| 452 | DWORD nSize)
|
|---|
| 453 | {
|
|---|
| 454 | char *astring, *asciibuffer;
|
|---|
| 455 | DWORD rc;
|
|---|
| 456 |
|
|---|
| 457 | dprintf(("KERNEL32: OS2GetEnvironmentVariableW\n"));
|
|---|
| 458 | asciibuffer = (char *)malloc(nSize+1);
|
|---|
| 459 | astring = UnicodeToAsciiString((LPWSTR)lpName);
|
|---|
| 460 |
|
|---|
| 461 | rc = O32_GetEnvironmentVariable(astring, asciibuffer, nSize);
|
|---|
| 462 | AsciiToUnicode(asciibuffer, lpBuffer);
|
|---|
| 463 | FreeAsciiString(astring);
|
|---|
| 464 | free(asciibuffer);
|
|---|
| 465 | return(rc);
|
|---|
| 466 | }
|
|---|
| 467 | //******************************************************************************
|
|---|
| 468 | //******************************************************************************
|
|---|
| 469 | HINSTANCE WIN32API WinExec(LPCSTR arg1, UINT arg2)
|
|---|
| 470 | {
|
|---|
| 471 | dprintf(("KERNEL32: WinExec %s\n", arg1));
|
|---|
| 472 | return (HINSTANCE)O32_WinExec(arg1, arg2);
|
|---|
| 473 | }
|
|---|
| 474 | //******************************************************************************
|
|---|
| 475 | //******************************************************************************
|
|---|
| 476 | BOOL WIN32API GetExitCodeProcess(HANDLE arg1, LPDWORD arg2)
|
|---|
| 477 | {
|
|---|
| 478 | dprintf(("KERNEL32: GetExitCodeProcess\n"));
|
|---|
| 479 | return O32_GetExitCodeProcess(arg1, arg2);
|
|---|
| 480 | }
|
|---|
| 481 | //******************************************************************************
|
|---|
| 482 | //******************************************************************************
|
|---|
| 483 | HANDLE WIN32API GetCurrentProcess(void)
|
|---|
| 484 | {
|
|---|
| 485 | //// dprintf(("KERNEL32: GetCurrentProcess\n"));
|
|---|
| 486 | return O32_GetCurrentProcess();
|
|---|
| 487 | }
|
|---|
| 488 | //******************************************************************************
|
|---|
| 489 | //******************************************************************************
|
|---|
| 490 | DWORD WIN32API GetCurrentProcessId(void)
|
|---|
| 491 | {
|
|---|
| 492 | dprintf(("KERNEL32: GetCurrentProcessId\n"));
|
|---|
| 493 | return O32_GetCurrentProcessId();
|
|---|
| 494 | }
|
|---|
| 495 | //******************************************************************************
|
|---|
| 496 | //******************************************************************************
|
|---|
| 497 | BOOL WIN32API TerminateProcess( HANDLE arg1, DWORD arg2)
|
|---|
| 498 | {
|
|---|
| 499 | dprintf(("KERNEL32: TerminateProcess\n"));
|
|---|
| 500 | return O32_TerminateProcess(arg1, arg2);
|
|---|
| 501 | }
|
|---|
| 502 | //******************************************************************************
|
|---|
| 503 | //******************************************************************************
|
|---|
| 504 | VOID WIN32API Sleep(DWORD arg1)
|
|---|
| 505 | {
|
|---|
| 506 | dprintf(("KERNEL32: Sleep %d\n", arg1));
|
|---|
| 507 | O32_Sleep(arg1);
|
|---|
| 508 | }
|
|---|
| 509 | //******************************************************************************
|
|---|
| 510 | //******************************************************************************
|
|---|
| 511 | DWORD WIN32API GetPriorityClass(HANDLE arg1)
|
|---|
| 512 | {
|
|---|
| 513 | dprintf(("KERNEL32: GetPriorityClass\n"));
|
|---|
| 514 | return O32_GetPriorityClass(arg1);
|
|---|
| 515 | }
|
|---|
| 516 | //******************************************************************************
|
|---|
| 517 | //******************************************************************************
|
|---|
| 518 | BOOL WIN32API SetPriorityClass(HANDLE arg1, DWORD arg2)
|
|---|
| 519 | {
|
|---|
| 520 | dprintf(("KERNEL32: SetPriorityClass\n"));
|
|---|
| 521 | return O32_SetPriorityClass(arg1, arg2);
|
|---|
| 522 | }
|
|---|
| 523 | //******************************************************************************
|
|---|
| 524 | //TODO!
|
|---|
| 525 | //******************************************************************************
|
|---|
| 526 | int WIN32API LCMapStringW(
|
|---|
| 527 | DWORD /*LCID*/ Locale,
|
|---|
| 528 | DWORD dwMapFlags,
|
|---|
| 529 | LPCWSTR lpSrcStr,
|
|---|
| 530 | int cchSrc,
|
|---|
| 531 | LPWSTR lpDestStr,
|
|---|
| 532 | int cchDest)
|
|---|
| 533 | {
|
|---|
| 534 | // quick hack! this code is not done!
|
|---|
| 535 | if(cchSrc == -1)
|
|---|
| 536 | cchSrc = strlen((const char *)lpSrcStr);
|
|---|
| 537 | if(!cchDest)
|
|---|
| 538 | return cchSrc;
|
|---|
| 539 | strncpy((char *)lpDestStr, (const char *)lpSrcStr, max(cchSrc, cchDest));
|
|---|
| 540 | return max(cchSrc, cchDest);
|
|---|
| 541 | }
|
|---|
| 542 | //******************************************************************************
|
|---|
| 543 | //TODO!
|
|---|
| 544 | //******************************************************************************
|
|---|
| 545 | int WIN32API LCMapStringA(
|
|---|
| 546 | DWORD /*LCID*/ Locale,
|
|---|
| 547 | DWORD dwMapFlags,
|
|---|
| 548 | LPCSTR lpSrcStr,
|
|---|
| 549 | int cchSrc,
|
|---|
| 550 | LPSTR lpDestStr,
|
|---|
| 551 | int cchDest)
|
|---|
| 552 | {
|
|---|
| 553 | dprintf(("KERNEL32: LCMapStringA not implemented\n"));
|
|---|
| 554 | if(cchSrc == -1)
|
|---|
| 555 | cchSrc = strlen((const char *)lpSrcStr);
|
|---|
| 556 | if(!cchDest)
|
|---|
| 557 | return cchSrc;
|
|---|
| 558 | strncpy((char *)lpDestStr, (const char *)lpSrcStr, max(cchSrc, cchDest));
|
|---|
| 559 | return max(cchSrc, cchDest);
|
|---|
| 560 | }
|
|---|
| 561 | //******************************************************************************
|
|---|
| 562 | //SvL: 24-6-'97 - Added
|
|---|
| 563 | //******************************************************************************
|
|---|
| 564 | VOID WIN32API DeleteCriticalSection( CRITICAL_SECTION * arg1)
|
|---|
| 565 | {
|
|---|
| 566 | dprintf(("KERNEL32: OS2DeleteCriticalSection\n"));
|
|---|
| 567 | O32_DeleteCriticalSection(arg1);
|
|---|
| 568 | }
|
|---|
| 569 | //******************************************************************************
|
|---|
| 570 | //******************************************************************************
|
|---|
| 571 | BOOL WIN32API Beep( DWORD arg1, DWORD arg2)
|
|---|
| 572 | {
|
|---|
| 573 | dprintf(("KERNEL32: OS2Beep\n"));
|
|---|
| 574 | return O32_Beep(arg1, arg2);
|
|---|
| 575 | }
|
|---|
| 576 | //******************************************************************************
|
|---|
| 577 | //******************************************************************************
|
|---|
| 578 | VOID WIN32API FatalAppExitA( UINT arg1, LPCSTR arg2)
|
|---|
| 579 | {
|
|---|
| 580 | dprintf(("KERNEL32: OS2FatalAppExitA\n"));
|
|---|
| 581 | O32_FatalAppExit(arg1, arg2);
|
|---|
| 582 | }
|
|---|
| 583 | //******************************************************************************
|
|---|
| 584 | //******************************************************************************
|
|---|
| 585 | VOID WIN32API FatalAppExitW(UINT arg1, LPCWSTR arg2)
|
|---|
| 586 | {
|
|---|
| 587 | char *astring;
|
|---|
| 588 |
|
|---|
| 589 | dprintf(("KERNEL32: OS2FatalAppExitW\n"));
|
|---|
| 590 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
|---|
| 591 | O32_FatalAppExit(arg1, astring);
|
|---|
| 592 | //probably won't return, but who cares..
|
|---|
| 593 | FreeAsciiString(astring);
|
|---|
| 594 | }
|
|---|
| 595 | //******************************************************************************
|
|---|
| 596 | //******************************************************************************
|
|---|
| 597 | VOID WIN32API FatalExit( UINT arg1)
|
|---|
| 598 | {
|
|---|
| 599 | dprintf(("KERNEL32: OS2FatalExit\n"));
|
|---|
| 600 | O32_FatalExit(arg1);
|
|---|
| 601 | }
|
|---|
| 602 | //******************************************************************************
|
|---|
| 603 | //******************************************************************************
|
|---|
| 604 | LPSTR WIN32API GetEnvironmentStringsA(void)
|
|---|
| 605 | {
|
|---|
| 606 | dprintf(("KERNEL32: OS2GetEnvironmentStringsA\n"));
|
|---|
| 607 | return (LPSTR) O32_GetEnvironmentStrings();
|
|---|
| 608 | }
|
|---|
| 609 | //******************************************************************************
|
|---|
| 610 | //******************************************************************************
|
|---|
| 611 | BOOL WIN32API IsBadHugeReadPtr( const void * arg1, UINT arg2)
|
|---|
| 612 | {
|
|---|
| 613 | dprintf(("KERNEL32: OS2IsBadHugeReadPtr\n"));
|
|---|
| 614 | return O32_IsBadHugeReadPtr(arg1, arg2);
|
|---|
| 615 | }
|
|---|
| 616 | //******************************************************************************
|
|---|
| 617 | //******************************************************************************
|
|---|
| 618 | BOOL WIN32API IsBadHugeWritePtr( PVOID arg1, UINT arg2)
|
|---|
| 619 | {
|
|---|
| 620 | dprintf(("KERNEL32: OS2IsBadHugeWritePtr\n"));
|
|---|
| 621 | return O32_IsBadHugeWritePtr(arg1, arg2);
|
|---|
| 622 | }
|
|---|
| 623 | //******************************************************************************
|
|---|
| 624 | //******************************************************************************
|
|---|
| 625 | BOOL WIN32API IsDBCSLeadByte(BYTE arg1)
|
|---|
| 626 | {
|
|---|
| 627 | dprintf(("KERNEL32: OS2IsDBCSLeadByte\n"));
|
|---|
| 628 | return O32_IsDBCSLeadByte(arg1);
|
|---|
| 629 | }
|
|---|
| 630 | //******************************************************************************
|
|---|
| 631 | //******************************************************************************
|
|---|
| 632 | DWORD WIN32API LoadModule( LPCSTR arg1, PVOID arg2)
|
|---|
| 633 | {
|
|---|
| 634 | dprintf(("KERNEL32: OS2LoadModule\n"));
|
|---|
| 635 | return O32_LoadModule(arg1, arg2);
|
|---|
| 636 | }
|
|---|
| 637 | //******************************************************************************
|
|---|
| 638 | //******************************************************************************
|
|---|
| 639 | int WIN32API MulDiv(int arg1, int arg2, int arg3)
|
|---|
| 640 | {
|
|---|
| 641 | dprintf(("KERNEL32: OS2MulDiv %d*%d/%d\n", arg1, arg2, arg3));
|
|---|
| 642 | return O32_MulDiv(arg1, arg2, arg3);
|
|---|
| 643 | }
|
|---|
| 644 | //******************************************************************************
|
|---|
| 645 | //******************************************************************************
|
|---|
| 646 | HANDLE WIN32API OpenProcess(DWORD arg1, BOOL arg2, DWORD arg3)
|
|---|
| 647 | {
|
|---|
| 648 | dprintf(("KERNEL32: OS2OpenProcess\n"));
|
|---|
| 649 | return O32_OpenProcess(arg1, arg2, arg3);
|
|---|
| 650 | }
|
|---|
| 651 | //******************************************************************************
|
|---|
| 652 | //******************************************************************************
|
|---|
| 653 | //SvL: BUGFIX: C calling convention!
|
|---|
| 654 | //******************************************************************************
|
|---|
| 655 | VOID __cdecl OS2memmove(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, DWORD Length)
|
|---|
| 656 | {
|
|---|
| 657 | memmove(Destination, Source, Length);
|
|---|
| 658 | }
|
|---|
| 659 | //******************************************************************************
|
|---|
| 660 |
|
|---|
| 661 | //******************************************************************************
|
|---|
| 662 | UINT WIN32API CompareStringA(LCID lcid, DWORD fdwStyle, LPCSTR lpString1,
|
|---|
| 663 | DWORD cch1, LPCSTR lpString2, DWORD cch2)
|
|---|
| 664 | {
|
|---|
| 665 | int i;
|
|---|
| 666 | int fEqual = TRUE;
|
|---|
| 667 | char *string1 = (char *)lpString1, *string2 = (char *)lpString2;
|
|---|
| 668 |
|
|---|
| 669 | #ifdef DEBUG
|
|---|
| 670 | if(fdwStyle & SORT_STRINGSORT)
|
|---|
| 671 | dprintf(("KERNEL32: SORT_STRINGSORT not supported!\n"));
|
|---|
| 672 | if(fdwStyle & NORM_IGNORENONSPACE)
|
|---|
| 673 | dprintf(("KERNEL32: NORM_IGNORENONSPACE not supported!\n"));
|
|---|
| 674 | if(fdwStyle & NORM_IGNORESYMBOLS)
|
|---|
| 675 | dprintf(("KERNEL32: NORM_IGNORESYMBOLS not supported!\n"));
|
|---|
| 676 | #endif
|
|---|
| 677 |
|
|---|
| 678 | if(cch1 == -1) cch1 = strlen(string1);
|
|---|
| 679 | if(cch2 == -1) cch2 = strlen(string2);
|
|---|
| 680 |
|
|---|
| 681 | if(fdwStyle) {
|
|---|
| 682 | //TODO!
|
|---|
| 683 | if(fdwStyle != 0 && fdwStyle != NORM_IGNORECASE)
|
|---|
| 684 | return(0); /*PLF Fri 98-03-13 04:09:32 was return 1 */
|
|---|
| 685 | }
|
|---|
| 686 | if(fdwStyle & NORM_IGNORECASE)
|
|---|
| 687 | fEqual = strnicmp(string1, string2, min(cch1, cch2));
|
|---|
| 688 | else
|
|---|
| 689 | fEqual = strncmp(string1, string2, min(cch1, cch2));
|
|---|
| 690 |
|
|---|
| 691 | if (fEqual < 0 ) fEqual = 1;
|
|---|
| 692 | else if(fEqual == 0) fEqual = 2;
|
|---|
| 693 | else if(fEqual > 0) fEqual = 3;
|
|---|
| 694 |
|
|---|
| 695 | //If equal, but different length, largest one is the greatest in lexical value
|
|---|
| 696 | if(fEqual == 2 && cch1 != cch2){
|
|---|
| 697 | if(cch1 < cch2)
|
|---|
| 698 | fEqual = 1;
|
|---|
| 699 | else
|
|---|
| 700 | fEqual = 3;
|
|---|
| 701 | }
|
|---|
| 702 | // dprintf(("KERNEL32: OS2CompareStringA '%s' - '%s' returned %d\n", lpString1, lpString2, fEqual));
|
|---|
| 703 | return(fEqual);
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 | //******************************************************************************
|
|---|
| 707 | //TODO: Not complete (fdwStyle flags specify compare method)
|
|---|
| 708 | //******************************************************************************
|
|---|
| 709 | UINT WIN32API CompareStringW(LCID lcid, DWORD fdwStyle, LPCWSTR lpString1,
|
|---|
| 710 | DWORD cch1, LPCWSTR lpString2, DWORD cch2)
|
|---|
| 711 | {
|
|---|
| 712 | int i;
|
|---|
| 713 | int fEqual = TRUE;
|
|---|
| 714 | char *string1 = UnicodeToAsciiString((LPWSTR)lpString1);
|
|---|
| 715 | char *string2 = UnicodeToAsciiString((LPWSTR)lpString2);
|
|---|
| 716 |
|
|---|
| 717 | // dprintf(("KERNEL32: OS2CompareStringW '%s' - '%s'\n", string1, string2));
|
|---|
| 718 |
|
|---|
| 719 | fEqual = CompareStringA(lcid, fdwStyle, string1, cch1, string2, cch2);
|
|---|
| 720 | FreeAsciiString(string1);
|
|---|
| 721 | FreeAsciiString(string2);
|
|---|
| 722 |
|
|---|
| 723 | return(fEqual);
|
|---|
| 724 | }
|
|---|
| 725 | //******************************************************************************
|
|---|
| 726 | //TODO:What does this do exactly??
|
|---|
| 727 | // @@@OPH -> see WINE
|
|---|
| 728 | //******************************************************************************
|
|---|
| 729 | BOOL WIN32API DisableThreadLibraryCalls(HMODULE hLibModule)
|
|---|
| 730 | {
|
|---|
| 731 | dprintf(("KERNEL32: (NI!)OS2DisableThreadLibraryCalls of %X\n", hLibModule));
|
|---|
| 732 | return(TRUE);
|
|---|
| 733 | }
|
|---|
| 734 | //******************************************************************************
|
|---|
| 735 | //******************************************************************************
|
|---|
| 736 | //TODO: Query processor info to complete this api
|
|---|
| 737 | //******************************************************************************
|
|---|
| 738 | VOID WIN32API GetSystemInfo(LPSYSTEM_INFO lpSystemInfo)
|
|---|
| 739 | {
|
|---|
| 740 | dprintf(("KERNEL32: GetSystemInfo, not completely accurate\n"));
|
|---|
| 741 | lpSystemInfo->u.x.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_INTEL;
|
|---|
| 742 | lpSystemInfo->u.x.wReserved = 0;
|
|---|
| 743 | lpSystemInfo->dwPageSize = 4096;
|
|---|
| 744 | lpSystemInfo->lpMinimumApplicationAddress = (LPVOID)0;
|
|---|
| 745 | lpSystemInfo->lpMaximumApplicationAddress = (LPVOID)(512*1024*1024);
|
|---|
| 746 | lpSystemInfo->dwActiveProcessorMask = 1;
|
|---|
| 747 | lpSystemInfo->dwNumberOfProcessors = 1; //assuming non-SMP OS/2
|
|---|
| 748 | lpSystemInfo->dwProcessorType = PROCESSOR_INTEL_PENTIUM;
|
|---|
| 749 | lpSystemInfo->dwAllocationGranularity = 64*1024;
|
|---|
| 750 | lpSystemInfo->wProcessorLevel = 5; //Pentium
|
|---|
| 751 | lpSystemInfo->wProcessorRevision = 0x201; //Model 2 stepping 1 (obviously not correct)
|
|---|
| 752 | }
|
|---|
| 753 | //******************************************************************************
|
|---|
| 754 | //Borrowed from Wine
|
|---|
| 755 | //******************************************************************************
|
|---|
| 756 | VOID WIN32API GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
|
|---|
| 757 | {
|
|---|
| 758 | dprintf(("KERNEL32: GetStartupInfo\n"));
|
|---|
| 759 | lpStartupInfo->cb = sizeof(STARTUPINFOA);
|
|---|
| 760 | lpStartupInfo->lpReserved = "<Reserved>";
|
|---|
| 761 | lpStartupInfo->lpDesktop = "Desktop";
|
|---|
| 762 | lpStartupInfo->lpTitle = "Title";
|
|---|
| 763 |
|
|---|
| 764 | lpStartupInfo->cbReserved2 = 0;
|
|---|
| 765 | lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
|
|---|
| 766 |
|
|---|
| 767 | /* @@@PH 98/07/13 Handlemanager support */
|
|---|
| 768 | lpStartupInfo->hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|---|
| 769 | lpStartupInfo->hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|---|
| 770 | lpStartupInfo->hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|---|
| 771 | return;
|
|---|
| 772 | }
|
|---|
| 773 | //******************************************************************************
|
|---|
| 774 | //Borrowed from Wine
|
|---|
| 775 | //******************************************************************************
|
|---|
| 776 | VOID WIN32API GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
|
|---|
| 777 | {
|
|---|
| 778 | static WCHAR lpReserved[] = {'<', 'R','e','s','e','r','v','e','d','>', 0};
|
|---|
| 779 | static WCHAR lpDesktop[] = {'D', 'e','s','k','t','o','p', 0};
|
|---|
| 780 | static WCHAR lpTitle[] = {'T', 'i','t','l','e', 0};
|
|---|
| 781 |
|
|---|
| 782 | dprintf(("KERNEL32: GetStartupInfoW\n"));
|
|---|
| 783 | lpStartupInfo->cb = sizeof(STARTUPINFOW);
|
|---|
| 784 | lpStartupInfo->lpReserved = lpReserved;
|
|---|
| 785 | lpStartupInfo->lpDesktop = lpDesktop;
|
|---|
| 786 | lpStartupInfo->lpTitle = lpTitle;
|
|---|
| 787 |
|
|---|
| 788 | lpStartupInfo->cbReserved2 = 0;
|
|---|
| 789 | lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
|
|---|
| 790 |
|
|---|
| 791 | /* @@@PH 98/07/13 Handlemanager support */
|
|---|
| 792 | lpStartupInfo->hStdInput = GetStdHandle(STD_INPUT_HANDLE);
|
|---|
| 793 | lpStartupInfo->hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
|
|---|
| 794 | lpStartupInfo->hStdError = GetStdHandle(STD_ERROR_HANDLE);
|
|---|
| 795 | return;
|
|---|
| 796 | }
|
|---|
| 797 | //******************************************************************************
|
|---|
| 798 | //TODO: Not complete or correct, but sufficient for now
|
|---|
| 799 | //******************************************************************************
|
|---|
| 800 | BOOL WIN32API GetBinaryTypeA(LPCTSTR lpApplicationName, LPDWORD lpBinaryType)
|
|---|
| 801 | {
|
|---|
| 802 | dprintf(("KERNEL32: OS2GetBinaryTypeA %s\n", lpApplicationName));
|
|---|
| 803 | if(strstr(lpApplicationName, ".EXE") || strstr(lpApplicationName, ".exe"))
|
|---|
| 804 | *lpBinaryType = SCS_32BIT_BINARY;
|
|---|
| 805 | else
|
|---|
| 806 | if(strstr(lpApplicationName, ".COM") || strstr(lpApplicationName, ".com"))
|
|---|
| 807 | *lpBinaryType = SCS_DOS_BINARY;
|
|---|
| 808 | else
|
|---|
| 809 | if(strstr(lpApplicationName, ".PIF") || strstr(lpApplicationName, ".pif"))
|
|---|
| 810 | *lpBinaryType = SCS_PIF_BINARY;
|
|---|
| 811 | else return(FALSE);
|
|---|
| 812 | return(TRUE);
|
|---|
| 813 | }
|
|---|
| 814 | //******************************************************************************
|
|---|
| 815 | //******************************************************************************
|
|---|
| 816 | BOOL WIN32API GetBinaryTypeW(LPCWSTR lpApplicationName, LPDWORD lpBinaryType)
|
|---|
| 817 | {
|
|---|
| 818 | BOOL rc;
|
|---|
| 819 | char *astring;
|
|---|
| 820 |
|
|---|
| 821 | dprintf(("KERNEL32: OS2GetBinaryTypeW\n"));
|
|---|
| 822 | astring = UnicodeToAsciiString((LPWSTR)lpApplicationName);
|
|---|
| 823 | rc = GetBinaryTypeA(astring, lpBinaryType);
|
|---|
| 824 | FreeAsciiString(astring);
|
|---|
| 825 | return(rc);
|
|---|
| 826 | }
|
|---|
| 827 | //******************************************************************************
|
|---|
| 828 | //TODO: SetLastError
|
|---|
| 829 | //******************************************************************************
|
|---|
| 830 | BOOL WIN32API GetVersionExA(OSVERSIONINFOA *lpVersionInformation)
|
|---|
| 831 | {
|
|---|
| 832 | dprintf(("KERNEL32: OS2GetVersionExA\n"));
|
|---|
| 833 |
|
|---|
| 834 | if(lpVersionInformation == NULL || lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOA))
|
|---|
| 835 | return(FALSE);
|
|---|
| 836 |
|
|---|
| 837 | lpVersionInformation->dwMajorVersion = 4; //pretend we're NT 4.0
|
|---|
| 838 | lpVersionInformation->dwMinorVersion = 0;
|
|---|
| 839 | lpVersionInformation->dwBuildNumber = 1564;
|
|---|
| 840 | lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
|---|
| 841 | lpVersionInformation->szCSDVersion[0]= 0;
|
|---|
| 842 | return(TRUE);
|
|---|
| 843 | }
|
|---|
| 844 | //******************************************************************************
|
|---|
| 845 | //******************************************************************************
|
|---|
| 846 | BOOL WIN32API GetVersionExW(OSVERSIONINFOW *lpVersionInformation)
|
|---|
| 847 | {
|
|---|
| 848 | dprintf(("KERNEL32: OS2GetVersionExW\n"));
|
|---|
| 849 |
|
|---|
| 850 | if(lpVersionInformation == NULL || lpVersionInformation->dwOSVersionInfoSize != sizeof(OSVERSIONINFOW))
|
|---|
| 851 | return(FALSE);
|
|---|
| 852 |
|
|---|
| 853 | lpVersionInformation->dwMajorVersion = 4; //pretend we're NT 4.0
|
|---|
| 854 | lpVersionInformation->dwMinorVersion = 0;
|
|---|
| 855 | lpVersionInformation->dwBuildNumber = 1564;
|
|---|
| 856 | lpVersionInformation->dwPlatformId = VER_PLATFORM_WIN32_NT;
|
|---|
| 857 | lpVersionInformation->szCSDVersion[0]= 0;
|
|---|
| 858 | return(TRUE);
|
|---|
| 859 | }
|
|---|
| 860 | //******************************************************************************
|
|---|
| 861 | //Should retrieve this from the exe...
|
|---|
| 862 | //******************************************************************************
|
|---|
| 863 | DWORD WIN32API GetProcessVersion(DWORD Processid)
|
|---|
| 864 | {
|
|---|
| 865 | dprintf(("KERNEL32: OS2GetProcessVersion not correctly implemented!!\n"));
|
|---|
| 866 | return(WIN32OS2_VERSION);
|
|---|
| 867 | }
|
|---|
| 868 | //******************************************************************************
|
|---|
| 869 | //******************************************************************************
|
|---|
| 870 | LONG WIN32API GetVersion()
|
|---|
| 871 | {
|
|---|
| 872 | dprintf(("KERNEL32: GetVersion\n"));
|
|---|
| 873 | // highword 0 = NT, lowword high byte major ver, low byte minor ver
|
|---|
| 874 | /* @@@PH 98/04/04 MFC30 makes assumptions about process control block */
|
|---|
| 875 | /* structures that lead to crashes if we don't identify as NT */
|
|---|
| 876 |
|
|---|
| 877 | // return(WIN32OS2_VERSION);
|
|---|
| 878 | return (0x0);
|
|---|
| 879 | }
|
|---|
| 880 | //******************************************************************************
|
|---|
| 881 | //SvL: 26-6-'97 - Added
|
|---|
| 882 | //******************************************************************************
|
|---|
| 883 | VOID WIN32API OutputDebugStringW(LPCWSTR arg1)
|
|---|
| 884 | {
|
|---|
| 885 | char *astring;
|
|---|
| 886 |
|
|---|
| 887 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
|---|
| 888 | dprintf(("KERNEL32: OS2OutputDebugStringW %s\n", astring));
|
|---|
| 889 | FreeAsciiString(astring);
|
|---|
| 890 | }
|
|---|
| 891 | //******************************************************************************
|
|---|
| 892 | //******************************************************************************
|
|---|
| 893 | VOID WIN32API OutputDebugStringA(LPCSTR lpszOutputString)
|
|---|
| 894 | {
|
|---|
| 895 | dprintf(("KERNEL32: OutputDebugStringA: %s\n", lpszOutputString));
|
|---|
| 896 | return;
|
|---|
| 897 | }
|
|---|
| 898 | //******************************************************************************
|
|---|
| 899 | //Obsolete
|
|---|
| 900 | //******************************************************************************
|
|---|
| 901 | DWORD WIN32API GetProcessHeaps(DWORD NumberOfHeaps, PHANDLE ProcessHeaps)
|
|---|
| 902 | {
|
|---|
| 903 | dprintf(("KERNEL32: GetProcessHeaps, Not implemented\n"));
|
|---|
| 904 | return(0);
|
|---|
| 905 | }
|
|---|
| 906 | //******************************************************************************
|
|---|
| 907 | //WINE
|
|---|
| 908 | //******************************************************************************
|
|---|
| 909 | BOOL WIN32API GetProcessAffinityMask(HANDLE hProcess,
|
|---|
| 910 | LPDWORD lpProcessAffinityMask,
|
|---|
| 911 | LPDWORD lpSystemAffinityMask)
|
|---|
| 912 | {
|
|---|
| 913 | /* It is definitely important for a process to know on what processor
|
|---|
| 914 | it is running :-) */
|
|---|
| 915 | if(lpProcessAffinityMask)
|
|---|
| 916 | *lpProcessAffinityMask=1;
|
|---|
| 917 | if(lpSystemAffinityMask)
|
|---|
| 918 | *lpSystemAffinityMask=1;
|
|---|
| 919 | return TRUE;
|
|---|
| 920 | }
|
|---|
| 921 | //******************************************************************************
|
|---|
| 922 | //******************************************************************************
|
|---|
| 923 |
|
|---|
| 924 |
|
|---|
| 925 | BOOL WIN32API FlushInstructionCache( /*PLF Mon 98-02-09 23:56:49 : STUB STUB STUB STUB STUB */
|
|---|
| 926 | HANDLE hProcess, /* process with cache to flush */
|
|---|
| 927 | LPCVOID lpvBase, /* address of region to flush */
|
|---|
| 928 | DWORD cbFlush) /* length of region to flush */
|
|---|
| 929 |
|
|---|
| 930 | {
|
|---|
| 931 | dprintf(("FlushInstructionCache() - NIY\n"));
|
|---|
| 932 | return TRUE;
|
|---|
| 933 | }
|
|---|
| 934 |
|
|---|
| 935 |
|
|---|
| 936 | //******************************************************************************
|
|---|
| 937 | VOID WIN32API UninitializeCriticalSection(CRITICAL_SECTION * lpcsCriticalSection)
|
|---|
| 938 | {
|
|---|
| 939 | dprintf(("KERNEL32: UninitializeCriticalSection NOT IMPLEMENTED\n"));
|
|---|
| 940 | }
|
|---|
| 941 |
|
|---|
| 942 | int WIN32API GetNumberFormatA(LCID Locale,
|
|---|
| 943 | DWORD dwFlags,
|
|---|
| 944 | LPCSTR lpValue,
|
|---|
| 945 | CONST NUMBERFMTA *lpFormat,
|
|---|
| 946 | LPSTR lpNumberStr,
|
|---|
| 947 | int cchNumber)
|
|---|
| 948 | {
|
|---|
| 949 | dprintf(("KERNEL32::OS2GetNumberFormatA(%08x,%08x,%s,%08x,%s,%08x) not implemented.\n",
|
|---|
| 950 | Locale,
|
|---|
| 951 | dwFlags,
|
|---|
| 952 | lpValue,
|
|---|
| 953 | lpFormat,
|
|---|
| 954 | lpNumberStr,
|
|---|
| 955 | cchNumber));
|
|---|
| 956 |
|
|---|
| 957 | return 0;
|
|---|
| 958 | }
|
|---|
| 959 |
|
|---|
| 960 | int WIN32API GetNumberFormatW(LCID Locale,
|
|---|
| 961 | DWORD dwFlags,
|
|---|
| 962 | LPCWSTR lpValue,
|
|---|
| 963 | CONST NUMBERFMTW *lpFormat,
|
|---|
| 964 | LPWSTR lpNumberStr,
|
|---|
| 965 | int cchNumber)
|
|---|
| 966 | {
|
|---|
| 967 | dprintf(("KERNEL32::OS2GetNumberFormatW(%08x,%08x,%s,%08x,%s,%08x) not implemented.\n",
|
|---|
| 968 | Locale,
|
|---|
| 969 | dwFlags,
|
|---|
| 970 | lpValue,
|
|---|
| 971 | lpFormat,
|
|---|
| 972 | lpNumberStr,
|
|---|
| 973 | cchNumber));
|
|---|
| 974 |
|
|---|
| 975 | return 0;
|
|---|
| 976 | }
|
|---|
| 977 |
|
|---|
| 978 | BOOL WIN32API FindCloseChangeNotification(HANDLE hChange)
|
|---|
| 979 | {
|
|---|
| 980 | dprintf(("KERNEL32: OS2FindNextChangeNotification, Not implemented\n"));
|
|---|
| 981 |
|
|---|
| 982 | return(TRUE);
|
|---|
| 983 | }
|
|---|
| 984 |
|
|---|
| 985 | //******************************************************************************
|
|---|
| 986 | //******************************************************************************
|
|---|
| 987 | void WIN32API WrongComctl32()
|
|---|
| 988 | {
|
|---|
| 989 | O32_MessageBox(NULL,
|
|---|
| 990 | "KERNEL32.36 not implemented",
|
|---|
| 991 | "Win32 for OS/2 Error",
|
|---|
| 992 | MB_OK);
|
|---|
| 993 | ExitProcess(987);
|
|---|
| 994 | }
|
|---|
| 995 | //******************************************************************************
|
|---|
| 996 |
|
|---|
| 997 |
|
|---|
| 998 |
|
|---|
| 999 | /***********************************************************************
|
|---|
| 1000 | * RtlFillMemory (KERNEL32.441)
|
|---|
| 1001 | */
|
|---|
| 1002 | VOID WIN32API RtlFillMemory(LPVOID ptr,
|
|---|
| 1003 | UINT len,
|
|---|
| 1004 | UINT fill )
|
|---|
| 1005 | {
|
|---|
| 1006 | #ifdef DEBUG_LOCAL
|
|---|
| 1007 | dprintf(("KERNEL32: RtlFillMemory(%08x,%08x,%08x)\n",
|
|---|
| 1008 | ptr,
|
|---|
| 1009 | len,
|
|---|
| 1010 | fill));
|
|---|
| 1011 | #endif
|
|---|
| 1012 |
|
|---|
| 1013 | memset(ptr,
|
|---|
| 1014 | fill,
|
|---|
| 1015 | len );
|
|---|
| 1016 | }
|
|---|
| 1017 |
|
|---|
| 1018 |
|
|---|
| 1019 | /***********************************************************************
|
|---|
| 1020 | * RtlMoveMemory (KERNEL32.442)
|
|---|
| 1021 | */
|
|---|
| 1022 | VOID WIN32API RtlMoveMemory(LPVOID dst,
|
|---|
| 1023 | LPCVOID src,
|
|---|
| 1024 | UINT len )
|
|---|
| 1025 | {
|
|---|
| 1026 | #ifdef DEBUG_LOCAL
|
|---|
| 1027 | dprintf(("KERNEL32: RtlMoveMemory(%08x,%08x,%08x)\n",
|
|---|
| 1028 | dst,
|
|---|
| 1029 | src,
|
|---|
| 1030 | len));
|
|---|
| 1031 | #endif
|
|---|
| 1032 |
|
|---|
| 1033 | memmove(dst,
|
|---|
| 1034 | src,
|
|---|
| 1035 | len );
|
|---|
| 1036 | }
|
|---|
| 1037 |
|
|---|
| 1038 |
|
|---|
| 1039 | /***********************************************************************
|
|---|
| 1040 | * RtlZeroMemory (KERNEL32.444)
|
|---|
| 1041 | */
|
|---|
| 1042 | VOID WIN32API RtlZeroMemory(LPVOID ptr,
|
|---|
| 1043 | UINT len)
|
|---|
| 1044 | {
|
|---|
| 1045 | #ifdef DEBUG_LOCAL
|
|---|
| 1046 | dprintf(("KERNEL32: RtlZeroMemory(%08x,%08x)\n",
|
|---|
| 1047 | ptr,
|
|---|
| 1048 | len));
|
|---|
| 1049 | #endif
|
|---|
| 1050 |
|
|---|
| 1051 | memset(ptr,
|
|---|
| 1052 | 0,
|
|---|
| 1053 | len);
|
|---|
| 1054 | }
|
|---|
| 1055 |
|
|---|
| 1056 |
|
|---|
| 1057 | //******************************************************************************
|
|---|
| 1058 | /*KSO Thu 21.05.1998*/
|
|---|
| 1059 | BOOL WIN32API IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar)
|
|---|
| 1060 | {
|
|---|
| 1061 | dprintf(("KERNEL32: OS2IsDBCSLeadByteEx - not correctly implemented\n"));
|
|---|
| 1062 | return O32_IsDBCSLeadByte(TestChar);
|
|---|
| 1063 | }
|
|---|
| 1064 | //******************************************************************************
|
|---|
| 1065 |
|
|---|
| 1066 |
|
|---|
| 1067 |
|
|---|
| 1068 |
|
|---|
| 1069 |
|
|---|
| 1070 |
|
|---|
| 1071 |
|
|---|
| 1072 |
|
|---|