diff --git a/armsrc/Standalone/hf_young.c b/armsrc/Standalone/hf_young.c index 3ef9e37cf..906d0b36c 100644 --- a/armsrc/Standalone/hf_young.c +++ b/armsrc/Standalone/hf_young.c @@ -8,14 +8,16 @@ //----------------------------------------------------------------------------- // main code for HF standalone mode Mifare /sniff/emulation by Craig Young //----------------------------------------------------------------------------- + #include "hf_young.h" +#include "common.h" typedef struct { uint8_t uid[10]; uint8_t uidlen; uint8_t atqa[2]; uint8_t sak; -} __attribute__((__packed__)) card_clone_t; +} PACKED card_clone_t; void ModInfo(void) { diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 8895fd327..d9c17e3b3 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -13,6 +13,7 @@ #include #include "usb_cdc.h" #include "proxmark3.h" +#include "pmflash.h" #include "apps.h" #include "fpga.h" #include "util.h" diff --git a/armsrc/flashmem.c b/armsrc/flashmem.c index 4584d41b2..ad4861ce3 100644 --- a/armsrc/flashmem.c +++ b/armsrc/flashmem.c @@ -1,4 +1,5 @@ #include "flashmem.h" +#include "pmflash.h" /* here: use NCPS2 @ PA10: */ #define SPI_CSR_NUM 2 diff --git a/armsrc/lfops.c b/armsrc/lfops.c index 09a1632cb..96fd3ae37 100644 --- a/armsrc/lfops.c +++ b/armsrc/lfops.c @@ -19,6 +19,7 @@ #include "protocols.h" #include "usb_cdc.h" // for usb_poll_validate_length #include "common.h" +#include "pmflash.h" #include "flashmem.h" // persistence on mem //#define START_GAP 31*8 // was 250 // SPEC: 1*8 to 50*8 - typ 15*8 (15fc) diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index 26b6583fc..2d56a8a37 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -14,8 +14,11 @@ //----------------------------------------------------------------------------- #include "mifarecmd.h" + #include +#include "pmflash.h" + #ifndef HARDNESTED_AUTHENTICATION_TIMEOUT # define HARDNESTED_AUTHENTICATION_TIMEOUT 848 // card times out 1ms after wrong authentication (according to NXP documentation) #endif diff --git a/client/cmdflashmem.h b/client/cmdflashmem.h index 3c37239b7..790d42a5d 100644 --- a/client/cmdflashmem.h +++ b/client/cmdflashmem.h @@ -15,10 +15,11 @@ #include #include #include +#include "pmflash.h" +#include "common.h" #include "proxmark3.h" #include "ui.h" #include "cmdparser.h" -#include "common.h" #include "util.h" #include "util_posix.h" // msclock #include "loclass/fileutils.h" //saveFile diff --git a/client/deprecated-hid-flasher/flasher/elf.h b/client/deprecated-hid-flasher/flasher/elf.h index 0551cbd76..eef2863d8 100644 --- a/client/deprecated-hid-flasher/flasher/elf.h +++ b/client/deprecated-hid-flasher/flasher/elf.h @@ -9,6 +9,8 @@ #ifndef __ELF_H__ #define __ELF_H__ +#include "proxmark3.h" + typedef struct { uint32_t p_type; uint32_t p_offset; @@ -18,7 +20,7 @@ typedef struct { uint32_t p_memsz; uint32_t p_flags; uint32_t p_align; -} __attribute__((__packed__)) Elf32_Phdr; +} PACKED Elf32_Phdr; #define EI_NIDENT 16 @@ -37,7 +39,7 @@ typedef struct { uint16_t e_shentsize; uint16_t e_shnum; uint16_t e_shtrndx; -} __attribute__((__packed__)) Elf32_Ehdr; +} PACKED Elf32_Ehdr; #define PT_NULL 0 #define PT_LOAD 1 diff --git a/client/deprecated-hid-flasher/flasher/proxmark3.h b/client/deprecated-hid-flasher/flasher/proxmark3.h index f5dd2b7fa..c9e42efd8 100644 --- a/client/deprecated-hid-flasher/flasher/proxmark3.h +++ b/client/deprecated-hid-flasher/flasher/proxmark3.h @@ -14,4 +14,16 @@ #define PROXPROMPT "proxmark3> " +#ifdef _MSC_VER +typedef DWORD uint32_t; +typedef BYTE uint8_t; +#define PACKED +// stuff +#else +#include +#include +#define PACKED __attribute__((packed)) +#endif + + #endif diff --git a/client/deprecated-hid-flasher/flasher/usb_cmd.h b/client/deprecated-hid-flasher/flasher/usb_cmd.h index 2b383faf8..60c359e5a 100644 --- a/client/deprecated-hid-flasher/flasher/usb_cmd.h +++ b/client/deprecated-hid-flasher/flasher/usb_cmd.h @@ -12,16 +12,8 @@ #ifndef __USB_CMD_H #define __USB_CMD_H -#ifdef _MSC_VER -typedef DWORD uint32_t; -typedef BYTE uint8_t; -#define PACKED -// stuff -#else -#include -#include -#define PACKED __attribute__((packed)) -#endif + +#include "proxmark3.h" typedef struct { uint32_t cmd; diff --git a/client/elf.h b/client/elf.h index 0551cbd76..50533224f 100644 --- a/client/elf.h +++ b/client/elf.h @@ -9,6 +9,8 @@ #ifndef __ELF_H__ #define __ELF_H__ +#include "common.h" + typedef struct { uint32_t p_type; uint32_t p_offset; @@ -18,7 +20,7 @@ typedef struct { uint32_t p_memsz; uint32_t p_flags; uint32_t p_align; -} __attribute__((__packed__)) Elf32_Phdr; +} PACKED Elf32_Phdr; #define EI_NIDENT 16 @@ -37,7 +39,7 @@ typedef struct { uint16_t e_shentsize; uint16_t e_shnum; uint16_t e_shtrndx; -} __attribute__((__packed__)) Elf32_Ehdr; +} PACKED Elf32_Ehdr; #define PT_NULL 0 #define PT_LOAD 1 diff --git a/client/lualibs/read14a.lua b/client/lualibs/read14a.lua index f68dfff81..3bf243235 100644 --- a/client/lualibs/read14a.lua +++ b/client/lualibs/read14a.lua @@ -60,7 +60,7 @@ local function parse14443a(data) uint8_t sak; uint8_t ats_len; uint8_t ats[256]; - } __attribute__((__packed__)) iso14a_card_select_t; + } PACKED iso14a_card_select_t; --]] local count, uid, uidlen, atqa, sak, ats_len, ats = bin.unpack('H10CH2CCH', data) diff --git a/client/lualibs/read14b.lua b/client/lualibs/read14b.lua index 0be958e25..67d2bd469 100644 --- a/client/lualibs/read14b.lua +++ b/client/lualibs/read14b.lua @@ -39,7 +39,7 @@ local function parse1443b(data) uint8_t atqb[7]; uint8_t chipid; uint8_t cid; - } __attribute__((__packed__)) iso14b_card_select_t; + } PACKED iso14b_card_select_t; --]] diff --git a/client/util.h b/client/util.h index 3d2de1dc7..3f677df7a 100644 --- a/client/util.h +++ b/client/util.h @@ -20,100 +20,12 @@ #include #include "ui.h" // PrintAndLog #include "commonutil.h" - -#ifdef _MSC_VER -#define PACKED -#else -#define PACKED __attribute__((packed)) -#endif +#include "common.h" #ifdef ANDROID #include #endif -#ifndef ROTR -# define ROTR(x,n) (((uintmax_t)(x) >> (n)) | ((uintmax_t)(x) << ((sizeof(x) * 8) - (n)))) -#endif -#ifndef ROTL -# define ROTL(x,n) (((uintmax_t)(x) << (n)) | ((uintmax_t)(x) >> ((sizeof(x) * 8) - (n)))) -#endif - -#ifndef MIN -# define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#endif -#ifndef MAX -# define MAX(a, b) (((a) > (b)) ? (a) : (b)) -#endif - -// endian change for 64bit -#ifdef __GNUC__ -#ifndef BSWAP_64 -#define BSWAP_64(x) __builtin_bswap64(x) -#endif -#else -#ifdef _MSC_VER -#ifndef BSWAP_64 -#define BSWAP_64(x) _byteswap_uint64(x) -#endif -#else -#ifndef BSWAP_64 -#define BSWAP_64(x) \ - (((uint64_t)(x) << 56) | \ - (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ - (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ - (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ - (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ - (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ - (((uint64_t)(x) >> 40) & 0xff00ULL) | \ - ((uint64_t)(x) >> 56)) -#endif -#endif -#endif - -// endian change for 32bit -#ifdef __GNUC__ -#ifndef BSWAP_32 -#define BSWAP_32(x) __builtin_bswap32(x) -#endif -#else -#ifdef _MSC_VER -#ifndef BSWAP_32 -#define BSWAP_32(x) _byteswap_ulong(x) -#endif -#else -#ifndef BSWAP_32 -# define BSWAP_32(x) \ - ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ - (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) -#endif -#endif -#endif - -#define EVEN 0 -#define ODD 1 - -// Nibble logic -#ifndef NIBBLE_HIGH -# define NIBBLE_HIGH(b) ( (b & 0xF0) >> 4 ) -#endif -#ifndef NIBBLE_LOW -# define NIBBLE_LOW(b) ( b & 0x0F ) -#endif -#ifndef CRUMB -# define CRUMB(b,p) (((b & (0x3 << p) ) >> p ) & 0xF) -#endif -#ifndef SWAP_NIBBLE -# define SWAP_NIBBLE(b) ( (NIBBLE_LOW(b)<< 4) | NIBBLE_HIGH(b)) -#endif - -// Binary Encoded Digit -#ifndef BCD2DEC -# define BCD2DEC(bcd) HornerScheme(bcd, 0x10, 10) -#endif -#ifndef DEC2BCD -# define DEC2BCD(dec) HornerScheme(dec, 10, 0x10) -#endif - // used for save/load files #ifndef FILE_PATH_SIZE # define FILE_PATH_SIZE 1000 diff --git a/include/common.h b/include/common.h index 3dbf77622..dec2261ec 100644 --- a/include/common.h +++ b/include/common.h @@ -19,9 +19,20 @@ extern "C" { #include #include #include -#include + typedef unsigned char byte_t; +#ifdef _MSC_VER +typedef DWORD uint32_t; +typedef BYTE uint8_t; +#define PACKED +// stuff +#else +#include +#include +#define PACKED __attribute__((packed)) +#endif + // debug #define DBG_NONE 0 // no messages #define DBG_ERROR 1 // errors only @@ -30,9 +41,6 @@ typedef unsigned char byte_t; #define DBG_EXTENDED 4 // errors + info + debug + breaking debug messages extern int DBGLEVEL; -// Flashmem spi baudrate -extern uint32_t FLASHMEM_SPIBAUDRATE; - // reader voltage field detector #define MF_MINFIELDV 4000 @@ -49,74 +57,87 @@ extern uint32_t FLASHMEM_SPIBAUDRATE; #endif #define RAMFUNC __attribute((long_call, section(".ramfunc"))) -// RDV40 Section -// 256kb divided into 4k sectors. -// -// 0x3F000 - 1 4kb sector = signature -// 0x3E000 - 1 4kb sector = settings -// 0x3D000 - 1 4kb sector = default T55XX keys dictionary -// 0x3B000 - 1 4kb sector = default ICLASS keys dictionary -// 0x39000 - 2 4kb sectors = default MFC keys dictionary -// -#ifndef FLASH_MEM_BLOCK_SIZE -# define FLASH_MEM_BLOCK_SIZE 256 +#ifndef ROTR +# define ROTR(x,n) (((uintmax_t)(x) >> (n)) | ((uintmax_t)(x) << ((sizeof(x) * 8) - (n)))) #endif -#ifndef FLASH_MEM_MAX_SIZE -# define FLASH_MEM_MAX_SIZE 0x40000 // (262144) +#ifndef ROTL +# define ROTL(x,n) (((uintmax_t)(x) << (n)) | ((uintmax_t)(x) >> ((sizeof(x) * 8) - (n)))) #endif -#ifndef FLASH_MEM_MAX_4K_SECTOR -# define FLASH_MEM_MAX_4K_SECTOR 0x3F000 +// endian change for 64bit +#ifdef __GNUC__ +#ifndef BSWAP_64 +#define BSWAP_64(x) __builtin_bswap64(x) +#endif +#else +#ifdef _MSC_VER +#ifndef BSWAP_64 +#define BSWAP_64(x) _byteswap_uint64(x) +#endif +#else +#ifndef BSWAP_64 +#define BSWAP_64(x) \ + (((uint64_t)(x) << 56) | \ + (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ + (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ + (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ + (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ + (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ + (((uint64_t)(x) >> 40) & 0xff00ULL) | \ + ((uint64_t)(x) >> 56)) +#endif +#endif #endif - -#ifndef FLASH_MEM_ID_LEN -# define FLASH_MEM_ID_LEN 8 +// endian change for 32bit +#ifdef __GNUC__ +#ifndef BSWAP_32 +#define BSWAP_32(x) __builtin_bswap32(x) +#endif +#else +#ifdef _MSC_VER +#ifndef BSWAP_32 +#define BSWAP_32(x) _byteswap_ulong(x) +#endif +#else +#ifndef BSWAP_32 +# define BSWAP_32(x) \ + ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) +#endif +#endif #endif -#ifndef FLASH_MEM_SIGNATURE_LEN -# define FLASH_MEM_SIGNATURE_LEN 128 +#define EVEN 0 +#define ODD 1 + +// Nibble logic +#ifndef NIBBLE_HIGH +# define NIBBLE_HIGH(b) ( (b & 0xF0) >> 4 ) #endif -#ifndef FLASH_MEM_SIGNATURE_OFFSET -// -1 for historical compatibility with already released Proxmark3 RDV4.0 devices -# define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN - 1) +#ifndef NIBBLE_LOW +# define NIBBLE_LOW(b) ( b & 0x0F ) #endif -#ifndef T55XX_CONFIG_LEN -# define T55XX_CONFIG_LEN sizeof( t55xx_config ) +#ifndef CRUMB +# define CRUMB(b,p) (((b & (0x3 << p) ) >> p ) & 0xF) #endif -#ifndef T55XX_CONFIG_OFFSET -# define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000) +#ifndef SWAP_NIBBLE +# define SWAP_NIBBLE(b) ( (NIBBLE_LOW(b)<< 4) | NIBBLE_HIGH(b)) #endif -// Reserved space for T55XX PWD = 4 kb -#ifndef DEFAULT_T55XX_KEYS_OFFSET -# define DEFAULT_T55XX_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x3000) +// Binary Encoded Digit +#ifndef BCD2DEC +# define BCD2DEC(bcd) HornerScheme(bcd, 0x10, 10) #endif -// Reserved space for iClass keys = 4 kb -#ifndef DEFAULT_ICLASS_KEYS_OFFSET -# define DEFAULT_ICLASS_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x4000) +#ifndef DEC2BCD +# define DEC2BCD(dec) HornerScheme(dec, 10, 0x10) #endif -// Reserved space for MIFARE Keys = 8 kb -#ifndef DEFAULT_MF_KEYS_OFFSET -# define DEFAULT_MF_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x6000) -#endif - - - -// RDV40, validation structure to help identifying that client/firmware is talking with RDV40 -typedef struct { - uint8_t magic[4]; - uint8_t flashid[FLASH_MEM_ID_LEN]; - uint8_t signature[FLASH_MEM_SIGNATURE_LEN]; -} __attribute__((__packed__)) rdv40_validation_t; - - #ifdef __cplusplus } #endif diff --git a/include/hitag.h b/include/hitag.h index f57f1180a..9df93fcf7 100644 --- a/include/hitag.h +++ b/include/hitag.h @@ -14,11 +14,7 @@ #ifndef HITAG_H__ #define HITAG_H__ -#ifdef _MSC_VER -#define PACKED -#else -#define PACKED __attribute__((packed)) -#endif +#include "common.h" typedef enum { RHTSF_CHALLENGE = 01, diff --git a/include/mifare.h b/include/mifare.h index 87ba3a74e..9d444e833 100644 --- a/include/mifare.h +++ b/include/mifare.h @@ -46,7 +46,7 @@ typedef struct { uint8_t sak; uint8_t ats_len; uint8_t ats[256]; -} __attribute__((__packed__)) iso14a_card_select_t; +} PACKED iso14a_card_select_t; typedef enum ISO14A_COMMAND { ISO14A_CONNECT = (1 << 0), @@ -129,7 +129,7 @@ typedef struct { typedef struct { uint8_t atr_len; uint8_t atr[30]; -} __attribute__((__packed__)) smart_card_atr_t; +} PACKED smart_card_atr_t; typedef enum SMARTCARD_COMMAND { SC_CONNECT = (1 << 0), @@ -167,7 +167,7 @@ typedef struct { uint8_t iccode[2]; uint8_t mrt[6]; uint8_t servicecode[2]; -} __attribute__((__packed__)) felica_card_select_t; +} PACKED felica_card_select_t; typedef enum FELICA_COMMAND { FELICA_CONNECT = (1 << 0), diff --git a/include/pm3_cmd.h b/include/pm3_cmd.h index 284b072eb..d271d3099 100644 --- a/include/pm3_cmd.h +++ b/include/pm3_cmd.h @@ -13,20 +13,11 @@ #ifndef __PM3_CMD_H #define __PM3_CMD_H +#include "common.h" + // Use it e.g. when using slow links such as BT #define USART_SLOW_LINK -#ifdef _MSC_VER -typedef DWORD uint32_t; -typedef BYTE uint8_t; -#define PACKED -// stuff -#else -#include -#include -#define PACKED __attribute__((packed)) -#endif - #define PM3_CMD_DATA_SIZE 512 #define PM3_CMD_DATA_SIZE_MIX ( PM3_CMD_DATA_SIZE - 3 * sizeof(uint64_t) ) diff --git a/include/pmflash.h b/include/pmflash.h new file mode 100644 index 000000000..a76b90dae --- /dev/null +++ b/include/pmflash.h @@ -0,0 +1,97 @@ +//----------------------------------------------------------------------------- +// (c) RFID Research Group - 2019 +// +// This code is licensed to you under the terms of the GNU GPL, version 2 or, +// at your option, any later version. See the LICENSE.txt file for the text of +// the license. +// +//----------------------------------------------------------------------------- +// RDV4 flash constants +//----------------------------------------------------------------------------- + +#ifndef __PMFLASH_H +#define __PMFLASH_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#include "common.h" + +// Flashmem spi baudrate +extern uint32_t FLASHMEM_SPIBAUDRATE; + +// RDV40 Section +// 256kb divided into 4k sectors. +// +// 0x3F000 - 1 4kb sector = signature +// 0x3E000 - 1 4kb sector = settings +// 0x3D000 - 1 4kb sector = default T55XX keys dictionary +// 0x3B000 - 1 4kb sector = default ICLASS keys dictionary +// 0x39000 - 2 4kb sectors = default MFC keys dictionary +// +#ifndef FLASH_MEM_BLOCK_SIZE +# define FLASH_MEM_BLOCK_SIZE 256 +#endif + +#ifndef FLASH_MEM_MAX_SIZE +# define FLASH_MEM_MAX_SIZE 0x40000 // (262144) +#endif + +#ifndef FLASH_MEM_MAX_4K_SECTOR +# define FLASH_MEM_MAX_4K_SECTOR 0x3F000 +#endif + + +#ifndef FLASH_MEM_ID_LEN +# define FLASH_MEM_ID_LEN 8 +#endif + +#ifndef FLASH_MEM_SIGNATURE_LEN +# define FLASH_MEM_SIGNATURE_LEN 128 +#endif + +#ifndef FLASH_MEM_SIGNATURE_OFFSET +// -1 for historical compatibility with already released Proxmark3 RDV4.0 devices +# define FLASH_MEM_SIGNATURE_OFFSET (FLASH_MEM_MAX_SIZE - FLASH_MEM_SIGNATURE_LEN - 1) +#endif + +#ifndef T55XX_CONFIG_LEN +# define T55XX_CONFIG_LEN sizeof( t55xx_config ) +#endif + +#ifndef T55XX_CONFIG_OFFSET +# define T55XX_CONFIG_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x2000) +#endif + +// Reserved space for T55XX PWD = 4 kb +#ifndef DEFAULT_T55XX_KEYS_OFFSET +# define DEFAULT_T55XX_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x3000) +#endif + +// Reserved space for iClass keys = 4 kb +#ifndef DEFAULT_ICLASS_KEYS_OFFSET +# define DEFAULT_ICLASS_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x4000) +#endif + +// Reserved space for MIFARE Keys = 8 kb +#ifndef DEFAULT_MF_KEYS_OFFSET +# define DEFAULT_MF_KEYS_OFFSET (FLASH_MEM_MAX_4K_SECTOR - 0x6000) +#endif + +// RDV40, validation structure to help identifying that client/firmware is talking with RDV40 +typedef struct { + uint8_t magic[4]; + uint8_t flashid[FLASH_MEM_ID_LEN]; + uint8_t signature[FLASH_MEM_SIGNATURE_LEN]; +} PACKED rdv40_validation_t; + +#ifdef __cplusplus +} +#endif + +#endif // __PMFLASH_H \ No newline at end of file diff --git a/include/proxmark3.h b/include/proxmark3.h index 8748e82d8..469713b5b 100644 --- a/include/proxmark3.h +++ b/include/proxmark3.h @@ -15,6 +15,7 @@ #include "at91sam7s512.h" #include "config_gpio.h" #include "pm3_cmd.h" +#include "common.h" #define WDT_HIT() AT91C_BASE_WDTC->WDTC_WDCR = 0xa5000001 @@ -71,8 +72,6 @@ #define COTAG_BITS 264 #endif -//#define PACKED __attribute__((__packed__)) - #define LED_A_ON() HIGH(GPIO_LED_A) #define LED_A_OFF() LOW(GPIO_LED_A) #define LED_A_INV() INVBIT(GPIO_LED_A) @@ -116,7 +115,7 @@ struct version_information { char clean; /* 1: Tree was clean, no local changes. 0: Tree was unclean. 2: Couldn't be determined */ char gitversion[50]; /* String with the git revision */ char buildtime[30]; /* string with the build time */ -} __attribute__((packed)); +} PACKED; #define COMMON_AREA_MAGIC 0x43334d50 // "PM3C" #define COMMON_AREA_COMMAND_NONE 0 @@ -129,8 +128,8 @@ struct common_area { unsigned int bootrom_present: 1; /* Set when a bootrom that is capable of parsing the common area is present */ unsigned int osimage_present: 1; /* Set when a osimage that is capable of parsing the common area is present */ unsigned int button_pressed: 1; - } __attribute__((packed)) flags; + } PACKED flags; int arg1, arg2; -} __attribute__((packed)); +} PACKED; #endif