return 0;
}
+\r
+// Mifare Memory Structure: up to 32 Sectors with 4 blocks each (1k and 2k cards),\r
+// plus evtl. 8 sectors with 16 blocks each (4k cards)\r
+uint8_t NumBlocksPerSector(uint8_t sectorNo) \r
+{\r
+ if (sectorNo < 32) \r
+ return 4;\r
+ else\r
+ return 16;\r
+}\r
+\r
+uint8_t FirstBlockOfSector(uint8_t sectorNo) \r
+{\r
+ if (sectorNo < 32)\r
+ return sectorNo * 4;\r
+ else\r
+ return 32*4 + (sectorNo - 32) * 16;\r
+ \r
+}\r
+\r
+\r
// work with emulator memory
void emlSetMem(uint8_t *data, int blockNum, int blocksCount) {
uint8_t* emCARD = eml_get_bigbufptr_cardmem();
uint8_t key[6];\r
uint8_t* emCARD = eml_get_bigbufptr_cardmem();\r
\r
- memcpy(key, emCARD + 3 * 16 + sectorNum * 4 * 16 + keyType * 10, 6);\r
+ memcpy(key, emCARD + 16 * (FirstBlockOfSector(sectorNum) + NumBlocksPerSector(sectorNum) - 1) + keyType * 10, 6);\r
return bytes_to_num(key, 6);\r
}\r
\r