cod-internal.h

Go to the documentation of this file.
00001 ///
00002 /// \file       cod-internal.h
00003 ///             COD structure
00004 ///
00005 
00006 /*
00007     Copyright (C) 2008-2009, Nicolas VIVIEN
00008     Copyright (C) 2009, Josh Kropf
00009     See also:
00010         http://drbolsen.wordpress.com/2006/07/26/blackberry-cod-file-format/
00011         http://drbolsen.wordpress.com/2006/08/11/10/
00012         http://www.pkware.com/documents/casestudies/APPNOTE.TXT
00013 
00014     This program is free software; you can redistribute it and/or modify
00015     it under the terms of the GNU General Public License as published by
00016     the Free Software Foundation; either version 2 of the License, or
00017     (at your option) any later version.
00018 
00019     This program is distributed in the hope that it will be useful,
00020     but WITHOUT ANY WARRANTY; without even the implied warranty of
00021     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 
00023     See the GNU General Public License in the COPYING file at the
00024     root directory of this project for more details.
00025 */
00026 
00027 
00028 #ifndef __BARRY_COD_INTERNAL_H__
00029 #define __BARRY_COD_INTERNAL_H__
00030 
00031 #include "dll.h"
00032 #include <stdint.h>
00033 #include <sys/types.h>
00034 #include "platform.h"           // safe to include platform.h here, since
00035                                 // cod-internal.h is not installed either
00036 
00037 #if USE_PACK_PRAGMA
00038 #pragma pack(push, 1)
00039 #endif
00040 
00041 #define CODFILE_TYPE_SIMPLE     {0xDE, 0xC0}
00042 #define CODFILE_TYPE_PKZIP      {0x50, 0x4B}
00043 #define PKZIP_LOCAL_FILE_SIG    {0x50, 0x4B, 0x03, 0x04}
00044 #define PKZIP_DIRECTORY_SIG     {0x50, 0x4B, 0x01, 0x02}
00045 #define PKZIP_END_DIRECTORY_SIG {0x50, 0x4B, 0x05, 0x06}
00046 
00047 
00048 typedef struct BXLOCAL {
00049         uint16_t        hour:5;
00050         uint16_t        minute:6;
00051         uint16_t        second:5;
00052 } ATTRIBUTE_PACKED msdos_time_t;
00053 
00054 
00055 typedef struct BXLOCAL {
00056         uint16_t        year:7;         // number of years since 1980
00057         uint16_t        month:4;
00058         uint16_t        day:5;
00059 } ATTRIBUTE_PACKED msdos_date_t;
00060 
00061 
00062 typedef struct BXLOCAL {
00063         //uint8_t       signature[4];           // PKZIP local file header 0x504B0304
00064         uint16_t        version_needed;         // version needed to extract, 0x0A00
00065         uint16_t        general_flag;           // general purpose bit flag, 0x0000
00066         uint16_t        compression_method;     // compression method, 0x0000 = stored, no compression
00067         msdos_time_t    last_mod_time;
00068         msdos_date_t    last_mod_date;
00069         uint32_t        crc_32;
00070         uint32_t        compressed_size;        // compression method is 'stored'
00071         uint32_t        uncompressed_size;      // both sizes are equal
00072         uint16_t        file_name_length;
00073         uint16_t        extra_field_length;
00074         //char          file_name[variable];
00075         //char          extra_field[variable];
00076 } ATTRIBUTE_PACKED pkzip_local_header_t;
00077 
00078 
00079 typedef struct BXLOCAL {
00080         //uint8_t       signature[4];           // PKZIP central directory 0x504B0304
00081         uint16_t        version_madeby;         // version used to compress, 0x0A00
00082         uint16_t        version_needed;         // version needed to extract, 0x0A00
00083         uint16_t        general_flag;           // general purpose bit flag, 0x0000
00084         uint16_t        compression_method;     // compression method, 0x0000 = stored, no compression
00085         msdos_time_t    last_mod_time;
00086         msdos_date_t    last_mod_date;
00087         uint32_t        crc_32;
00088         uint32_t        compressed_size;        // size of corresponding local file entry
00089         uint32_t        uncompressed_size;      // both sizes are equal
00090         uint16_t        file_name_length;
00091         uint16_t        extra_field_length;
00092         uint16_t        file_comment_length;
00093         uint16_t        disk_number;            // number of the disk on which this file begins, always zero
00094         uint16_t        internal_file_attr;     // always zero
00095         uint32_t        external_file_attr;     // always zero
00096         uint32_t        relative_offset;        // offset from beginning of this disk (this zip file)
00097                                                 // to start of corresponding local file entry
00098         //char          file_name[variable];
00099         //char          extra_field[variable];
00100         //char          file_comment[variable];
00101 } ATTRIBUTE_PACKED pkzip_directory_t;
00102 
00103 
00104 typedef struct BXLOCAL {
00105         //uint8_t       signature[4];           // PKZIP end central directory 0x504B0506
00106         uint16_t        this_disk_number;       // number of this disk, always zero
00107         uint16_t        disk_with_first;        // number of the disk with the start of
00108                                                 // central directory, always zero
00109         uint16_t        this_disk_entry_count;  // total number of entries in the central directory on this disk
00110         uint16_t        total_entry_count;      // total number of entries in the central directory
00111                                                 // always equals this_disk_entry_count
00112         uint32_t        directory_length;       // total size of the central directory
00113         uint32_t        directory_offset;       // offset from beginning of this disk (this zip file)
00114                                                 // to the first central directory entry
00115         uint16_t        file_comment_length;
00116         //char          file_comment[variable];
00117 } ATTRIBUTE_PACKED pkzip_end_directory_t;
00118 
00119 
00120 typedef struct BXLOCAL {
00121         uint16_t        type;                   // Type                 // 50 4B
00122         uint8_t         unknown1[8];            //                      // 03 04 0A 00 00 00 00 00
00123         uint8_t         unknown2[4];            //                      // AB 5C 6A 39
00124         uint8_t         unknown3[4];            //                      // BE 5C 58 D1
00125         uint32_t        size1;                  // COD size 0x0DCC      // CC 0D 01 00
00126         uint32_t        size2;                  // COD size 0x0DCC      // CC OD 01 00
00127         uint8_t         strsize;                // Size of string       // 19
00128         uint8_t         reserved2;              // Reserved 0x00        // 00
00129         uint8_t         strfree;                // Empty uint8_t        // 04
00130         uint8_t         reserved3;              // Reserved 0x00        // 00
00131 }  ATTRIBUTE_PACKED codfile_header_t;
00132 
00133 
00134 typedef struct BXLOCAL {
00135         uint32_t        flashid;
00136         uint32_t        section_number;         // always 0
00137         uint32_t        vtable_pointer;         // always 0
00138         time_t          timestamp;
00139         uint32_t        user_version;
00140         uint32_t        fieldref_pointer;
00141         uint16_t        maxtype_list_size;
00142         uint16_t        reserved;               // always 0xFF
00143         int32_t         data_section;           // always 0xFFFF
00144         int32_t         module_info;            // always 0xFFFF
00145         uint16_t        version;
00146         uint16_t        code_size;
00147         uint16_t        data_size;
00148         uint16_t        flags;
00149 }  ATTRIBUTE_PACKED code_header_t;
00150 
00151 
00152 typedef struct BXLOCAL {
00153         uint8_t         flags;
00154         uint8_t         version;
00155         uint16_t        num_icalls;
00156         uint8_t         num_modules;
00157         uint8_t         num_classes ;
00158         uint16_t        exported_string_offset;
00159         uint16_t        data_uint8_ts_offset;
00160         uint16_t        empty_field;
00161         uint16_t        class_definitions;
00162         uint16_t        array_of_unknow1_fields[14];
00163         uint16_t        aliases;
00164         uint16_t        array_of_unknow2_fields[22];
00165 }  ATTRIBUTE_PACKED data_header_t;
00166 
00167 #if USE_PACK_PRAGMA
00168 #pragma pack(pop)
00169 #endif
00170 
00171 #endif
00172