1 #ifndef RKIMAGE_HEADER 2 #define RKIMAGE_HEADER 3 #include "DefineHeader.h" 4 #include "RKBoot.h" 5 #define IMAGE_RESERVED_SIZE 61 6 #pragma pack(1) 7 typedef struct { 8 UINT uiTag; 9 USHORT usSize; 10 DWORD dwVersion; 11 DWORD dwMergeVersion; 12 STRUCT_RKTIME stReleaseTime; 13 ENUM_RKDEVICE_TYPE emSupportChip; 14 DWORD dwBootOffset; 15 DWORD dwBootSize; 16 DWORD dwFWOffset; 17 DWORD dwFWSize; 18 BYTE reserved[IMAGE_RESERVED_SIZE]; 19 } STRUCT_RKIMAGE_HEAD, *PSTRUCT_RKIMAGE_HEAD; 20 #pragma pack() 21 class CRKImage 22 { 23 public: 24 UINT GetVersion(); 25 property<CRKImage, UINT, READ_ONLY> Version; 26 UINT GetMergeVersion(); 27 property<CRKImage, UINT, READ_ONLY> MergeVersion; 28 STRUCT_RKTIME GetReleaseTime(); 29 property<CRKImage, STRUCT_RKTIME, READ_ONLY> ReleaseTime; 30 ENUM_RKDEVICE_TYPE GetSupportDevice(); 31 property<CRKImage, ENUM_RKDEVICE_TYPE, READ_ONLY> SupportDevice; 32 ENUM_OS_TYPE GetOsType(); 33 property<CRKImage, ENUM_OS_TYPE, READ_ONLY> OsType; 34 35 unsigned short GetBackupSize(); 36 property<CRKImage, unsigned short, READ_ONLY> BackupSize; 37 UINT GetBootOffset(); 38 property<CRKImage, UINT, READ_ONLY> BootOffset; 39 UINT GetBootSize(); 40 property<CRKImage, UINT, READ_ONLY> BootSize; 41 UINT GetFWOffset(); 42 property<CRKImage, UINT, READ_ONLY> FWOffset; 43 long long GetFWSize(); 44 property<CRKImage, long long, READ_ONLY> FWSize; 45 bool GetSignFlag(); 46 property<CRKImage, bool, READ_ONLY> SignFlag; 47 48 CRKBoot *m_bootObject; 49 bool SaveBootFile(string filename); 50 bool SaveFWFile(string filename); 51 bool GetData(long long dwOffset, DWORD dwSize, PBYTE lpBuffer); 52 void GetReservedData(PBYTE &lpData, USHORT &usSize); 53 int GetMd5Data(PBYTE &lpMd5, PBYTE &lpSignMd5); 54 long long GetImageSize(); 55 CRKImage(string filename, bool &bCheck); 56 ~CRKImage(); 57 protected: 58 59 private: 60 DWORD m_version; 61 DWORD m_mergeVersion; 62 STRUCT_RKTIME m_releaseTime; 63 ENUM_RKDEVICE_TYPE m_supportDevice; 64 DWORD m_bootOffset; 65 DWORD m_bootSize; 66 DWORD m_fwOffset; 67 long long m_fwSize; 68 69 BYTE m_md5[32]; 70 BYTE m_signMd5[256]; 71 BYTE m_reserved[IMAGE_RESERVED_SIZE]; 72 bool m_bSignFlag; 73 int m_signMd5Size; 74 FILE *m_pFile; 75 long long m_fileSize; 76 }; 77 #endif