-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCryDisasmGoToAddressDialog.cpp
74 lines (63 loc) · 2.22 KB
/
CryDisasmGoToAddressDialog.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
73
74
#include "CryDisasmGoToAddressDialog.h"
#include "ImlProvider.h"
#include "BackendGlobalDef.h"
// Default constructor of the CryDisasmGoToAddressDialog, accepting a pointer to data the user needs.
CryDisasmGoToAddressDialog::CryDisasmGoToAddressDialog(LONG_PTR* addr) : CryDialogTemplate(CrySearchIml::CrySearch())
{
this->addrPtr = addr;
this->Title("Go to Address").SetRect(0, 0, 180, 75);
this->mOk <<= THISBACK(OkButtonClicked);
this->mCancel <<= THISBACK(CancelButtonClicked);
*this
<< this->mAddressDesc.SetLabel("Address:").LeftPos(5, 75).TopPos(5, 25)
<< this->mAddressInput.HSizePos(80, 5).TopPos(5, 25)
<< this->mOk.Ok().SetLabel("OK").BottomPos(5, 25).RightPos(5, 70)
<< this->mCancel.SetLabel("Cancel").BottomPos(5, 25).RightPos(80, 70)
;
}
// Default destructor of the CryDisasmGoToAddressDialog.
CryDisasmGoToAddressDialog::~CryDisasmGoToAddressDialog()
{
}
// Executed when the user accepts the dialog.
void CryDisasmGoToAddressDialog::OkButtonClicked()
{
// Check if a valid address was entered.
if (this->mAddressInput.GetText().IsEmpty())
{
Prompt("Input Error", CtrlImg::error(), "Please enter an address.", "OK");
return;
}
// If the address input contains a plus, the input is a relative address.
const String& addrField = this->mAddressInput.GetText().ToString();
const int plusIndex = addrField.Find("+");
if (plusIndex != -1)
{
// Parse the relative address into the new address table entry.
const Win32ModuleInformation* mod = mModuleManager->FindModule(addrField.Left(plusIndex));
if (!mod)
{
// If the module was not found in the loaded modules list, the relative address cannot be calculated.
Prompt("Input Error", CtrlImg::error(), "The module was not found!", "OK");
return;
}
// Still here, so calculate the address.
*this->addrPtr = mod->BaseAddress + ScanInt(addrField.Mid(plusIndex + 1), NULL, 16);
}
else
{
// Regularly parse the address. It is not a relative one.
#ifdef _WIN64
*this->addrPtr = ScanInt64(addrField, NULL, 16);
#else
*this->addrPtr = ScanInt(addrField, NULL, 16);
#endif
}
this->AcceptBreak(10);
}
// Executed when the user cancels the dialog.
void CryDisasmGoToAddressDialog::CancelButtonClicked()
{
*this->addrPtr = -1;
this->Close();
}