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/dbglog.cpp

    r9938 r21302  
    3030#include "initterm.h"
    3131#include "logging.h"
     32#include "exceptions.h"
    3233#include "exceptutil.h"
    3334#include <wprocess.h>
     
    3637#include <cpuhlp.h>
    3738
     39#include "asmutil.h"
     40#include "WinImageBase.h"
     41#include "WinDllBase.h"
     42#include "WinExeBase.h"
    3843/*****************************************************************************
    3944 * PMPRINTF Version                                                          *
     
    284289#endif
    285290
     291static void win32modname (ULONG eip, char *szModName, int cbModName)
     292{
     293    Win32ImageBase *pMod = NULL;
     294    if (WinExe && WinExe->insideModule(eip))
     295        pMod = WinExe;
     296    else
     297        pMod = Win32DllBase::findModuleByAddr(eip);
     298    if (pMod != NULL)
     299    {
     300        szModName[0] = '\0';
     301        strncat(szModName, pMod->getModuleName(), cbModName);
     302    }
     303}
     304
    286305int SYSTEM WriteLog(char *tekst, ...)
    287306{
     
    476495        if(tekst[strlen(tekst)-1] != '\n')
    477496            fprintf(flog, "\n");
    478 
     497#if 0       
     498if (teb && LOWORD(teb->o.odin.threadId) > 1)
     499{
     500  TEB *winteb = GetThreadTEB();
     501  PWINEXCEPTION_FRAME pframe = (PWINEXCEPTION_FRAME)winteb->except;
     502
     503  fprintf(flog, "debug Win32 exception chain %08X (%08X) (teb = %08X, esp = %08X)\n", pframe, QueryExceptionChain(), teb, getESP());
     504  fprintf(flog, "Top record at %08X, Prev at %08X, handler at %08X\n", (PWINEXCEPTION_FRAME)QueryExceptionChain(), ((PWINEXCEPTION_FRAME)QueryExceptionChain())->Prev, ((PWINEXCEPTION_FRAME)QueryExceptionChain())->Handler);
     505  fprintf(flog, "*teb %08X %08X %08X %08X %08X %08X %08X %08X\n",
     506          ((ULONG *)teb)[0],((ULONG *)teb)[1],((ULONG *)teb)[2],((ULONG *)teb)[3],
     507          ((ULONG *)teb)[4],((ULONG *)teb)[5],((ULONG *)teb)[6],((ULONG *)teb)[7]);
     508  while ((pframe != NULL) && ((ULONG)pframe != 0xFFFFFFFF)) {
     509        if ((void *)pframe > winteb->stack_top || (void *)pframe < winteb->stack_low)
     510        {
     511            fprintf(flog, "Chain corrupted! Record at %08X is outside stack boundaries!\n", pframe);
     512            break;
     513        }
     514       
     515        if ((ULONG)pframe < getESP())
     516        {
     517            fprintf(flog, "Chain corrupted! Record at %08X is below stack pointer!\n", pframe);
     518            break;
     519        }
     520
     521        char szModName[32] = "";
     522        char szModName2[32] = "";
     523        win32modname ((ULONG)pframe->Handler, szModName, sizeof (szModName));
     524        win32modname ((ULONG)pframe->Prev, szModName2, sizeof (szModName2));
     525        fprintf(flog, "Record at %08X, Prev at %08X [%s], handler at %08X [%s]\n", pframe, pframe->Prev, szModName2, pframe->Handler, szModName);
     526        if (pframe == pframe->Prev) {
     527            fprintf(flog, "Chain corrupted! Record at %08X pointing to itself!\n", pframe);
     528            break;
     529        }
     530        pframe = pframe->Prev;
     531  }
     532}
     533#endif
    479534        if(fFlushLines)
    480535            fflush(flog);
Note: See TracChangeset for help on using the changeset viewer.