diff --git a/src/Core/PS4/Linker.cpp b/src/Core/PS4/Linker.cpp index fa66ed3d..98ce25a9 100644 --- a/src/Core/PS4/Linker.cpp +++ b/src/Core/PS4/Linker.cpp @@ -11,6 +11,22 @@ Linker::~Linker() Module* Linker::LoadModule(const std::string& elf_name) { auto* m = new Module; + m->elf = new Elf; + m->elf->Open(elf_name);//load elf + + m_modules.push_back(m);//added it to load modules return m; +} + +Module* Linker::FindModule(/*u32 id*/) +{ + //find module . TODO atm we only have 1 module so we don't need to iterate on vector + Module* m = m_modules.at(0); + + if (m) + { + return m; + } + return nullptr; } \ No newline at end of file diff --git a/src/Core/PS4/Linker.h b/src/Core/PS4/Linker.h index 6543e648..7a098489 100644 --- a/src/Core/PS4/Linker.h +++ b/src/Core/PS4/Linker.h @@ -1,5 +1,6 @@ #pragma once #include "../../Loader/Elf.h" +#include /*this struct keeps neccesary info about loaded modules.Main executeable is included too as well*/ struct Module @@ -14,4 +15,8 @@ public: virtual ~Linker(); Module* LoadModule(const std::string& elf_name); + Module* FindModule(/*u32 id*/); + +private: + std::vector m_modules; }; \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index e910e5b4..8fdb32ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,14 +24,18 @@ #ifdef __EMSCRIPTEN__ #include "../libs/emscripten/emscripten_mainloop_stub.h" #endif +#include "Core/PS4/Linker.h" +#include "Util/Singleton.h" + // Main code int main(int argc, char* argv[]) { logging::init(true);//init logging const char* const path = argv[1]; //argument 1 is the path of self file to boot - Elf* elf = new Elf; - elf->Open(path); + auto* linker = Singleton::Instance(); + auto *module =linker->LoadModule(path);//load main executable + // Setup SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD) != 0) @@ -188,8 +192,8 @@ int main(int argc, char* argv[]) show_another_window = false; ImGui::End(); } - - ElfViewer elfview(elf); + auto* linker = Singleton::Instance(); + ElfViewer elfview(linker->FindModule()->elf); elfview.display(show_another_window); // Rendering ImGui::Render();