BearParser
Portable Executable parsing library (from PE-bear)
Loading...
Searching...
No Matches
parser
WrappedValue.cpp
Go to the documentation of this file.
1
#include "
WrappedValue.h
"
2
3
QVariant
WrappedValue::getQVariant
()
4
{
5
if
(
m_Type
==
INT
) {
6
bool
isOk =
false
;
7
8
qlonglong num = (qlonglong)
m_Owner
->
getNumValue
(
m_Offset
,
m_Size
, &isOk);
9
if
(!isOk)
return
QVariant(
"INVALID"
);
10
return
QVariant(num);
11
}
12
if
(
m_Type
==
STRING
) {
13
char
*strPtr = (
char
*) this->
m_Owner
->
getContentAt
(
m_Offset
,
m_Size
);
14
if
(strPtr == NULL)
return
QVariant();
15
return
QString(strPtr);
16
}
17
if
(this->
m_Type
==
WSTRING
) {
18
19
bufsize_t
wSize =
m_Size
/
bufsize_t
(
sizeof
(WORD));
20
WORD *strPtr = (WORD*) this->
m_Owner
->
getContentAt
(
m_Offset
,
m_Size
);
21
return
QString::fromUtf16(strPtr,
static_cast<
int
>
(wSize));
22
}
23
return
QVariant(
"..."
);
24
}
25
26
QString
WrappedValue::getIntFormat
()
27
{
28
QString format =
"%0"
+ QString::number(
m_Size
* 2) +
"llX"
;
29
return
format;
30
}
31
32
QString
WrappedValue::toQString
()
33
{
34
if
(this->
m_Type
==
NONE
)
return
""
;
35
if
(this->
m_Type
==
COMPLEX
)
return
"..."
;
36
37
QVariant val =
getQVariant
();
38
39
if
(this->
m_Type
==
STRING
|| this->
m_Type
==
WSTRING
) {
40
return
val.toString();
41
}
42
if
(this->
m_Type
==
INT
) {
43
44
bufsize_t
size = this->
m_Size
;
45
if
(size >
sizeof
(uint64_t))
return
"..."
;
46
47
bool
isOk =
false
;
48
uint64_t num =
m_Owner
->
getNumValue
(
m_Offset
,
m_Size
, &isOk);
49
if
(!isOk)
return
"INVALID"
;
50
QString out;
51
#if QT_VERSION >= 0x050000
52
out = QString::asprintf(
getIntFormat
().toStdString().c_str(), num);
53
#else
54
out.sprintf(
getIntFormat
().toStdString().c_str(), num);
55
#endif
56
return
out;
57
}
58
return
getQVariant
().toString();
59
}
bufsize_t
uint32_t bufsize_t
Definition
AbstractByteBuffer.h:14
WrappedValue.h
AbstractByteBuffer::getContentAt
virtual BYTE * getContentAt(offset_t offset, bufsize_t size, bool allowExceptions=false)
Definition
AbstractByteBuffer.cpp:57
AbstractByteBuffer::getNumValue
uint64_t getNumValue(offset_t offset, bufsize_t size, bool *isOk)
Definition
AbstractByteBuffer.cpp:297
WrappedValue::getQVariant
QVariant getQVariant()
Definition
WrappedValue.cpp:3
WrappedValue::m_Owner
AbstractByteBuffer * m_Owner
Definition
WrappedValue.h:39
WrappedValue::INT
@ INT
Definition
WrappedValue.h:17
WrappedValue::NONE
@ NONE
Definition
WrappedValue.h:16
WrappedValue::WSTRING
@ WSTRING
Definition
WrappedValue.h:19
WrappedValue::COMPLEX
@ COMPLEX
Definition
WrappedValue.h:20
WrappedValue::STRING
@ STRING
Definition
WrappedValue.h:18
WrappedValue::m_Offset
offset_t m_Offset
Definition
WrappedValue.h:40
WrappedValue::toQString
QString toQString()
Definition
WrappedValue.cpp:32
WrappedValue::m_Size
bufsize_t m_Size
Definition
WrappedValue.h:41
WrappedValue::getIntFormat
virtual QString getIntFormat()
Definition
WrappedValue.cpp:26
WrappedValue::m_Type
data_type m_Type
Definition
WrappedValue.h:38
Generated by
1.12.0