X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/6658905f18a1eebc148836f26c731dea9c1377dc..4271e82d56403879635cabe17a0e959c49fc1a83:/winsrc/prox.cpp diff --git a/winsrc/prox.cpp b/winsrc/prox.cpp index e95a4aff..bbc9adbd 100644 --- a/winsrc/prox.cpp +++ b/winsrc/prox.cpp @@ -13,6 +13,7 @@ extern "C" { #define OUR_VID 0x9ac4 #define OUR_PID 0x4b8f +int offline = 0; HANDLE UsbHandle; static void ShowError(void) @@ -193,6 +194,7 @@ void SendCommand(UsbCommand *c, BOOL wantAck) DWORD written; OVERLAPPED ov; + memset(&ov, 0, sizeof(ov)); WriteFile(UsbHandle, buf, 65, &written, &ov); if(GetLastError() != ERROR_IO_PENDING) { @@ -228,8 +230,6 @@ static void FlushPrevious(void) UsbCommand c; memset(&c, 0, sizeof(c)); - printf("expected = %08x flush, ", ExpectedAddr); - int i; for(i = 0; i < 240; i += 48) { c.cmd = CMD_SETUP_WRITE; @@ -240,7 +240,7 @@ static void FlushPrevious(void) c.cmd = CMD_FINISH_WRITE; c.ext1 = (ExpectedAddr-1) & (~255); - printf("c.ext1 = %08x\r", c.ext1); + printf("Flashing address: %08x\r", c.ext1); memcpy(c.d.asBytes, QueuedToSend+240, 16); SendCommand(&c, TRUE); @@ -326,30 +326,35 @@ static void LoadFlashFromSRecords(char *file, int addr) int main(int argc, char **argv) { int i = 0; - + if(argc < 2) { printf("Usage: %s bootrom file.s19\n", argv[0]); printf(" %s load osimage.s19\n", argv[0]); printf(" %s fpga fpgaimg.s19\n", argv[0]); printf(" %s gui\n", argv[0]); + printf(" %s offline\n", argv[0]); return -1; } - - for(;;) { - if(UsbConnect()) { - break; - } - if(i == 0) { - printf("...no device connected, polling for it now\n"); - } - if(i > 50000) { - printf("Could not connect to USB device; exiting.\n"); - return -1; + + // Only do this if NOT in offline mode + if (strcmp(argv[1], "offline")) + { + for(;;) { + if(UsbConnect()) { + break; + } + if(i == 0) { + printf("...no device connected, polling for it now\n"); + } + if(i > 50000) { + printf("Could not connect to USB device; exiting.\n"); + return -1; + } + i++; + Sleep(5); } - i++; - Sleep(5); } - + if(strcmp(argv[1], "bootrom")==0 || strcmp(argv[1], "load")==0 || strcmp(argv[1], "fpga")==0) { if(argc != 3) { printf("Need filename.\n"); @@ -364,6 +369,9 @@ int main(int argc, char **argv) } } else if(strcmp(argv[1], "gui")==0) { ShowGui(); + } else if(strcmp(argv[1], "offline")==0) { + offline = 1; + ShowGui(); } else if(strcmp(argv[1], "cmd")==0) { if(argc != 3) { printf("Need command.\n");