-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCryByteArrayGenerationWindow.cpp
72 lines (61 loc) · 2.36 KB
/
CryByteArrayGenerationWindow.cpp
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
#include "CryByteArrayGenerationWindow.h"
#include "ImlProvider.h"
#include "UIUtilities.h"
#include "BackendGlobalDef.h"
// This window needs access to the visible disassembly lines.
extern Vector<LONG_PTR> DisasmVisibleLines;
// The CryByteArrayGenerationWindow default constructor, accepting a number of selected rows.
CryByteArrayGenerationWindow::CryByteArrayGenerationWindow(const Vector<int>& rows) : CryDialogTemplate(CrySearchIml::GenerateByteArrayButton())
{
this->Title("Generate Byte-array").SetRect(0, 0, 300, 140);
this->mClose <<= THISBACK(CloseWindow);
*this
<< this->mCPPStyleSection.SetLabel("C++").HSizePos(5, 5).TopPos(5, 45)
<< this->mCPPStyle.SetLabel("Byte-array:").LeftPos(10, 80).TopPos(20, 25)
<< this->mCPPStyleSig.SetEditable(false).HSizePos(90, 10).TopPos(20, 25)
<< this->mCSharpStyleSection.SetLabel("C#").HSizePos(5, 5).TopPos(55, 45)
<< this->mCSharpStyle.SetLabel("Byte-array:").LeftPos(10, 80).TopPos(70, 25)
<< this->mCSharpStyleSig.SetEditable(false).HSizePos(90, 10).TopPos(70, 25)
<< this->mClose.SetLabel("Close").RightPos(5, 70).BottomPos(5, 25)
;
// Retrieve byte sets that are selected.
Vector<Byte> byteSets;
const int count = rows.GetCount();
for (int i = 0; i < count; ++i)
{
ArrayOfBytes sequence;
#ifdef _WIN64
DisasmGetLine(DisasmVisibleLines[rows[i]], mMemoryScanner->IsX86Process() ? CS_MODE_32 : CS_MODE_64, &sequence);
#else
DisasmGetLine(DisasmVisibleLines[rows[i]], CS_MODE_32, &sequence);
#endif
for (int y = 0; y < sequence.Size; ++y)
{
byteSets << sequence.Data[y];
}
}
// Generate signatures in all supported styles.
this->GenerateCPPStyle(byteSets);
this->GenerateCSharpStyle(byteSets);
}
// The CryByteArrayGenerationWindow default destructor.
CryByteArrayGenerationWindow::~CryByteArrayGenerationWindow()
{
}
// Generates a C++-style byte array.
void CryByteArrayGenerationWindow::GenerateCPPStyle(const Vector<Byte>& aobs)
{
// Set the string in the user interface controls.
this->mCPPStyleSig.SetText(GenerateByteArray(aobs, ARRAYTYPE_CPP));
}
// Generates a C#-style byte array.
void CryByteArrayGenerationWindow::GenerateCSharpStyle(const Vector<Byte>& aobs)
{
// Set generated signature inside top textbox.
this->mCSharpStyleSig.SetText(GenerateByteArray(aobs, ARRAYTYPE_CSHARP));
}
// Executed when the dialog is closed.
void CryByteArrayGenerationWindow::CloseWindow()
{
this->Close();
}