Changeset 4839 for zzuf


Ignore:
Timestamp:
Aug 23, 2012, 4:10:27 PM (7 years ago)
Author:
Sam Hocevar
Message:

win32: add some console handling function diversions.

Location:
zzuf/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/configure.ac

    r4836 r4839  
    7474AC_CHECK_FUNCS(__fgets_chk __fgets_unlocked_chk __fread_chk __fread_unlocked_chk __read_chk __recv_chk __recvfrom_chk)
    7575AC_CHECK_FUNCS(CreateFileA CreateFileW ReOpenFile ReadFile CloseHandle)
     76AC_CHECK_FUNCS(AllocConsole AttachConsole SetConsoleMode WriteConsoleOutputA WriteConsoleOutputW)
    7677
    7778AC_CHECK_TYPES(sighandler_t, [], [],
  • zzuf/trunk/msvc/config.h

    r4837 r4839  
    2323/* #undef HAVE_AIO_H */
    2424/* #undef HAVE_AIO_READ */
     25#define HAVE_ALLOCCONSOLE 1
    2526/* #undef HAVE_ARPA_INET_H */
     27#define HAVE_ATTACHCONSOLE 1
    2628#define HAVE_BIND 1
    2729#define HAVE_CLOSEHANDLE 1
     
    8991#define HAVE_REGWEXEC 1
    9092#define HAVE_REOPENFILE 1
     93#define HAVE_SETCONSOLEMODE 1
    9194/* #undef HAVE_SETENV */
    9295/* #undef HAVE_SETRLIMIT */
     
    115118#define HAVE_WINDOWS_H 1
    116119#define HAVE_WINSOCK2_H 1
     120#define HAVE_WRITECONSOLEOUTPUTA 1
     121#define HAVE_WRITECONSOLEOUTPUTW 1
    117122/* #undef HAVE__IO_GETC */
    118123#define HAVE__PIPE 1
  • zzuf/trunk/src/libzzuf/lib-win32.c

    r4837 r4839  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
     3 *  Copyright (c) 2006-2012 Sam Hocevar <sam@hocevar.net>
     4 *                2012 Kévin Szkudłapski <kszkudlapski@quarkslab.com>
    45 *                All Rights Reserved
    56 *
     
    8586static BOOL (__stdcall *ORIG(CloseHandle))(HANDLE);
    8687#endif
     88#if defined HAVE_ALLOCCONSOLE
     89static BOOL (__stdcall *ORIG(AllocConsole))();
     90#endif
     91#if defined HAVE_ATTACHCONSOLE
     92static BOOL (__stdcall *ORIG(AttachConsole))(DWORD dwProcessId);
     93#endif
     94#if defined HAVE_SETCONSOLEMODE
     95static BOOL (__stdcall *ORIG(SetConsoleMode))(HANDLE hConsoleHandle,
     96                                              DWORD dwMode);
     97#endif
     98#if defined HAVE_WRITECONSOLEOUTPUTA
     99static BOOL (__stdcall *ORIG(WriteConsoleOutputA))(HANDLE hConsoleOutput,
     100                 CONST CHAR_INFO *lpBuffer, COORD dwBufferSize,
     101                 COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
     102#endif
     103#if defined HAVE_WRITECONSOLEOUTPUTW
     104static BOOL (__stdcall *ORIG(WriteConsoleOutputW))(HANDLE hConsoleOutput,
     105                 CONST CHAR_INFO *lpBuffer, COORD dwBufferSize,
     106                 COORD dwBufferCoord, PSMALL_RECT lpWriteRegion);
     107#endif
    87108
    88109/*
     
    213234HANDLE __stdcall NEW(CreateIoCompletionPort)(HANDLE FileHandle, HANDLE ExistingCompletionPort, ULONG_PTR CompletionKey, DWORD NumberOfConcurrentThreads)
    214235{
    215         HANDLE ret;
    216 
    217         ret = ORIG(CreateIoCompletionPort)(FileHandle, ExistingCompletionPort, CompletionKey, NumberOfConcurrentThreads);
    218 
    219         debug("GetQueuedCompletionStatus(0x%08x, 0x%08x, 0x%08x, %d) = 0x%08x",
    220                 FileHandle, ExistingCompletionPort, CompletionKey, NumberOfConcurrentThreads, ret);
     236    HANDLE ret;
     237
     238    ret = ORIG(CreateIoCompletionPort)(FileHandle, ExistingCompletionPort,
     239                                   CompletionKey, NumberOfConcurrentThreads);
     240
     241    debug("GetQueuedCompletionStatus(0x%08x, 0x%08x, 0x%08x, %d) = 0x%08x",
     242          FileHandle, ExistingCompletionPort, CompletionKey,
     243          NumberOfConcurrentThreads, ret);
    221244
    222245    if (!_zz_ready || !_zz_iswatched(FileHandle) /*|| !_zz_hostwatched(hFile)*/ || _zz_islocked(FileHandle) || !_zz_isactive(FileHandle))
     
    229252    }
    230253
    231         return ret;
     254    return ret;
    232255}
    233256#endif
     
    240263    ret = ORIG(GetQueuedCompletionStatus)(CompletionPort, lpNumberOfBytes, lpCompletion, lpOverlapped, dwMilliseconds);
    241264
    242         debug("GetQueuedCompletionStatus(0x%08x, { %d }, %p, %p, %d) = %s",
     265    debug("GetQueuedCompletionStatus(0x%08x, { %d }, %p, %p, %d) = %s",
    243266        CompletionPort, *lpNumberOfBytes, lpCompletion, lpOverlapped, dwMilliseconds, (ret ? "TRUE" : "FALSE"));
    244267
     
    345368    _zz_unregister(hObject);
    346369    return ret;
     370}
     371#endif
     372
     373#if defined HAVE_ALLOCCONSOLE
     374BOOL __stdcall NEW(AllocConsole)()
     375{
     376    debug("AllocConsole()");
     377    return ORIG(AllocConsole)();
     378}
     379#endif
     380
     381#if defined HAVE_ATTACHCONSOLE
     382BOOL __stdcall NEW(AttachConsole)(DWORD dwProcessId)
     383{
     384    debug("AttachConsole(%#08x)");
     385    return ORIG(AttachConsole)(dwProcessId);
     386}
     387#endif
     388
     389#if defined HAVE_SETCONSOLEMODE
     390BOOL __stdcall NEW(SetConsoleMode)(HANDLE hConsoleHandle, DWORD dwMode)
     391{
     392    debug("SetConsoleMode(%#08x, %#08x)", (int)hConsoleHandle, dwMode);
     393    return ORIG(SetConsoleMode)(hConsoleHandle, dwMode);
     394}
     395#endif
     396
     397#if defined HAVE_WRITECONSOLEOUTPUTA
     398BOOL __stdcall NEW(WriteConsoleOutputA)(HANDLE hConsoleOutput,
     399                               CONST CHAR_INFO *lpBuffer, COORD dwBufferSize,
     400                               COORD dwBufferCoord, PSMALL_RECT lpWriteRegion)
     401{
     402    debug("WriteConsoleOutputA(%#08x, %p, ...)", (int)hConsoleOutput, lpBuffer);
     403    return ORIG(WriteConsoleOutputA)(hConsoleOutput, lpBuffer, dwBufferSize,
     404                                     dwBufferCoord, lpWriteRegion);
     405}
     406#endif
     407
     408#if defined HAVE_WRITECONSOLEOUTPUTW
     409BOOL __stdcall NEW(WriteConsoleOutputW)(HANDLE hConsoleOutput,
     410                               CONST CHAR_INFO *lpBuffer, COORD dwBufferSize,
     411                               COORD dwBufferCoord, PSMALL_RECT lpWriteRegion)
     412{
     413    debug("WriteConsoleOutputW(%#08x, %p, ...)", (int)hConsoleOutput, lpBuffer);
     414    return ORIG(WriteConsoleOutputW)(hConsoleOutput, lpBuffer, dwBufferSize,
     415                                     dwBufferCoord, lpWriteRegion);
    347416}
    348417#endif
     
    361430    DIVERT(ReadFile),
    362431    DIVERT(ReadFileEx),
    363         DIVERT(CreateIoCompletionPort),
     432    DIVERT(CreateIoCompletionPort),
    364433    DIVERT(GetQueuedCompletionStatus),
    365434    DIVERT(GetOverlappedResult),
     
    367436    DIVERT(CreateFileMappingW),
    368437    DIVERT(MapViewOfFile),
     438
     439#if defined HAVE_ALLOCCONSOLE
     440    DIVERT(AllocConsole),
     441#endif
     442#if defined HAVE_ATTACHCONSOLE
     443    DIVERT(AttachConsole),
     444#endif
     445#if defined HAVE_SETCONSOLEMODE
     446    DIVERT(SetConsoleMode),
     447#endif
     448#if defined HAVE_WRITECONSOLEOUTPUTA
     449    DIVERT(WriteConsoleOutputA),
     450#endif
     451#if defined HAVE_WRITECONSOLEOUTPUTW
     452    DIVERT(WriteConsoleOutputW),
     453#endif
     454
    369455    DIVERT_END
    370456};
  • zzuf/trunk/src/libzzuf/sys.c

    r4838 r4839  
    11/*
    22 *  zzuf - general purpose fuzzer
    3  *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
     3 *  Copyright (c) 2006-2012 Sam Hocevar <sam@hocevar.net>
     4 *                2012 Kévin Szkudłapski <kszkudlapski@quarkslab.com>
    45 *                All Rights Reserved
    56 *
     
    264265static int relocate_hook(uint8_t **code)
    265266{
    266         uint8_t *cur_code = *code;
     267    uint8_t *cur_code = *code;
    267268
    268269#ifdef _M_AMD64
    269270    // we ignore the REX prefix
    270271    if ((*cur_code & 0xf8) == 0x48)
    271                 ++cur_code;
     272        ++cur_code;
    272273#endif
    273274
Note: See TracChangeset for help on using the changeset viewer.