Fixed compilation problems on Windows with MinGW-w64 4.8

This commit is contained in:
Shane Peelar 2013-04-30 19:34:54 -04:00 committed by pancake
parent 4c6bc1d28b
commit 24ccb7aabb
5 changed files with 35 additions and 16 deletions

View File

@ -79,11 +79,15 @@ static int r_line_readchar_utf8(unsigned char *s) {
static int r_line_readchar() {
ut8 buf[2];
*buf = '\0';
do_it_again:
#if __WINDOWS__
BOOL ret;
LPDWORD mode, out;
HANDLE h = GetStdHandle (STD_INPUT_HANDLE);
HANDLE h;
#endif
do_it_again:
#if __WINDOWS__
h = GetStdHandle (STD_INPUT_HANDLE);
GetConsoleMode (h, &mode);
SetConsoleMode (h, 0); // RAW

View File

@ -17,6 +17,8 @@
#include <openssl/bn.h>
#endif
#include <dirent.h>
// TODO: use lowercase here?
#define R_REFCTR_CLASS int refctr;void (*ref_free)(x)
#define R_REFCTR_INIT(x,y) x->refctr=0;x->ref_free=y

View File

@ -26,6 +26,10 @@ R_API RSocket *r_socket_new (int is_ssl) { return NULL; }
//#include <sys/fcntl.h>
#endif
#ifdef __WINDOWS__
#include <ws2tcpip.h>
#endif
#define BUFFER_SIZE 4096
#if __UNIX__

View File

@ -265,23 +265,24 @@ R_API int r_file_mmap_write(const char *file, ut64 addr, const ut8 *buf, int len
#if __WINDOWS__
HANDLE fm, fh;
if (r_sandbox_enable (0)) return -1;
fh = CreateFile (file, rw?GENERIC_WRITE:GENERIC_READ,
fh = CreateFile (file, GENERIC_WRITE,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (fh == INVALID_HANDLE_VALUE) {
r_sys_perror ("CreateFile");
free (m);
return -1;
}
fm = CreateFileMapping (m->fh, NULL,
rw? PAGE_READWRITE:PAGE_READONLY, 0, 0, NULL);
fm = CreateFileMapping (fh, NULL,
PAGE_READWRITE, 0, 0, NULL);
if (fm == NULL) {
CloseHandle (fh);
return -1;
}
if (fm != INVALID_HANDLE_VALUE) {
ut8 *obuf = MapViewOfFile (m->fm, rw?
(FILE_MAP_READ|FILE_MAP_WRITE):FILE_MAP_READ,
UT32_HI (base), UT32_LO (base), 0);
ut8 *obuf = MapViewOfFile (fm,
FILE_MAP_READ|FILE_MAP_WRITE,
0, 0, len);
memcpy (obuf, buf, len);
UnmapViewOfFile (obuf);
}
@ -310,29 +311,33 @@ R_API int r_file_mmap_write(const char *file, ut64 addr, const ut8 *buf, int len
R_API int r_file_mmap_read (const char *file, ut64 addr, ut8 *buf, int len) {
#if __WINDOWS__
HANDLE fm, fh;
if (r_sandbox_enable (0)) return -1;
fh = CreateFile (file, rw?GENERIC_WRITE:GENERIC_READ,
fh = CreateFile (file, GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (fh == INVALID_HANDLE_VALUE) {
r_sys_perror ("CreateFile");
free (m);
return -1;
}
fm = CreateFileMapping (m->fh, NULL,
rw? PAGE_READWRITE:PAGE_READONLY, 0, 0, NULL);
fm = CreateFileMapping (fh, NULL,
PAGE_READONLY, 0, 0, NULL);
if (fm == NULL) {
CloseHandle (fh);
return -1;
}
if (fm != INVALID_HANDLE_VALUE) {
ut8 *obuf = MapViewOfFile (m->fm, rw?
(FILE_MAP_READ|FILE_MAP_WRITE):FILE_MAP_READ,
UT32_HI (base), UT32_LO (base), 0);
ut8 *obuf = MapViewOfFile (fm,
FILE_MAP_READ,
0, 0, len);
memcpy (obuf, buf, len);
UnmapViewOfFile (obuf);
}
CloseHandle (fh);
CloseHandle (fm);
#elif __UNIX__
int fd = r_sandbox_open (file, O_RDONLY, 0644);
const int pagesize = 4096;

View File

@ -13,6 +13,10 @@
#define O_BINARY 0
#endif
#if __WINDOWS__
#include <windows.h>
#endif
// must be deprecated
static ut32 eod, pos; // what about lseek?