Skip to content

Commit

Permalink
nfc magic fixes merge
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Mar 23, 2024
1 parent 90edac5 commit 7f07604
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions base_pack/nfc_magic/lib/magic/protocols/gen4/gen4_poller.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,47 @@ static NfcCommand gen4_poller_write_mf_ultralight(Gen4Poller* instance) {
break;
}

// Password
MfUltralightConfigPages* config_pages = malloc(sizeof(MfUltralightConfigPages));
mf_ultralight_get_config_page(mfu_data, &config_pages);

block[0] = config_pages->password.data[0];
block[1] = config_pages->password.data[1];
block[2] = config_pages->password.data[2];
block[3] = config_pages->password.data[3];
error = gen4_poller_write_block(instance, instance->password, 0xE5, block);
if(error != Gen4PollerErrorNone) {
FURI_LOG_E(TAG, "Failed to write Password to sector E5");
instance->state = Gen4PollerStateFail;
break;
}
error = gen4_poller_write_block(instance, instance->password, 0xF0, block);
if(error != Gen4PollerErrorNone) {
FURI_LOG_E(TAG, "Failed to write Password to sector F0");
instance->state = Gen4PollerStateFail;
break;
}

// PACK
block[0] = config_pages->pack.data[0];
block[1] = config_pages->pack.data[1];
block[2] = 0x00;
block[3] = 0x00;
error = gen4_poller_write_block(instance, instance->password, 0xE6, block);
if(error != Gen4PollerErrorNone) {
FURI_LOG_E(TAG, "Failed to write PACK to sector E6");
instance->state = Gen4PollerStateFail;
break;
}
error = gen4_poller_write_block(instance, instance->password, 0xF1, block);
if(error != Gen4PollerErrorNone) {
FURI_LOG_E(TAG, "Failed to write PACK to sector F1");
instance->state = Gen4PollerStateFail;
break;
}

free(config_pages);

instance->state = Gen4PollerStateSuccess;
}
} while(false);
Expand Down

0 comments on commit 7f07604

Please sign in to comment.