Ignore:
Timestamp:
Jun 18, 2009, 11:53:26 AM (16 years ago)
Author:
ydario
Message:

Kernel32 updates.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/exceptstackdump.cpp

    r8401 r21302  
    2525#include "windllbase.h"
    2626
     27#include <_ras.h>
     28
    2729#define DBG_LOCALLOG    DBG_exceptstackdump
    2830#include "dbglocal.h"
     
    3032int SYSTEM EXPORT WriteLogNoEOL(char *tekst, ...);
    3133
     34#define FIX64KLIMIT
     35
    3236#undef dprintf
    33 #define dprintf(a)     if(DbgEnabledKERNEL32[DBG_LOCALLOG] == 1) WriteLogNoEOL a
     37#ifdef RAS
     38#  ifdef DEBUG
     39#    define dprintf(a)     RasLogNoEOL a; if(DbgEnabledKERNEL32[DBG_LOCALLOG] == 1) WriteLogNoEOL a
     40#  else
     41#    define dprintf(a)     RasLogNoEOL a;
     42#  endif
     43#else
     44#  ifdef DEBUG
     45#    define dprintf(a)     if(DbgEnabledKERNEL32[DBG_LOCALLOG] == 1) WriteLogNoEOL a
     46#  else
     47#    define dprintf(a)
     48#  endif
     49#endif
    3450
    3551/* ******************************************************************
     
    5571 */
    5672
    57 BOOL dbgPrintSYMInfo(CHAR * SymFileName, ULONG Object, ULONG TrapOffset)
     73BOOL dbgGetSYMInfo(CHAR * SymFileName, ULONG Object, ULONG TrapOffset, CHAR *Info, ULONG cbInfo)
    5874{
    5975    static FILE    *SymFile;
     
    88104        if (fseek(SymFile, SegOffset, SEEK_SET))
    89105        {
    90             dprintf(("Seek error."));
     106//            dprintf(("Seek error."));
    91107            goto endofprintsym;
    92108        }
     
    100116            LastVal = 0;
    101117
     118#ifdef FIX64KLIMIT
     119            // Custom build dll's SYM file is much greater than 64K.
     120            // SYM file structures use 16 bit offsets in the file and
     121            // therefore these offsets can't be directly used as they
     122            // are overflowed.
     123            // Some offsets like segment definition offsets are
     124            // paragraph (*16) ones and will overflow for an 1 meg file.
     125            // In particular this affects SYMbol searching algorithm
     126            // used here.
     127            // With the #ifdef it will be changed to so we will
     128            // extract symbol by symbol from the file instead of using
     129            // symbol table that is far further 64K fence.
     130           
     131            // Offset of first symbol
     132            SymOffset = sizeof (SEGDEF) - 1 + SegDef.cbSegName;
     133#endif
     134
    102135            // go thru all symbols in this object
    103136            for (SymNum = 0; SymNum < SegDef.cSymbols; SymNum++)
    104137            {
     138#ifndef FIX64KLIMIT
    105139                // read in symbol offset USHORT
    106140                SymPtrOffset = SYMDEFOFFSET(SegOffset, SegDef, SymNum);
    107141                fseek(SymFile, SymPtrOffset, SEEK_SET);
    108142                fread(&SymOffset, sizeof(unsigned short int), 1, SymFile);
     143#endif
    109144
    110145                // go to symbol definition
     
    121156                        fread(&Buffer[1], 1, SymDef32.cbSymName, SymFile);
    122157                        Buffer[SymDef32.cbSymName] = 0x00;
    123                         dprintf(("%s\n", Buffer));
     158//                        dprintf(("%s\n", Buffer));
     159                        strcpy (Info, Buffer);
    124160                        rc = TRUE;
    125161                        break;
     
    134170                    {
    135171                        // symbol found
    136                         dprintf(("between %s + 0x%X", Buffer, TrapOffset - LastVal));
     172#ifdef RAS
     173                        snprintf(Info, cbInfo, "between %s + 0x%X", Buffer, TrapOffset - LastVal);
     174#else
     175                        sprintf(Info, "between %s + 0x%X", Buffer, TrapOffset - LastVal);
     176#endif
    137177                    }
    138178                    LastVal = SymDef32.wSymVal;
     
    144184                    {
    145185                        // symbol found, as above
    146                         dprintf(("  and %s - 0x%X\n", Buffer, LastVal - TrapOffset));
     186#ifdef RAS
     187                        snprintf(&Info[strlen(Info)], cbInfo - strlen(Info),  "  and %s - 0x%X\n", Buffer, LastVal - TrapOffset);
     188#else
     189                        sprintf(&Info[strlen(Info)], "  and %s - 0x%X\n", Buffer, LastVal - TrapOffset);
     190#endif
    147191                        rc = TRUE;
    148192                        break;
    149193                    }
    150194                    /*printf("32 Bit Symbol <%s> Address %p",Buffer,SymDef32.wSymVal); */
     195#ifdef FIX64KLIMIT
     196                    SymOffset += sizeof (SYMDEF32) + SymDef32.cbSymName - 1;
     197#endif
    151198                }
    152199                else
     
    163210                    if (SymDef16.wSymVal > TrapOffset)
    164211                    {
    165                         dprintf(("between %s + %X", Buffer, TrapOffset - LastVal));
     212#ifdef RAS
     213                        snprintf(Info, cbInfo, "between %s + 0x%X", Buffer, TrapOffset - LastVal);
     214#else
     215                        sprintf(Info, "between %s + 0x%X", Buffer, TrapOffset - LastVal);
     216#endif
    166217                    }
    167218                    LastVal = SymDef16.wSymVal;
     
    171222                    if (SymDef16.wSymVal > TrapOffset)
    172223                    {
    173                         dprintf(("  and %s - %X\n", Buffer, LastVal - TrapOffset));
     224#ifdef RAS
     225                        snprintf(&Info[strlen(Info)], cbInfo - strlen(Info),  "  and %s - 0x%X\n", Buffer, LastVal - TrapOffset);
     226#else
     227                        sprintf(&Info[strlen(Info)], "  and %s - 0x%X\n", Buffer, LastVal - TrapOffset);
     228#endif
    174229                        rc = TRUE;
    175230                        break;
    176231                    }
    177232                    /*printf("16 Bit Symbol <%s> Address %p",Buffer,SymDef16.wSymVal); */
     233#ifdef FIX64KLIMIT
     234                    SymOffset += sizeof (SYMDEF16) + SymDef16.cbSymName - 1;
     235#endif
    178236                }               // endif
    179237            }
     238#ifdef FIX64KLIMIT
     239            if (SymNum < SegDef.cSymbols)
     240            {
     241#endif
    180242            break;
     243#ifdef FIX64KLIMIT
     244            }
     245#endif
    181246        }                       // endif
    182247        SegOffset = NEXTSEGDEFOFFSET(SegDef);
     
    184249endofprintsym:
    185250    if(SymFile) fclose(SymFile);
    186     if(rc == FALSE) dprintf(("\n"));
     251//    if(rc == FALSE) dprintf(("\n"));
     252    if(rc == FALSE) strcpy (Info, "\n");
     253    return rc;
     254}
     255BOOL dbgPrintSYMInfo(CHAR * SymFileName, ULONG Object, ULONG TrapOffset)
     256{
     257    static char szInfo[256];
     258    BOOL rc = dbgGetSYMInfo (SymFileName, Object, TrapOffset, szInfo, sizeof (szInfo));
     259    dprintf(("%s", szInfo));
    187260    return rc;
    188261}
Note: See TracChangeset for help on using the changeset viewer.