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