forked from silicontrip/SkyReader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileio.h
60 lines (45 loc) · 1.29 KB
/
fileio.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include "skylander.h"
#include "portalio.h"
#include "crypt.h"
#define BLOCK_SIZE 16
class SkylanderIO {
Skylander *sky;
unsigned char * buffer;
Crypt crypt;
public:
SkylanderIO();
~SkylanderIO();
void fprinthex(FILE *, unsigned char *, unsigned int);
void initWithUnencryptedFile(char *) throw (int);
void initWithEncryptedFile(char *) throw (int);
void initWithPortal(int) throw (int);
void listSkylanders();
Skylander * getSkylander() { return sky; }
// void setSkylander(Skylander *);
bool writeSkylanderToPortal(int) throw (int);
bool writeSkylanderToUnencryptedFile(char *) throw (int);
bool writeSkylanderToEncryptedFile(char *) throw (int);
enum IOException {
Success,
CannotOpenFile,
InvalidFile,
CannotWriteFile,
UnableToGetUSBDevices,
UnableToFindPortal,
UnableToWriteToPortal,
InvalidSkylanderBlock,
UnableToReadFromPortal,
PortalNotReady,
WriteVerifyError,
};
protected:
void ReadSkylanderFile(char *name) throw (int);
bool WriteSkylanderFile(char *name, unsigned char *) throw (int);
void ReadPortal(unsigned char *, int) throw (int);
void EncryptBuffer(unsigned char* );
void DecryptBuffer(unsigned char* );
};