source: zzuf/trunk/src/libzzuf/lib-win32.c @ 4658

Last change on this file since 4658 was 4658, checked in by Sam Hocevar, 11 years ago

Divert CreateFileW in addition to CreateFileA.

File size: 2.5 KB
Line 
1/*
2 *  zzuf - general purpose fuzzer
3 *  Copyright (c) 2006-2010 Sam Hocevar <sam@hocevar.net>
4 *                All Rights Reserved
5 *
6 *  This program is free software. It comes without any warranty, to
7 *  the extent permitted by applicable law. You can redistribute it
8 *  and/or modify it under the terms of the Do What The Fuck You Want
9 *  To Public License, Version 2, as published by Sam Hocevar. See
10 *  http://sam.zoy.org/wtfpl/COPYING for more details.
11 */
12
13/*
14 *  load-win32.c: loaded Win32 functions
15 */
16
17#include "config.h"
18
19#if defined HAVE_STDINT_H
20#   include <stdint.h>
21#elif defined HAVE_INTTYPES_H
22#   include <inttypes.h>
23#endif
24
25#include <stdio.h>
26
27#if defined HAVE_WINDOWS_H
28#   include <windows.h>
29#endif
30
31#include "common.h"
32#include "libzzuf.h"
33#include "lib-load.h"
34#include "debug.h"
35#include "fuzz.h"
36#include "fd.h"
37
38/* Kernel functions that we divert */
39#if defined HAVE_CREATEFILEA
40static HANDLE (*ORIG(CreateFileA))(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
41                                   DWORD, DWORD, HANDLE);
42#endif
43
44#if defined HAVE_CREATEFILEA
45static HANDLE (*ORIG(CreateFileW))(LPCWSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES,
46                                   DWORD, DWORD, HANDLE);
47#endif
48
49#if defined HAVE_CREATEFILEA
50HANDLE NEW(CreateFileA)(LPCTSTR lpFileName, DWORD dwDesiredAccess,
51           DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
52           DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
53           HANDLE hTemplateFile)
54{
55    fprintf(stderr, "CreateFileA diverted!\n");
56    return ORIG(CreateFileA)(lpFileName, dwDesiredAccess, dwShareMode,
57                             lpSecurityAttributes, dwCreationDisposition,
58                             dwFlagsAndAttributes, hTemplateFile);
59}
60#endif
61
62#if defined HAVE_CREATEFILEW
63HANDLE NEW(CreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess,
64           DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
65           DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
66           HANDLE hTemplateFile)
67{
68    fprintf(stderr, "CreateFileW diverted!\n");
69    return ORIG(CreateFileW)(lpFileName, dwDesiredAccess, dwShareMode,
70                             lpSecurityAttributes, dwCreationDisposition,
71                             dwFlagsAndAttributes, hTemplateFile);
72}
73#endif
74
75/* Win32 function table */
76#if defined _WIN32
77zzuf_table_t table_win32[] =
78{
79#if defined HAVE_CREATEFILEA
80    DIVERT(CreateFileA),
81#endif
82#if defined HAVE_CREATEFILEW
83    DIVERT(CreateFileW),
84#endif
85    DIVERT_END
86};
87#endif
88
Note: See TracBrowser for help on using the repository browser.