84 lines
4.2 KiB
C
84 lines
4.2 KiB
C
#pragma once
|
|
#include <windows.h>
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
struct bpreader_config {
|
|
bool enable;
|
|
uint16_t port;
|
|
wchar_t access_code[21];
|
|
wchar_t chip_id[33];
|
|
uint8_t access_code_bytes[10];
|
|
uint8_t chip_id_bytes[16];
|
|
};
|
|
|
|
HRESULT bpreader_init(struct bpreader_config *cfg, uint16_t port);
|
|
void bpreader_congif_load(struct bpreader_config *cfg, const wchar_t *filename);
|
|
|
|
/*
|
|
bpreader packet format WIP
|
|
n = final offset
|
|
| Offset | Meaning |
|
|
|--------|--------------------------------------------------------------------|
|
|
| 0 | Always 00 |
|
|
| 1 | Always 00 |
|
|
| 2 | Always FF | Header
|
|
| 3 | len(Data), 0 means no data |
|
|
| 4 | FF - ((sum of header bytes) & FF) if data is present |
|
|
|--------|--------------------------------------------------------------------|
|
|
| 5 | Always D5 (resp) or D4 (req) if data is present, identifier? |
|
|
| 6 | Command if data is present | Data
|
|
| 7..n-2 | Data if data is present |
|
|
|--------|--------------------------------------------------------------------|
|
|
| n-1 | FF - ((sum of head + data bytes) & FF) if data is present, else FF | Footer
|
|
| n | Always 00 |
|
|
|
|
Commands
|
|
| Command | Response | Meaning | Response Data (not including leading 0xD5) |
|
|
|---------|----------|----------------------------------------------------|------------------------------------------------------------------------|
|
|
| 0x00 | 0x00 | Wait Next Command | None |
|
|
| 0x02 | 0x05 | Unknown | 0x0D, 0x00, 0x06, 0x00 |
|
|
| 0x03 | 0x02 | Unknown, first command and then sent randomly | 0x19 |
|
|
| 0x04 | 0x02 | Unknown, only command seen to change it's req data | 0x0F/0x33 |
|
|
| 0x05 | 0x03 | Unknown | 0x09, 0x00 |
|
|
| 0x06 | 0x02 | Unknown | 0x0F |
|
|
| 0x09 | 0x18 | Poll for card | 0x4B, 0x01, 0x01, 0x14, 0x01, [IDm], [PMm], [Sys Code] |
|
|
| 0x0E | 0x02 | Unknown | 0x33 |
|
|
| 0x12 | 0x0A | Unknown | 0x07, 0xFF, 0x3F, 0x0E, 0xF1, 0xFF, 0x3F, 0x0E, 0xF1 |
|
|
| 0x14 | 0x20 | Unknown | a lot, see bpreader.c |
|
|
| 0x18 | 0x0D | Unknown | 0x07, 0xDC, 0xF4, 0x3F, 0x11, 0x4D, 0x85, 0x61, 0xF1, 0x26, 0x6A, 0x87 |
|
|
*/
|
|
|
|
struct bpreader_cmd_header {
|
|
uint8_t padding0_00;
|
|
uint8_t padding1_00;
|
|
uint8_t padding2_ff;
|
|
uint8_t data_len;
|
|
uint8_t header_checksum;
|
|
uint8_t d_identifier;
|
|
uint8_t cmd;
|
|
};
|
|
|
|
struct bpreader_cmd_footer {
|
|
uint8_t checksum;
|
|
uint8_t padding;
|
|
};
|
|
|
|
struct bpreader_poll_banapass_data {
|
|
uint8_t card_present;
|
|
uint8_t unknown1; // 0x01
|
|
uint8_t atqa[2];
|
|
uint8_t sak;
|
|
uint8_t unknown5; // 0x04
|
|
uint8_t serial_number[4]; // first 4 bytes of Chip ID
|
|
};
|
|
|
|
struct bpreader_poll_felica_data {
|
|
uint8_t card_present;
|
|
uint8_t unknown1; // 0x01
|
|
uint8_t unknown2[2]; // 0x14, 0x01
|
|
uint8_t idm[8];
|
|
uint8_t pmm[8];
|
|
uint8_t system_code[2];
|
|
};
|