This repository has been archived by the owner on Feb 10, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathxivParser.ahk
80 lines (71 loc) · 1.48 KB
/
xivParser.ahk
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
xor(text, key) {
count := 1
Loop % strlen(text)
{
out .= chr((asc(substr(text, count, 1)) ^ key))
count += 1
}
return out
}
headerSize(file) {
file.Seek(0x04, 0)
hf := file.ReadUInt()
if((file.Length - hf) == 32) {
return hf
}
return 0
}
dataSize(file) {
file.Seek(0x08, 0)
return file.ReadUInt() + 16
}
readHeader(file) {
header := {}
header["file_size"] := headerSize(file)
header["data_size"] := dataSize(file)
return header
}
readSection(file, key) {
data := xor(file.Read(3), key)
type := Asc(SubStr(data, 1, 1))
size := Asc(SubStr(data, 2, 1))
; size should be read from two bytes, not 1 as above, fix this first if something breaks
; should be fine with only keybind info, as the info is static
if(size) {
return xor(file.Read(size), key)
}
return 0
}
class ffxivKey
{
key1 := 0
key1mod := 0
key2 := 0
key2mod := 0
__New(str) {
array := StrSplit(str, .)
this.key1 := "0x" . array[1]
this.key1mod := "0x" . array[2]
this.key2 := "0x" . array[3]
this.key2mod := "0x" . array[4]
base.__New()
}
}
readKeybinds(filename)
{
keyArray := {}
file := FileOpen(filename, "r-d")
if(file) {
header := readHeader(file)
if(header["file_size"] != 0) {
file.Seek(0x11, 0)
while(file.Pos < header["data_size"]) {
command := readSection(file, 0x73)
str := readSection(file, 0x73)
keyArray[command] := new ffxivKey(str)
}
}
file.Close()
}
return keyArray
}