void UpdateMoney(IsoCard card) { string cfg = CardDumper.GetConfigurationKey("UpdateMoney"); int money = 0; if (!int.TryParse(cfg, out money)) { return; } string data = DumpMoney(card); if (string.IsNullOrEmpty(data)) { return; } int first = money & 0x0000FF; int second = (money >> 8) & 0x0000FF; //9 // 10 byte[] bytes = FromHex(data); bytes[9] = (byte)second; bytes[10] = (byte)first; if (!Write(card, 45, bytes)) { Log("Write failed!"); } DumpMoney(card); }
void CardInserted(object sender, CardStatusEventArgs args) { SCardMonitor monitor = (SCardMonitor)sender; Log("CardInserted Event for reader: " + args.ReaderName); try { SCardReader reader = new SCardReader(m_card_context); if (reader.Connect(args.ReaderName, SCardShareMode.Shared, SCardProtocol.Any) == SCardError.Success) { DumpStatus(reader); IsoCard card = new IsoCard(reader); if (CardDumper.IsKeyEnabled("DumpCard")) { DumpCard(card); } if (CardDumper.IsKeyEnabled("DumpMoney")) { DumpMoney(card); } if (!string.IsNullOrEmpty(CardDumper.GetConfigurationKey("UpdateMoney"))) { UpdateMoney(card); } } reader.Disconnect(SCardReaderDisposition.Reset); } catch (Exception ex) { Log("Exception: " + ex.ToString()); } }
public CardDumper() { //LoadKeysFromFile(CardDumper.GetConfigurationKey("MfocLog")); LoadKeysFromDumpFile(CardDumper.GetConfigurationKey("MfocDump")); }