Changeset 21972 for trunk/src


Ignore:
Timestamp:
Feb 17, 2012, 2:50:41 PM (14 years ago)
Author:
dmik
Message:

Add extra logging to DosQueryModuleHandleStrict().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/odincrt/dos.cpp

    r21658 r21972  
    1818
    1919#include "odincrt.h"
     20
     21//#define EXTRALOG
     22
     23#undef dprintf
     24#ifdef EXTRALOG
     25
     26#include <stdio.h>
     27#include <stdarg.h>
     28
     29void dbg(const char *fmt, ...)
     30{
     31    static FILE *f = 0;
     32    if (!f)
     33    {
     34        f = fopen ("/odin32_odincrt_dos.log", "w+");
     35        setbuf (f, NULL);
     36    }
     37    if (f)
     38    {
     39        va_list args;
     40        va_start (args, fmt);
     41        vfprintf (f, fmt, args);
     42        fprintf (f, "\n");
     43        va_end (args);
     44    }
     45}
     46
     47#define dprintf(a) do { dbg a; } while(0)
     48
     49#else // EXTRALOG
     50#define dprintf(a) do {} while(0)
     51#endif // EXTRALOG
    2052
    2153static BOOL matchModuleName(PCSZ pszFullModname, PCSZ pszModname)
     
    88120APIRET WIN32API DosQueryModuleHandleStrict(PCSZ pszModname, PHMODULE pHmod)
    89121{
     122    dprintf(("DosQueryModuleHandleStrict: BEGIN (%s, %p)", pszModname, pHmod));
     123
    90124    PPIB ppib;
    91125    APIRET arc = DosGetInfoBlocks(NULL, &ppib);
    92126    if (arc != NO_ERROR)
     127    {
     128        dprintf(("DosQueryModuleHandleStrict: DosGetInfoBlocks failed with %d", arc));
    93129        return arc;
     130    }
    94131
    95132    *pHmod = NULLHANDLE;
     
    102139    char *buf = (char *)malloc(64 * 1024);
    103140    if (buf == NULL)
     141    {
     142        dprintf(("DosQueryModuleHandleStrict: not enough memory"));
    104143        return ERROR_NOT_ENOUGH_MEMORY;
     144    }
    105145
    106146    arc = DosQuerySysState(QS_PROCESS | QS_MTE, QS_MTE,
     
    108148    if (arc != NO_ERROR)
    109149    {
     150        dprintf(("DosQueryModuleHandleStrict: DosQuerySysState failed with %d", arc));
    110151        free(buf);
    111152        return arc;
     
    126167            if (walkModules(pPtrRec, hmte, pszModname, pHmod))
    127168            {
     169                dprintf(("DosQueryModuleHandleStrict: found pHmod %x", *pHmod));
    128170                arc = NO_ERROR;
    129171                break;
     
    137179    }
    138180
     181    dprintf(("DosQueryModuleHandleStrict: END (%d)", arc));
    139182    free(buf);
    140183    return arc;
Note: See TracChangeset for help on using the changeset viewer.