22#include " support/utils.h"
33#include < QPushButton>
44
5- LoaderDialog::LoaderDialog (RDContextSlice ctxslice, QWidget* parent)
6- : QDialog{parent}, m_ui{this }, m_contextslice {ctxslice} {
5+ LoaderDialog::LoaderDialog (RDTestResultSlice ctxslice, QWidget* parent)
6+ : QDialog{parent}, m_ui{this }, m_testslice {ctxslice} {
77 utils::configure_hex_input (m_ui.leentrypoint );
88 utils::configure_hex_input (m_ui.leaddress );
99 utils::configure_hex_input (m_ui.leoffset );
1010
11+ this ->accept_params .min_string = RD_MIN_STRING_LENGTH ;
12+
1113 m_ui.gbaddressing ->setEnabled (false );
1214 m_ui.leentrypoint ->setText (QString{" 0" }.repeated (sizeof (u32 ) * 2 ));
1315 m_ui.leaddress ->setText (QString{" 0" }.repeated (sizeof (u32 ) * 2 ));
1416 m_ui.leoffset ->setText (QString{" 0" }.repeated (sizeof (u32 ) * 2 ));
1517
1618 this ->populate_processors ();
1719
18- for (usize i = 0 ; i < rd_slice_length (m_contextslice ); i++) {
20+ for (usize i = 0 ; i < rd_slice_length (m_testslice ); i++) {
1921 const char * ldr_name =
20- rd_get_loader_name (rd_slice_at (m_contextslice , i));
22+ rd_testresult_get_loader_name (rd_slice_at (m_testslice , i));
2123 m_ui.lwloaders ->addItem (QString::fromUtf8 (ldr_name));
2224 }
2325
@@ -30,6 +32,15 @@ LoaderDialog::LoaderDialog(RDContextSlice ctxslice, QWidget* parent)
3032 connect (m_ui.sbminstring , &QSpinBox::valueChanged, this ,
3133 &LoaderDialog::update_min_string);
3234
35+ connect (m_ui.rbnewanalysis , &QRadioButton::clicked, this ,
36+ &LoaderDialog::update_open_mode);
37+
38+ connect (m_ui.rbopenproject , &QRadioButton::clicked, this ,
39+ &LoaderDialog::update_open_mode);
40+
41+ connect (m_ui.rbresumesession , &QRadioButton::clicked, this ,
42+ &LoaderDialog::update_open_mode);
43+
3344 connect (m_ui.leentrypoint , &QLineEdit::textChanged, this ,
3445 &LoaderDialog::update_entry_point);
3546
@@ -40,20 +51,24 @@ LoaderDialog::LoaderDialog(RDContextSlice ctxslice, QWidget* parent)
4051 &LoaderDialog::update_offset);
4152
4253 // Trigger "on_loader_changed"
43- if (!rd_slice_is_empty (m_contextslice )) m_ui.lwloaders ->setCurrentRow (0 );
54+ if (!rd_slice_is_empty (m_testslice )) m_ui.lwloaders ->setCurrentRow (0 );
4455
4556 this ->validate_fields ();
57+ this ->update_open_mode ();
4658}
4759
4860void LoaderDialog::on_loader_changed (int currentrow) {
4961 if (currentrow != -1 ) {
50- this ->context = rd_slice_at (m_contextslice , currentrow);
51- m_ui.sbminstring ->setValue (rd_get_min_string ( this -> context ) );
62+ this ->sel_test = rd_slice_at (m_testslice , currentrow);
63+ m_ui.sbminstring ->setValue (RD_MIN_STRING_LENGTH );
5264
53- const RDLoaderPlugin* l = rd_get_loader_plugin (this ->context );
54- const RDProcessorPlugin* p = rd_get_processor_plugin (this ->context );
65+ const RDLoaderPlugin* l =
66+ rd_testresult_get_loader_plugin (this ->sel_test );
67+ const RDProcessorPlugin* p =
68+ rd_testresult_get_processor_plugin (this ->sel_test );
5569
56- m_ui.gbaddressing ->setEnabled (l->flags & RD_LF_MANUAL );
70+ m_ui.gbaddressing ->setEnabled (m_ui.rbnewanalysis ->isChecked () &&
71+ (l->flags & RD_LF_MANUAL ));
5772
5873 for (int i = 0 ; i < m_ui.cbprocessors ->count (); i++) {
5974 if (m_ui.cbprocessors ->itemData (i).toString () == p->id ) {
@@ -66,7 +81,7 @@ void LoaderDialog::on_loader_changed(int currentrow) {
6681 }
6782 else {
6883 m_ui.gbaddressing ->setEnabled (false );
69- this ->context = nullptr ;
84+ this ->sel_test = nullptr ;
7085 }
7186
7287 this ->validate_fields ();
@@ -77,10 +92,11 @@ void LoaderDialog::on_processor_changed(int currentrow) {
7792
7893 if (loaderidx != -1 && currentrow != -1 ) {
7994 QVariant d = m_ui.cbprocessors ->itemData (currentrow);
80- this ->processorplugin = rd_processor_find (qUtf8Printable (d.toString ()));
95+ this ->accept_params .processorplugin =
96+ rd_processor_find (qUtf8Printable (d.toString ()));
8197 }
8298 else
83- this ->processorplugin = nullptr ;
99+ this ->accept_params . processorplugin = nullptr ;
84100
85101 this ->validate_fields ();
86102}
@@ -95,37 +111,53 @@ void LoaderDialog::populate_processors() const {
95111 }
96112}
97113
98- void LoaderDialog::update_min_string () { // NOLINT
99- if (!this ->context ) return ;
100- rd_set_min_string (this ->context , m_ui.sbminstring ->value ());
114+ void LoaderDialog::update_min_string () {
115+ this ->accept_params .min_string = m_ui.sbminstring ->value ();
116+ }
117+
118+ void LoaderDialog::update_open_mode () {
119+ if (m_ui.rbnewanalysis ->isChecked ())
120+ this ->accept_params .mode = RD_AM_NEW ;
121+ else if (m_ui.rbopenproject ->isChecked ())
122+ this ->accept_params .mode = RD_AM_PROJECT ;
123+ else if (m_ui.rbresumesession ->isChecked ())
124+ this ->accept_params .mode = RD_AM_DATABASE ;
125+ else
126+ qFatal (" cannot set an open mode" );
127+
128+ m_ui.gbloader ->setEnabled (m_ui.rbnewanalysis ->isChecked () ||
129+ m_ui.rbresumesession ->isChecked ());
130+
131+ m_ui.gbaddressing ->setEnabled (m_ui.rbnewanalysis ->isChecked ());
101132}
102133
103134void LoaderDialog::update_entry_point () {
104- this ->addressing .entrypoint =
135+ this ->accept_params . addressing .entrypoint =
105136 m_ui.leentrypoint ->text ().toULongLong (nullptr , 16 );
106137 this ->validate_fields ();
107138}
108139
109140void LoaderDialog::update_address () {
110- this ->addressing .address =
141+ this ->accept_params . addressing .address =
111142 m_ui.leentrypoint ->text ().toULongLong (nullptr , 16 );
112143 this ->validate_fields ();
113144}
114145
115146void LoaderDialog::update_offset () {
116- this ->addressing .offset = m_ui.leoffset ->text ().toULongLong (nullptr , 16 );
147+ this ->accept_params .addressing .offset =
148+ m_ui.leoffset ->text ().toULongLong (nullptr , 16 );
117149 this ->validate_fields ();
118150}
119151
120152void LoaderDialog::validate_fields () { // NOLINT
121153 QPushButton* pb = m_ui.buttonbox ->button (QDialogButtonBox::Ok);
122154
123- if (!this ->context || m_ui.cbprocessors ->currentIndex () == -1 ) {
155+ if (!this ->sel_test || m_ui.cbprocessors ->currentIndex () == -1 ) {
124156 pb->setEnabled (false );
125157 return ;
126158 }
127159
128- const RDLoaderPlugin* l = rd_get_loader_plugin (this ->context );
160+ const RDLoaderPlugin* l = rd_testresult_get_loader_plugin (this ->sel_test );
129161
130162 if (l->flags & RD_LF_MANUAL ) {
131163 pb->setEnabled (!m_ui.leentrypoint ->text ().isEmpty () &&
0 commit comments