Changeset 4224 for trunk/src


Ignore:
Timestamp:
Sep 8, 2000, 8:07:52 PM (25 years ago)
Author:
sandervl
Message:

exception changes, implemented enumresourcelanguages + put back some old code

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 phaller Exp $ */
     1/* $Id: environ.cpp,v 1.6 2000-09-08 18:07:49 sandervl Exp $ */
    22
    33/*
     
    1717 *
    1818 */
    19 
    20 /*****************************************************************************
    21  * Includes                                                                  *
    22  *****************************************************************************/
    23 
    2419#include <odin.h>
    2520#include <odinwrap.h>
     
    3833#include "dbglocal.h"
    3934
    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//******************************************************************************
     37LPSTR WIN32API GetEnvironmentStringsA(void)
     38{
     39    dprintf(("KERNEL32:  OS2GetEnvironmentStringsA\n"));
     40    return (LPSTR) O32_GetEnvironmentStrings();
     41}
     42//******************************************************************************
     43//******************************************************************************
     44LPWSTR WIN32API GetEnvironmentStringsW(VOID)
    5645{
    5746 char *envstrings = (char *)O32_GetEnvironmentStrings();
     
    5948 LPWSTR wenvstrings;
    6049 int len, i;
     50
     51  dprintf(("KERNEL32:  GetEnvironmentStringsW\n"));
    6152
    6253  if(envstrings == NULL)
     
    8273//******************************************************************************
    8374//******************************************************************************
    84 ODINFUNCTION1(BOOL, FreeEnvironmentStringsA,
    85               LPSTR, envstrings)
    86 {
    87   dprintf(("not correctly implemented.\n"));
    88   //free(envstrings);
     75BOOL WIN32API FreeEnvironmentStringsA(LPSTR envstrings)
     76{
     77  dprintf(("KERNEL32:  FreeEnvironmentStringsA\n"));
    8978  return(TRUE);
    9079}
    9180//******************************************************************************
    9281//******************************************************************************
    93 ODINFUNCTION1(BOOL,   FreeEnvironmentStringsW,
    94               LPWSTR, envstrings)
    95 {
    96   dprintf(("not correctly implemented.\n"));
    97   //free(envstrings);
     82BOOL WIN32API FreeEnvironmentStringsW(LPWSTR envstrings)
     83{
     84  dprintf(("KERNEL32:  FreeEnvironmentStringsW\n"));
     85  free(envstrings);
    9886  return(TRUE);
    9987}
    10088//******************************************************************************
    10189//******************************************************************************
    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)
     90BOOL 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//******************************************************************************
     97BOOL 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//******************************************************************************
     112DWORD 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//******************************************************************************
     119DWORD WIN32API GetEnvironmentVariableW(LPCWSTR lpName, LPWSTR lpBuffer,
     120                                       DWORD nSize)
    139121{
    140122  char *astring, *asciibuffer;
    141123  DWORD rc;
    142124
    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);
    152135}
    153136/***********************************************************************
     
    186169 *****************************************************************************/
    187170
    188 ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsA,
    189               LPCSTR, lpSrc,
    190               LPSTR,  lpDst,
    191               DWORD,  nSize)
     171DWORD WIN32API ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
    192172{
    193173    DWORD len, total_size = 1;  /* 1 for terminating '\0' */
    194174    LPCSTR p, var;
    195175
    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 != '%')
    201185        {
    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;
    206190        }
    207191        else  /* we are at the start of a variable */
    208192        {
    209             if ((p = strchr( lpSrc + 1, '%' )))
     193            if ((p = strchr( src + 1, '%' )))
    210194            {
    211                 len = p - lpSrc - 1;  /* Length of the variable name */
     195                len = p - src - 1;  /* Length of the variable name */   
    212196                if ((var = ENV_FindVariable( GetEnvironmentStringsA(),
    213                                              lpSrc + 1, len )))
     197                                             src + 1, len )))
    214198                {
    215                     lpSrc += len + 2;  /* Skip the variable name */
     199                    src += len + 2;  /* Skip the variable name */
    216200                    len = strlen(var);
    217201                }
    218202                else
    219203                {
    220                     var = lpSrc;  /* Copy original name instead */
     204                    var = src;  /* Copy original name instead */
    221205                    len += 2;
    222                     lpSrc += len;
     206                    src += len;
    223207                }
    224208            }
    225209            else  /* unfinished variable name, ignore it */
    226210            {
    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;
    230214            }
    231215        }
    232216        total_size += len;
    233         if (lpDst)
     217        if (dst)
    234218        {
    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;
    239223        }
    240224    }
    241225
    242226    /* 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';
    247231    }
    248232    dprintf(("KERNEL32:ExpandEnvironmentStringsA returned %s %d",
    249               lpDst, total_size));
     233              dst, total_size));
    250234    return total_size;
    251235}
     
    270254 *****************************************************************************/
    271255
    272 ODINFUNCTION3(DWORD,  ExpandEnvironmentStringsW,
    273               LPCWSTR,lpSrc,
    274               LPWSTR, lpDst,
    275               DWORD,  nSize)
     256DWORD WIN32API ExpandEnvironmentStringsW(LPCWSTR lpSrc, LPWSTR lpDst, DWORD nSize)
    276257{
    277258    LPSTR srcA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpSrc );
    278259    LPSTR dstA = lpDst ? (LPSTR)HeapAlloc( GetProcessHeap(), 0, nSize ) : NULL;
    279260
     261    dprintf(("KERNEL32:ExpandEnvironmentStringsW(%08x,%08x,%08x)", lpSrc, lpDst, nSize));
     262
    280263    DWORD ret  = ExpandEnvironmentStringsA( srcA, dstA, nSize );
    281264    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.                 */
    26
    37/*
     
    6771#include "exceptstackdump.h"
    6872
    69 #define DBG_LOCALLOG    DBG_exceptions
     73#define DBG_LOCALLOG    DBG_exceptions
    7074#include "dbglocal.h"
    7175
     
    8084void KillWin32Process(void);
    8185
     86#ifdef DEBUG
     87void PrintWin32ExceptionChain(PWINEXCEPTION_FRAME pframe);
     88#else
     89#define PrintWin32ExceptionChain(a)
     90#endif
    8291
    8392/*****************************************************************************
     
    142151  dprintf(("KERNEL32: RaiseException(%08xh)\n",
    143152           dwExceptionCode));
     153
     154  memset(&record, 0, sizeof(record));
    144155
    145156  /* compose an exception record */
     
    182193  if(rc == ExceptionContinueSearch && UnhandledExceptionFilter != NULL)
    183194  {
     195    dprintf(("KERNEL32: RaiseException calling UnhandledExceptionFilter.\n"));
     196
    184197    ExceptionInfo.ExceptionRecord = &record;
    185198    ExceptionInfo.ContextRecord   = &context;
    186199
    187200    rc = UnhandledExceptionFilter(&ExceptionInfo);
     201    //FIXME: UnhandledExceptionFilter does NOT return the same values as
     202    //       other filters!!
    188203  }
    189204
     
    196211  }
    197212
     213  dprintf(("KERNEL32: RaiseException returns.\n"));
    198214  return;
    199215}
     216
     217
    200218//******************************************************************************
    201219//******************************************************************************
     
    212230  pframe      = (PWINEXCEPTION_FRAME)winteb->except;
    213231
     232  dprintf(("KERNEL32: RtlDispatchException entered"));
     233
     234  PrintWin32ExceptionChain(pframe);
     235
    214236  // walk the exception chain
    215237  while( (pframe != NULL) && (pframe != ((void *)0xFFFFFFFF)) )
    216238  {
    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
    220247        /* Check frame address */
    221248        if (((void*)pframe < winteb->stack_low) ||
     
    223250            (int)pframe & 3)
    224251        {
     252            dprintf(("Invalid stack! low=%08X, top=%08X, pframe = %08X",
     253                    winteb->stack_low, winteb->stack_top, pframe));
     254
    225255            pRecord->ExceptionFlags |= EH_STACK_INVALID;
    226256            break;
    227257        }
    228258
    229         rc = pframe->Handler(pRecord,
     259        dprintf(("KERNEL32: RtlDispatchException - calling exception handler %08X", pframe->Handler));
     260
     261        rc = pframe->Handler(pRecord,
    230262                             pframe,
    231263                             pContext,
    232264                             dispatch);
     265
     266        dprintf(("KERNEL32: RtlDispatchException - exception handler returned %#x", rc));
     267        PrintWin32ExceptionChain(pframe);
    233268
    234269        if (pframe == nested_frame)
     
    239274        }
    240275
    241         dprintf(("exception handler returned %x", rc));
    242276
    243277        switch(rc)
    244278        {
    245279        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            }
    247284            break;
    248285        case ExceptionContinueSearch:
     
    256293        }
    257294
     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        }
    258300        pframe = pframe->Prev;
    259301  }
     302  dprintf(("KERNEL32: RtlDispatchException returns %#x", rc));
     303  PrintWin32ExceptionChain(pframe);
    260304  return rc;
    261305}
     
    284328  WINEXCEPTION_RECORD record, newrec;
    285329  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
    289334
    290335  memset(&context, 0, sizeof(context));
     
    310355  if(!pRecord)
    311356  {
     357    memset(&record, 0, sizeof(record));
    312358    record.ExceptionCode    = STATUS_UNWIND;
    313359    record.ExceptionFlags   = 0;
     
    324370  TEB *winteb = GetThreadTEB();
    325371  frame       = (PWINEXCEPTION_FRAME)winteb->except;
     372
     373  PrintWin32ExceptionChain(frame);
    326374
    327375  while ((frame != (PWINEXCEPTION_FRAME)0xffffffff) && (frame != pEndFrame))
     
    334382            newrec.ExceptionRecord  = pRecord;
    335383            newrec.NumberParameters = 0;
    336             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    337             DosExit(EXIT_THREAD, 0);
     384            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     385            DosExit(EXIT_THREAD, 0);
    338386        }
    339387        if (((void*)frame < winteb->stack_low) ||
     
    345393            newrec.ExceptionRecord  = pRecord;
    346394            newrec.NumberParameters = 0;
    347             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    348             DosExit(EXIT_THREAD, 0);
     395            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     396            DosExit(EXIT_THREAD, 0);
    349397        }
    350398
    351399        /* 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)
    354404        {
    355405        case ExceptionContinueSearch:
     
    363413            newrec.ExceptionRecord  = pRecord;
    364414            newrec.NumberParameters = 0;
    365             dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
    366             DosExit(EXIT_THREAD, 0);
     415            dprintf(("KERNEL32: RtlUnwind terminating thread.\n"));
     416            DosExit(EXIT_THREAD, 0);
    367417            break;
    368418        }
     419        dprintf(("KERNEL32: RtlUnwind (before)- frame=%08X, frame->Prev=%08X", frame, frame->Prev));
    369420        SetExceptionChain((DWORD)frame->Prev);
    370421        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);
    372486  return(0);
    373487}
     
    415529                                  };
    416530
    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)))
    420536  {
     537    dprintf(("KERNEL32: Calling user UnhandledExceptionFilter"));
    421538    rc = CurrentUnhExceptionFlt(lpexpExceptionInfo);
    422539    if(rc != WINEXCEPTION_CONTINUE_SEARCH)
     
    492609  LPTOP_LEVEL_EXCEPTION_FILTER old = CurrentUnhExceptionFlt;
    493610
    494   dprintf(("KERNEL32: SetUnhandledExceptionFilter to %X\n",
     611  dprintf(("KERNEL32: SetUnhandledExceptionFilter to %08X\n",
    495612           lpTopLevelExceptionFilter));
    496613
     
    524641
    525642  if(fEntry == FALSE) {
    526         fEntry = TRUE;
    527         ExitProcess(666);
    528         return;
     643        fEntry = TRUE;
     644        ExitProcess(666);
     645        return;
    529646  }
    530647  //Restore original OS/2 TIB selector
     
    857974
    858975  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",
    861977             pCtxRec->ctx_SegSs,
    862978             pCtxRec->ctx_RegEsp,
    863              pCtxRec->ctx_EFlags,
     979             pCtxRec->ctx_EFlags));
     980    dprintf(("   CS:EIP=%04x:%08x EBP   =%08x\n",
    864981             pCtxRec->ctx_SegCs,
    865982             pCtxRec->ctx_RegEip,
     
    867984
    868985  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",
    871987             pCtxRec->ctx_RegEax,
    872988             pCtxRec->ctx_RegEbx,
    873              pCtxRec->ctx_RegEsi,
     989             pCtxRec->ctx_RegEsi));
     990    dprintf(("   ECX=%08x EDX=%08x EDI=%08x\n",
    874991             pCtxRec->ctx_RegEcx,
    875992             pCtxRec->ctx_RegEdx,
     
    877994
    878995  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",
    881997              pCtxRec->ctx_SegDs,
    882               pCtxRec->ctx_SegEs,
     998              pCtxRec->ctx_SegEs));
     999    dprintf(("   FS=%04x     GS=%04x\n",
    8831000              pCtxRec->ctx_SegFs,
    8841001              pCtxRec->ctx_SegGs));
     
    9361053                                   PVOID                        p)
    9371054{
     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
    9381061  //SvL: Check if exception inside debug fprintf -> if so, clear lock so
    9391062  //     next dprintf won't wait forever
    9401063  CheckLogException();
     1064
    9411065
    9421066  /* Access violation at a known location */
     
    9501074  case XCPT_FLOAT_STACK_CHECK:
    9511075  case XCPT_FLOAT_UNDERFLOW:
    952         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    953         dprintf(("KERNEL32: OS2ExceptionHandler: FPU exception\n"));
    954         if(fIsOS2Image == FALSE)  //Only for real win32 apps
    955         {
    956                 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == FALSE)
    957                 {
    958                         pCtxRec->ctx_env[0] |= 0x1F;
    959                         pCtxRec->ctx_stack[0].losig = 0;
    960                         pCtxRec->ctx_stack[0].hisig = 0;
    961                         pCtxRec->ctx_stack[0].signexp = 0;
    962                 }
    963                 dprintf(("KERNEL32: OS2ExceptionHandler: fix and continue\n"));
    964                 return (XCPT_CONTINUE_EXECUTION);
    965         }
    966         else
    967         {
    968                 dprintf(("KERNEL32: OS2ExceptionHandler: continue search\n"));
    969                 return (XCPT_CONTINUE_SEARCH);
    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        }
    9711095
    9721096  case XCPT_PROCESS_TERMINATE:
    9731097  case XCPT_ASYNC_PROCESS_TERMINATE:
    974         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    975         SetExceptionChain((ULONG)-1);
    976         return (XCPT_CONTINUE_SEARCH);
     1098        dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1099        SetExceptionChain((ULONG)-1);
     1100        return (XCPT_CONTINUE_SEARCH);
    9771101
    9781102  case XCPT_ACCESS_VIOLATION:
    979   {     
     1103  {
    9801104   Win32MemMap *map;
    9811105   BOOL  fWriteAccess = FALSE;
    9821106   ULONG offset, accessflag;
    9831107
    984         if(pERepRec->ExceptionInfo[1] == 0 && pERepRec->ExceptionInfo[1] == XCPT_DATA_UNKNOWN) {
    985                 goto continueFail;
    986         }
    987         switch(pERepRec->ExceptionInfo[0]) {
    988         case XCPT_READ_ACCESS:
    989                 accessflag = MEMMAP_ACCESS_READ;
    990                 break;
    991         case XCPT_WRITE_ACCESS:
    992                 accessflag = MEMMAP_ACCESS_WRITE;
    993                 fWriteAccess = TRUE;
    994                 break;
    995         case XCPT_EXECUTE_ACCESS:
    996                 accessflag = MEMMAP_ACCESS_EXECUTE;
    997                 break;
    998         default:
    999                 goto continueFail;
    1000         }
    1001 
    1002         map = Win32MemMapView::findMapByView(pERepRec->ExceptionInfo[1], &offset, accessflag);
    1003         if(map == NULL) {
    1004                 goto continueFail;
    1005         }
    1006         if(map->commitPage(offset, fWriteAccess) == TRUE)
    1007                 return (XCPT_CONTINUE_EXECUTION);
    1008 
    1009         //no break;
     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;
    10101134  }
    10111135continueFail:
     
    10141138#ifdef DEBUGSTACK
    10151139  if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
    1016         ULONG *stackptr;
    1017         APIRET rc;
    1018         int    i;
    1019         ULONG  ulOffset, ulModule, ulObject;
    1020         CHAR   szModule[CCHMAXPATH];
    1021 
    1022         stackptr = (ULONG *)pCtxRec->ctx_RegEsp;
    1023         dprintf(("Stack DUMP:"));
    1024         for(i=0;i<16;i++) {
    1025                 rc = DosQueryModFromEIP(&ulModule,
    1026                                         &ulObject,
     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,
    10271151                                        sizeof(szModule),
    10281152                                        szModule,
     
    10301154                                        (ULONG)*stackptr);
    10311155
    1032                 if (rc == NO_ERROR)
    1033                         dprintf(("0x%8x: 0x%8x %s (#%u), obj #%u:%08x", stackptr, *stackptr, szModule, ulModule, ulObject, ulOffset));
    1034                 else    dprintf(("0x%8x: 0x%8x", stackptr, *stackptr));
    1035                 stackptr++;
    1036         }
    1037         dprintf(("Stack DUMP END"));
     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"));
    10381162  }
    10391163#endif
     
    10521176CrashAndBurn:
    10531177#ifdef DEBUG
    1054         dprintfException(pERepRec, pERegRec, pCtxRec, p);
    1055         if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
    1056                 dbgPrintStack(pERepRec, pERegRec, pCtxRec, p);
    1057         }
     1178        dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1179        if(pCtxRec->ContextFlags & CONTEXT_CONTROL) {
     1180                dbgPrintStack(pERepRec, pERegRec, pCtxRec, p);
     1181        }
    10581182#endif
    1059         if(fIsOS2Image == FALSE)  //Only for real win32 apps
    1060         {
    1061                 if(OSLibDispatchException(pERepRec, pERegRec, pCtxRec, p) == TRUE)
    1062                 {
    1063                         return (XCPT_CONTINUE_EXECUTION);
    1064                 }
    1065         }
    1066         else    return XCPT_CONTINUE_SEARCH; //pass on to OS/2 RTL or app exception handler
    1067 
    1068         dprintf(("KERNEL32: OS2ExceptionHandler: Continue and kill\n"));
    1069         pCtxRec->ctx_RegEip = (ULONG)KillWin32Process;
    1070         pCtxRec->ctx_RegEsp = pCtxRec->ctx_RegEsp + 0x10;
    1071         pCtxRec->ctx_RegEax = pERepRec->ExceptionNum;
    1072         pCtxRec->ctx_RegEbx = pCtxRec->ctx_RegEip;
    1073         return (XCPT_CONTINUE_EXECUTION);
     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);
    10741198
    10751199  //@@@PH: growing thread stacks might need special treatment
    10761200  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)"));
    10781202    return (XCPT_CONTINUE_SEARCH);
    10791203
     
    10811205      if(pERepRec->ExceptionInfo[0] == XCPT_SIGNAL_KILLPROC)          /* resolve signal information */
    10821206      {
    1083         SetExceptionChain((ULONG)-1);
    1084         return (XCPT_CONTINUE_SEARCH);
     1207        SetExceptionChain((ULONG)-1);
     1208        return (XCPT_CONTINUE_SEARCH);
    10851209      }
    10861210      goto CrashAndBurn;
    10871211
    10881212  default: //non-continuable exceptions
    1089         dprintfException(pERepRec, pERegRec, pCtxRec, p);
     1213        dprintfException(pERepRec, pERegRec, pCtxRec, p);
    10901214        return (XCPT_CONTINUE_SEARCH);
    10911215  }
     
    11291253  dprintf(("Exception chain list:"));
    11301254  while(pExceptRec != 0 && (ULONG)pExceptRec != -1) {
    1131         dprintf(("record %x", pExceptRec));
    1132         pExceptRec = pExceptRec->prev_structure;
     1255        dprintf(("record %x", pExceptRec));
     1256        pExceptRec = pExceptRec->prev_structure;
    11331257  }
    11341258  SetFS(sel);
    11351259}
     1260
     1261void 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
    11361274#endif
    11371275
     
    11731311
    11741312    if(sel == 0x150b) {
    1175         SetFS(sel);
    1176         return FALSE;
     1313        SetFS(sel);
     1314        return FALSE;
    11771315    }
    11781316    pExceptRec = (PEXCEPTIONREGISTRATIONRECORD)QueryExceptionChain();
    11791317    if(pExceptRec->ExceptionHandler != OS2ExceptionHandler) {
    1180         SetFS(sel);
    1181         return FALSE;
     1318        SetFS(sel);
     1319        return FALSE;
    11821320    }
    11831321    SetFS(sel);
  • trunk/src/kernel32/exceptutil.asm

    r4189 r4224  
    1 ; $Id: exceptutil.asm,v 1.10 2000-09-04 18:24:42 sandervl Exp $
     1; $Id: exceptutil.asm,v 1.11 2000-09-08 18:07:49 sandervl Exp $
    22
    33;/*
     
    5353
    5454_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
    5561        push dword ptr [esp+4]  ;PWINEXCEPTION_FRAME  pEndFrame
    5662        push dword ptr [esp+12] ;LPVOID unusedEip
     
    135141        PUBLIC getEAX
    136142        PUBLIC getEBX
    137 getEAX  proc near
    138         ret
    139 getEAX  endp
    140 
    141 getEBX  proc near
     143getEAX  proc near
     144        ret
     145getEAX  endp
     146
     147getEBX  proc near
    142148        mov  eax, ebx
    143149        ret
    144 getEBX  endp
     150getEBX  endp
    145151
    146152        PUBLIC GetFS
    147 GetFS   proc near
    148         mov     eax, fs
    149         ret
    150 GetFS   endp
     153GetFS   proc near
     154        mov     eax, fs
     155        ret
     156GetFS   endp
    151157
    152158        PUBLIC SetFS
    153 SetFS   proc near
    154         mov     eax, [esp+4]
    155         mov     fs, eax
    156         ret
    157 SetFS   endp
     159SetFS   proc near
     160        mov     eax, [esp+4]
     161        mov     fs, eax
     162        ret
     163SetFS   endp
    158164
    159165        PUBLIC getCS
    160 getCS   proc near
    161         mov     eax, cs
    162         ret
    163 getCS   endp
     166getCS   proc near
     167        mov     eax, cs
     168        ret
     169getCS   endp
    164170
    165171        PUBLIC getDS
    166 getDS   proc near
    167         mov     eax, ds
    168         ret
    169 getDS   endp
    170 
    171         PUBLIC SetReturnFS
     172getDS   proc near
     173        mov     eax, ds
     174        ret
     175getDS   endp
     176
     177        PUBLIC SetReturnFS
    172178SetReturnFS proc near
    173         push    fs
    174         mov     eax, [esp+8]
    175         mov     fs, eax
    176         pop     eax
    177         ret
     179        push    fs
     180        mov     eax, [esp+8]
     181        mov     fs, eax
     182        pop     eax
     183        ret
    178184SetReturnFS endp
    179185
    180186        PUBLIC getSS
    181 getSS   proc near
    182         mov     ax, ss
    183         ret
    184 getSS   endp
     187getSS   proc near
     188        mov     ax, ss
     189        ret
     190getSS   endp
    185191
    186192        PUBLIC getES
    187 getES   proc near
    188         mov     eax, es
    189         ret
    190 getES   endp
     193getES   proc near
     194        mov     eax, es
     195        ret
     196getES   endp
    191197
    192198        PUBLIC getGS
    193 getGS   proc near
    194         mov     eax, gs
    195         ret
    196 getGS   endp
    197 
    198         PUBLIC getESP
     199getGS   proc near
     200        mov     eax, gs
     201        ret
     202getGS   endp
     203
     204        PUBLIC getESP
    199205getESP  proc near
    200         mov     eax, esp
    201         ret
    202 getESP  endp
    203 
    204         PUBLIC RestoreOS2FS
     206        mov     eax, esp
     207        ret
     208getESP  endp
     209
     210        PUBLIC RestoreOS2FS
    205211RestoreOS2FS proc near
    206         push    150bh
    207         mov     ax, fs
    208         pop     fs
    209         ret
     212        push    150bh
     213        mov     ax, fs
     214        pop     fs
     215        ret
    210216RestoreOS2FS endp
    211217
    212         PUBLIC _Mul32x32to64
     218        PUBLIC _Mul32x32to64
    213219_Mul32x32to64 proc near
    214         push    ebp
    215         mov     ebp, esp
    216         push    eax
    217         push    edx
    218         push    edi
    219 
    220         mov     edi, [ebp+8]    ;64 bits result
    221         mov     eax, [ebp+12]   ;op1
    222         mov     edx, [ebp+16]   ;op2
    223         mul     edx
    224         mov     [edi], eax
    225         mov     [edi+4], edx
    226 
    227         pop     edi
    228         pop     edx
    229         pop     eax
    230         pop     ebp
    231         ret
     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
    232238_Mul32x32to64 endp
    233239
  • trunk/src/kernel32/heap.cpp

    r4214 r4224  
    1 /* $Id: heap.cpp,v 1.21 2000-09-08 04:28:46 phaller Exp $ */
     1/* $Id: heap.cpp,v 1.22 2000-09-08 18:07:50 sandervl Exp $ */
    22
    33/*
     
    180180//******************************************************************************
    181181//******************************************************************************
    182 ODINFUNCTIONNODBG2(HLOCAL, LocalAlloc,
    183                    UINT,   fuFlags,
    184                    DWORD,  cbBytes)
     182HLOCAL WIN32API LocalAlloc(UINT fuFlags, DWORD cbBytes)
    185183{
    186184 HLOCAL lmem;
     
    219217//******************************************************************************
    220218//******************************************************************************
    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
     219HLOCAL 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
    232229  }
    233230  return NULL; //success
     
    252249//TODO: cbBytes==0 && fuFlags & LMEM_MOVEABLE not handled!!
    253250//******************************************************************************
    254 ODINFUNCTIONNODBG3(HLOCAL, LocalReAlloc,
    255                    HLOCAL, hMem,
    256                    DWORD,  cbBytes,
    257                    UINT,   fuFlags)
     251HLOCAL WIN32API LocalReAlloc(HLOCAL hMem, DWORD cbBytes, UINT fuFlags)
    258252{
    259253  HLOCAL hLocalNew;
    260254  LPVOID lpMem;
     255
     256  dprintf(("KERNEL32: LocalReAlloc %X %d %X\n", hMem, cbBytes, fuFlags));
    261257
    262258  //SvL: 8-8-'98: Notepad bugfix (assumes address is identical when new size < old size)
     
    322318}
    323319//******************************************************************************
     320#ifdef DEBUG
     321static ULONG totalGlobalAlloc = 0;
     322#endif
    324323//******************************************************************************
    325324HGLOBAL WIN32API GlobalAlloc(UINT fuFlags, DWORD dwBytes)
    326325{
    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;
    330334}
    331335//******************************************************************************
     
    333337HGLOBAL WIN32API GlobalFree( HGLOBAL arg1)
    334338{
    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;
    338347}
    339348//******************************************************************************
     
    365374PVOID WIN32API GlobalLock(HGLOBAL arg1)
    366375{
    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;
    370381}
    371382//******************************************************************************
  • trunk/src/kernel32/makefile

    r4174 r4224  
    1 # $Id: makefile,v 1.99 2000-09-03 18:04:54 phaller Exp $
     1# $Id: makefile,v 1.100 2000-09-08 18:07:50 sandervl Exp $
    22
    33#
     
    181181!include $(PDWIN32_INCLUDE)/pdwin32.post
    182182
     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:45 sandervl Exp $ */
     1/* $Id: oslibexcept.cpp,v 1.3 2000-09-08 18:07:50 sandervl Exp $ */
    22/*
    33 * Exception handler util. procedures
     
    1818#include "oslibexcept.h"
    1919#include <exceptions.h>
    20 
    21 #define DBG_LOCALLOG    DBG_oslibexcept
     20#include <wprocess.h>
     21
     22#define DBG_LOCALLOG    DBG_oslibexcept
    2223#include "dbglocal.h"
    2324
     
    2728//         FALSE, otherwise
    2829//******************************************************************************
    29 BOOL OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,
    30                             PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,
    31                             PCONTEXTRECORD pContextRec, PVOID p)
     30BOOL APIENTRY OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,
     31                                     PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,
     32                                     PCONTEXTRECORD pContextRec, PVOID p)
    3233{
    3334 WINEXCEPTION_RECORD winreportrec;
     
    4041  switch(pReportRec->ExceptionNum) {
    4142  case XCPT_FLOAT_DENORMAL_OPERAND:
    42         winreportrec.ExceptionCode = EXCEPTION_FLT_DENORMAL_OPERAND;
    43         break;
     43        winreportrec.ExceptionCode = EXCEPTION_FLT_DENORMAL_OPERAND;
     44        break;
    4445  case XCPT_FLOAT_DIVIDE_BY_ZERO:
    45         winreportrec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
    46         break;
     46        winreportrec.ExceptionCode = EXCEPTION_FLT_DIVIDE_BY_ZERO;
     47        break;
    4748  case XCPT_FLOAT_INEXACT_RESULT:
    48         winreportrec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
    49         break;
     49        winreportrec.ExceptionCode = EXCEPTION_FLT_INEXACT_RESULT;
     50        break;
    5051  case XCPT_FLOAT_INVALID_OPERATION:
    51         winreportrec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
    52         break;
     52        winreportrec.ExceptionCode = EXCEPTION_FLT_INVALID_OPERATION;
     53        break;
    5354  case XCPT_FLOAT_OVERFLOW:
    54         winreportrec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
    55         break;
     55        winreportrec.ExceptionCode = EXCEPTION_FLT_OVERFLOW;
     56        break;
    5657  case XCPT_FLOAT_STACK_CHECK:
    57         winreportrec.ExceptionCode = EXCEPTION_FLT_STACK_CHECK;
    58         break;
     58        winreportrec.ExceptionCode = EXCEPTION_FLT_STACK_CHECK;
     59        break;
    5960  case XCPT_FLOAT_UNDERFLOW:
    60         winreportrec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
    61         break;
     61        winreportrec.ExceptionCode = EXCEPTION_FLT_UNDERFLOW;
     62        break;
    6263  case XCPT_INTEGER_DIVIDE_BY_ZERO:
    63         winreportrec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
    64         break;
     64        winreportrec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
     65        break;
    6566  case XCPT_INTEGER_OVERFLOW:
    66         winreportrec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
    67         break;
     67        winreportrec.ExceptionCode = EXCEPTION_INT_OVERFLOW;
     68        break;
    6869  case XCPT_PRIVILEGED_INSTRUCTION:
    69         winreportrec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
    70         break;
     70        winreportrec.ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
     71        break;
    7172  case XCPT_BREAKPOINT:
    72         winreportrec.ExceptionCode = EXCEPTION_BREAKPOINT;
    73         break;
     73        winreportrec.ExceptionCode = EXCEPTION_BREAKPOINT;
     74        break;
    7475  case XCPT_SINGLE_STEP:
    75         winreportrec.ExceptionCode = EXCEPTION_SINGLE_STEP;
    76         break;
     76        winreportrec.ExceptionCode = EXCEPTION_SINGLE_STEP;
     77        break;
    7778  case XCPT_ARRAY_BOUNDS_EXCEEDED:
    78         winreportrec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
    79         break;
     79        winreportrec.ExceptionCode = EXCEPTION_ARRAY_BOUNDS_EXCEEDED;
     80        break;
    8081  case XCPT_DATATYPE_MISALIGNMENT:
    81         winreportrec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
    82         break;
     82        winreportrec.ExceptionCode = EXCEPTION_DATATYPE_MISALIGNMENT;
     83        break;
    8384  case XCPT_ILLEGAL_INSTRUCTION:
    84         winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
    85         break;
     85        winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
     86        break;
    8687  case XCPT_INVALID_LOCK_SEQUENCE:
    87         winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
    88         break;
     88        winreportrec.ExceptionCode = EXCEPTION_ILLEGAL_INSTRUCTION;
     89        break;
    8990  case XCPT_GUARD_PAGE_VIOLATION:
    90         winreportrec.ExceptionCode = EXCEPTION_GUARD_PAGE;
    91         break;
     91        winreportrec.ExceptionCode = EXCEPTION_GUARD_PAGE;
     92        break;
    9293  case XCPT_UNABLE_TO_GROW_STACK:
    93         winreportrec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
    94         break;
     94        winreportrec.ExceptionCode = EXCEPTION_STACK_OVERFLOW;
     95        break;
    9596  case XCPT_IN_PAGE_ERROR:
    96         winreportrec.ExceptionCode = EXCEPTION_IN_PAGE_ERROR;
    97         break;
     97        winreportrec.ExceptionCode = EXCEPTION_IN_PAGE_ERROR;
     98        break;
    9899  case XCPT_ACCESS_VIOLATION:
    99         winreportrec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
    100         break;
     100        winreportrec.ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
     101        break;
    101102  default: //no other exceptions should be dispatched to win32 apps
    102         return FALSE;
     103        return FALSE;
    103104  }
    104105  //TODO:
     
    109110  memset(&wincontextrec, 0, sizeof(wincontextrec));
    110111  if(pContextRec->ContextFlags & CONTEXT_CONTROL) {
    111         wincontextrec.ContextFlags |= WINCONTEXT_CONTROL;
    112         wincontextrec.Ebp     = pContextRec->ctx_RegEbp;
    113         wincontextrec.Eip     = pContextRec->ctx_RegEip;
    114         wincontextrec.SegCs   = pContextRec->ctx_SegCs;
    115         wincontextrec.EFlags  = pContextRec->ctx_EFlags;
    116         wincontextrec.Esp     = pContextRec->ctx_RegEsp;
    117         wincontextrec.SegSs   = pContextRec->ctx_SegSs;
     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;
    118119  }
    119120  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
    128133  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;
    134141  }
    135142  if(pContextRec->ContextFlags & CONTEXT_FLOATING_POINT) {
    136         wincontextrec.ContextFlags |= WINCONTEXT_FLOATING_POINT;
    137         //TODO: First 7 dwords the same?
    138         memcpy(&wincontextrec.FloatSave, pContextRec->ctx_env, sizeof(pContextRec->ctx_env));
    139         memcpy(&wincontextrec.FloatSave.RegisterArea, pContextRec->ctx_stack, sizeof(pContextRec->ctx_stack));
     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));
    140147  }
    141148  //It doesn't seem correct if we dispatch real exceptions to win32 apps
    142149  //Some just call RtlUnwind and continue as if they were processing an
    143150  //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
    145157  switch(pReportRec->ExceptionNum) {
    146158  case XCPT_FLOAT_DENORMAL_OPERAND:
     
    151163  case XCPT_FLOAT_STACK_CHECK:
    152164  case XCPT_FLOAT_UNDERFLOW:
    153         rc = RtlDispatchException(&winreportrec, &wincontextrec);
    154         break;
     165        rc = RtlDispatchException(&winreportrec, &wincontextrec);
     166        break;
    155167
    156168  case XCPT_ACCESS_VIOLATION:
    157         rc = RtlDispatchException(&winreportrec, &wincontextrec);
    158         break;
     169        rc = RtlDispatchException(&winreportrec, &wincontextrec);
     170        break;
    159171
    160172  case XCPT_INTEGER_DIVIDE_BY_ZERO:
     
    170182  case XCPT_UNABLE_TO_GROW_STACK:
    171183  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
    174188
    175189  if(rc == ExceptionContinueExecution) {
    176         dprintf(("Win32 exception handler returned ExceptionContinueExecution"));
    177         if(wincontextrec.ContextFlags & WINCONTEXT_CONTROL) {
    178                 pContextRec->ctx_RegEbp = wincontextrec.Ebp;
    179                 pContextRec->ctx_RegEip = wincontextrec.Eip;
    180                 pContextRec->ctx_SegCs  = wincontextrec.SegCs;
    181                 pContextRec->ctx_EFlags = wincontextrec.EFlags;
    182                 pContextRec->ctx_RegEsp = wincontextrec.Esp;
    183                 pContextRec->ctx_SegSs  = wincontextrec.SegSs;
    184         }
    185         if(wincontextrec.ContextFlags & WINCONTEXT_INTEGER) {
    186                 pContextRec->ctx_RegEdi = wincontextrec.Edi;
    187                 pContextRec->ctx_RegEsi = wincontextrec.Esi;
    188                 pContextRec->ctx_RegEbx = wincontextrec.Ebx;
    189                 pContextRec->ctx_RegEdx = wincontextrec.Edx;
    190                 pContextRec->ctx_RegEcx = wincontextrec.Ecx;
    191                 pContextRec->ctx_RegEax = wincontextrec.Eax;
    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        }
    193207#if 0
    194         //This is not a good idea
    195         if(wincontextrec.ContextFlags & WINCONTEXT_SEGMENTS) {
    196                 pContextRec->ctx_SegGs = wincontextrec.SegGs;
    197                 pContextRec->ctx_SegFs = wincontextrec.SegFs;
    198                 pContextRec->ctx_SegEs = wincontextrec.SegEs;
    199                 pContextRec->ctx_SegDs = wincontextrec.SegDs;
    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        }
    201215#endif
    202         if(wincontextrec.ContextFlags & WINCONTEXT_FLOATING_POINT) {
    203                 //TODO: First 7 dwords the same?
    204                 memcpy(pContextRec->ctx_env, &wincontextrec.FloatSave, sizeof(pContextRec->ctx_env));
    205                 memcpy(pContextRec->ctx_stack, &wincontextrec.FloatSave.RegisterArea, sizeof(pContextRec->ctx_stack));
    206         }
    207         if (pContextRec->ContextFlags & CONTEXT_CONTROL)         /* check flags */
    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                              pContextRec->ctx_SegCs,
    214                              pContextRec->ctx_RegEip,
    215                              pContextRec->ctx_RegEbp));
    216 
    217         if (pContextRec->ContextFlags & CONTEXT_INTEGER)         /* check flags */
    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                              pContextRec->ctx_RegEcx,
    224                              pContextRec->ctx_RegEdx,
    225                              pContextRec->ctx_RegEdi));
    226                
    227         if (pContextRec->ContextFlags & CONTEXT_SEGMENTS)        /* check flags */
    228                     dprintf(("   DS=%04x     ES=%08x"
    229                              "   FS=%04x     GS=%04x\n",
    230                               pContextRec->ctx_SegDs,
    231                               pContextRec->ctx_SegEs,
    232                               pContextRec->ctx_SegFs,
    233                               pContextRec->ctx_SegGs));
    234 
    235         if (pContextRec->ContextFlags & CONTEXT_FLOATING_POINT)  /* check flags */
    236         {
    237             ULONG ulCounter;                 /* temporary local counter for fp stack */
    238 
    239                 dprintf(("   Env[0]=%08x Env[1]=%08x Env[2]=%08x Env[3]=%08x\n",
    240                              pContextRec->ctx_env[0],
    241                              pContextRec->ctx_env[1],
    242                              pContextRec->ctx_env[2],
    243                              pContextRec->ctx_env[3]));
    244                
    245                 dprintf(("   Env[4]=%08x Env[5]=%08x Env[6]=%08x\n",
    246                              pContextRec->ctx_env[4],
    247                              pContextRec->ctx_env[5],
    248                              pContextRec->ctx_env[6]));
    249 
    250                 for (ulCounter = 0;
    251                      ulCounter < 8; /* see TOOLKIT\INCLUDE\BSEEXPT.H, _CONTEXT structure */
    252                      ulCounter ++)
    253                       dprintf(("   FP-Stack[%u] losig=%08x hisig=%08x signexp=%04x\n",
    254                                ulCounter,
    255                                pContextRec->ctx_stack[0].losig,
    256                                pContextRec->ctx_stack[0].hisig,
    257                                pContextRec->ctx_stack[0].signexp));
    258         }
    259        
    260         return TRUE;
     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;
    261275  }
    262276  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:24 sandervl Exp $ */
     1/* $Id: oslibexcept.h,v 1.2 2000-09-08 18:07:50 sandervl Exp $ */
    22/*
    33 * Exception handler util. procedures
     
    1414//         FALSE, otherwise
    1515//******************************************************************************
    16 BOOL OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,
    17                             PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,
    18                             PCONTEXTRECORD pContextRec, PVOID p);
     16BOOL APIENTRY OSLibDispatchException(PEXCEPTIONREPORTRECORD pReportRec,
     17                                     PEXCEPTIONREGISTRATIONRECORD pRegistrationRec,
     18                                     PCONTEXTRECORD pContextRec, PVOID p);
    1919
    2020#endif
  • trunk/src/kernel32/resource.cpp

    r3625 r4224  
    1 /* $Id: resource.cpp,v 1.16 2000-05-28 16:45:12 sandervl Exp $ */
     1/* $Id: resource.cpp,v 1.17 2000-09-08 18:07:50 sandervl Exp $ */
    22
    33/*
     
    206206    if (pModule == NULL)
    207207    {
    208         SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     208        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error????
    209209        return FALSE;
    210210    }
     
    244244    if (pModule == NULL)
    245245    {
    246         SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     246        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error????
    247247        return FALSE;
    248248    }
     
    277277                                     LONG lParam)
    278278{
    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);
    285292}
    286293
     
    311318                                     LONG lParam)
    312319{
    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}
    322333
    323334/*****************************************************************************
     
    331342 * Variables :
    332343 * Result    : If the function succeeds, the return value is nonzero.
    333  * If the function fails, the return value is zero
     344 *             If the function fails, the return value is zero
    334345 * Remark    :
    335346 * Status    : UNTESTED STUB
     
    349360    if (pModule == NULL)
    350361    {
    351         SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     362        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error????
    352363        return FALSE;
    353364    }
     
    366377 * Variables :
    367378 * Result    : If the function succeeds, the return value is nonzero.
    368  * If the function fails, the return value is zero
     379 *             If the function fails, the return value is zero
    369380 * Remark    :
    370381 * Status    : UNTESTED STUB
     
    384395    if (pModule == NULL)
    385396    {
    386         SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND);
     397        SetLastError(ERROR_RESOURCE_DATA_NOT_FOUND); //todo: right error????
    387398        return FALSE;
    388399    }
  • trunk/src/kernel32/stubs.cpp

    r4176 r4224  
    17391739                                 LPDWORD lpNumberOfBytesWritten)
    17401740{
    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!!)",
    17421745           hProcess,
    17431746           lpBaseAddress,
     
    17451748           cbWrite,
    17461749           lpNumberOfBytesWritten));
    1747  
    1748   // do some (faked) access check
    1749   if (hProcess != GetCurrentProcess())
    1750   {
    17511750    SetLastError(ERROR_ACCESS_DENIED);
    17521751    return FALSE;
    17531752  }
     1753  dprintf(("Kernel32: WriteProcessMemory(%08xh,%08xh,%08xh,%08xh,%08xh))",
     1754           hProcess,
     1755           lpBaseAddress,
     1756           lpBuffer,
     1757           cbWrite,
     1758           lpNumberOfBytesWritten));
    17541759 
    17551760  // 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.14 2000-08-16 08:04:44 sandervl Exp $ */
     1/* $Id: winimagebase.h,v 1.15 2000-09-08 18:07:51 sandervl Exp $ */
    22
    33/*
     
    8282        BOOL  enumResourceTypesW(HMODULE hmod, ENUMRESTYPEPROCW lpEnumFunc,
    8383                                 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);
    8488
    8589        ULONG getVersionSize();
  • trunk/src/kernel32/winimgres.cpp

    r4029 r4224  
    1 /* $Id: winimgres.cpp,v 1.45 2000-08-17 18:22:18 sandervl Exp $ */
     1/* $Id: winimgres.cpp,v 1.46 2000-09-08 18:07:52 sandervl Exp $ */
    22
    33/*
     
    810810//******************************************************************************
    811811//******************************************************************************
     812BOOL 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//******************************************************************************
     860BOOL 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.