summaryrefslogtreecommitdiff
path: root/ui/compiledialog.h
blob: a0218cca11db2b82358069c678215890b2146a77 (plain)
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
#pragma once

#include <QtWidgets/QDialog>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLabel>
#include <set>
#include "binaryninjaapi.h"
#include "dialogtextedit.h"
#include "uicontext.h"

/*!

	\defgroup compiledialog CompileDialog
 	\ingroup uiapi
*/

/*!

    \ingroup compiledialog
*/
enum CompileMode
{
	CompileStandalone,
	CompilePatch
};

/*!

    \ingroup compiledialog
*/
class BINARYNINJAUIAPI CompileDialog : public QDialog
{
	Q_OBJECT

	BinaryViewRef m_view;
	uint64_t m_addr;
	QComboBox* m_arch;
	QComboBox* m_os;
	DialogTextEdit* m_code;
	QLabel* m_optionsText;
	bool m_saveOSSetting;
	std::map<std::string, std::string> m_options;
	std::set<std::string> m_unsavedOptions;
	BinaryNinja::DataBuffer m_bytes;
	bool m_setDefault;

	void appendOptionString(std::string& out, const std::string& text);
	void updateOptionsText();

  public:
	CompileDialog(QWidget* parent, BinaryViewRef data, uint64_t addr, CompileMode mode, const QString& code = "");

	ArchitectureRef getArchitecture();
	const BinaryNinja::DataBuffer& getBytes() const { return m_bytes; }

  private Q_SLOTS:
	void saveOnFinish(int result);
	void compile();
	void options();

  protected:
	virtual void accept() override;
};