]> git.zerfleddert.de Git - proxmark3-svn/commitdiff
change usb_cmd struct to be more sane
authorbushing <bushing@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 22 Dec 2009 12:34:24 +0000 (12:34 +0000)
committerbushing <bushing@ef4ab9da-24cd-11de-8aaa-f3a34680c41f>
Tue, 22 Dec 2009 12:34:24 +0000 (12:34 +0000)
wean ourselves off translate.h

client/command.cpp
client/flasher.c
client/prox.cpp
client/prox.h
client/snooper.c
client/usb.c
include/usb_cmd.h

index 0214a0ab94af36d895f3c72f145155ffb7b718ea..108cd770118e4bfc2afbf86bb7947d45aab5f4ec 100644 (file)
@@ -34,7 +34,7 @@ static void GetFromBigBuf(BYTE *dest, int bytes)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -91,7 +91,7 @@ static void CmdHi14read(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -104,30 +104,30 @@ static void CmdSri512read(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_READ_SRI512_TAG;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
-
-/* New command to read the contents of a SRIX4K tag
- * SRIX4K tags are ISO14443-B modulated memory tags,
- * this command just dumps the contents of the memory/
- */
-static void CmdSrix4kread(char *str)
-{
-        UsbCommand c;
-        c.cmd = CMD_READ_SRIX4K_TAG;
-        c.ext1 = atoi(str);
-        SendCommand(&c, FALSE);
-}
-
-
+\r
+/* New command to read the contents of a SRIX4K tag\r
+ * SRIX4K tags are ISO14443-B modulated memory tags,\r
+ * this command just dumps the contents of the memory/\r
+ */\r
+static void CmdSrix4kread(char *str)\r
+{\r
+        UsbCommand c;\r
+        c.cmd = CMD_READ_SRIX4K_TAG;\r
+        c.arg[0] = atoi(str);\r
+        SendCommand(&c, FALSE);\r
+}\r
+\r
+\r
 \r
 // ## New command\r
 static void CmdHi14areader(char *str)\r
 {\r
        UsbCommand c;\r
        c.cmd = CMD_READER_ISO_14443a;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -136,7 +136,7 @@ static void CmdHi15reader(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_READER_ISO_15693;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -145,7 +145,7 @@ static void CmdHi15tag(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_SIMTAG_ISO_15693;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -153,7 +153,7 @@ static void CmdHi14read_sim(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -161,13 +161,13 @@ static void CmdHi14readt(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 \r
        //CmdHisamplest(str);\r
        while(CmdHisamplest(str,atoi(str))==0) {\r
                c.cmd = CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443;\r
-               c.ext1 = atoi(str);\r
+               c.arg[0] = atoi(str);\r
                SendCommand(&c, FALSE);\r
        }\r
        RepaintGraphWindow();\r
@@ -201,8 +201,8 @@ static void CmdHi14asim(char *str)  // ## simulate iso14443a tag
 \r
        c.cmd = CMD_SIMULATE_TAG_ISO_14443a;\r
        // c.ext should be set to *str or convert *str to the correct format for a uid\r
-       c.ext1 = hi;\r
-       c.ext2 = lo;\r
+       c.arg[0] = hi;\r
+       c.arg[1] = lo;\r
        PrintToScrollback("Emulating 14443A TAG with UID %x%16x", hi, lo);\r
        SendCommand(&c, FALSE);\r
 }\r
@@ -681,13 +681,13 @@ static void CmdLosim(char *str)
                        c.d.asBytes[j] = GraphBuffer[i+j];\r
                }\r
                c.cmd = CMD_DOWNLOADED_SIM_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
        }\r
 \r
        UsbCommand c;\r
        c.cmd = CMD_SIMULATE_TAG_125K;\r
-       c.ext1 = GraphTraceLen;\r
+       c.arg[0] = GraphTraceLen;\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -695,8 +695,8 @@ static void CmdLosimBidir(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_LF_SIMULATE_BIDIR;\r
-       c.ext1 = 47; /* Set ADC to twice the carrier for a slight supersampling */\r
-       c.ext2 = 384;\r
+       c.arg[0] = 47; /* Set ADC to twice the carrier for a slight supersampling */\r
+       c.arg[1] = 384;\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -705,9 +705,9 @@ static void CmdLoread(char *str)
        UsbCommand c;\r
        // 'h' means higher-low-frequency, 134 kHz\r
        if(*str == 'h') {\r
-               c.ext1 = 1;\r
+               c.arg[0] = 1;\r
        } else if (*str == '\0') {\r
-               c.ext1 = 0;\r
+               c.arg[0] = 0;\r
        } else {\r
                PrintToScrollback("use 'loread' or 'loread h'");\r
                return;\r
@@ -721,9 +721,9 @@ static void CmdDetectReader(char *str)
        UsbCommand c;\r
        // 'l' means LF - 125/134 kHz\r
        if(*str == 'l') {\r
-               c.ext1 = 1;\r
+               c.arg[0] = 1;\r
        } else if (*str == 'h') {\r
-               c.ext1 = 2;\r
+               c.arg[0] = 2;\r
        } else if (*str != '\0') {\r
                PrintToScrollback("use 'detectreader' or 'detectreader l' or 'detectreader h'");\r
                return;\r
@@ -741,7 +741,7 @@ static void CmdLoCommandRead(char *str)
 \r
        UsbCommand c;\r
        c.cmd = CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K;\r
-       sscanf(str, "%i %i %i %s %s", &c.ext1, &c.ext2, &c.ext3, (char *) &c.d.asBytes,(char *) &dummy+1);\r
+       sscanf(str, "%i %i %i %s %s", &c.arg[0], &c.arg[1], &c.arg[2], (char *) &c.d.asBytes,(char *) &dummy+1);\r
        // in case they specified 'h'\r
        strcpy((char *)&c.d.asBytes + strlen((char *)c.d.asBytes), dummy);\r
        SendCommand(&c, FALSE);\r
@@ -760,7 +760,7 @@ static void CmdLosamples(char *str)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -787,7 +787,7 @@ static void CmdBitsamples(char *str)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -818,7 +818,7 @@ static void CmdHisamples(char *str)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -850,7 +850,7 @@ static int CmdHisamplest(char *str, int nrlow)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -922,7 +922,7 @@ static void CmdHexsamples(char *str)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -966,7 +966,7 @@ static void CmdHisampless(char *str)
        for(i = 0; i < n; i += 12) {\r
                UsbCommand c;\r
                c.cmd = CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K;\r
-               c.ext1 = i;\r
+               c.arg[0] = i;\r
                SendCommand(&c, FALSE);\r
                ReceiveCommand(&c);\r
                if(c.cmd != CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K) {\r
@@ -1577,8 +1577,8 @@ static void CmdTIWrite(char *str)
        int res=0;\r
 \r
        c.cmd = CMD_WRITE_TI_TYPE;\r
-       res = sscanf(str, "0x%x 0x%x 0x%x ", &c.ext1, &c.ext2, &c.ext3);\r
-       if (res == 2) c.ext3=0;\r
+       res = sscanf(str, "0x%x 0x%x 0x%x ", &c.arg[0], &c.arg[1], &c.arg[2]);\r
+       if (res == 2) c.arg[2]=0;\r
        if (res<2)\r
                PrintToScrollback("Please specify the data as two hex strings, optionally the CRC as a third");\r
        else\r
@@ -2809,8 +2809,8 @@ static void CmdHIDsimTAG(char *str)
        PrintToScrollback("Emulating tag with ID %x%16x", hi, lo);\r
 \r
        c.cmd = CMD_HID_SIM_TAG;\r
-       c.ext1 = hi;\r
-       c.ext2 = lo;\r
+       c.arg[0] = hi;\r
+       c.arg[1] = lo;\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -2818,7 +2818,7 @@ static void CmdReadmem(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_READ_MEM;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -2833,7 +2833,7 @@ static void CmdLcdReset(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_LCD_RESET;\r
-       c.ext1 = atoi(str);\r
+       c.arg[0] = atoi(str);\r
        SendCommand(&c, FALSE);\r
 }\r
 \r
@@ -2844,7 +2844,7 @@ static void CmdLcd(char *str)
        c.cmd = CMD_LCD;\r
        sscanf(str, "%x %d", &i, &j);\r
        while (j--) {\r
-               c.ext1 = i&0x1ff;\r
+               c.arg[0] = i&0x1ff;\r
                SendCommand(&c, FALSE);\r
        }\r
 }\r
@@ -2857,12 +2857,12 @@ static void CmdSetDivisor(char *str)
 {\r
        UsbCommand c;\r
        c.cmd = CMD_SET_LF_DIVISOR;\r
-       c.ext1 = atoi(str);\r
-       if (( c.ext1<0) || (c.ext1>255)) {\r
+       c.arg[0] = atoi(str);\r
+       if (( c.arg[0]<0) || (c.arg[0]>255)) {\r
                        PrintToScrollback("divisor must be between 19 and 255");\r
        } else {\r
                        SendCommand(&c, FALSE);\r
-                       PrintToScrollback("Divisor set, expected freq=%dHz", 12000000/(c.ext1+1));\r
+                       PrintToScrollback("Divisor set, expected freq=%dHz", 12000000/(c.arg[0]+1));\r
        }\r
 }\r
 \r
@@ -2871,13 +2871,13 @@ static void CmdSetMux(char *str)
        UsbCommand c;\r
        c.cmd = CMD_SET_ADC_MUX;\r
        if(strcmp(str, "lopkd") == 0) {\r
-               c.ext1 = 0;\r
+               c.arg[0] = 0;\r
        } else if(strcmp(str, "loraw") == 0) {\r
-               c.ext1 = 1;\r
+               c.arg[0] = 1;\r
        } else if(strcmp(str, "hipkd") == 0) {\r
-               c.ext1 = 2;\r
+               c.arg[0] = 2;\r
        } else if(strcmp(str, "hiraw") == 0) {\r
-               c.ext1 = 3;\r
+               c.arg[0] = 3;\r
        }\r
        SendCommand(&c, FALSE);\r
 }\r
@@ -2957,7 +2957,7 @@ static struct {
        {"setlfdivisor",        CmdSetDivisor,                  0, "<19 - 255> -- Drive LF antenna at 12Mhz/(divisor+1)"},\r
        {"setmux",              CmdSetMux,                      0, "<loraw|hiraw|lopkd|hipkd> -- Set the ADC mux to a specific value"},\r
        {"sri512read",          CmdSri512read,                  0, "<int> -- Read contents of a SRI512 tag"},\r
-       {"srix4kread",          CmdSrix4kread,                  0, "<int> -- Read contents of a SRIX4K tag"},
+       {"srix4kread",          CmdSrix4kread,                  0, "<int> -- Read contents of a SRIX4K tag"},\r
        {"tidemod",                             CmdTIDemod,                                     1, "Demodulate raw bits for TI-type LF tag"},\r
        {"tiread",                              CmdTIRead,                                      0, "Read and decode a TI 134 kHz tag"},\r
        {"tiwrite",                             CmdTIWrite,                                     0, "Write new data to a r/w TI 134 kHz tag"},\r
@@ -3049,27 +3049,27 @@ void UsbCommandReceived(UsbCommand *c)
        switch(c->cmd) {\r
                case CMD_DEBUG_PRINT_STRING: {\r
                        char s[100];\r
-                       if(c->ext1 > 70 || c->ext1 < 0) {\r
-                               c->ext1 = 0;\r
+                       if(c->arg[0] > 70 || c->arg[0] < 0) {\r
+                               c->arg[0] = 0;\r
                        }\r
-                       memcpy(s, c->d.asBytes, c->ext1);\r
-                       s[c->ext1] = '\0';\r
+                       memcpy(s, c->d.asBytes, c->arg[0]);\r
+                       s[c->arg[0]] = '\0';\r
                        PrintToScrollback("#db# %s", s);\r
                        break;\r
                }\r
 \r
                case CMD_DEBUG_PRINT_INTEGERS:\r
-                       PrintToScrollback("#db# %08x, %08x, %08x\r\n", c->ext1, c->ext2, c->ext3);\r
+                       PrintToScrollback("#db# %08x, %08x, %08x\r\n", c->arg[0], c->arg[1], c->arg[2]);\r
                        break;\r
 \r
                case CMD_MEASURED_ANTENNA_TUNING: {\r
                        int peakv, peakf;\r
                        int vLf125, vLf134, vHf;\r
-                       vLf125 = c->ext1 & 0xffff;\r
-                       vLf134 = c->ext1 >> 16;\r
-                       vHf = c->ext2 & 0xffff;;\r
-                       peakf = c->ext3 & 0xffff;\r
-                       peakv = c->ext3 >> 16;\r
+                       vLf125 = c->arg[0] & 0xffff;\r
+                       vLf134 = c->arg[0] >> 16;\r
+                       vHf = c->arg[1] & 0xffff;;\r
+                       peakf = c->arg[2] & 0xffff;\r
+                       peakv = c->arg[2] >> 16;\r
                        PrintToScrollback("");\r
                        PrintToScrollback("");\r
                        PrintToScrollback("# LF antenna: %5.2f V @   125.00 kHz", vLf125/1000.0);\r
index e3043fa33363ea2bf6d01846111d0d5f4177db6c..bcbe2d7773fe9bad8bc32ecd893dea2390055980 100644 (file)
@@ -42,16 +42,16 @@ static void FlushPrevious(int translate)
        for(i = 0; i < 240; i += 48) {
                c.cmd = CMD_SETUP_WRITE;
                memcpy(c.d.asBytes, QueuedToSend+i, 48);
-               c.ext1 = (i/4);
+               c.arg[0] = (i/4);
                SendCommand(&c, TRUE);
        }
 
        c.cmd = CMD_FINISH_WRITE;
-       c.ext1 = (ExpectedAddr-1) & (~255);
+       c.arg[0] = (ExpectedAddr-1) & (~255);
        if(translate) {
-               c.ext1 -= PHYSICAL_FLASH_START;
+               c.arg[0] -= PHYSICAL_FLASH_START;
        }
-       printf("c.ext1 = %08x\r", c.ext1);
+       printf("c.arg[0] = %08x\r", c.arg[0]);
        memcpy(c.d.asBytes, QueuedToSend+240, 16);
        SendCommand(&c, TRUE);
 
@@ -151,14 +151,14 @@ static int PrepareFlash(struct partition *p, const char *filename, unsigned int
        if(state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {
                UsbCommand c;
                c.cmd = CMD_START_FLASH;
-               c.ext1 = p->start;
-               c.ext2 = p->end;
+               c.arg[0] = p->start;
+               c.arg[1] = p->end;
                
                /* Only send magic when flashing bootrom */
                if(p->precious) {
-                       c.ext3 = START_FLASH_MAGIC;
+                       c.arg[2] = START_FLASH_MAGIC;
                } else {
-                       c.ext3 = 0;
+                       c.arg[2] = 0;
                }
                SendCommand(&c, TRUE);
                translate = 0;
@@ -196,7 +196,7 @@ static unsigned int GetProxmarkState(void)
                state = DEVICE_INFO_FLAG_CURRENT_MODE_OS;
                break;
        case CMD_DEVICE_INFO:
-               state = resp.ext1;
+               state = resp.arg[0];
                break;
        default:
                fprintf(stderr, "Couldn't get proxmark state, bad response type: 0x%04X\n", resp.cmd);
index 4b80e3cc98895785987ff8065b07bcfa698f9ebc..86a0ff4537de886216c6efbb496ac8a4c4f4df8c 100644 (file)
@@ -253,16 +253,16 @@ static void FlushPrevious(int translate)
        for(i = 0; i < 240; i += 48) {\r
                c.cmd = CMD_SETUP_WRITE;\r
                memcpy(c.d.asBytes, QueuedToSend+i, 48);\r
-               c.ext1 = (i/4);\r
+               c.arg[0] = (i/4);\r
                SendCommand(&c, TRUE);\r
        }\r
 \r
        c.cmd = CMD_FINISH_WRITE;\r
-       c.ext1 = (ExpectedAddr-1) & (~255);\r
+       c.arg[0] = (ExpectedAddr-1) & (~255);\r
        if(translate) {\r
-               c.ext1 -= PHYSICAL_FLASH_START;\r
+               c.arg[0] -= PHYSICAL_FLASH_START;\r
        }\r
-       printf("Flashing address: %08x\r", c.ext1);\r
+       printf("Flashing address: %08x\r", c.arg[0]);\r
        memcpy(c.d.asBytes, QueuedToSend+240, 16);\r
        SendCommand(&c, TRUE);\r
 \r
@@ -362,14 +362,14 @@ static int PrepareFlash(struct partition *p, const char *filename, unsigned int
        if(state & DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH) {\r
                UsbCommand c;\r
                c.cmd = CMD_START_FLASH;\r
-               c.ext1 = p->start;\r
-               c.ext2 = p->end;\r
+               c.arg[0] = p->start;\r
+               c.arg[1] = p->end;\r
 \r
                /* Only send magic when flashing bootrom */\r
                if(p->precious) {\r
-                       c.ext3 = START_FLASH_MAGIC;\r
+                       c.arg[2] = START_FLASH_MAGIC;\r
                } else {\r
-                       c.ext3 = 0;\r
+                       c.arg[2] = 0;\r
                }\r
                SendCommand(&c, TRUE);\r
                translate = 0;\r
@@ -407,7 +407,7 @@ static unsigned int GetProxmarkState(void)
                state = DEVICE_INFO_FLAG_CURRENT_MODE_OS;\r
                break;\r
        case CMD_DEVICE_INFO:\r
-               state = resp.ext1;\r
+               state = resp.arg[0];\r
                break;\r
        default:\r
                fprintf(stderr, "Couldn't get proxmark state, bad response type: 0x%04X\n", resp.cmd);\r
index aeb6dfea3ec5699090d5866a2956608f0d24027a..21ee8c1a4cd6496eae5be044cd15c4ac80a91e97 100644 (file)
@@ -1,15 +1,24 @@
 #ifndef __PROX_H\r
 #define __PROX_H\r
-\r
+#ifdef _MSC_VER\r
+typedef DWORD uint32_t;\r
+typedef BYTE uint8_t;\r
+typedef WORD uint16_t;\r
+#define bool BOOL\r
+#else\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+#endif\r
 #include "../include/usb_cmd.h"\r
 \r
 // prox.cpp\r
 void ReceiveCommand(UsbCommand *c);\r
-BOOL ReceiveCommandPoll(UsbCommand *c);\r
-void SendCommand(UsbCommand *c, BOOL wantAck);\r
+bool ReceiveCommandPoll(UsbCommand *c);\r
+void SendCommand(UsbCommand *c, bool);\r
+void wait_for_response(uint32_t command_type);\r
 \r
 // gui.cpp\r
-void ShowGui();\r
+void ShowGui(void);\r
 void HideGraphWindow(void);\r
 void ShowGraphWindow(void);\r
 void RepaintGraphWindow(void);\r
@@ -24,7 +33,7 @@ extern int offline;
 \r
 // command.cpp\r
 static void CmdBuffClear(char *str);\r
-static void GetFromBigBuf(BYTE *dest, int bytes);\r
+static void GetFromBigBuf(uint8_t *dest, int bytes);\r
 static void CmdReset(char *str);\r
 static void CmdQuit(char *str);\r
 static void CmdEM410xread(char *str);\r
@@ -61,7 +70,7 @@ static void CmdHisamples(char *str);
 static int CmdHisamplest(char *str, int nrlow);\r
 static void CmdHexsamples(char *str);\r
 static void CmdHisampless(char *str);\r
-static WORD Iso15693Crc(BYTE *v, int n);\r
+static uint16_t Iso15693Crc(uint8_t *v, int n);\r
 static void CmdHi14bdemod(char *str);\r
 static void CmdHi14list(char *str);\r
 static void CmdHi14alist(char *str);\r
index 9a92e84de4b5517494439f6377d006aed4cc4095..e382eddfef4219f1e37977ebf069ed0e163e26e8 100644 (file)
@@ -6,7 +6,7 @@
 #include <string.h>
 #include <errno.h>
 
-#include "translate.h"
+//#include "translate.h"
 #include "prox.h"
 #include "proxmark3.h"
 
index c326aeca76327de4493bfc06795078e657f374cc..8f5f38a7179736f69b851157a7ea8d25c25c4c22 100644 (file)
@@ -1,11 +1,12 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include <usb.h>
 #include <strings.h>
 #include <errno.h>
 
-#include "translate.h"
 #include "prox.h"
 #include "proxmark3.h"
 
@@ -14,7 +15,7 @@ static unsigned int claimed_iface = 0;
 unsigned char return_on_error = 0;
 unsigned char error_occured = 0;
 
-void SendCommand(UsbCommand *c, BOOL wantAck) {
+void SendCommand(UsbCommand *c, bool wantAck) {
        int ret;
 
 #if 0
index 76b543f6effa971a029f71e14d2084277f9a3ade..40e4dc8c44632b6bde754ccfca83ef79258e3483 100644 (file)
 \r
 #ifndef __USB_CMD_H\r
 #define __USB_CMD_H\r
+#ifdef _MSC_VER\r
+typedef DWORD uint32_t;\r
+typedef BYTE uint8_t;\r
+#define PACKED\r
+// stuff\r
+#else\r
+#include <stdint.h>\r
+#include <stdbool.h>\r
+#define PACKED __attribute__((packed))\r
+#endif\r
 \r
 typedef struct {\r
-       DWORD   cmd;\r
-       DWORD   ext1;\r
-       DWORD   ext2;\r
-       DWORD   ext3;\r
+       uint32_t        cmd;\r
+       uint32_t        arg[3];\r
        union {\r
-               BYTE    asBytes[48];\r
-               DWORD   asDwords[12];\r
+               uint8_t         asBytes[48];\r
+               uint32_t        asDwords[12];\r
        } d;\r
-} UsbCommand;\r
+} PACKED UsbCommand;\r
 \r
 // For the bootloader\r
-#define CMD_DEVICE_INFO                                                                                                                                0x0000\r
-#define CMD_SETUP_WRITE                                                                                                                                0x0001\r
-#define CMD_FINISH_WRITE                                                                                                                       0x0003\r
-#define CMD_HARDWARE_RESET                                                                                                             0x0004\r
-#define CMD_START_FLASH                                                                                                                                0x0005\r
-#define CMD_NACK                                                                                                                                                               0x00fe\r
-#define CMD_ACK                                                                                                                                                                0x00ff\r
+#define CMD_DEVICE_INFO                                        0x0000\r
+#define CMD_SETUP_WRITE                                        0x0001\r
+#define CMD_FINISH_WRITE                               0x0003\r
+#define CMD_HARDWARE_RESET                             0x0004\r
+#define CMD_START_FLASH                                        0x0005\r
+#define CMD_NACK                                       0x00fe\r
+#define CMD_ACK                                                0x00ff\r
 \r
 // For general mucking around\r
-#define CMD_DEBUG_PRINT_STRING                                                                                         0x0100\r
-#define CMD_DEBUG_PRINT_INTEGERS                                                                                       0x0101\r
-#define CMD_DEBUG_PRINT_BYTES                                                                                                  0x0102\r
-#define CMD_LCD_RESET                                                                                                                                  0x0103\r
-#define CMD_LCD                                                                                                                                                                0x0104\r
-#define CMD_BUFF_CLEAR                                                                                                                         0x0105\r
-#define CMD_READ_MEM                                                                                                                                   0x0106\r
-#define CMD_VERSION                                                                                                                                    0x0107\r
+#define CMD_DEBUG_PRINT_STRING                         0x0100\r
+#define CMD_DEBUG_PRINT_INTEGERS                       0x0101\r
+#define CMD_DEBUG_PRINT_BYTES                          0x0102\r
+#define CMD_LCD_RESET                                  0x0103\r
+#define CMD_LCD                                                0x0104\r
+#define CMD_BUFF_CLEAR                                 0x0105\r
+#define CMD_READ_MEM                                   0x0106\r
+#define CMD_VERSION                                    0x0107\r
 \r
 // For low-frequency tags\r
-#define CMD_READ_TI_TYPE                                                                                                                       0x0202\r
-#define CMD_WRITE_TI_TYPE                                                                                                                      0x0203\r
-#define CMD_DOWNLOADED_RAW_BITS_TI_TYPE                                                                0x0204\r
-#define CMD_ACQUIRE_RAW_ADC_SAMPLES_125K                                                       0x0205\r
-#define CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K                      0x0206\r
-#define CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K                                                      0x0207\r
-#define CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K                                            0x0208\r
-#define CMD_DOWNLOADED_SIM_SAMPLES_125K                                                                0x0209\r
-#define CMD_SIMULATE_TAG_125K                                                                                                  0x020A\r
-#define CMD_HID_DEMOD_FSK                                                                                                                      0x020B\r
-#define CMD_HID_SIM_TAG                                                                                                                                0x020C\r
-#define CMD_SET_LF_DIVISOR                                                                                                             0x020D\r
-#define CMD_LF_SIMULATE_BIDIR                                                                                                          0x020E\r
-#define CMD_SET_ADC_MUX                                                                                0x020F\r
+#define CMD_READ_TI_TYPE                               0x0202\r
+#define CMD_WRITE_TI_TYPE                              0x0203\r
+#define CMD_DOWNLOADED_RAW_BITS_TI_TYPE                        0x0204\r
+#define CMD_ACQUIRE_RAW_ADC_SAMPLES_125K               0x0205\r
+#define CMD_MOD_THEN_ACQUIRE_RAW_ADC_SAMPLES_125K      0x0206\r
+#define CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K              0x0207\r
+#define CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K            0x0208\r
+#define CMD_DOWNLOADED_SIM_SAMPLES_125K                        0x0209\r
+#define CMD_SIMULATE_TAG_125K                          0x020A\r
+#define CMD_HID_DEMOD_FSK                              0x020B\r
+#define CMD_HID_SIM_TAG                                        0x020C\r
+#define CMD_SET_LF_DIVISOR                             0x020D\r
+#define CMD_LF_SIMULATE_BIDIR                          0x020E\r
+#define CMD_SET_ADC_MUX                                        0x020F\r
 /* CMD_SET_ADC_MUX: ext1 is 0 for lopkd, 1 for loraw, 2 for hipkd, 3 for hiraw */\r
 \r
 // For the 13.56 MHz tags\r
-#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693                                  0x0300\r
-#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443                                  0x0301\r
-#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM                      0x0302\r
-#define CMD_READ_SRI512_TAG                                                                                                            0x0303\r
-#define CMD_READ_SRIX4K_TAG                                                    0x0304\r
-#define CMD_READER_ISO_15693                                                                                                   0x0310
-#define CMD_SIMTAG_ISO_15693                                                                                                   0x0311\r
-#define CMD_SIMULATE_TAG_HF_LISTEN                                                                             0x0380\r
-#define CMD_SIMULATE_TAG_ISO_14443                                                                             0x0381\r
-#define CMD_SNOOP_ISO_14443                                                                                                            0x0382\r
-#define CMD_SNOOP_ISO_14443a                                                                                                   0x0383\r
-#define CMD_SIMULATE_TAG_ISO_14443a                                                                            0x0384\r
-#define CMD_READER_ISO_14443a                                                                                                  0x0385\r
-#define CMD_SIMULATE_MIFARE_CARD                                                                                       0x0386\r
-#define CMD_SIMULATE_TAG_LEGIC_RF                                      0x387\r
-#define CMD_READER_LEGIC_RF                                            0x388\r
+#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_15693          0x0300\r
+#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443          0x0301\r
+#define CMD_ACQUIRE_RAW_ADC_SAMPLES_ISO_14443_SIM      0x0302\r
+#define CMD_READ_SRI512_TAG                            0x0303\r
+#define CMD_READ_SRIX4K_TAG                            0x0304\r
+#define CMD_READER_ISO_15693                           0x0310\r
+#define CMD_SIMTAG_ISO_15693                           0x0311\r
+#define CMD_SIMULATE_TAG_HF_LISTEN                     0x0380\r
+#define CMD_SIMULATE_TAG_ISO_14443                     0x0381\r
+#define CMD_SNOOP_ISO_14443                            0x0382\r
+#define CMD_SNOOP_ISO_14443a                           0x0383\r
+#define CMD_SIMULATE_TAG_ISO_14443a                    0x0384\r
+#define CMD_READER_ISO_14443a                          0x0385\r
+#define CMD_SIMULATE_MIFARE_CARD                       0x0386\r
+#define CMD_SIMULATE_TAG_LEGIC_RF                      0x0387\r
+#define CMD_READER_LEGIC_RF                            0x0388\r
 \r
 // For measurements of the antenna tuning\r
-#define CMD_MEASURE_ANTENNA_TUNING                                                                             0x0400\r
-#define CMD_MEASURED_ANTENNA_TUNING                                                                            0x0401\r
-#define CMD_LISTEN_READER_FIELD                                                                                                0x0402\r
+#define CMD_MEASURE_ANTENNA_TUNING                     0x0400\r
+#define CMD_MEASURED_ANTENNA_TUNING                    0x0401\r
+#define CMD_LISTEN_READER_FIELD                                0x0402\r
 \r
 // For direct FPGA control\r
-#define CMD_FPGA_MAJOR_MODE_OFF                                                                                                0x0500\r
+#define CMD_FPGA_MAJOR_MODE_OFF                                0x0500\r
+\r
+#define CMD_UNKNOWN                                    0xFFFF\r
+\r
+// CMD_DEVICE_INFO response packet has flags in arg[0], flag definitions:\r
+/* Whether a bootloader that understands the common_area is present */ \r
+#define DEVICE_INFO_FLAG_BOOTROM_PRESENT               (1<<0)\r
+\r
+/* Whether a osimage that understands the common_area is present */\r
+#define DEVICE_INFO_FLAG_OSIMAGE_PRESENT               (1<<1)\r
+\r
+/* Set if the bootloader is currently executing */\r
+#define DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM          (1<<2)\r
+\r
+/* Set if the OS is currently executing */\r
+#define DEVICE_INFO_FLAG_CURRENT_MODE_OS               (1<<3)\r
+\r
+/* Set if this device understands the extend start flash command */\r
+#define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH       (1<<4)\r
 \r
-// CMD_DEVICE_INFO response packet has flags in ext1, flag definitions:\r
-#define DEVICE_INFO_FLAG_BOOTROM_PRESENT         (1<<0) /* Whether a bootloader that understands the common_area is present */ \r
-#define DEVICE_INFO_FLAG_OSIMAGE_PRESENT         (1<<1) /* Whether a osimage that understands the common_area is present */\r
-#define DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM    (1<<2) /* Set if the bootloader is currently executing */\r
-#define DEVICE_INFO_FLAG_CURRENT_MODE_OS         (1<<3) /* Set if the OS is currently executing */\r
-#define DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH (1<<4) /* Set if this device understands the extend start flash command */\r
+/* CMD_START_FLASH may have three arguments: start of area to flash, \r
+   end of area to flash, optional magic.\r
+   The bootrom will not allow to overwrite itself unless this magic\r
+   is given as third parameter */\r
 \r
-// CMD_START_FLASH may have three arguments: start of area to flash, end of area to flash, optional magic defined below\r
-#define START_FLASH_MAGIC 0x54494f44 /* The bootrom will not allow to overwrite itself unless this magic is given as third parameter */\r
+#define START_FLASH_MAGIC 0x54494f44 // 'DOIT'\r
 \r
 #endif\r
Impressum, Datenschutz