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