Fix windows compilation issues. But still not final. We should move to pthread and factorize the code with *nix). Ideally we should move to libusb-1.0 too.

This commit is contained in:
izsh@fail0verflow.com 2010-02-20 00:36:48 +00:00
parent 3ec3a4724e
commit 91c38cf715
8 changed files with 30 additions and 40 deletions

View file

@ -1,4 +1,4 @@
WINCC=c:\mingw\bin\gcc
CC=gcc
#COMMON_FLAGS = -m32
VPATH = ../common
@ -12,8 +12,8 @@ CXXFLAGS = $(shell pkg-config --cflags QtCore QtGui 2>/dev/null) -Wall
QTLDLIBS = $(shell pkg-config --libs QtCore QtGui 2>/dev/null)
CMDSRCS = \
$(VPATH)\crc16.c \
$(VPATH)\iso14443crc.c \
crc16.c \
iso14443crc.c \
data.c \
graph.c \
ui.c \
@ -64,8 +64,8 @@ all: $(BINS)
all-static: LDLIBS:=-static $(LDLIBS)
all-static: snooper cli flasher
prox.exe: prox.c wingui.c $(CMDSRCS) flash.c
$(WINCC) $(CFLAGS) $(DEFINES) -o prox.exe prox.c wingui.c $(CMDSRCS) flash.c $(WINLIBS)
prox.exe: prox.o wingui.o $(CMDOBJS) flash.o
$(CC) $(CFLAGS) $(DEFINES) -o prox.exe prox.o wingui.o $(CMDOBJS) flash.c $(WINLIBS)
proxmark3: LDLIBS+=$(QTLDLIBS)
proxmark3: proxmark3.o $(CMDOBJS) proxusb.o $(QTGUI)

View file

@ -2,9 +2,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#endif
#include "sleep.h"
#include "cmdparser.h"
#include "data.h"
#include "usb_cmd.h"
@ -14,7 +12,6 @@
#include "cmdhw.h"
#include "cmdlf.h"
#include "cmdmain.h"
#include "proxusb.h"
unsigned int current_command = CMD_UNKNOWN;
unsigned int received_command = CMD_UNKNOWN;
@ -50,13 +47,16 @@ void WaitForResponse(uint32_t response_type)
{
while (received_command != response_type) {
#ifdef WIN32
// FIXME: Do we really need this under windows or is it
// just some historical code?
// pthread seems to be availabe for win32 nowadays
// so we should be able to port the code and get rid
// of this part.
UsbCommand c;
if (ReceiveCommandPoll(&c))
UsbCommandReceived(&c);
Sleep(0);
#else
usleep(10000); // XXX ugh
#endif
msleep(10); // XXX ugh
}
received_command = CMD_UNKNOWN;
}

View file

@ -14,7 +14,6 @@ BOOL UsbConnect(void);
static uint32_t ExpectedAddr;
static uint8_t QueuedToSend[256];
static bool AllWritten;
#define PHYSICAL_FLASH_START 0x100000
#define PHYSICAL_FLASH_END 0x200000
@ -63,8 +62,6 @@ void WriteBlock(unsigned int block_start, unsigned int len, unsigned char *buf)
memcpy(c.d.asBytes, temp_buf+240, 16);
SendCommand(&c);
WaitForAck();
AllWritten = true;
}
void LoadFlashFromFile(const char *file, int start_addr, int end_addr)

View file

@ -1,6 +1,8 @@
#ifndef __FLASH_H__
#define __FLASH_H__
#include <stdint.h>
struct partition {
int start;
int end;

View file

@ -3,16 +3,15 @@
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdint.h>
//extern "C" {
#include "include/hidusage.h"
#include "include/hidpi.h"
#include "include/hidsdi.h"
//}
#include "ui.h"
#include "flash.h"
#include "proxusb.h"
#include "usb_cmd.h"
#include "ui.h"
#define OUR_VID 0x9ac4
#define OUR_PID 0x4b8f

View file

@ -1,14 +1,10 @@
#ifndef PROXUSB_H__
#define PROXUSB_H__
#ifdef _MSC_VER
typedef DWORD uint32_t;
typedef BYTE uint8_t;
typedef WORD uint16_t;
#define bool BOOL
#else
#include <stdint.h>
#include <stdbool.h>
#ifndef WIN32
#include <usb.h>
#endif
#include "usb_cmd.h"

View file

@ -10,6 +10,11 @@ int offline;
static char *logfilename = "proxmark3.log";
// FIXME: ifndef not really nice...
// We should eventually get rid of it once
// we fully factorize the code between *nix and windows
// (using pthread and alikes...)
#ifndef WIN32
void PrintAndLog(char *fmt, ...)
{
va_list argptr, argptr2;
@ -30,23 +35,13 @@ void PrintAndLog(char *fmt, ...)
va_end(argptr);
printf("\n");
if (logging && logfile) {
#if 0
char zeit[25];
time_t jetzt_t;
struct tm *jetzt;
jetzt_t = time(NULL);
jetzt = localtime(&jetzt_t);
strftime(zeit, 25, "%b %e %T", jetzt);
fprintf(logfile,"%s ", zeit);
#endif
vfprintf(logfile, fmt, argptr2);
fprintf(logfile,"\n");
fflush(logfile);
}
va_end(argptr2);
}
#endif
void SetLogFilename(char *fn)
{

View file

@ -10,10 +10,11 @@
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "graph.h"
#include "proxusb.h"
#include "cmdmain.h"
#include "graph.h"
#include "ui.h"
#include "cmdmain.h"
#define oops() do { \
char line[100]; \
@ -354,7 +355,7 @@ nopaint:
return 1;
}
void PrintToScrollback(char *fmt, ...)
void PrintAndLog(char *fmt, ...)
{
va_list f;
char str[1024];
@ -450,8 +451,8 @@ void ShowGui()
ResizeCommandWindow();
SetFocus(CommandEdit);
PrintToScrollback(">> Started prox, built " __DATE__ " " __TIME__);
PrintToScrollback(">> Connected to device");
PrintAndLog(">> Started prox, built " __DATE__ " " __TIME__);
PrintAndLog(">> Connected to device");
GreyPenLite = CreatePen(PS_SOLID, 1, RGB(50, 50, 50));
GreyPen = CreatePen(PS_SOLID, 1, RGB(100, 100, 100));