magic Chinese card fully supported. Added commands:csetuid-set card uid and wipe it, csetblk-set 16 byte block, cload-load dump from emulator memory or emulator file

This commit is contained in:
Merlokbr@gmail.com 2012-07-05 10:59:15 +00:00
commit 208a0166b9
4 changed files with 149 additions and 39 deletions

View file

@ -222,13 +222,13 @@ int mfCSetUID(uint8_t *uid, uint8_t *oldUID, int wantWipe) {
memcpy(block0, uid, 4);
block0[4] = block0[0]^block0[1]^block0[2]^block0[3]; // Mifare UID BCC
return mfCSetBlock(0, block0, oldUID, wantWipe);
return mfCSetBlock(0, block0, oldUID, wantWipe, CSETBLOCK_SINGLE_OPER);
}
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe) {
int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe, uint8_t params) {
uint8_t isOK = 0;
UsbCommand c = {CMD_MIFARE_EML_CSETBLOCK, {wantWipe, 1, blockNo}};
UsbCommand c = {CMD_MIFARE_EML_CSETBLOCK, {wantWipe, params & (0xFE | (uid == NULL ? 0:1)), blockNo}};
memcpy(c.d.asBytes, data, 16);
SendCommand(&c);
@ -236,8 +236,7 @@ int mfCSetBlock(uint8_t blockNo, uint8_t *data, uint8_t *uid, int wantWipe) {
if (resp != NULL) {
isOK = resp->arg[0] & 0xff;
PrintAndLog("isOk:%02x", isOK);
memcpy(uid, resp->d.asBytes, 4);
if (uid != NULL) memcpy(uid, resp->d.asBytes, 4);
if (!isOK) return 2;
} else {
PrintAndLog("Command execute timeout");