Ejemplo n.º 1
0
bool NT3HEraseAllTag(void) {
    bool ret = true;
    uint8_t erase[NFC_PAGE_SIZE+1] = {USER_START_REG, 0x03, 0x03, 0xD0, 0x00, 0x00, 0xFE};
    ret = writeTimeout(erase, sizeof(erase));

    if (ret == false) {
        errNo = NT3HERROR_ERASE_USER_MEMORY_PAGE;
    }
    return ret;
}
Ejemplo n.º 2
0
int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPTSTR    lpCmdLine,
					int       nCmdShow)
{
	BYTE* b;
	b = new BYTE[MAX_KEYCOUNT];
	ULONG size = MAX_KEYCOUNT;
	initKeysArray(b, MAX_KEYCOUNT);

	DWORD _timeOut=30;

	if(wcsstr(lpCmdLine, L"writereg")!=NULL){
		writeReg(b, size);
		writeTimeout(_timeOut);
	}

	int iTimeOut=30;
	if(readTimeOut(&iTimeOut)==0)
		_timeOut=iTimeOut;

	int test=0;
 	// wait until timeout (default 30 seconds)
	do{
		Sleep(1000);
		test++;
	}while( test < _timeOut );

#ifndef DEBUG
	Sleep(10000); // wait for cprog to initialize
#endif

	readReg(b, &size);
	UINT x=0;
	DWORD dwKey;
	while ( x < size ){
		dwKey=b[x];
		//unRegKey(dwKey);
		regKey(NULL, dwKey); //unRegKey and then RegKey
		x++;
	}
	MessageBeep(MB_ICONQUESTION);
	return 0;
}
Ejemplo n.º 3
0
bool NT3HWriteUserData(uint8_t page, const uint8_t* data) {
    bool ret = true;
    uint8_t dataSend[NFC_PAGE_SIZE +1]; // data plus register
    uint8_t reg = USER_START_REG+page;

    // if the requested page is out of the register exit with error
    if (reg > USER_END_REG) {
        errNo = NT3HERROR_INVALID_USER_MEMORY_PAGE;
        ret = false;
        goto end;
    }

    dataSend[0] = reg; // store the register
    memcpy(&dataSend[1], data, NFC_PAGE_SIZE);
    ret = writeTimeout(dataSend, sizeof(dataSend));
    if (ret == false) {
        errNo = NT3HERROR_WRITE_USER_MEMORY_PAGE;
        goto end;
    }

    end:
    return ret;
}