-
Notifications
You must be signed in to change notification settings - Fork 1
/
sibo.h
144 lines (118 loc) · 4.63 KB
/
sibo.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#ifndef SIBO_LIB
#define SIBO_LIB
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <ctype.h>
#include <time.h>
#include <utime.h>
#include <stdarg.h>
#ifdef _WIN32
#include <windows.h>
const char *slash = "\\";
#else // _WIN32
// Assume it's something POSIX-compliant
#include <unistd.h>
const char *slash = "/";
#endif // _WIN32
#define FLASH_TYPE 0xf1a5
#define IMAGE_ISROM 0xffffffff
#define FEFS24_NULL_PTR 0xffffff
#define FEFS32_NULL_PTR 0xffffffff
#define FEFS32_PTR_LEN 4
#define FEFS24_PTR_LEN 3
// IMAGE INFO OFFSETS AND SIZES
#define IMAGE_POINTERSIZE_OFFSET 10
#define IMAGE_ROOTPTR_OFFSET 11
#define IMAGE_NAME_OFFSET_24 14
#define IMAGE_NAME_OFFSET_32 15
#define IMAGE_NAME_LENGTH 11
#define IMAGE_FLASHCOUNT_OFFSET_24 25
#define IMAGE_FLASHCOUNT_OFFSET_32 26
#define IMAGE_FLASHCOUNT_LENGTH 4
#define IMAGE_FLASHIDSTRING_OFFSET_24 33
#define IMAGE_FLASHIDSTRING_OFFSET_32 34
#define IMAGE_ROMIDSTRING_OFFSET_24 29
#define IMAGE_ROMIDSTRING_OFFSET_32 30
// ENTRY INFO OFFSETS AND SIZES
// Next Entry Pointer
#define ENTRY_NEXTENTRYPTR_OFFSET 0x00 // 0
// Entry Name
#define ENTRY_NAME_OFFSET_24 0x03 // 3
#define ENTRY_NAME_OFFSET_32 0x04 // 4
#define ENTRY_NAME_LENGTH 0x08 // 8
// Entry Extension
#define ENTRY_EXT_OFFSET_24 0x0b // 11
#define ENTRY_EXT_OFFSET_32 0x0c // 12
#define ENTRY_EXT_LENGTH 0x03 // 3
// Entry Flags (Hidden, System, etc)
#define ENTRY_FLAGS_OFFSET_24 0x0e // 14
#define ENTRY_FLAGS_OFFSET_32 0x0f // 15
#define ENTRY_FLAGS_LENGTH 0x01 // 1
// First entry record pointer
#define ENTRY_FIRSTENTRYRECORDPTR_OFFSET_24 0x0f // 15
#define ENTRY_FIRSTENTRYRECORDPTR_OFFSET_32 0x10 // 16
// Alternative Record Pointer (currently unused in SIBOIMG)
#define ENTRY_ALTRECORDPTR_OFFSET_24 0x12 // 18
#define ENTRY_ALTRECORDPTR_OFFSET_32 0x14 // 20
/// Properties
#define ENTRY_PROPERTIES_OFFSET_24 0x15 // 21
#define ENTRY_PROPERTIES_OFFSET_32 0x18 // 24
#define ENTRY_PROPERTIES_LENGTH 0x01 // 1
// Timecode
#define ENTRY_TIMECODE_OFFSET_24 0x16 // 22
#define ENTRY_TIMECODE_OFFSET_32 0x19 // 25
#define ENTRY_TIMECODE_LENGTH 0x02 // 2
// Datecode (Rolled into timecode in SIBOIMG)
#define ENTRY_DATECODE_OFFSET_24 0x18 // 24
#define ENTRY_DATECODE_OFFSET_32 0x1b // 27
#define ENTRY_DATECODE_LENGTH 0x02 // 2
// First data record pointer (for a file)
#define ENTRY_FIRSTDATARECORDPTR_OFFSET_24 0x1a // 26
#define ENTRY_FIRSTDATARECORDPTR_OFFSET_32 0x1d // 29
// First data record length
#define ENTRY_FIRSTDATALEN_OFFSET_24 0x1d // 29
#define ENTRY_FIRSTDATALEN_OFFSET_32 0x21 // 33
#define ENTRY_FIRSTDATALEN_LENGTH 0x02 // 2
// Entry Flags
#define ENTRY_FLAG_ENTRYISVALID 1 << 0
#define ENTRY_FLAG_PROPERTIESDATETIMEISVALID 1 << 1
#define ENTRY_FLAG_ISFILE 1 << 2
#define ENTRY_FLAG_NOENTRYRECORD 1 << 3
#define ENTRY_FLAG_NOALTRECORD 1 << 4
#define ENTRY_FLAG_ISLASTENTRY 1 << 5
#define ENTRY_FLAG_BIT6 1 << 6 // Unused/Reserved
#define ENTRY_FLAG_BIT7 1 << 7 // Unused/Reserved
#define ENTRY_PROPERTY_ISREADONLY 1 << 0
#define ENTRY_PROPERTY_ISHIDDEN 1 << 1
#define ENTRY_PROPERTY_ISSYSTEM 1 << 2
#define ENTRY_PROPERTY_ISVOLUMENAME 1 << 3
#define ENTRY_PROPERTY_ISDIRECTORY 1 << 4
#define ENTRY_PROPERTY_ISMODIFIED 1 << 5
// FILE INFO OFFSETS AND LENGTHS
#define FILE_FLAGS_OFFSET 0
#define FILE_FLAGS_LENGTH 1
#define FILE_NEXTRECORDPTR_OFFSET 1
#define FILE_ALTRECORDPTR_OFFSET_24 4
#define FILE_ALTRECORDPTR_OFFSET_32 5
#define FILE_DATARECORDPTR_OFFSET_24 7
#define FILE_DATARECORDPTR_OFFSET_32 9
#define FILE_DATARECORDLEN_OFFSET_24 10
#define FILE_DATARECORDLEN_OFFSET_32 13
#define FILE_DATARECORDLEN_LENGTH 2
#define FILE_ENTRYPROPERTIES_OFFSET_24 12
#define FILE_ENTRYPROPERTIES_OFFSET_32 15
#define FILE_ENTRYPROPERTIES_LENGTH 1
#define FILE_TIMECODE_OFFSET_24 13
#define FILE_TIMECODE_OFFSET_32 16
#define FILE_TIMECODE_LENGTH 2
#define FILE_DATECODE_OFFSET_24 15
#define FILE_DATECODE_OFFSET_32 18
#define FILE_DATECODE_LENGTH 2
struct PsiDateTime {
uint16_t psi_time;
uint16_t psi_date;
};
#endif // SIBO_LIB