forked from ImpulseAdventure/JPEGsnoop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DbSigs.h
138 lines (104 loc) · 4.3 KB
/
DbSigs.h
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// JPEGsnoop - JPEG Image Decoder & Analysis Utility
// Copyright (C) 2017 - Calvin Hass
// http://www.impulseadventure.com/photo/jpeg-snoop.html
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ==========================================================================
// CLASS DESCRIPTION:
// - Class provides management of the signatures database
// - Supports both built-in and user database entries
//
// ==========================================================================
#pragma once
#define DBEX_ENTRIES_MAX 300
#define DB_VER_STR "03"
#include "snoop.h"
// Signature exception structure with metadata fields
struct CompExcMm {
LPTSTR strXMake; // EXIF Make
LPTSTR strXModel; // EXIF Model
};
// Signature structure for hardcoded table
struct CompSigConst {
teEditor eEditor; // Digicam vs software/editor
LPTSTR strXMake; // Blank for editors (set to strMSwDisp)
LPTSTR strXModel; // Blank for editors
LPTSTR strUmQual;
LPTSTR strCSig; // Signature
LPTSTR strCSigRot; // Signature of rotated DQTs
LPTSTR strXSubsamp; // Blank for editors
LPTSTR strMSwTrim; // Blank for digicam
LPTSTR strMSwDisp; // Blank for digicam
};
// Signature structure for runtime table (can use CStrings)
struct CompSig {
bool bValid; // Set to FALSE for removal
teEditor eEditor;
CString strXMake; // Blank for editors
CString strXModel; // Blank for editors
CString strUmQual;
CString strCSig;
CString strCSigRot;
CString strXSubsamp; // Blank for editors
CString strMSwTrim; // Blank for digicam
CString strMSwDisp; // Blank for digicam
};
class CDbSigs
{
public:
CDbSigs();
~CDbSigs();
unsigned GetNumSigsInternal();
unsigned GetNumSigsExtra();
unsigned GetDBNumEntries();
bool GetDBEntry(unsigned nInd,CompSig* pEntry);
unsigned IsDBEntryUser(unsigned nInd);
void SetEntryValid(unsigned nInd,bool bValid);
void DatabaseExtraClean();
void DatabaseExtraLoad();
void DatabaseExtraStore();
unsigned DatabaseExtraGetNum();
CompSig DatabaseExtraGet(unsigned nInd);
void DatabaseExtraAdd(CString strExifMake,CString strExifModel,
CString strQual,CString strSig,CString strSigRot,CString strCss,
teSource eUserSource,CString strUserSoftware);
bool BufReadNum(PBYTE pBuf,unsigned &nOut,unsigned nMaxBytes,unsigned &nOffsetBytes);
bool BufReadStr(PBYTE pBuf,CString &strOut,unsigned nMaxBytes,bool bUni,unsigned &nOffsetBytes);
bool BufWriteNum(PBYTE pBuf,unsigned nIn,unsigned nMaxBytes,unsigned &nOffsetBytes);
bool BufWriteStr(PBYTE pBuf,CString strIn,unsigned nMaxBytes,bool bUni,unsigned &nOffsetBytes);
bool SearchSignatureExactInternal(CString strMake, CString strModel, CString strSig);
bool SearchCom(CString strCom);
bool LookupExcMmNoMkr(CString strMake,CString strModel);
bool LookupExcMmIsEdit(CString strMake,CString strModel);
unsigned GetIjgNum();
LPTSTR GetIjgEntry(unsigned nInd);
void SetDbDir(CString strDbDir);
void SetFirstRun(bool bFirstRun);
private:
CompSig m_sSigListExtra[DBEX_ENTRIES_MAX]; // Extra entries
unsigned m_nSigListExtraNum;
unsigned m_nSigListNum;
static const CompSigConst m_sSigList[]; // Built-in entries
unsigned m_nExcMmNoMkrListNum;
static const CompExcMm m_sExcMmNoMkrList[];
unsigned m_nExcMmIsEditListNum;
static const CompExcMm m_sExcMmIsEditList[];
unsigned m_nSwIjgListNum;
static LPTSTR m_sSwIjgList[];
unsigned m_nXcomSwListNum;
static LPTSTR m_sXComSwList[];
CString m_strDbDir; // Database directory
bool m_bFirstRun; // First time running app?
};