Applied Ryan Li's PPP chat script for China Mobile
[barry.git] / src / cod-internal.h
blob2a97420523e5a614d084d85da1a2df81f3724864
1 ///
2 /// \file cod-internal.h
3 /// COD structure
4 ///
6 /*
7 Copyright (C) 2008-2009, Nicolas VIVIEN
8 Copyright (C) 2009, Josh Kropf
9 See also:
10 http://drbolsen.wordpress.com/2006/07/26/blackberry-cod-file-format/
11 http://drbolsen.wordpress.com/2006/08/11/10/
12 http://www.pkware.com/documents/casestudies/APPNOTE.TXT
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 2 of the License, or
17 (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 See the GNU General Public License in the COPYING file at the
24 root directory of this project for more details.
28 #ifndef __BARRY_COD_INTERNAL_H__
29 #define __BARRY_COD_INTERNAL_H__
31 #include "dll.h"
32 #include <stdint.h>
33 #include <sys/types.h>
35 #define CODFILE_TYPE_SIMPLE {0xDE, 0xC0}
36 #define CODFILE_TYPE_PKZIP {0x50, 0x4B}
37 #define PKZIP_LOCAL_FILE_SIG {0x50, 0x4B, 0x03, 0x04}
38 #define PKZIP_DIRECTORY_SIG {0x50, 0x4B, 0x01, 0x02}
39 #define PKZIP_END_DIRECTORY_SIG {0x50, 0x4B, 0x05, 0x06}
42 typedef struct BXLOCAL {
43 uint16_t hour:5;
44 uint16_t minute:6;
45 uint16_t second:5;
46 } __attribute__ ((packed)) msdos_time_t;
49 typedef struct BXLOCAL {
50 uint16_t year:7; // number of years since 1980
51 uint16_t month:4;
52 uint16_t day:5;
53 } __attribute__ ((packed)) msdos_date_t;
56 typedef struct BXLOCAL {
57 //uint8_t signature[4]; // PKZIP local file header 0x504B0304
58 uint16_t version_needed; // version needed to extract, 0x0A00
59 uint16_t general_flag; // general purpose bit flag, 0x0000
60 uint16_t compression_method; // compression method, 0x0000 = stored, no compression
61 msdos_time_t last_mod_time;
62 msdos_date_t last_mod_date;
63 uint32_t crc_32;
64 uint32_t compressed_size; // compression method is 'stored'
65 uint32_t uncompressed_size; // both sizes are equal
66 uint16_t file_name_length;
67 uint16_t extra_field_length;
68 //char file_name[variable];
69 //char extra_field[variable];
70 } __attribute__ ((packed)) pkzip_local_header_t;
73 typedef struct BXLOCAL {
74 //uint8_t signature[4]; // PKZIP central directory 0x504B0304
75 uint16_t version_madeby; // version used to compress, 0x0A00
76 uint16_t version_needed; // version needed to extract, 0x0A00
77 uint16_t general_flag; // general purpose bit flag, 0x0000
78 uint16_t compression_method; // compression method, 0x0000 = stored, no compression
79 msdos_time_t last_mod_time;
80 msdos_date_t last_mod_date;
81 uint32_t crc_32;
82 uint32_t compressed_size; // size of corresponding local file entry
83 uint32_t uncompressed_size; // both sizes are equal
84 uint16_t file_name_length;
85 uint16_t extra_field_length;
86 uint16_t file_comment_length;
87 uint16_t disk_number; // number of the disk on which this file begins, always zero
88 uint16_t internal_file_attr; // always zero
89 uint32_t external_file_attr; // always zero
90 uint32_t relative_offset; // offset from beginning of this disk (this zip file)
91 // to start of corresponding local file entry
92 //char file_name[variable];
93 //char extra_field[variable];
94 //char file_comment[variable];
95 } __attribute__ ((packed)) pkzip_directory_t;
98 typedef struct BXLOCAL {
99 //uint8_t signature[4]; // PKZIP end central directory 0x504B0506
100 uint16_t this_disk_number; // number of this disk, always zero
101 uint16_t disk_with_first; // number of the disk with the start of
102 // central directory, always zero
103 uint16_t this_disk_entry_count; // total number of entries in the central directory on this disk
104 uint16_t total_entry_count; // total number of entries in the central directory
105 // always equals this_disk_entry_count
106 uint32_t directory_length; // total size of the central directory
107 uint32_t directory_offset; // offset from beginning of this disk (this zip file)
108 // to the first central directory entry
109 uint16_t file_comment_length;
110 //char file_comment[variable];
111 } __attribute__ ((packed)) pkzip_end_directory_t;
114 typedef struct BXLOCAL {
115 uint16_t type; // Type // 50 4B
116 uint8_t unknown1[8]; // // 03 04 0A 00 00 00 00 00
117 uint8_t unknown2[4]; // // AB 5C 6A 39
118 uint8_t unknown3[4]; // // BE 5C 58 D1
119 uint32_t size1; // COD size 0x0DCC // CC 0D 01 00
120 uint32_t size2; // COD size 0x0DCC // CC OD 01 00
121 uint8_t strsize; // Size of string // 19
122 uint8_t reserved2; // Reserved 0x00 // 00
123 uint8_t strfree; // Empty uint8_t // 04
124 uint8_t reserved3; // Reserved 0x00 // 00
125 } __attribute__ ((packed)) codfile_header_t;
128 typedef struct BXLOCAL {
129 uint32_t flashid;
130 uint32_t section_number; // always 0
131 uint32_t vtable_pointer; // always 0
132 time_t timestamp;
133 uint32_t user_version;
134 uint32_t fieldref_pointer;
135 uint16_t maxtype_list_size;
136 uint16_t reserved; // always 0xFF
137 int32_t data_section; // always 0xFFFF
138 int32_t module_info; // always 0xFFFF
139 uint16_t version;
140 uint16_t code_size;
141 uint16_t data_size;
142 uint16_t flags;
143 } __attribute__ ((packed)) code_header_t;
146 typedef struct BXLOCAL {
147 uint8_t flags;
148 uint8_t version;
149 uint16_t num_icalls;
150 uint8_t num_modules;
151 uint8_t num_classes ;
152 uint16_t exported_string_offset;
153 uint16_t data_uint8_ts_offset;
154 uint16_t empty_field;
155 uint16_t class_definitions;
156 uint16_t array_of_unknow1_fields[14];
157 uint16_t aliases;
158 uint16_t array_of_unknow2_fields[22];
159 } __attribute__ ((packed)) data_header_t;
161 #endif