Tentative de mise en place d'une classe dérivée
This commit is contained in:
parent
fe633ab032
commit
e51bf45b53
57
ia86.cpp
57
ia86.cpp
|
@ -130,6 +130,26 @@ void ScenarioWindow::adjustSize()
|
||||||
listview.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
listview.setGeometry (FPoint{1, 2}, FSize(getWidth(), getHeight() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
// Classe FListViewEx
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
namespace finalcut
|
||||||
|
{
|
||||||
|
FListViewEx::FListViewEx (FWidget* parent)
|
||||||
|
: FListView{parent}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
FListViewEx::~FListViewEx()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FListViewEx::setindex(int index)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Classe InstructionWindow
|
// Classe InstructionWindow
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
@ -159,6 +179,11 @@ void InstructionWindow::clear()
|
||||||
listview.redraw();
|
listview.redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstructionWindow::setindex(int index)
|
||||||
|
{
|
||||||
|
listview.setindex(index);
|
||||||
|
}
|
||||||
|
|
||||||
void InstructionWindow::set(std::vector<std::array<std::string, 5>> src)
|
void InstructionWindow::set(std::vector<std::array<std::string, 5>> src)
|
||||||
{
|
{
|
||||||
content=src;
|
content=src;
|
||||||
|
@ -538,6 +563,17 @@ void VMEngine::Prepare(State *init, Code *code)
|
||||||
SetRegs(init, code);
|
SetRegs(init, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int VMEngine::getEIP(Code *code)
|
||||||
|
{
|
||||||
|
int eip=-666;
|
||||||
|
err = uc_reg_read(uc, UC_X86_REG_EIP, &eip);
|
||||||
|
if (err != UC_ERR_OK)
|
||||||
|
log->append("Impossible de récupérer le registre: EIP");
|
||||||
|
if ((eip<code->address) || (eip>code->address+code->size))
|
||||||
|
eip=-666;
|
||||||
|
return eip;
|
||||||
|
}
|
||||||
|
|
||||||
void VMEngine::SetMem(State *init, Code *code)
|
void VMEngine::SetMem(State *init, Code *code)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -861,7 +897,7 @@ void Menu::initMenusCallBack()
|
||||||
Init.addCallback (
|
Init.addCallback (
|
||||||
"clicked",
|
"clicked",
|
||||||
this,
|
this,
|
||||||
&Menu::initIA
|
&Menu::verify
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,11 +985,6 @@ void Menu::about()
|
||||||
AdjustWindows();
|
AdjustWindows();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::initIA()
|
|
||||||
{
|
|
||||||
vm.Prepare(&goals[scenar.getselected()].init,code);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Menu::verify()
|
bool Menu::verify()
|
||||||
{
|
{
|
||||||
if (!code->assembled)
|
if (!code->assembled)
|
||||||
|
@ -962,7 +993,7 @@ bool Menu::verify()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!code->initialized)
|
if (!code->initialized)
|
||||||
initIA();
|
vm.Prepare(&goals[scenar.getselected()].init,code);
|
||||||
if (!code->initialized)
|
if (!code->initialized)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -970,15 +1001,23 @@ bool Menu::verify()
|
||||||
|
|
||||||
void Menu::refresh()
|
void Menu::refresh()
|
||||||
{
|
{
|
||||||
|
if (!code->initialized)
|
||||||
|
{
|
||||||
|
regs.set("En attente d'initialisation...");
|
||||||
|
debug.setindex(-666);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
regs.set(vm.getRegs(goals[scenar.getselected()].level));
|
||||||
|
debug.setindex(vm.getEIP(code));
|
||||||
|
}
|
||||||
if (!code->executed)
|
if (!code->executed)
|
||||||
{
|
{
|
||||||
finalcut::FApplication::setDarkTheme();
|
finalcut::FApplication::setDarkTheme();
|
||||||
regs.set("En attente d'initialisation...");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
finalcut::FApplication::setDefaultTheme();
|
finalcut::FApplication::setDefaultTheme();
|
||||||
regs.set(vm.getRegs(goals[scenar.getselected()].level));
|
|
||||||
}
|
}
|
||||||
auto root_widget = getRootWidget();
|
auto root_widget = getRootWidget();
|
||||||
root_widget->resetColors();
|
root_widget->resetColors();
|
||||||
|
|
26
ia86.h
26
ia86.h
|
@ -167,6 +167,27 @@ class ScenarioWindow final : public finalcut::FDialog
|
||||||
finalcut::FListView listview{this};
|
finalcut::FListView listview{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
namespace finalcut
|
||||||
|
{
|
||||||
|
class FListViewEx final : public finalcut::FListView
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Using-declaration
|
||||||
|
using FWidget::setGeometry;
|
||||||
|
using FListViewItems = std::list<FListViewItem*>;
|
||||||
|
// Constructor
|
||||||
|
explicit FListViewEx (FWidget* = nullptr);
|
||||||
|
// Disable copy constructor
|
||||||
|
FListViewEx (const FListViewEx&) = delete;
|
||||||
|
// Destructor
|
||||||
|
~FListViewEx() override;
|
||||||
|
// Disable copy assignment operator (=)
|
||||||
|
FListViewEx& operator = (const FListViewEx&) = delete;
|
||||||
|
void setindex(int index);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class InstructionWindow final : public finalcut::FDialog
|
class InstructionWindow final : public finalcut::FDialog
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -182,13 +203,14 @@ class InstructionWindow final : public finalcut::FDialog
|
||||||
std::vector<std::array<std::string, 5>> get();
|
std::vector<std::array<std::string, 5>> get();
|
||||||
void set(std::vector<std::array<std::string, 5>> src);
|
void set(std::vector<std::array<std::string, 5>> src);
|
||||||
void clear();
|
void clear();
|
||||||
|
void setindex(int index);
|
||||||
private:
|
private:
|
||||||
// Method
|
// Method
|
||||||
std::vector<std::array<std::string, 5>> content;
|
std::vector<std::array<std::string, 5>> content;
|
||||||
void initLayout() override;
|
void initLayout() override;
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
// Data members
|
// Data members
|
||||||
finalcut::FListView listview{this};
|
finalcut::FListViewEx listview{this};
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextEditWindow final : public finalcut::FDialog
|
class TextEditWindow final : public finalcut::FDialog
|
||||||
|
@ -283,6 +305,7 @@ class VMEngine
|
||||||
void Prepare(State *init, Code *code);
|
void Prepare(State *init, Code *code);
|
||||||
void SetMem(State *init, Code *code);
|
void SetMem(State *init, Code *code);
|
||||||
void SetRegs(State *init, Code *code);
|
void SetRegs(State *init, Code *code);
|
||||||
|
int getEIP(Code *code);
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
void Close();
|
void Close();
|
||||||
|
@ -323,7 +346,6 @@ class Menu final : public finalcut::FDialog
|
||||||
void about();
|
void about();
|
||||||
void AdjustWindows();
|
void AdjustWindows();
|
||||||
void initWindows();
|
void initWindows();
|
||||||
void initIA();
|
|
||||||
void initLayout() override;
|
void initLayout() override;
|
||||||
void adjustSize() override;
|
void adjustSize() override;
|
||||||
// Event handler
|
// Event handler
|
||||||
|
|
Loading…
Reference in New Issue