hc
2025-02-14 bbb9540dc49f70f6b703d1c8d1b85fa5f602d86e
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
#ifndef RKIMAGE_HEADER
#define RKIMAGE_HEADER
#include "DefineHeader.h"
#include "RKBoot.h"
#define  IMAGE_RESERVED_SIZE 61
#pragma pack(1)
typedef struct
{
    UINT uiTag;
    USHORT usSize;
    DWORD  dwVersion;
    DWORD  dwMergeVersion;
    STRUCT_RKTIME stReleaseTime;
    ENUM_RKDEVICE_TYPE emSupportChip;
    DWORD  dwBootOffset;
    DWORD  dwBootSize;
    DWORD  dwFWOffset;
    DWORD  dwFWSize;
    BYTE   reserved[IMAGE_RESERVED_SIZE];
} STRUCT_RKIMAGE_HEAD, *PSTRUCT_RKIMAGE_HEAD;
#pragma pack()
class CRKImage
{
public:
    UINT GetVersion();
    property<CRKImage, UINT, READ_ONLY> Version;
    UINT GetMergeVersion();
    property<CRKImage, UINT, READ_ONLY> MergeVersion;
    STRUCT_RKTIME GetReleaseTime();
    property<CRKImage, STRUCT_RKTIME, READ_ONLY> ReleaseTime;
    ENUM_RKDEVICE_TYPE GetSupportDevice();
    property<CRKImage, ENUM_RKDEVICE_TYPE, READ_ONLY> SupportDevice;
    ENUM_OS_TYPE GetOsType();
    property<CRKImage, ENUM_OS_TYPE, READ_ONLY> OsType;
    unsigned short GetBackupSize();
    property<CRKImage, unsigned short, READ_ONLY> BackupSize;
    UINT GetBootOffset();
    property<CRKImage, UINT, READ_ONLY> BootOffset;
    UINT GetBootSize();
    property<CRKImage, UINT, READ_ONLY> BootSize;
    UINT GetFWOffset();
    property<CRKImage, UINT, READ_ONLY> FWOffset;
    FILE *GetFWFileHandle();
    property<CRKImage, FILE *, READ_ONLY> FWFileHandle;
    long long GetFWSize();
    property<CRKImage, long long, READ_ONLY> FWSize;
    char *GetFwPath();
    property<CRKImage, char *, READ_ONLY> FwPath;
 
    CRKBoot *m_bootObject;
    bool Md5Check(long long nCheckSize);
    bool SaveBootFile(tstring filename);
    bool SaveFWFile(tstring filename);
    bool GetData(long long dwOffset, DWORD dwSize, PBYTE lpBuffer);
    void GetReservedData(PBYTE &lpData, USHORT &usSize);
    long long GetImageSize();
    int GetMd5Data(PBYTE &lpMd5, PBYTE &lpSignMd5);
    CRKImage(tstring filename, bool &bCheck);
    ~CRKImage();
protected:
 
private:
    DWORD m_version;
    DWORD m_mergeVersion;
    STRUCT_RKTIME m_releaseTime;
    ENUM_RKDEVICE_TYPE m_supportDevice;
    DWORD m_bootOffset;
    DWORD m_bootSize;
    DWORD m_fwOffset;
    long long m_fwSize;
    BYTE  m_md5[32];
    BYTE  m_signMd5[256];
    BYTE  m_reserved[IMAGE_RESERVED_SIZE];
    bool  m_bSignFlag;
    int   m_signMd5Size;
    FILE *m_pFile;
    char m_imgPath[256];
    long long m_fileSize;
};
#endif