- Timestamp:
- Sep 8, 2000, 8:07:52 PM (25 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/environ.cpp
r4208 r4224 1 /* $Id: environ.cpp,v 1. 5 2000-09-07 21:40:28 phallerExp $ */1 /* $Id: environ.cpp,v 1.6 2000-09-08 18:07:49 sandervl Exp $ */ 2 2 3 3 /* … … 17 17 * 18 18 */ 19 20 /*****************************************************************************21 * Includes *22 *****************************************************************************/23 24 19 #include <odin.h> 25 20 #include <odinwrap.h> … … 38 33 #include "dbglocal.h" 39 34 40 /***************************************************************************** 41 * Defines * 42 *****************************************************************************/ 43 44 ODINDEBUGCHANNEL(KERNEL32-ENVIRONMENT) 45 46 47 //****************************************************************************** 48 //****************************************************************************** 49 ODINFUNCTION0(LPSTR, GetEnvironmentStringsA) 50 { 51 return (LPSTR) O32_GetEnvironmentStrings(); 52 } 53 //****************************************************************************** 54 //****************************************************************************** 55 ODINFUNCTION0(LPWSTR, GetEnvironmentStringsW) 35 //****************************************************************************** 36 //****************************************************************************** 37 LPSTR WIN32API GetEnvironmentStringsA(void) 38 { 39 dprintf(("KERNEL32: OS2GetEnvironmentStringsA\n")); 40 return (LPSTR) O32_GetEnvironmentStrings(); 41 } 42 //****************************************************************************** 43 //****************************************************************************** 44 LPWSTR WIN32API GetEnvironmentStringsW(VOID) 56 45 { 57 46 char *envstrings = (char *)O32_GetEnvironmentStrings(); … … 59 48 LPWSTR wenvstrings; 60 49 int len, i; 50 51 dprintf(("KERNEL32: GetEnvironmentStringsW\n")); 61 52 62 53 if(envstrings == NULL) … … 82 73 //****************************************************************************** 83 74 //****************************************************************************** 84 ODINFUNCTION1(BOOL, FreeEnvironmentStringsA, 85 LPSTR, envstrings) 86 { 87 dprintf(("not correctly implemented.\n")); 88 //free(envstrings); 75 BOOL WIN32API FreeEnvironmentStringsA(LPSTR envstrings) 76 { 77 dprintf(("KERNEL32: FreeEnvironmentStringsA\n")); 89 78 return(TRUE); 90 79 } 91 80 //****************************************************************************** 92 81 //****************************************************************************** 93 ODINFUNCTION1(BOOL, FreeEnvironmentStringsW, 94 LPWSTR, envstrings) 95 { 96 dprintf(("not correctly implemented.\n")); 97 //free(envstrings); 82 BOOL WIN32API FreeEnvironmentStringsW(LPWSTR envstrings) 83 { 84 dprintf(("KERNEL32: FreeEnvironmentStringsW\n")); 85 free(envstrings); 98 86 return(TRUE); 99 87 } 100 88 //****************************************************************************** 101 89 //****************************************************************************** 102 ODINFUNCTION2(BOOL, SetEnvironmentVariableA, 103 LPCSTR, lpszName, 104 LPCSTR, lpszValue) 105 { 106 return O32_SetEnvironmentVariable(lpszName, lpszValue); 107 } 108 //****************************************************************************** 109 //****************************************************************************** 110 ODINFUNCTION2(BOOL, SetEnvironmentVariableW, 111 LPCWSTR, lpszName, 112 LPCWSTR, lpszValue) 113 { 114 char *asciiname, *asciivalue; 115 BOOL rc; 116 117 asciiname = UnicodeToAsciiString((LPWSTR)lpszName); 118 asciivalue = UnicodeToAsciiString((LPWSTR)lpszValue); 119 rc = O32_SetEnvironmentVariable(asciiname, asciivalue); 120 FreeAsciiString(asciivalue); 121 FreeAsciiString(asciiname); 122 return(rc); 123 } 124 //****************************************************************************** 125 //****************************************************************************** 126 ODINFUNCTION3(DWORD, GetEnvironmentVariableA, 127 LPCSTR, lpName, 128 LPSTR, lpBuffer, 129 DWORD, nSize) 130 { 131 return O32_GetEnvironmentVariable(lpName, lpBuffer, nSize); 132 } 133 //****************************************************************************** 134 //****************************************************************************** 135 ODINFUNCTION3(DWORD, GetEnvironmentVariableW, 136 LPCWSTR, lpName, 137 LPWSTR, lpBuffer, 138 DWORD, nSize) 90 BOOL WIN32API SetEnvironmentVariableA(LPCSTR arg1, LPCSTR arg2) 91 { 92 dprintf(("KERNEL32: SetEnvironmentVariable %s to %s\n", arg1, arg2)); 93 return O32_SetEnvironmentVariable(arg1, arg2); 94 } 95 //****************************************************************************** 96 //****************************************************************************** 97 BOOL WIN32API SetEnvironmentVariableW(LPCWSTR lpName, LPCWSTR lpValue) 98 { 99 char *asciiname, *asciivalue; 100 BOOL rc; 101 102 dprintf(("KERNEL32: OS2SetEnvironmentVariableW\n")); 103 asciiname = UnicodeToAsciiString((LPWSTR)lpName); 104 asciivalue = UnicodeToAsciiString((LPWSTR)lpValue); 105 rc = O32_SetEnvironmentVariable(asciiname, asciivalue); 106 FreeAsciiString(asciivalue); 107 FreeAsciiString(asciiname); 108 return(rc); 109 } 110 //****************************************************************************** 111 //****************************************************************************** 112 DWORD WIN32API GetEnvironmentVariableA(LPCSTR arg1, LPSTR arg2, DWORD arg3) 113 { 114 dprintf(("KERNEL32: GetEnvironmentVariable %s\n", arg1)); 115 return O32_GetEnvironmentVariable(arg1, arg2, arg3); 116 } 117 //****************************************************************************** 118 //****************************************************************************** 119 DWORD WIN32API GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer, 120 DWORD nSize) 139 121 { 140 122 char *astring, *asciibuffer; 141 123 DWORD rc; 142 124 143 asciibuffer = (char *)malloc(nSize+1); 144 *asciibuffer = 0; 145 astring = UnicodeToAsciiString((LPWSTR)lpName); 146 147 rc = O32_GetEnvironmentVariable(astring, asciibuffer, nSize); 148 AsciiToUnicode(asciibuffer, lpBuffer); 149 FreeAsciiString(astring); 150 free(asciibuffer); 151 return(rc); 125 dprintf(("KERNEL32: OS2GetEnvironmentVariableW\n")); 126 asciibuffer = (char *)malloc(nSize+1); 127 *asciibuffer = 0; 128 astring = UnicodeToAsciiString((LPWSTR)lpName); 129 130 rc = O32_GetEnvironmentVariable(astring, asciibuffer, nSize); 131 AsciiToUnicode(asciibuffer, lpBuffer); 132 FreeAsciiString(astring); 133 free(asciibuffer); 134 return(rc); 152 135 } 153 136 /*********************************************************************** … … 186 169 *****************************************************************************/ 187 170 188 ODINFUNCTION3(DWORD, ExpandEnvironmentStringsA, 189 LPCSTR, lpSrc, 190 LPSTR, lpDst, 191 DWORD, nSize) 171 DWORD WIN32API ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count ) 192 172 { 193 173 DWORD len, total_size = 1; /* 1 for terminating '\0' */ 194 174 LPCSTR p, var; 195 175 196 if (!nSize) lpDst = NULL; 197 198 while (*lpSrc) 199 { 200 if (*lpSrc != '%') 176 dprintf(("KERNEL32:ExpandEnvironmentStringsA '%s', %08x, %08x", 177 src, dst, count 178 )); 179 180 if (!count) dst = NULL; 181 182 while (*src) 183 { 184 if (*src != '%') 201 185 { 202 if ((p = strchr( lpSrc, '%' ))) len = p - lpSrc;203 else len = strlen( lpSrc);204 var = lpSrc;205 lpSrc += len;186 if ((p = strchr( src, '%' ))) len = p - src; 187 else len = strlen(src); 188 var = src; 189 src += len; 206 190 } 207 191 else /* we are at the start of a variable */ 208 192 { 209 if ((p = strchr( lpSrc + 1, '%' )))193 if ((p = strchr( src + 1, '%' ))) 210 194 { 211 len = p - lpSrc - 1; /* Length of the variable name */195 len = p - src - 1; /* Length of the variable name */ 212 196 if ((var = ENV_FindVariable( GetEnvironmentStringsA(), 213 lpSrc + 1, len )))197 src + 1, len ))) 214 198 { 215 lpSrc += len + 2; /* Skip the variable name */199 src += len + 2; /* Skip the variable name */ 216 200 len = strlen(var); 217 201 } 218 202 else 219 203 { 220 var = lpSrc; /* Copy original name instead */204 var = src; /* Copy original name instead */ 221 205 len += 2; 222 lpSrc += len;206 src += len; 223 207 } 224 208 } 225 209 else /* unfinished variable name, ignore it */ 226 210 { 227 var = lpSrc;228 len = strlen( lpSrc); /* Copy whole string */229 lpSrc += len;211 var = src; 212 len = strlen(src); /* Copy whole string */ 213 src += len; 230 214 } 231 215 } 232 216 total_size += len; 233 if ( lpDst)217 if (dst) 234 218 { 235 if ( nSize < len) len = nSize;236 memcpy( lpDst, var, len );237 lpDst += len;238 nSize-= len;219 if (count < len) len = count; 220 memcpy( dst, var, len ); 221 dst += len; 222 count -= len; 239 223 } 240 224 } 241 225 242 226 /* Null-terminate the string */ 243 if ( lpDst)244 { 245 if (! nSize) lpDst--;246 * lpDst = '\0';227 if (dst) 228 { 229 if (!count) dst--; 230 *dst = '\0'; 247 231 } 248 232 dprintf(("KERNEL32:ExpandEnvironmentStringsA returned %s %d", 249 lpDst, total_size));233 dst, total_size)); 250 234 return total_size; 251 235 } … … 270 254 *****************************************************************************/ 271 255 272 ODINFUNCTION3(DWORD, ExpandEnvironmentStringsW, 273 LPCWSTR,lpSrc, 274 LPWSTR, lpDst, 275 DWORD, nSize) 256 DWORD WIN32API ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize) 276 257 { 277 258 LPSTR srcA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpSrc ); 278 259 LPSTR dstA = lpDst ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize ) : NULL; 279 260 261 dprintf(("KERNEL32:ExpandEnvironmentStringsW(%08x,%08x,%08x)", lpSrc, lpDst, nSize)); 262 280 263 DWORD ret = ExpandEnvironmentStringsA( srcA, dstA, nSize ); 281 264 if (dstA) -
trunk/src/kernel32/exceptions.cpp
r3872 r4224 1 /* $Id: exceptions.cpp,v 1.42 2000-07-20 18:06:59 sandervl Exp $ */ 1 /* $Id: exceptions.cpp,v 1.43 2000-09-08 18:07:49 sandervl Exp $ */ 2 3 /* WARNING: Compiling this module with ICC with optimizations turned on */ 4 /* currently breaks this module. To get correct code, it is not necessary */ 5 /* to turn all optimizations off, just use the -Op- flag. */ 2 6 3 7 /* … … 67 71 #include "exceptstackdump.h" 68 72 69 #define DBG_LOCALLOG 73 #define DBG_LOCALLOG DBG_exceptions 70 74 #include "dbglocal.h" 71 75 … … 80 84 void KillWin32Process(void); 81 85 86 #ifdef DEBUG 87 void PrintWin32ExceptionChain(PWINEXCEPTION_FRAME pframe); 88 #else 89 #define PrintWin32ExceptionChain(a) 90 #endif 82 91 83 92 /***************************************************************************** … … 142 151 dprintf(("KERNEL32: RaiseException(%08xh)\n", 143 152 dwExceptionCode)); 153 154 memset(&record, 0, sizeof(record)); 144 155 145 156 /* compose an exception record */ … … 182 193 if(rc == ExceptionContinueSearch && UnhandledExceptionFilter != NULL) 183 194 { 195 dprintf(("KERNEL32: RaiseException calling UnhandledExceptionFilter.\n")); 196 184 197 ExceptionInfo.ExceptionRecord = &record; 185 198 ExceptionInfo.ContextRecord = &context; 186 199 187 200 rc = UnhandledExceptionFilter(&ExceptionInfo); 201 //FIXME: UnhandledExceptionFilter does NOT return the same values as 202 // other filters!! 188 203 } 189 204 … … 196 211 } 197 212 213 dprintf(("KERNEL32: RaiseException returns.\n")); 198 214 return; 199 215 } 216 217 200 218 //****************************************************************************** 201 219 //****************************************************************************** … … 212 230 pframe = (PWINEXCEPTION_FRAME)winteb->except; 213 231 232 dprintf(("KERNEL32: RtlDispatchException entered")); 233 234 PrintWin32ExceptionChain(pframe); 235 214 236 // walk the exception chain 215 237 while( (pframe != NULL) && (pframe != ((void *)0xFFFFFFFF)) ) 216 238 { 217 dispatch=0; 218 219 dprintf(("Calling exception handler %x", pframe->Handler)); 239 dprintf(("KERNEL32: RtlDispatchException - pframe=%08X, pframe->Prev=%08X", pframe, pframe->Prev)); 240 if (pframe == pframe->Prev) { 241 dprintf(("KERNEL32: RtlDispatchException - Invalid exception frame!!")); 242 return 0; 243 } 244 245 dispatch=0; 246 220 247 /* Check frame address */ 221 248 if (((void*)pframe < winteb->stack_low) || … … 223 250 (int)pframe & 3) 224 251 { 252 dprintf(("Invalid stack! low=%08X, top=%08X, pframe = %08X", 253 winteb->stack_low, winteb->stack_top, pframe)); 254 225 255 pRecord->ExceptionFlags |= EH_STACK_INVALID; 226 256 break; 227 257 } 228 258 229 rc = pframe->Handler(pRecord, 259 dprintf(("KERNEL32: RtlDispatchException - calling exception handler %08X", pframe->Handler)); 260 261 rc = pframe->Handler(pRecord, 230 262 pframe, 231 263 pContext, 232 264 dispatch); 265 266 dprintf(("KERNEL32: RtlDispatchException - exception handler returned %#x", rc)); 267 PrintWin32ExceptionChain(pframe); 233 268 234 269 if (pframe == nested_frame) … … 239 274 } 240 275 241 dprintf(("exception handler returned %x", rc));242 276 243 277 switch(rc) 244 278 { 245 279 case ExceptionContinueExecution: 246 if (!(pRecord->ExceptionFlags & EH_NONCONTINUABLE)) return rc; 280 if (!(pRecord->ExceptionFlags & EH_NONCONTINUABLE)) { 281 dprintf(("KERNEL32: RtlDispatchException returns %#x (ContinueExecution)", rc)); 282 return rc; 283 } 247 284 break; 248 285 case ExceptionContinueSearch: … … 256 293 } 257 294 295 dprintf(("KERNEL32: RtlDispatchException - going from frame %08X to previous frame %08X", pframe, pframe->Prev)); 296 if (pframe == pframe->Prev) { 297 dprintf(("KERNEL32: RtlDispatchException - Invalid exception frame!!")); 298 break; 299 } 258 300 pframe = pframe->Prev; 259 301 } 302 dprintf(("KERNEL32: RtlDispatchException returns %#x", rc)); 303 PrintWin32ExceptionChain(pframe); 260 304 return rc; 261 305 } … … 284 328 WINEXCEPTION_RECORD record, newrec; 285 329 WINCONTEXT context; 286 int rc; 287 288 dprintf(("KERNEL32: RtlUnwind %x %x\n", pEndFrame, pRecord)); 330 DWORD rc; 331 332 dprintf(("KERNEL32: RtlUnwind pEndFrame=%08X, unusedEip=%08X, pRecord=%08X, returnEax=%#x\n", pEndFrame, unusedEip, pRecord, returnEax)); 333 289 334 290 335 memset(&context, 0, sizeof(context)); … … 310 355 if(!pRecord) 311 356 { 357 memset(&record, 0, sizeof(record)); 312 358 record.ExceptionCode = STATUS_UNWIND; 313 359 record.ExceptionFlags = 0; … … 324 370 TEB *winteb = GetThreadTEB(); 325 371 frame = (PWINEXCEPTION_FRAME)winteb->except; 372 373 PrintWin32ExceptionChain(frame); 326 374 327 375 while ((frame != (PWINEXCEPTION_FRAME)0xffffffff) && (frame != pEndFrame)) … … 334 382 newrec.ExceptionRecord = pRecord; 335 383 newrec.NumberParameters = 0; 336 337 384 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 385 DosExit(EXIT_THREAD, 0); 338 386 } 339 387 if (((void*)frame < winteb->stack_low) || … … 345 393 newrec.ExceptionRecord = pRecord; 346 394 newrec.NumberParameters = 0; 347 348 395 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 396 DosExit(EXIT_THREAD, 0); 349 397 } 350 398 351 399 /* Call handler */ 352 dprintf(("Calling exception handler %x", frame->Handler)); 353 switch(frame->Handler(pRecord, frame, &context, &dispatch )) 400 dprintf(("KERNEL32: RtlUnwind - calling exception handler %08X", frame->Handler)); 401 rc = frame->Handler(pRecord, frame, &context, &dispatch); 402 dprintf(("KERNEL32: RtlUnwind - handler returned %#x", rc)); 403 switch (rc) 354 404 { 355 405 case ExceptionContinueSearch: … … 363 413 newrec.ExceptionRecord = pRecord; 364 414 newrec.NumberParameters = 0; 365 366 415 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 416 DosExit(EXIT_THREAD, 0); 367 417 break; 368 418 } 419 dprintf(("KERNEL32: RtlUnwind (before)- frame=%08X, frame->Prev=%08X", frame, frame->Prev)); 369 420 SetExceptionChain((DWORD)frame->Prev); 370 421 frame = frame->Prev; 371 } 422 dprintf(("KERNEL32: RtlUnwind (after) - frame=%08X, frame->Prev=%08X", frame, frame->Prev)); 423 } 424 425 426 /* Note: I _think_ that on Win32, RtlUnwind unwinds exception handlers up */ 427 /* and _including_ the handler in pEndFrame argument. My reasons are: */ 428 /* - MSVCRT sometimes calls RtlUnwind with the address of the very first */ 429 /* exception handler - could be just inefficient code */ 430 /* - after a call to RtlUnwind, MSVCRT in some cases tries to restore */ 431 /* the original exception handler. If RtlUnwind didn't remove it, */ 432 /* the exception chain gets looped, spelling very bad mojo! */ 433 if (frame == pEndFrame) 434 { 435 /* Just repeat what we did in the while loop above */ 436 /* Check frame address */ 437 if (pEndFrame && (frame > pEndFrame)) 438 { 439 newrec.ExceptionCode = STATUS_INVALID_UNWIND_TARGET; 440 newrec.ExceptionFlags = EH_NONCONTINUABLE; 441 newrec.ExceptionRecord = pRecord; 442 newrec.NumberParameters = 0; 443 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 444 DosExit(EXIT_THREAD, 0); 445 } 446 if (((void*)frame < winteb->stack_low) || 447 ((void*)(frame+1) > winteb->stack_top) || 448 (int)frame & 3) 449 { 450 newrec.ExceptionCode = STATUS_BAD_STACK; 451 newrec.ExceptionFlags = EH_NONCONTINUABLE; 452 newrec.ExceptionRecord = pRecord; 453 newrec.NumberParameters = 0; 454 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 455 DosExit(EXIT_THREAD, 0); 456 } 457 458 /* Call handler */ 459 dprintf(("KERNEL32: RtlUnwind - calling exception handler %08X", frame->Handler)); 460 rc = frame->Handler(pRecord, frame, &context, &dispatch); 461 dprintf(("KERNEL32: RtlUnwind - handler returned %#x", rc)); 462 switch (rc) 463 { 464 case ExceptionContinueSearch: 465 break; 466 case ExceptionCollidedUnwind: 467 frame = dispatch; 468 break; 469 default: 470 newrec.ExceptionCode = STATUS_INVALID_DISPOSITION; 471 newrec.ExceptionFlags = EH_NONCONTINUABLE; 472 newrec.ExceptionRecord = pRecord; 473 newrec.NumberParameters = 0; 474 dprintf(("KERNEL32: RtlUnwind terminating thread.\n")); 475 DosExit(EXIT_THREAD, 0); 476 break; 477 } 478 dprintf(("KERNEL32: RtlUnwind (before)- frame=%08X, frame->Prev=%08X", frame, frame->Prev)); 479 SetExceptionChain((DWORD)frame->Prev); 480 frame = frame->Prev; 481 dprintf(("KERNEL32: RtlUnwind (after) - frame=%08X, frame->Prev=%08X", frame, frame->Prev)); 482 } 483 484 dprintf(("KERNEL32: RtlUnwind returning.\n")); 485 PrintWin32ExceptionChain(frame); 372 486 return(0); 373 487 } … … 415 529 }; 416 530 417 dprintf(("KERNEL32: UnhandledExceptionFilter\n")); 418 419 if(CurrentUnhExceptionFlt && !(CurrentErrorMode & (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX))) 531 dprintf(("KERNEL32: Default UnhandledExceptionFilter, CurrentErrorMode=%X", CurrentErrorMode)); 532 533 // We must not care about ErrorMode here!! The app expects that its own 534 // UnhandledExceptionFilter will be cared even if it never touched ErrorMode. 535 if(CurrentUnhExceptionFlt) // && !(CurrentErrorMode & (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX))) 420 536 { 537 dprintf(("KERNEL32: Calling user UnhandledExceptionFilter")); 421 538 rc = CurrentUnhExceptionFlt(lpexpExceptionInfo); 422 539 if(rc != WINEXCEPTION_CONTINUE_SEARCH) … … 492 609 LPTOP_LEVEL_EXCEPTION_FILTER old = CurrentUnhExceptionFlt; 493 610 494 dprintf(("KERNEL32: SetUnhandledExceptionFilter to % X\n",611 dprintf(("KERNEL32: SetUnhandledExceptionFilter to %08X\n", 495 612 lpTopLevelExceptionFilter)); 496 613 … … 524 641 525 642 if(fEntry == FALSE) { 526 527 528 643 fEntry = TRUE; 644 ExitProcess(666); 645 return; 529 646 } 530 647 //Restore original OS/2 TIB selector … … 857 974 858 975 if (pCtxRec->ContextFlags & CONTEXT_CONTROL) /* check flags */ 859 dprintf((" SS:ESP=%04x:%08x EFLAGS=%08x\n" 860 " CS:EIP=%04x:%08x EBP =%08x\n", 976 dprintf((" SS:ESP=%04x:%08x EFLAGS=%08x\n", 861 977 pCtxRec->ctx_SegSs, 862 978 pCtxRec->ctx_RegEsp, 863 pCtxRec->ctx_EFlags, 979 pCtxRec->ctx_EFlags)); 980 dprintf((" CS:EIP=%04x:%08x EBP =%08x\n", 864 981 pCtxRec->ctx_SegCs, 865 982 pCtxRec->ctx_RegEip, … … 867 984 868 985 if (pCtxRec->ContextFlags & CONTEXT_INTEGER) /* check flags */ 869 dprintf((" EAX=%08x EBX=%08x ESI=%08x\n" 870 " ECX=%08x EDX=%08x EDI=%08x\n", 986 dprintf((" EAX=%08x EBX=%08x ESI=%08x\n", 871 987 pCtxRec->ctx_RegEax, 872 988 pCtxRec->ctx_RegEbx, 873 pCtxRec->ctx_RegEsi, 989 pCtxRec->ctx_RegEsi)); 990 dprintf((" ECX=%08x EDX=%08x EDI=%08x\n", 874 991 pCtxRec->ctx_RegEcx, 875 992 pCtxRec->ctx_RegEdx, … … 877 994 878 995 if (pCtxRec->ContextFlags & CONTEXT_SEGMENTS) /* check flags */ 879 dprintf((" DS=%04x ES=%08x" 880 " FS=%04x GS=%04x\n", 996 dprintf((" DS=%04x ES=%08x", 881 997 pCtxRec->ctx_SegDs, 882 pCtxRec->ctx_SegEs, 998 pCtxRec->ctx_SegEs)); 999 dprintf((" FS=%04x GS=%04x\n", 883 1000 pCtxRec->ctx_SegFs, 884 1001 pCtxRec->ctx_SegGs)); … … 936 1053 PVOID p) 937 1054 { 1055 //MN: If EH_NESTED_CALL is set, an exception occurred during the execution 1056 // of this exception handler. We better bail out ASAP or we'll likely 1057 // recurse infinitely until we run out of stack space!! 1058 if (pERepRec->fHandlerFlags & EH_NESTED_CALL) 1059 return XCPT_CONTINUE_SEARCH; 1060 938 1061 //SvL: Check if exception inside debug fprintf -> if so, clear lock so 939 1062 // next dprintf won't wait forever 940 1063 CheckLogException(); 1064 941 1065 942 1066 /* Access violation at a known location */ … … 950 1074 case XCPT_FLOAT_STACK_CHECK: 951 1075 case XCPT_FLOAT_UNDERFLOW: 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 1076 dprintfException(pERepRec, pERegRec, pCtxRec, p); 1077 dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception\n")); 1078 if(fIsOS2Image == FALSE) //Only for real win32 apps 1079 { 1080 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == FALSE) 1081 { 1082 pCtxRec->ctx_env[0] |= 0x1F; 1083 pCtxRec->ctx_stack[0].losig = 0; 1084 pCtxRec->ctx_stack[0].hisig = 0; 1085 pCtxRec->ctx_stack[0].signexp = 0; 1086 } 1087 dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n")); 1088 return (XCPT_CONTINUE_EXECUTION); 1089 } 1090 else 1091 { 1092 dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n")); 1093 return (XCPT_CONTINUE_SEARCH); 1094 } 971 1095 972 1096 case XCPT_PROCESS_TERMINATE: 973 1097 case XCPT_ASYNC_PROCESS_TERMINATE: 974 975 976 1098 dprintfException(pERepRec, pERegRec, pCtxRec, p); 1099 SetExceptionChain((ULONG)-1); 1100 return (XCPT_CONTINUE_SEARCH); 977 1101 978 1102 case XCPT_ACCESS_VIOLATION: 979 { 1103 { 980 1104 Win32MemMap *map; 981 1105 BOOL fWriteAccess = FALSE; 982 1106 ULONG offset, accessflag; 983 1107 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1108 if(pERepRec->ExceptionInfo[1] == 0 && pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN) { 1109 goto continueFail; 1110 } 1111 switch(pERepRec->ExceptionInfo[0]) { 1112 case XCPT_READ_ACCESS: 1113 accessflag = MEMMAP_ACCESS_READ; 1114 break; 1115 case XCPT_WRITE_ACCESS: 1116 accessflag = MEMMAP_ACCESS_WRITE; 1117 fWriteAccess = TRUE; 1118 break; 1119 case XCPT_EXECUTE_ACCESS: 1120 accessflag = MEMMAP_ACCESS_EXECUTE; 1121 break; 1122 default: 1123 goto continueFail; 1124 } 1125 1126 map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag); 1127 if(map == NULL) { 1128 goto continueFail; 1129 } 1130 if(map->commitPage(offset, fWriteAccess) == TRUE) 1131 return (XCPT_CONTINUE_EXECUTION); 1132 1133 //no break; 1010 1134 } 1011 1135 continueFail: … … 1014 1138 #ifdef DEBUGSTACK 1015 1139 if(pCtxRec->ContextFlags & CONTEXT_CONTROL) { 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1140 ULONG *stackptr; 1141 APIRET rc; 1142 int i; 1143 ULONG ulOffset, ulModule, ulObject; 1144 CHAR szModule[CCHMAXPATH]; 1145 1146 stackptr = (ULONG *)pCtxRec->ctx_RegEsp; 1147 dprintf(("Stack DUMP:")); 1148 for(i=0;i<16;i++) { 1149 rc = DosQueryModFromEIP(&ulModule, 1150 &ulObject, 1027 1151 sizeof(szModule), 1028 1152 szModule, … … 1030 1154 (ULONG)*stackptr); 1031 1155 1032 1033 1034 elsedprintf(("0x%8x: 0x%8x", stackptr, *stackptr));1035 1036 1037 1156 if (rc == NO_ERROR) 1157 dprintf(("0x%8x: 0x%8x %s (#%u), obj #%u:%08x", stackptr, *stackptr, szModule, ulModule, ulObject, ulOffset)); 1158 else dprintf(("0x%8x: 0x%8x", stackptr, *stackptr)); 1159 stackptr++; 1160 } 1161 dprintf(("Stack DUMP END")); 1038 1162 } 1039 1163 #endif … … 1052 1176 CrashAndBurn: 1053 1177 #ifdef DEBUG 1054 1055 1056 1057 1178 dprintfException(pERepRec, pERegRec, pCtxRec, p); 1179 if(pCtxRec->ContextFlags & CONTEXT_CONTROL) { 1180 dbgPrintStack(pERepRec, pERegRec, pCtxRec, p); 1181 } 1058 1182 #endif 1059 1060 1061 1062 1063 1064 1065 1066 elsereturn XCPT_CONTINUE_SEARCH; //pass on to OS/2 RTL or app exception handler1067 1068 1069 1070 1071 1072 1073 1183 if(fIsOS2Image == FALSE) //Only for real win32 apps 1184 { 1185 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == TRUE) 1186 { 1187 return (XCPT_CONTINUE_EXECUTION); 1188 } 1189 } 1190 else return XCPT_CONTINUE_SEARCH; //pass on to OS/2 RTL or app exception handler 1191 1192 dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n")); 1193 pCtxRec->ctx_RegEip = (ULONG)KillWin32Process; 1194 pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10; 1195 pCtxRec->ctx_RegEax = pERepRec->ExceptionNum; 1196 pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip; 1197 return (XCPT_CONTINUE_EXECUTION); 1074 1198 1075 1199 //@@@PH: growing thread stacks might need special treatment 1076 1200 case XCPT_GUARD_PAGE_VIOLATION: 1077 dprintf(("KERNEL32: OS2ExceptionHandler: trying to grow stack (continue )\n"));1201 dprintf(("KERNEL32: OS2ExceptionHandler: trying to grow stack (continue search)")); 1078 1202 return (XCPT_CONTINUE_SEARCH); 1079 1203 … … 1081 1205 if(pERepRec->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC) /* resolve signal information */ 1082 1206 { 1083 1084 1207 SetExceptionChain((ULONG)-1); 1208 return (XCPT_CONTINUE_SEARCH); 1085 1209 } 1086 1210 goto CrashAndBurn; 1087 1211 1088 1212 default: //non-continuable exceptions 1089 1213 dprintfException(pERepRec, pERegRec, pCtxRec, p); 1090 1214 return (XCPT_CONTINUE_SEARCH); 1091 1215 } … … 1129 1253 dprintf(("Exception chain list:")); 1130 1254 while(pExceptRec != 0 && (ULONG)pExceptRec != -1) { 1131 1132 1255 dprintf(("record %x", pExceptRec)); 1256 pExceptRec = pExceptRec->prev_structure; 1133 1257 } 1134 1258 SetFS(sel); 1135 1259 } 1260 1261 void PrintWin32ExceptionChain(PWINEXCEPTION_FRAME pframe) 1262 { 1263 dprintf(("Win32 exception chain:")); 1264 while ((pframe != NULL) && ((ULONG)pframe != 0xFFFFFFFF)) { 1265 dprintf(("Record at %08X, Prev at %08X, handler at %08X", pframe, pframe->Prev, pframe->Handler)); 1266 if (pframe == pframe->Prev) { 1267 dprintf(("Chain corrupted! Record at %08X pointing to itself!", pframe)); 1268 break; 1269 } 1270 pframe = pframe->Prev; 1271 } 1272 } 1273 1136 1274 #endif 1137 1275 … … 1173 1311 1174 1312 if(sel == 0x150b) { 1175 1176 1313 SetFS(sel); 1314 return FALSE; 1177 1315 } 1178 1316 pExceptRec = (PEXCEPTIONREGISTRATIONRECORD)QueryExceptionChain(); 1179 1317 if(pExceptRec->ExceptionHandler != OS2ExceptionHandler) { 1180 1181 1318 SetFS(sel); 1319 return FALSE; 1182 1320 } 1183 1321 SetFS(sel); -
trunk/src/kernel32/exceptutil.asm
r4189 r4224 1 ; $Id: exceptutil.asm,v 1.1 0 2000-09-04 18:24:42sandervl Exp $1 ; $Id: exceptutil.asm,v 1.11 2000-09-08 18:07:49 sandervl Exp $ 2 2 3 3 ;/* … … 53 53 54 54 _RtlUnwind@16 proc near 55 ; fudge return address 56 push eax 57 mov eax, dword ptr [esp+12] 58 mov dword ptr [esp+4], eax 59 pop eax 60 55 61 push dword ptr [esp+4] ;PWINEXCEPTION_FRAME pEndFrame 56 62 push dword ptr [esp+12] ;LPVOID unusedEip … … 135 141 PUBLIC getEAX 136 142 PUBLIC getEBX 137 getEAX 138 ret 139 getEAX 140 141 getEBX 143 getEAX proc near 144 ret 145 getEAX endp 146 147 getEBX proc near 142 148 mov eax, ebx 143 149 ret 144 getEBX 150 getEBX endp 145 151 146 152 PUBLIC GetFS 147 GetFS 148 moveax, fs149 150 GetFS 153 GetFS proc near 154 mov eax, fs 155 ret 156 GetFS endp 151 157 152 158 PUBLIC SetFS 153 SetFS 154 moveax, [esp+4]155 movfs, eax156 157 SetFS 159 SetFS proc near 160 mov eax, [esp+4] 161 mov fs, eax 162 ret 163 SetFS endp 158 164 159 165 PUBLIC getCS 160 getCS 161 moveax, cs162 163 getCS 166 getCS proc near 167 mov eax, cs 168 ret 169 getCS endp 164 170 165 171 PUBLIC getDS 166 getDS 167 moveax, ds168 169 getDS 170 171 172 getDS proc near 173 mov eax, ds 174 ret 175 getDS endp 176 177 PUBLIC SetReturnFS 172 178 SetReturnFS proc near 173 pushfs174 moveax, [esp+8]175 movfs, eax176 popeax177 179 push fs 180 mov eax, [esp+8] 181 mov fs, eax 182 pop eax 183 ret 178 184 SetReturnFS endp 179 185 180 186 PUBLIC getSS 181 getSS 182 movax, ss183 184 getSS 187 getSS proc near 188 mov ax, ss 189 ret 190 getSS endp 185 191 186 192 PUBLIC getES 187 getES 188 moveax, es189 190 getES 193 getES proc near 194 mov eax, es 195 ret 196 getES endp 191 197 192 198 PUBLIC getGS 193 getGS 194 moveax, gs195 196 getGS 197 198 199 getGS proc near 200 mov eax, gs 201 ret 202 getGS endp 203 204 PUBLIC getESP 199 205 getESP proc near 200 moveax, esp201 202 getESP 203 204 206 mov eax, esp 207 ret 208 getESP endp 209 210 PUBLIC RestoreOS2FS 205 211 RestoreOS2FS proc near 206 push150bh207 movax, fs208 popfs209 212 push 150bh 213 mov ax, fs 214 pop fs 215 ret 210 216 RestoreOS2FS endp 211 217 212 218 PUBLIC _Mul32x32to64 213 219 _Mul32x32to64 proc near 214 pushebp215 movebp, esp216 pusheax217 pushedx218 pushedi219 220 mov edi, [ebp+8];64 bits result221 mov eax, [ebp+12];op1222 mov edx, [ebp+16];op2223 muledx224 mov[edi], eax225 mov[edi+4], edx226 227 popedi228 popedx229 popeax230 popebp231 220 push ebp 221 mov ebp, esp 222 push eax 223 push edx 224 push edi 225 226 mov edi, [ebp+8] ;64 bits result 227 mov eax, [ebp+12] ;op1 228 mov edx, [ebp+16] ;op2 229 mul edx 230 mov [edi], eax 231 mov [edi+4], edx 232 233 pop edi 234 pop edx 235 pop eax 236 pop ebp 237 ret 232 238 _Mul32x32to64 endp 233 239 -
trunk/src/kernel32/heap.cpp
r4214 r4224 1 /* $Id: heap.cpp,v 1.2 1 2000-09-08 04:28:46 phallerExp $ */1 /* $Id: heap.cpp,v 1.22 2000-09-08 18:07:50 sandervl Exp $ */ 2 2 3 3 /* … … 180 180 //****************************************************************************** 181 181 //****************************************************************************** 182 ODINFUNCTIONNODBG2(HLOCAL, LocalAlloc, 183 UINT, fuFlags, 184 DWORD, cbBytes) 182 HLOCAL WIN32API LocalAlloc(UINT fuFlags, DWORD cbBytes) 185 183 { 186 184 HLOCAL lmem; … … 219 217 //****************************************************************************** 220 218 //****************************************************************************** 221 ODINFUNCTIONNODBG1(HLOCAL, LocalFree, 222 HLOCAL, hMem) 223 { 224 if(OS2ProcessHeap->GetLockCnt((LPVOID)hMem) != 0) 225 { 226 dprintf(("LocalFree, lock count != 0\n")); 227 return(hMem); //TODO: SetLastError 228 } 229 if(OS2ProcessHeap->Free(0, (LPVOID)hMem) == FALSE) 230 { 231 return(hMem); //TODO: SetLastError 219 HLOCAL WIN32API LocalFree(HLOCAL hMem) 220 { 221 dprintf(("KERNEL32: LocalFree %X\n", hMem)); 222 223 if(OS2ProcessHeap->GetLockCnt((LPVOID)hMem) != 0) { 224 dprintf(("LocalFree, lock count != 0\n")); 225 return(hMem); //TODO: SetLastError 226 } 227 if(OS2ProcessHeap->Free(0, (LPVOID)hMem) == FALSE) { 228 return(hMem); //TODO: SetLastError 232 229 } 233 230 return NULL; //success … … 252 249 //TODO: cbBytes==0 && fuFlags & LMEM_MOVEABLE not handled!! 253 250 //****************************************************************************** 254 ODINFUNCTIONNODBG3(HLOCAL, LocalReAlloc, 255 HLOCAL, hMem, 256 DWORD, cbBytes, 257 UINT, fuFlags) 251 HLOCAL WIN32API LocalReAlloc(HLOCAL hMem, DWORD cbBytes, UINT fuFlags) 258 252 { 259 253 HLOCAL hLocalNew; 260 254 LPVOID lpMem; 255 256 dprintf(("KERNEL32: LocalReAlloc %X %d %X\n", hMem, cbBytes, fuFlags)); 261 257 262 258 //SvL: 8-8-'98: Notepad bugfix (assumes address is identical when new size < old size) … … 322 318 } 323 319 //****************************************************************************** 320 #ifdef DEBUG 321 static ULONG totalGlobalAlloc = 0; 322 #endif 324 323 //****************************************************************************** 325 324 HGLOBAL WIN32API GlobalAlloc(UINT fuFlags, DWORD dwBytes) 326 325 { 327 dprintf(("KERNEL32: GlobalAlloc %d\n", dwBytes)); 328 329 return O32_GlobalAlloc(fuFlags, dwBytes); 326 HGLOBAL ret; 327 328 ret = O32_GlobalAlloc(fuFlags, dwBytes); 329 #ifdef DEBUG 330 totalGlobalAlloc += dwBytes; 331 #endif 332 dprintf(("KERNEL32: GlobalAlloc %x %d returned %x (total %x)", fuFlags, dwBytes, ret, totalGlobalAlloc)); 333 return ret; 330 334 } 331 335 //****************************************************************************** … … 333 337 HGLOBAL WIN32API GlobalFree( HGLOBAL arg1) 334 338 { 335 dprintf(("KERNEL32: GlobalFree\n")); 336 337 return O32_GlobalFree(arg1); 339 HGLOBAL ret; 340 341 #ifdef DEBUG 342 totalGlobalAlloc -= O32_GlobalSize(arg1); 343 #endif 344 ret = O32_GlobalFree(arg1); 345 dprintf(("KERNEL32: GlobalFree %x returned %x (lasterr=%x) total %x", arg1, ret, GetLastError(), totalGlobalAlloc)); 346 return ret; 338 347 } 339 348 //****************************************************************************** … … 365 374 PVOID WIN32API GlobalLock(HGLOBAL arg1) 366 375 { 367 dprintf(("KERNEL32: GlobalLock\n")); 368 369 return O32_GlobalLock(arg1); 376 PVOID ret; 377 378 ret = O32_GlobalLock(arg1); 379 dprintf(("KERNEL32: GlobalLock %x returned %x", arg1, ret)); 380 return ret; 370 381 } 371 382 //****************************************************************************** -
trunk/src/kernel32/makefile
r4174 r4224 1 # $Id: makefile,v 1. 99 2000-09-03 18:04:54 phallerExp $1 # $Id: makefile,v 1.100 2000-09-08 18:07:50 sandervl Exp $ 2 2 3 3 # … … 181 181 !include $(PDWIN32_INCLUDE)/pdwin32.post 182 182 183 184 #override flags for exceptions.cpp 185 $(OBJDIR)\exceptions.obj: exceptions.cpp 186 $(CXX) $(CXXFLAGS) -Op- -Fo$(OBJDIR)\$(@B).obj -c exceptions.cpp -
trunk/src/kernel32/oslibexcept.cpp
r2803 r4224 1 /* $Id: oslibexcept.cpp,v 1. 2 2000-02-16 14:25:45sandervl Exp $ */1 /* $Id: oslibexcept.cpp,v 1.3 2000-09-08 18:07:50 sandervl Exp $ */ 2 2 /* 3 3 * Exception handler util. procedures … … 18 18 #include "oslibexcept.h" 19 19 #include <exceptions.h> 20 21 #define DBG_LOCALLOG DBG_oslibexcept 20 #include <wprocess.h> 21 22 #define DBG_LOCALLOG DBG_oslibexcept 22 23 #include "dbglocal.h" 23 24 … … 27 28 // FALSE, otherwise 28 29 //****************************************************************************** 29 BOOL OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,30 PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,31 PCONTEXTRECORD pContextRec, PVOID p)30 BOOL APIENTRY OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec, 31 PEXCEPTIONREGISTRATIONRECORD pRegistrationRec, 32 PCONTEXTRECORD pContextRec, PVOID p) 32 33 { 33 34 WINEXCEPTION_RECORD winreportrec; … … 40 41 switch(pReportRec->ExceptionNum) { 41 42 case XCPT_FLOAT_DENORMAL_OPERAND: 42 43 43 winreportrec.ExceptionCode = EXCEPTION_FLT_DENORMAL_OPERAND; 44 break; 44 45 case XCPT_FLOAT_DIVIDE_BY_ZERO: 45 46 46 winreportrec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO; 47 break; 47 48 case XCPT_FLOAT_INEXACT_RESULT: 48 49 49 winreportrec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT; 50 break; 50 51 case XCPT_FLOAT_INVALID_OPERATION: 51 52 52 winreportrec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION; 53 break; 53 54 case XCPT_FLOAT_OVERFLOW: 54 55 55 winreportrec.ExceptionCode = EXCEPTION_FLT_OVERFLOW; 56 break; 56 57 case XCPT_FLOAT_STACK_CHECK: 57 58 58 winreportrec.ExceptionCode = EXCEPTION_FLT_STACK_CHECK; 59 break; 59 60 case XCPT_FLOAT_UNDERFLOW: 60 61 61 winreportrec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW; 62 break; 62 63 case XCPT_INTEGER_DIVIDE_BY_ZERO: 63 64 64 winreportrec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO; 65 break; 65 66 case XCPT_INTEGER_OVERFLOW: 66 67 67 winreportrec.ExceptionCode = EXCEPTION_INT_OVERFLOW; 68 break; 68 69 case XCPT_PRIVILEGED_INSTRUCTION: 69 70 70 winreportrec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION; 71 break; 71 72 case XCPT_BREAKPOINT: 72 73 73 winreportrec.ExceptionCode = EXCEPTION_BREAKPOINT; 74 break; 74 75 case XCPT_SINGLE_STEP: 75 76 76 winreportrec.ExceptionCode = EXCEPTION_SINGLE_STEP; 77 break; 77 78 case XCPT_ARRAY_BOUNDS_EXCEEDED: 78 79 79 winreportrec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED; 80 break; 80 81 case XCPT_DATATYPE_MISALIGNMENT: 81 82 82 winreportrec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT; 83 break; 83 84 case XCPT_ILLEGAL_INSTRUCTION: 84 85 85 winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 86 break; 86 87 case XCPT_INVALID_LOCK_SEQUENCE: 87 88 88 winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION; 89 break; 89 90 case XCPT_GUARD_PAGE_VIOLATION: 90 91 91 winreportrec.ExceptionCode = EXCEPTION_GUARD_PAGE; 92 break; 92 93 case XCPT_UNABLE_TO_GROW_STACK: 93 94 94 winreportrec.ExceptionCode = EXCEPTION_STACK_OVERFLOW; 95 break; 95 96 case XCPT_IN_PAGE_ERROR: 96 97 97 winreportrec.ExceptionCode = EXCEPTION_IN_PAGE_ERROR; 98 break; 98 99 case XCPT_ACCESS_VIOLATION: 99 100 100 winreportrec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION; 101 break; 101 102 default: //no other exceptions should be dispatched to win32 apps 102 103 return FALSE; 103 104 } 104 105 //TODO: … … 109 110 memset(&wincontextrec, 0, sizeof(wincontextrec)); 110 111 if(pContextRec->ContextFlags & CONTEXT_CONTROL) { 111 112 113 114 115 116 117 112 wincontextrec.ContextFlags |= WINCONTEXT_CONTROL; 113 wincontextrec.Ebp = pContextRec->ctx_RegEbp; 114 wincontextrec.Eip = pContextRec->ctx_RegEip; 115 wincontextrec.SegCs = pContextRec->ctx_SegCs; 116 wincontextrec.EFlags = pContextRec->ctx_EFlags; 117 wincontextrec.Esp = pContextRec->ctx_RegEsp; 118 wincontextrec.SegSs = pContextRec->ctx_SegSs; 118 119 } 119 120 if(pContextRec->ContextFlags & CONTEXT_INTEGER) { 120 wincontextrec.ContextFlags |= WINCONTEXT_INTEGER; 121 wincontextrec.Edi = pContextRec->ctx_RegEdi; 122 wincontextrec.Esi = pContextRec->ctx_RegEsi; 123 wincontextrec.Ebx = pContextRec->ctx_RegEbx; 124 wincontextrec.Edx = pContextRec->ctx_RegEdx; 125 wincontextrec.Ecx = pContextRec->ctx_RegEcx; 126 wincontextrec.Eax = pContextRec->ctx_RegEax; 127 } 121 wincontextrec.ContextFlags |= WINCONTEXT_INTEGER; 122 wincontextrec.Edi = pContextRec->ctx_RegEdi; 123 wincontextrec.Esi = pContextRec->ctx_RegEsi; 124 wincontextrec.Ebx = pContextRec->ctx_RegEbx; 125 wincontextrec.Edx = pContextRec->ctx_RegEdx; 126 wincontextrec.Ecx = pContextRec->ctx_RegEcx; 127 wincontextrec.Eax = pContextRec->ctx_RegEax; 128 } 129 130 TEB *winteb = GetThreadTEB(); 131 THDB *thdb = (THDB *)(winteb+1); 132 128 133 if(pContextRec->ContextFlags & CONTEXT_SEGMENTS) { 129 wincontextrec.ContextFlags |= WINCONTEXT_SEGMENTS; 130 wincontextrec.SegGs = pContextRec->ctx_SegGs; 131 wincontextrec.SegFs = pContextRec->ctx_SegFs; 132 wincontextrec.SegEs = pContextRec->ctx_SegEs; 133 wincontextrec.SegDs = pContextRec->ctx_SegDs; 134 wincontextrec.ContextFlags |= WINCONTEXT_SEGMENTS; 135 wincontextrec.SegGs = pContextRec->ctx_SegGs; 136 // This resets FS to 0x150B - we DON'T want that!! 137 // wincontextrec.SegFs = pContextRec->ctx_SegFs; 138 wincontextrec.SegFs = thdb->teb_sel; 139 wincontextrec.SegEs = pContextRec->ctx_SegEs; 140 wincontextrec.SegDs = pContextRec->ctx_SegDs; 134 141 } 135 142 if(pContextRec->ContextFlags & CONTEXT_FLOATING_POINT) { 136 137 138 139 143 wincontextrec.ContextFlags |= WINCONTEXT_FLOATING_POINT; 144 //TODO: First 7 dwords the same? 145 memcpy(&wincontextrec.FloatSave, pContextRec->ctx_env, sizeof(pContextRec->ctx_env)); 146 memcpy(&wincontextrec.FloatSave.RegisterArea, pContextRec->ctx_stack, sizeof(pContextRec->ctx_stack)); 140 147 } 141 148 //It doesn't seem correct if we dispatch real exceptions to win32 apps 142 149 //Some just call RtlUnwind and continue as if they were processing an 143 150 //exception thrown by C++ code. (instead of real OS exception) 144 #if 0 151 #if 1 152 // We need to reset FS to its original (Win32) value, otherwise we'll likely 153 // fuck up the Win32 exception handlers. They could end up using the wrong 154 // exception chain if they access FS:[0] directly. 155 DWORD oldsel = SetReturnFS(thdb->teb_sel); 156 145 157 switch(pReportRec->ExceptionNum) { 146 158 case XCPT_FLOAT_DENORMAL_OPERAND: … … 151 163 case XCPT_FLOAT_STACK_CHECK: 152 164 case XCPT_FLOAT_UNDERFLOW: 153 154 165 rc = RtlDispatchException(&winreportrec, &wincontextrec); 166 break; 155 167 156 168 case XCPT_ACCESS_VIOLATION: 157 158 169 rc = RtlDispatchException(&winreportrec, &wincontextrec); 170 break; 159 171 160 172 case XCPT_INTEGER_DIVIDE_BY_ZERO: … … 170 182 case XCPT_UNABLE_TO_GROW_STACK: 171 183 case XCPT_IN_PAGE_ERROR: 172 return FALSE; //let's no dispatch those for now 173 } 184 SetFS(oldsel); //restore FS 185 return FALSE; //let's not dispatch those for now 186 } 187 SetFS(oldsel); //restore FS 174 188 175 189 if(rc == ExceptionContinueExecution) { 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 190 dprintf(("Win32 exception handler returned ExceptionContinueExecution")); 191 if(wincontextrec.ContextFlags & WINCONTEXT_CONTROL) { 192 pContextRec->ctx_RegEbp = wincontextrec.Ebp; 193 pContextRec->ctx_RegEip = wincontextrec.Eip; 194 pContextRec->ctx_SegCs = wincontextrec.SegCs; 195 pContextRec->ctx_EFlags = wincontextrec.EFlags; 196 pContextRec->ctx_RegEsp = wincontextrec.Esp; 197 pContextRec->ctx_SegSs = wincontextrec.SegSs; 198 } 199 if(wincontextrec.ContextFlags & WINCONTEXT_INTEGER) { 200 pContextRec->ctx_RegEdi = wincontextrec.Edi; 201 pContextRec->ctx_RegEsi = wincontextrec.Esi; 202 pContextRec->ctx_RegEbx = wincontextrec.Ebx; 203 pContextRec->ctx_RegEdx = wincontextrec.Edx; 204 pContextRec->ctx_RegEcx = wincontextrec.Ecx; 205 pContextRec->ctx_RegEax = wincontextrec.Eax; 206 } 193 207 #if 0 194 195 196 197 198 199 200 208 //This is not a good idea 209 if(wincontextrec.ContextFlags & WINCONTEXT_SEGMENTS) { 210 pContextRec->ctx_SegGs = wincontextrec.SegGs; 211 pContextRec->ctx_SegFs = wincontextrec.SegFs; 212 pContextRec->ctx_SegEs = wincontextrec.SegEs; 213 pContextRec->ctx_SegDs = wincontextrec.SegDs; 214 } 201 215 #endif 202 203 204 205 206 207 208 dprintf((" SS:ESP=%04x:%08x EFLAGS=%08x\n"209 " CS:EIP=%04x:%08x EBP =%08x\n",210 pContextRec->ctx_SegSs,211 pContextRec->ctx_RegEsp, 212 pContextRec->ctx_EFlags,213 214 215 216 217 218 dprintf((" EAX=%08x EBX=%08x ESI=%08x\n" 219 " ECX=%08x EDX=%08x EDI=%08x\n",220 pContextRec->ctx_RegEax,221 pContextRec->ctx_RegEbx, 222 pContextRec->ctx_RegEsi,223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 216 if(wincontextrec.ContextFlags & WINCONTEXT_FLOATING_POINT) { 217 //TODO: First 7 dwords the same? 218 memcpy(pContextRec->ctx_env, &wincontextrec.FloatSave, sizeof(pContextRec->ctx_env)); 219 memcpy(pContextRec->ctx_stack, &wincontextrec.FloatSave.RegisterArea, sizeof(pContextRec->ctx_stack)); 220 } 221 if (pContextRec->ContextFlags & CONTEXT_CONTROL) /* check flags */ 222 dprintf((" SS:ESP=%04x:%08x EFLAGS=%08x\n", 223 pContextRec->ctx_SegSs, 224 pContextRec->ctx_RegEsp, 225 pContextRec->ctx_EFlags)); 226 dprintf((" CS:EIP=%04x:%08x EBP =%08x\n", 227 pContextRec->ctx_SegCs, 228 pContextRec->ctx_RegEip, 229 pContextRec->ctx_RegEbp)); 230 231 if (pContextRec->ContextFlags & CONTEXT_INTEGER) /* check flags */ 232 dprintf((" EAX=%08x EBX=%08x ESI=%08x\n", 233 pContextRec->ctx_RegEax, 234 pContextRec->ctx_RegEbx, 235 pContextRec->ctx_RegEsi)); 236 dprintf((" ECX=%08x EDX=%08x EDI=%08x\n", 237 pContextRec->ctx_RegEcx, 238 pContextRec->ctx_RegEdx, 239 pContextRec->ctx_RegEdi)); 240 241 if (pContextRec->ContextFlags & CONTEXT_SEGMENTS) /* check flags */ 242 dprintf((" DS=%04x ES=%08x" 243 " FS=%04x GS=%04x\n", 244 pContextRec->ctx_SegDs, 245 pContextRec->ctx_SegEs, 246 pContextRec->ctx_SegFs, 247 pContextRec->ctx_SegGs)); 248 249 if (pContextRec->ContextFlags & CONTEXT_FLOATING_POINT) /* check flags */ 250 { 251 ULONG ulCounter; /* temporary local counter for fp stack */ 252 253 dprintf((" Env[0]=%08x Env[1]=%08x Env[2]=%08x Env[3]=%08x\n", 254 pContextRec->ctx_env[0], 255 pContextRec->ctx_env[1], 256 pContextRec->ctx_env[2], 257 pContextRec->ctx_env[3])); 258 259 dprintf((" Env[4]=%08x Env[5]=%08x Env[6]=%08x\n", 260 pContextRec->ctx_env[4], 261 pContextRec->ctx_env[5], 262 pContextRec->ctx_env[6])); 263 264 for (ulCounter = 0; 265 ulCounter < 8; /* see TOOLKIT\INCLUDE\BSEEXPT.H, _CONTEXT structure */ 266 ulCounter ++) 267 dprintf((" FP-Stack[%u] losig=%08x hisig=%08x signexp=%04x\n", 268 ulCounter, 269 pContextRec->ctx_stack[0].losig, 270 pContextRec->ctx_stack[0].hisig, 271 pContextRec->ctx_stack[0].signexp)); 272 } 273 274 return TRUE; 261 275 } 262 276 dprintf(("Win32 exception handler returned %x", rc)); -
trunk/src/kernel32/oslibexcept.h
r1224 r4224 1 /* $Id: oslibexcept.h,v 1. 1 1999-10-09 15:03:24sandervl Exp $ */1 /* $Id: oslibexcept.h,v 1.2 2000-09-08 18:07:50 sandervl Exp $ */ 2 2 /* 3 3 * Exception handler util. procedures … … 14 14 // FALSE, otherwise 15 15 //****************************************************************************** 16 BOOL OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,17 PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,18 PCONTEXTRECORD pContextRec, PVOID p);16 BOOL APIENTRY OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec, 17 PEXCEPTIONREGISTRATIONRECORD pRegistrationRec, 18 PCONTEXTRECORD pContextRec, PVOID p); 19 19 20 20 #endif -
trunk/src/kernel32/resource.cpp
r3625 r4224 1 /* $Id: resource.cpp,v 1.1 6 2000-05-28 16:45:12sandervl Exp $ */1 /* $Id: resource.cpp,v 1.17 2000-09-08 18:07:50 sandervl Exp $ */ 2 2 3 3 /* … … 206 206 if (pModule == NULL) 207 207 { 208 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 208 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 209 209 return FALSE; 210 210 } … … 244 244 if (pModule == NULL) 245 245 { 246 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 246 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 247 247 return FALSE; 248 248 } … … 277 277 LONG lParam) 278 278 { 279 280 dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)\n not implemented", 281 hModule, lpType, lpName, lpEnumFunc, lParam 282 )); 283 284 return (FALSE); 279 Win32ImageBase *pModule; 280 281 dprintf(("KERNEL32:EnumResourceLanguagesA(%08x,%08x,%08x,%08x,%08x)", 282 hModule, lpType, lpName, lpEnumFunc, lParam)); 283 284 pModule = Win32ImageBase::findModule(hModule); 285 if (pModule == NULL) 286 { 287 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 288 return FALSE; 289 } 290 291 return pModule->enumResourceLanguagesA(hModule, lpType, lpName, lpEnumFunc, lParam); 285 292 } 286 293 … … 311 318 LONG lParam) 312 319 { 313 314 dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)\n not implemented", 315 hModule, lpType, lpName, lpEnumFunc, lParam 316 )); 317 318 return (FALSE); 319 } 320 321 320 Win32ImageBase *pModule; 321 322 dprintf(("KERNEL32:EnumResourceLanguagesW(%08x,%08x,%08x,%08x,%08x)", 323 hModule, lpType, lpName, lpEnumFunc, lParam)); 324 325 pModule = Win32ImageBase::findModule(hModule); 326 if (pModule == NULL) 327 { 328 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 329 return FALSE; 330 } 331 return pModule->enumResourceLanguagesW(hModule, lpType, lpName, lpEnumFunc, lParam); 332 } 322 333 323 334 /***************************************************************************** … … 331 342 * Variables : 332 343 * Result : If the function succeeds, the return value is nonzero. 333 * If the function fails, the return value is zero344 * If the function fails, the return value is zero 334 345 * Remark : 335 346 * Status : UNTESTED STUB … … 349 360 if (pModule == NULL) 350 361 { 351 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 362 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 352 363 return FALSE; 353 364 } … … 366 377 * Variables : 367 378 * Result : If the function succeeds, the return value is nonzero. 368 * If the function fails, the return value is zero379 * If the function fails, the return value is zero 369 380 * Remark : 370 381 * Status : UNTESTED STUB … … 384 395 if (pModule == NULL) 385 396 { 386 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 397 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error???? 387 398 return FALSE; 388 399 } -
trunk/src/kernel32/stubs.cpp
r4176 r4224 1739 1739 LPDWORD lpNumberOfBytesWritten) 1740 1740 { 1741 dprintf(("Kernel32: WriteProcessMemory(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n", 1741 // do some (faked) access check 1742 if (hProcess != GetCurrentProcess()) 1743 { 1744 dprintf(("Kernel32: WriteProcessMemory(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented (different process!!)", 1742 1745 hProcess, 1743 1746 lpBaseAddress, … … 1745 1748 cbWrite, 1746 1749 lpNumberOfBytesWritten)); 1747 1748 // do some (faked) access check1749 if (hProcess != GetCurrentProcess())1750 {1751 1750 SetLastError(ERROR_ACCESS_DENIED); 1752 1751 return FALSE; 1753 1752 } 1753 dprintf(("Kernel32: WriteProcessMemory(%08xh,%08xh,%08xh,%08xh,%08xh))", 1754 hProcess, 1755 lpBaseAddress, 1756 lpBuffer, 1757 cbWrite, 1758 lpNumberOfBytesWritten)); 1754 1759 1755 1760 // FIXME: check this, if we ever run win32 binaries in different addressspaces -
trunk/src/kernel32/winimagebase.h
r4023 r4224 1 /* $Id: winimagebase.h,v 1.1 4 2000-08-16 08:04:44sandervl Exp $ */1 /* $Id: winimagebase.h,v 1.15 2000-09-08 18:07:51 sandervl Exp $ */ 2 2 3 3 /* … … 82 82 BOOL enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc, 83 83 LONG lParam); 84 BOOL enumResourceLanguagesA(HMODULE hmod, LPCSTR lpType, LPCSTR lpName, 85 ENUMRESLANGPROCA lpEnumFunc, LONG lParam); 86 BOOL enumResourceLanguagesW(HMODULE hmod, LPCWSTR lpType, LPCWSTR lpName, 87 ENUMRESLANGPROCW lpEnumFunc, LONG lParam); 84 88 85 89 ULONG getVersionSize(); -
trunk/src/kernel32/winimgres.cpp
r4029 r4224 1 /* $Id: winimgres.cpp,v 1.4 5 2000-08-17 18:22:18sandervl Exp $ */1 /* $Id: winimgres.cpp,v 1.46 2000-09-08 18:07:52 sandervl Exp $ */ 2 2 3 3 /* … … 810 810 //****************************************************************************** 811 811 //****************************************************************************** 812 BOOL Win32ImageBase::enumResourceLanguagesA(HMODULE hmod, LPCSTR lpszType, 813 LPCSTR lpszName, 814 ENUMRESLANGPROCA lpEnumFunc, 815 LONG lParam) 816 { 817 PIMAGE_RESOURCE_DIRECTORY pResDirRet; 818 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 819 BOOL fRet; 820 821 if (pResRootDir == NULL) 822 { 823 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 824 return FALSE; 825 } 826 827 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000) 828 { 829 SetLastError(ERROR_NOACCESS); 830 return FALSE; 831 } 832 833 pResDirRet = getResSubDirA(pResRootDir, lpszType); 834 if(!pResDirRet) { 835 SetLastError(ERROR_RESOURCE_TYPE_NOT_FOUND); 836 return FALSE; 837 } 838 pResDirRet = getResSubDirA(pResDirRet, lpszName); 839 if(!pResDirRet) { 840 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND); 841 return FALSE; 842 } 843 844 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirRet + sizeof(*pResDirRet)); 845 if(pResDirRet->NumberOfNamedEntries) { 846 DebugInt3(); 847 } 848 paResDirEntries += pResDirRet->NumberOfNamedEntries; 849 850 for(int i = 0;i < pResDirRet->NumberOfIdEntries;i++) 851 { 852 fRet = lpEnumFunc(hmod, lpszType, lpszName, paResDirEntries[i].u1.Id, lParam); 853 if(!fRet) 854 break; 855 } 856 return fRet; 857 } 858 //****************************************************************************** 859 //****************************************************************************** 860 BOOL Win32ImageBase::enumResourceLanguagesW(HMODULE hmod, LPCWSTR lpszType, 861 LPCWSTR lpszName, 862 ENUMRESLANGPROCW lpEnumFunc, 863 LONG lParam) 864 { 865 PIMAGE_RESOURCE_DIRECTORY pResDirRet; 866 PIMAGE_RESOURCE_DIRECTORY_ENTRY paResDirEntries; 867 BOOL fRet; 868 869 if (pResRootDir == NULL) 870 { 871 SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); 872 return FALSE; 873 } 874 875 if ((ULONG)lpEnumFunc < 0x10000 || (ULONG)lpEnumFunc >= 0xc0000000) 876 { 877 SetLastError(ERROR_NOACCESS); 878 return FALSE; 879 } 880 881 pResDirRet = getResSubDirW(pResRootDir, lpszType); 882 if(!pResDirRet) { 883 SetLastError(ERROR_RESOURCE_TYPE_NOT_FOUND); 884 return FALSE; 885 } 886 pResDirRet = getResSubDirW(pResDirRet, lpszName); 887 if(!pResDirRet) { 888 SetLastError(ERROR_RESOURCE_NAME_NOT_FOUND); 889 return FALSE; 890 } 891 892 paResDirEntries = (PIMAGE_RESOURCE_DIRECTORY_ENTRY)((ULONG)pResDirRet + sizeof(*pResDirRet)); 893 if(pResDirRet->NumberOfNamedEntries) { 894 DebugInt3(); 895 } 896 paResDirEntries += pResDirRet->NumberOfNamedEntries; 897 898 for(int i = 0;i < pResDirRet->NumberOfIdEntries;i++) 899 { 900 fRet = lpEnumFunc(hmod, lpszType, lpszName, paResDirEntries[i].u1.Id, lParam); 901 if(!fRet) 902 break; 903 } 904 return fRet; 905 } 906 //****************************************************************************** 907 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.