# 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
    00035 #define CODFILE_TYPE_SIMPLE     {0xDE, 0xC0}
    00036 #define CODFILE_TYPE_PKZIP      {0x50, 0x4B}
    00037 #define PKZIP_LOCAL_FILE_SIG    {0x50, 0x4B, 0x03, 0x04}
    00038 #define PKZIP_DIRECTORY_SIG     {0x50, 0x4B, 0x01, 0x02}
    00039 #define PKZIP_END_DIRECTORY_SIG {0x50, 0x4B, 0x05, 0x06}
    00040
    00041
    00042 typedef struct BXLOCAL {
    00043         uint16_t        hour:5;
    00044         uint16_t        minute:6;
    00045         uint16_t        second:5;
    00046 } __attribute__ ((packed)) msdos_time_t;
    00047
    00048
    00049 typedef struct BXLOCAL {
    00050         uint16_t        year:7;         // number of years since 1980
    00051         uint16_t        month:4;
    00052         uint16_t        day:5;
    00053 } __attribute__ ((packed)) msdos_date_t;
    00054
    00055
    00056 typedef struct BXLOCAL {
    00057         //uint8_t       signature[4];           // PKZIP local file header 0x504B0304
    00058         uint16_t        version_needed;         // version needed to extract, 0x0A00
    00059         uint16_t        general_flag;           // general purpose bit flag, 0x0000
    00060         uint16_t        compression_method;     // compression method, 0x0000 = stored, no compression
    00061         msdos_time_t    last_mod_time;
    00062         msdos_date_t    last_mod_date;
    00063         uint32_t        crc_32;
    00064         uint32_t        compressed_size;        // compression method is 'stored'
    00065         uint32_t        uncompressed_size;      // both sizes are equal
    00066         uint16_t        file_name_length;
    00067         uint16_t        extra_field_length;
    00068         //char          file_name[variable];
    00069         //char          extra_field[variable];
    00070 } __attribute__ ((packed)) pkzip_local_header_t;
    00071
    00072
    00073 typedef struct BXLOCAL {
    00074         //uint8_t       signature[4];           // PKZIP central directory 0x504B0304
    00075         uint16_t        version_madeby;         // version used to compress, 0x0A00
    00076         uint16_t        version_needed;         // version needed to extract, 0x0A00
    00077         uint16_t        general_flag;           // general purpose bit flag, 0x0000
    00078         uint16_t        compression_method;     // compression method, 0x0000 = stored, no compression
    00079         msdos_time_t    last_mod_time;
    00080         msdos_date_t    last_mod_date;
    00081         uint32_t        crc_32;
    00082         uint32_t        compressed_size;        // size of corresponding local file entry
    00083         uint32_t        uncompressed_size;      // both sizes are equal
    00084         uint16_t        file_name_length;
    00085         uint16_t        extra_field_length;
    00086         uint16_t        file_comment_length;
    00087         uint16_t        disk_number;            // number of the disk on which this file begins, always zero
    00088         uint16_t        internal_file_attr;     // always zero
    00089         uint32_t        external_file_attr;     // always zero
    00090         uint32_t        relative_offset;        // offset from beginning of this disk (this zip file)
    00091                                                 // to start of corresponding local file entry
    00092         //char          file_name[variable];
    00093         //char          extra_field[variable];
    00094         //char          file_comment[variable];
    00095 } __attribute__ ((packed)) pkzip_directory_t;
    00096
    00097
    00098 typedef struct BXLOCAL {
    00099         //uint8_t       signature[4];           // PKZIP end central directory 0x504B0506
    00100         uint16_t        this_disk_number;       // number of this disk, always zero
    00101         uint16_t        disk_with_first;        // number of the disk with the start of
    00102                                                 // central directory, always zero
    00103         uint16_t        this_disk_entry_count;  // total number of entries in the central directory on this disk
    00104         uint16_t        total_entry_count;      // total number of entries in the central directory
    00105                                                 // always equals this_disk_entry_count
    00106         uint32_t        directory_length;       // total size of the central directory
    00107         uint32_t        directory_offset;       // offset from beginning of this disk (this zip file)
    00108                                                 // to the first central directory entry
    00109         uint16_t        file_comment_length;
    00110         //char          file_comment[variable];
    00111 } __attribute__ ((packed)) pkzip_end_directory_t;
    00112
    00113
    00114 typedef struct BXLOCAL {
    00115         uint16_t        type;                   // Type                 // 50 4B
    00116         uint8_t         unknown1[8];            //                      // 03 04 0A 00 00 00 00 00
    00117         uint8_t         unknown2[4];            //                      // AB 5C 6A 39
    00118         uint8_t         unknown3[4];            //                      // BE 5C 58 D1
    00119         uint32_t        size1;                  // COD size 0x0DCC      // CC 0D 01 00
    00120         uint32_t        size2;                  // COD size 0x0DCC      // CC OD 01 00
    00121         uint8_t         strsize;                // Size of string       // 19
    00122         uint8_t         reserved2;              // Reserved 0x00        // 00
    00123         uint8_t         strfree;                // Empty uint8_t        // 04
    00124         uint8_t         reserved3;              // Reserved 0x00        // 00
    00125 }  __attribute__ ((packed)) codfile_header_t;
    00126
    00127
    00128 typedef struct BXLOCAL {
    00129         uint32_t        flashid;
    00130         uint32_t        section_number;         // always 0
    00131         uint32_t        vtable_pointer;         // always 0
    00132         time_t          timestamp;
    00133         uint32_t        user_version;
    00134         uint32_t        fieldref_pointer;
    00135         uint16_t        maxtype_list_size;
    00136         uint16_t        reserved;               // always 0xFF
    00137         int32_t         data_section;           // always 0xFFFF
    00138         int32_t         module_info;            // always 0xFFFF
    00139         uint16_t        version;
    00140         uint16_t        code_size;
    00141         uint16_t        data_size;
    00142         uint16_t        flags;
    00143 }  __attribute__ ((packed)) code_header_t;
    00144
    00145
    00146 typedef struct BXLOCAL {
    00147         uint8_t         flags;
    00148         uint8_t         version;
    00149         uint16_t        num_icalls;
    00150         uint8_t         num_modules;
    00151         uint8_t         num_classes ;
    00152         uint16_t        exported_string_offset;
    00153         uint16_t        data_uint8_ts_offset;
    00154         uint16_t        empty_field;
    00155         uint16_t        class_definitions;
    00156         uint16_t        array_of_unknow1_fields[14];
    00157         uint16_t        aliases;
    00158         uint16_t        array_of_unknow2_fields[22];
    00159 }  __attribute__ ((packed)) data_header_t;
    00160
    00161 #endif
    00162