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