win32: some mingw32/mingw64 warning and compilation fixes.
This commit is contained in:
parent
7ade84442d
commit
e8abdc2bd0
@ -50,6 +50,8 @@ case "${host_os}" in
|
||||
*mingw32*)
|
||||
DLL_LDFLAGS="-Wl,-l,imagehlp" # Trick libtool here
|
||||
WINSOCK2_LIBS="-lws2_32"
|
||||
# This one is necessary if we want inet_pton() with mingw
|
||||
AC_DEFINE(_WIN32_WINNT, 0x600, [Define the Windows version to Vista])
|
||||
ac_cv_func_recv=yes
|
||||
ac_cv_func_recvfrom=yes
|
||||
ac_cv_func_socket=yes
|
||||
|
||||
@ -151,6 +151,7 @@
|
||||
#define RECV_T int
|
||||
#define SONAME "libzzuf.dll"
|
||||
#define STDC_HEADERS 1
|
||||
/* #undef _WIN32_WINNT */
|
||||
/* #undef __func__ */
|
||||
|
||||
/* Fucking Visual Studio should just shut the fuck up with this fucking
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
# endif
|
||||
#endif
|
||||
#if _WIN32
|
||||
# include <Windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
@ -85,10 +85,10 @@ void _zz_debug(char const *format, ...)
|
||||
if (buf[0] == '\0')
|
||||
return; /* if buf is empty, we don't bother to send it to zzuf */
|
||||
|
||||
/* FIXME: if len >= count, no null-terminator is appended, so we may erased the last character */
|
||||
if (ret >= sizeof(buf))
|
||||
buf[ret - 1] = '\n';
|
||||
else
|
||||
/* If len >= count, no null-terminator is appended, so we need to
|
||||
* erase the last character */
|
||||
if (ret >= (int)sizeof(buf))
|
||||
ret = (int)sizeof(buf) - 1;
|
||||
buf[ret++] = '\n';
|
||||
|
||||
EnterCriticalSection(&_zz_pipe_cs);
|
||||
@ -115,9 +115,11 @@ void _zz_debug2(char const *format, ...)
|
||||
if (buf[0] == '\0')
|
||||
return; /* if buf is empty, we don't bother to send it to zzuf */
|
||||
|
||||
/* FIXME: if len >= count, no null-terminator is appended, so we may erased the last character */
|
||||
if (ret >= sizeof(buf)) buf[ret - 1] = '\n';
|
||||
else buf[ret++] = '\n';
|
||||
/* If len >= count, no null-terminator is appended, so we need to
|
||||
* erase the last character */
|
||||
if (ret >= (int)sizeof(buf))
|
||||
ret = (int)sizeof(buf) - 1;
|
||||
buf[ret++] = '\n';
|
||||
|
||||
EnterCriticalSection(&_zz_pipe_cs);
|
||||
WriteFile(dbg_hdl, buf, ret, &written, NULL);
|
||||
|
||||
@ -183,12 +183,14 @@ static void make_jmp32(uint8_t *src, uint8_t *dst, uint8_t *code)
|
||||
*(uint32_t *)(code + 1) = (uint32_t)MK_JMP_JD(dst, src);
|
||||
}
|
||||
|
||||
#ifdef _M_AMD64
|
||||
static void make_jmp64(uint8_t *dst, uint8_t *code)
|
||||
{
|
||||
memcpy(code, "\x48\xb8", 2); /* MOV rAX, Iq */
|
||||
*(uint64_t *)(code + 2) = (uint64_t)dst;
|
||||
*(uintptr_t *)(code + 2) = (uintptr_t)dst;
|
||||
memcpy(code + 10, "\xff\xe0", 2); /* JMP rAX */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This function allocates and fills a trampoline for the function pointed by code. It also tries to handle some relocations. */
|
||||
static int make_trampoline(uint8_t *code, size_t patch_size, uint8_t **trampoline_buf, size_t *trampoline_size)
|
||||
|
||||
16
src/myfork.c
16
src/myfork.c
@ -78,7 +78,6 @@ static int mypipe(int pipefd[2]);
|
||||
static int run_process(struct child *child, struct opts *, int[][2]);
|
||||
|
||||
#if defined HAVE_WINDOWS_H
|
||||
static void rep32(uint8_t *buf, void *addr);
|
||||
static int dll_inject(PROCESS_INFORMATION *, char const *);
|
||||
static void *get_proc_address(void *, DWORD, char const *);
|
||||
#endif
|
||||
@ -343,8 +342,6 @@ static int run_process(struct child *child, struct opts *opts, int pipes[][2])
|
||||
return 0;
|
||||
|
||||
#elif HAVE_WINDOWS_H
|
||||
HANDLE pid = GetCurrentProcess();
|
||||
|
||||
/* Inherit standard handles */
|
||||
STARTUPINFO sinfo;
|
||||
memset(&sinfo, 0, sizeof(sinfo));
|
||||
@ -359,7 +356,9 @@ static int run_process(struct child *child, struct opts *opts, int pipes[][2])
|
||||
for (int i = 0; child->newargv[i]; ++i)
|
||||
len += (int)strlen(child->newargv[i]) + 1;
|
||||
char *cmdline = malloc(len);
|
||||
for (int i = 0, len = 0; child->newargv[i]; ++i)
|
||||
|
||||
len = 0;
|
||||
for (int i = 0; child->newargv[i]; ++i)
|
||||
{
|
||||
strcpy(cmdline + len, child->newargv[i]);
|
||||
len += (int)strlen(child->newargv[i]) + 1;
|
||||
@ -378,14 +377,14 @@ static int run_process(struct child *child, struct opts *opts, int pipes[][2])
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
LPTSTR buf;
|
||||
LPTSTR tmp;
|
||||
DWORD err = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL, err, 0, (LPTSTR)&buf, 0, NULL);
|
||||
fprintf(stderr, "error launching `%s': %s\n", child->newargv[0], buf);
|
||||
LocalFree(buf);
|
||||
NULL, err, 0, (LPTSTR)&tmp, 0, NULL);
|
||||
fprintf(stderr, "error launching `%s': %s\n", child->newargv[0], tmp);
|
||||
LocalFree(tmp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -475,7 +474,6 @@ static int dll_inject(PROCESS_INFORMATION *pinfo, char const *lib)
|
||||
DWORD pid = pinfo->dwProcessId;
|
||||
void *rldlib = NULL;
|
||||
SIZE_T written = 0;
|
||||
DWORD old_prot = 0;
|
||||
|
||||
/* Payload */
|
||||
void *rpl = NULL;
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <Windows.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
struct opts
|
||||
|
||||
@ -119,7 +119,7 @@ static void usage(void);
|
||||
((fd >= 0) && (FD_ISSET(fd, p_fdset)))
|
||||
|
||||
#if defined _WIN32
|
||||
# include <Windows.h>
|
||||
# include <windows.h>
|
||||
# include <fcntl.h> /* _O_RDWR */
|
||||
# include <io.h> /* _open */
|
||||
static CRITICAL_SECTION _zz_pipe_cs;
|
||||
@ -980,14 +980,15 @@ static void clean_children(struct opts *opts)
|
||||
struct child_overlapped
|
||||
{
|
||||
OVERLAPPED overlapped;
|
||||
char buf[BUFSIZ];
|
||||
uint8_t buf[BUFSIZ];
|
||||
struct opts * opts;
|
||||
int child_no;
|
||||
int fd_no;
|
||||
};
|
||||
|
||||
/* This callback is called when fuzzed applications write in fd out, err or debug */
|
||||
static void _stdcall read_child(DWORD err_code, DWORD nbr_of_bytes_transfered, LPOVERLAPPED overlapped)
|
||||
static void __stdcall read_child(DWORD err_code, DWORD nbr_of_bytes_transfered,
|
||||
LPOVERLAPPED overlapped)
|
||||
{
|
||||
struct child_overlapped * co = (struct child_overlapped *)overlapped;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user