Changeset 4672 for zzuf


Ignore:
Timestamp:
Oct 6, 2010, 11:10:15 PM (9 years ago)
Author:
Sam Hocevar
Message:

Get the debug channel to work on Win32.

Location:
zzuf/trunk/src/libzzuf
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/libzzuf/lib-load.h

    r4663 r4672  
    5656#   error no function diversion system for this platform
    5757#endif
     58
  • zzuf/trunk/src/libzzuf/lib-win32.c

    r4664 r4672  
    6969                            lpSecurityAttributes, dwCreationDisposition,
    7070                            dwFlagsAndAttributes, hTemplateFile);
    71     debug("%s(\"%s\", %x, %x, ..., %x, %x, ...) = [%i]",
    72           __func__, lpFileName, dwDesiredAccess, dwShareMode,
    73           dwCreationDisposition, dwFlagsAndAttributes, (int)ret); \
     71    debug("CreateFileA(\"%s\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]",
     72          lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition,
     73          dwFlagsAndAttributes, (int)ret);
    7474    return ret;
    7575}
     
    8282           HANDLE hTemplateFile)
    8383{
    84     fprintf(stderr, "CreateFileW(?)\n");
    85     return ORIG(CreateFileW)(lpFileName, dwDesiredAccess, dwShareMode,
    86                              lpSecurityAttributes, dwCreationDisposition,
    87                              dwFlagsAndAttributes, hTemplateFile);
     84    HANDLE ret;
     85    ret = ORIG(CreateFileW)(lpFileName, dwDesiredAccess, dwShareMode,
     86                            lpSecurityAttributes, dwCreationDisposition,
     87                            dwFlagsAndAttributes, hTemplateFile);
     88    debug("CreateFileW(\"%s\", 0x%x, 0x%x, ..., 0x%x, 0x%x, ...) = [%i]",
     89          lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition,
     90          dwFlagsAndAttributes, (int)ret);
     91    return ret;
    8892}
    8993#endif
     
    98102           LPOVERLAPPED lpOverlapped)
    99103{
    100     fprintf(stderr, "ReadFile(%i)\n", nNumberOfBytesToRead);
    101104    return ORIG(ReadFile)(hFile, lpBuffer, nNumberOfBytesToRead,
    102105                          lpNumberOfBytesRead, lpOverlapped);
     
    111114BOOL __stdcall NEW(CloseHandle)(HANDLE hObject)
    112115{
    113     fprintf(stderr, "CloseHandle(%i)\n", hObject);
    114116    return ORIG(CloseHandle)(hObject);
    115117}
     
    117119
    118120/* Win32 function table */
    119 #if defined _WIN32
     121#if defined HAVE_WINDOWS_H
    120122#   define DIVERT(x) { "kernel32.dll", #x, \
    121123                      (void **)&x##_orig, (void *)x##_new }
     
    124126zzuf_table_t table_win32[] =
    125127{
    126 #if defined HAVE_CLOSEHANDLE
    127128    DIVERT(CloseHandle),
    128 #endif
    129 #if defined HAVE_CREATEFILEA
    130129    DIVERT(CreateFileA),
    131 #endif
    132 #if defined HAVE_CREATEFILEW
    133130    DIVERT(CreateFileW),
    134 #endif
    135 #if defined HAVE_READFILE
    136131    DIVERT(ReadFile),
    137 #endif
    138132    DIVERT_END
    139133};
    140134#endif
    141 
  • zzuf/trunk/src/libzzuf/libzzuf.c

    r4282 r4672  
    117117    tmp = getenv("ZZUF_DEBUGFD");
    118118    if(tmp)
     119#if defined _WIN32
     120        _zz_debugfd = _open_osfhandle((HANDLE)atoi(tmp));
     121#else
    119122        _zz_debugfd = atoi(tmp);
     123#endif
    120124
    121125    /* We need this as soon as possible */
  • zzuf/trunk/src/libzzuf/sys.c

    r4663 r4672  
    4343HINSTANCE WINAPI LoadLibraryA_new(LPCSTR path)
    4444{
    45     void *ret;
    46     fprintf(stderr, "This is the diverted LoadLibraryA\n");
    47     ret = LoadLibraryA_orig(path);
    48     fprintf(stderr, "Now the real LoadLibraryA was called\n");
    49     return ret;
     45    return LoadLibraryA_orig(path);
    5046}
    5147
     
    5349BOOL WINAPI AllocConsole_new(void)
    5450{
    55     fprintf(stderr, "Allocating console\n");
    5651    return AllocConsole_orig();
    5752}
     
    6055BOOL WINAPI AttachConsole_new(DWORD d)
    6156{
    62     fprintf(stderr, "Attaching console\n");
    6357    return AttachConsole_orig(d);
    6458}
Note: See TracChangeset for help on using the changeset viewer.