#include "pch.h"
#include "matrix.h"

	_mxINT16 Init_MatrixAPI() {
		#pragma EXPORT
		return 0;
	}
	_mxINT16 Release_MatrixAPI() {
		#pragma EXPORT
		return 0;
	}
	_mxINT16 Dongle_Count(_mxINT16 dongleMemSize) {
		#pragma EXPORT
		return 1;
	}
	_mxINT16 Dongle_MemSize(_mxINT16 dongleIndex, _mxINT16 dongleMemSize) {
		#pragma EXPORT
		return 79 * 4; // 316 Bytes
	}
	_mxINT16 Dongle_ReadData(_mxINT32 dongleFuckFuck,  UINT_PTR targetMemoryPtr, _mxINT16 readLength, _mxINT16 dongleIndex, _mxINT16 dongleMemSize) {
		#pragma	EXPORT

		_mxINT32 dongleBytes[] = {
		0x00000000, //Var01:
		0x00000000, //Var02:
		0x00B727B1,	//Var03: Damm Serial Number
		0x4D4D4144, //Var04: TetraFlex Dongle Code
		0x00000000, //Var05: Brand/Logo: 0=Damm TetraFlex
		0x00000000, //Var06: Language 1: 0=English only 
		0x00000002, //Var07: Language 2: 2=German
		0x00000000, //Var08:
		0x00000000, //Var09:
		0x00000000, //Var10:
		0x00000000, //Var11:
		0x00000000, //Var12:
		0x00000000, //Var13:
		0x00000000, //Var14:
		0x00B727B1, //Var15: Key Ref. Serial Number (identical to Damm Serial Number)

		//Specific Licenses
		0x00000191, //Par0: License Mode: 0x191=API, 0x1A5=Node
		0x00000000, //Par1: Dongle Date Limit
		0x01404895, //Par2: Date limit of Application (expiry date 20990101)
		0x00000004, //Par3: API=>Voice Streams max.; NODE=>Nodes max.
		0x00000000, //Par4: API=>Flags: B00:Discreet Listening, B01:Ambience Listening; NODE=>Tetra Radio Cell TRmax.
		0x00000000, //Par5: API=>Application Server: B00:Service allowed, B01: GPS Position Service, B02: DGNA Service; NODE=>Voice GW. sessions max.
		0x00000000, //Par6: NODE=>Packet Data Gateway
		0x00000000, //Par7: NODE=>Application Gw. conn. max.
		0x00000000, //Par8: NODE=>Air Interface Encryption
		0x00000000, //Par9: NODE=>Flags: B00:AIE KSGTEA1; B01:AIE KSGTEA1; B02:AIE KSGTEA1; B03:AIE KSGTEA1; B16:Only 1 organization; B17:Only 1 profile
		0x00000000, //Par10: NODE=>Terminal Gw. Sessions max. (0=unlimited)
		0x00000000, //Par11: NODE=>Number of subscribers max. (0=unlimited)
		0x00000000, //Par12: 
		0x00000000, //Par13: NODE=>ISI Gw. Conn. max. (0=Disable)
			0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000,0x00000000,
			0x00000000,0x00000000,0x00000000
		};

		dongleBytes[15] = 401; // license validation type 1
		dongleBytes[15 + 4] = 0; // license validation type 1
		dongleBytes[15 + 16 + 0] = 402; // license validation type 2
		dongleBytes[15 + 16 + 1] = 0; // 20690325; // if less than o2, invalid
		dongleBytes[15 + 16 + 2] = 20121102; // 20121102 if less than this, invalid
		dongleBytes[15 + 16 + 3] = 7; // accesslvl?


		int* lol = (int*)targetMemoryPtr;
		for (int i = 0; i < readLength; i++) {
			lol[i] = dongleBytes[i];
		}
		// why u no work?
		//memcpy(&targetMemoryPtr, &staticFuck2, sizeof(int) * readLength);
		return 0;
	}
	int Dongle_ReadSerNr(int dongleFuckFuck, _mxINT16 dongleIndex, _mxINT16 dongleMemSize) {
		#pragma EXPORT
		return 1296908612;
	}
	int Dongle_Model(_mxINT16 dongleIndex, _mxINT16 dongleMemSize) {
		#pragma EXPORT
		return 420;
	}
