Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Commit

Permalink
Improvements to the way handling menu events works.
Browse files Browse the repository at this point in the history
- Menu events now dont have to iterate through the map rather finding the correct key.
- Continued work on implimenting the Payload Loader.
  • Loading branch information
OSM-Made committed Jun 4, 2021
1 parent 7ba8c2e commit 60180c8
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 259 deletions.
2 changes: 1 addition & 1 deletion Loader/Kernel/include/Resolver/Resolver-755.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(SOFTWARE_VERSION_672)
#if defined(SOFTWARE_VERSION_755)

/* Util */
#define addr_Xfast_syscall 0x1C0
Expand Down
4 changes: 2 additions & 2 deletions Loader/Kernel/include/Resolver/Resolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#include "Resolver-505.hpp"
#include "Resolver-672.hpp"
//#include "Resolver-702.hpp"
//#include "Resolver-755.hpp"
#include "Resolver-702.hpp"
#include "Resolver-755.hpp"

/* Util */
extern struct sysentvec* sysvec;
Expand Down
2 changes: 1 addition & 1 deletion Loader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
+$(MAKE) -C Userland pack_resources
+$(MAKE) -C Userland

objcopy -O binary Userland/Userland.elf ../Orbis-Toolbox-$(VERSION).bin
objcopy -O binary Userland/Userland.elf ../Build/Orbis-Toolbox-$(VERSION).bin

printf "\e[1m\e[32m[%0.2f Build Sucess!]\033[37m\n" "$$(($(VERSION) * 1))e-2"

Expand Down
2 changes: 1 addition & 1 deletion Loader/Userland/include/Resolver/Resolver-702.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(SOFTWARE_VERSION_672)
#if defined(SOFTWARE_VERSION_702)

/* Util */
#define addr_Xfast_syscall 0x1C0
Expand Down
2 changes: 1 addition & 1 deletion Loader/Userland/include/Resolver/Resolver-755.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(SOFTWARE_VERSION_672)
#if defined(SOFTWARE_VERSION_755)

/* Util */
#define addr_Xfast_syscall 0x1C0
Expand Down
38 changes: 33 additions & 5 deletions Loader/Userland/source/Util/Resources.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,38 @@ int Write_File(const char* File, char* Data, size_t size)
}
}

int MakeDir(const char* Dir)
int MakeDir(char* Dir, ...)
{
Log("Creating Directory \"%s\"...", Dir);
return sceKernelMkdir(Dir, 0777);
char buffer[0x400] = { 0 };
va_list args;
va_start(args, Dir);
vsprintf(buffer, Dir, args);
va_end(args);

Log("Creating Directory \"%s\"...", buffer);
return sceKernelMkdir(buffer, 0777);
}

void Install_Daemon(const char* TitleId, char* Eboot_start, char* Eboot_end, char* Param_sfo_start, char* Param_sfo_end, char* Icon_start, char* Icon_end)
{
Log("Installing Daemon %s", TitleId);

Log("Creating Directories...");
MakeDir("/system/vsh/app/%s", TitleId);
MakeDir("/system/vsh/app/%s/sce_module", TitleId);
MakeDir("/system/vsh/app/%s/sce_sys", TitleId);

Log("Writing Files...");
char Eboot_Dir[PATH_MAX], Param_sfo_Dir[PATH_MAX], Icon_Dir[PATH_MAX];
sprintf(Eboot_Dir, "/system/vsh/app/%s/eboot.bin", TitleId);
sprintf(Param_sfo_Dir, "/system/vsh/app/%s/sce_sys/icon0.png", TitleId);
sprintf(Icon_Dir, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId);

_Write_File("/data/Orbis Toolbox/Icons/icon_daemon.png", Eboot_start, Eboot_end);
_Write_File("/data/Orbis Toolbox/Icons/icon_payload.png", Param_sfo_start, Param_sfo_end);
_Write_File("/data/Orbis Toolbox/Icons/icon_pkg.png", Icon_start, Icon_end);

Log("Installing Daemon %s Complete!", TitleId);
}

void Install_Resources()
Expand Down Expand Up @@ -89,8 +117,8 @@ void Install_Resources()
_Write_File("/data/Orbis Toolbox/Icons/icon_system_settings.png", _binary_Resources_icon_system_settings_bin_start, _binary_Resources_icon_system_settings_bin_end);
_Write_File("/data/Orbis Toolbox/Icons/icon_toolbox.png", _binary_Resources_icon_toolbox_bin_start, _binary_Resources_icon_toolbox_bin_end);

//Included Daemons
//Install payload loader daemon
Log("Installing Daemons...");
//Install_Daemon("PLDR00000", ); //Install payload loader daemon

Log("Install_Resources() -> Sucess!");
}
120 changes: 120 additions & 0 deletions Orbis Toolbox/Daemons.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
#include "Common.h"
#include "Daemons.h"

#include "SysfileUtilWrapper.h"
#include "LncUtil.h"

bool Start_Daemon(char* TitleId)
{
if (!Is_Daemon_Running(TitleId))
{
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
LncUtil::LaunchApp(TitleId, 0, 0, &p);

if (!Is_Daemon_Running(TitleId))
return false;
}

return true;
}

bool Stop_Daemon(char* TitleId)
{
int AppId = LncUtil::GetAppId(TitleId);
if (AppId > 0)
{
LncUtil::KillApp(AppId);

if (Is_Daemon_Running(TitleId))
return false;
}

return true;
}

bool Is_Daemon_Running(char* TitleId)
{
return (LncUtil::GetAppId(TitleId) > 0);
}

/*
Will start or stop a Daemon depending on its state.
TitleId - A string representing the Daemons title Index usually in form of XXXX#####
Restart - If the Daemon is already running will stop and restart it.
*/
bool Start_Stop_Daemon(char* TitleId, bool Restart)
{
int AppId = LncUtil::GetAppId(TitleId);
if (AppId > 0)
{
LncUtil::KillApp(AppId);

if ((LncUtil::GetAppId(TitleId) <= 0) && Restart)
return Start_Stop_Daemon(TitleId, false);
else if (LncUtil::GetAppId(TitleId) <= 0)
return true;
else
return false;
}
else
{
LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
LncUtil::LaunchApp(TitleId, 0, 0, &p);

return (LncUtil::GetAppId(TitleId) > 0);
}
}

void Add_Daemon(char* dent)
{
char TitleId[10];
strcpy(TitleId, dent);

char Id_Name[0x100];
sprintf(Id_Name, "id_%s", TitleId);
klog("%s\n", Id_Name);

char Icon_Path[PATH_MAX];
sprintf(Icon_Path, "file://system/vsh/app/%s/sce_sys/icon0.png", TitleId);
klog("%s\n", Icon_Path);

char SFO_Path[PATH_MAX];
sprintf(SFO_Path, "/system/vsh/app/%s/sce_sys/param.sfo", TitleId);
klog("%s\n", SFO_Path);

UI::Utilities::AddMenuItem(UI::Utilities::ElementData(Id_Name, SysfileUtilWrapper::GetTitle(SFO_Path), SysfileUtilWrapper::GetDescription(SFO_Path), Icon_Path));

Menu::Add_Option(Id_Name, [TitleId, Id_Name]() -> void {

int AppId = LncUtil::GetAppId(TitleId);
if (AppId > 0) //App is Currently Running.
{
UI::Utilities::Set_Value(Id_Name, "Stopping");
UI::Utilities::ResetMenuItem(Id_Name);

//Kill the app.
LncUtil::KillApp(AppId);

//Check to see if it worked.
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
UI::Utilities::ResetMenuItem(Id_Name);
}
else
{
UI::Utilities::Set_Value(Id_Name, "Starting");
UI::Utilities::ResetMenuItem(Id_Name);

LncUtil::LaunchAppParam p = { sizeof(LncUtil::LaunchAppParam), -1, 0, 0, LncUtil::Flag_None };
LncUtil::LaunchApp(TitleId, 0, 0, &p);

//Check to see if it worked.
UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
UI::Utilities::ResetMenuItem(Id_Name);
}

});

UI::Utilities::Set_Value(Id_Name, (LncUtil::GetAppId(TitleId) > 0) ? "Running" : "Stopped");
UI::Utilities::ResetMenuItem(Id_Name);
}
7 changes: 7 additions & 0 deletions Orbis Toolbox/Daemons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
bool Start_Daemon(char* TitleId);
bool Stop_Daemon(char* TitleId);
bool Is_Daemon_Running(char* TitleId);
bool Start_Stop_Daemon(char* TitleId, bool Restart = false);

void Add_Daemon(char* dent);
Loading

0 comments on commit 60180c8

Please sign in to comment.