Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developer menu should have seperate folder to drag and drop menus so they can be loaded #54

Open
TheRouletteBoi opened this issue Mar 27, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@TheRouletteBoi
Copy link
Owner

The Developer menu should have seperate folder to drag and drop .sprx or .bin menus so they can be loaded.

Example /dev_hdd0/plugins/RouLetteVshMenu/modmenus/autoscan this will scan all .sprx in the folder and load them up into a submenu. Maybe we can do the same for all .sprx in the tmp folder /dev_hdd0/tmp/plugin.sprx

other names that might be better
/dev_hdd0/plugins/RouLetteVshMenu/menuloader/sprx/
/dev_hdd0/plugins/RouLetteVshMenu/menuloader/bin/

void DeveloperSubmenu()
{
g_Menu.Title(L"Developer");
g_Menu.Option(L"Load /dev_hdd0/tmp/plugin.sprx into game process").Action([]
{
if (FileExist("/dev_hdd0/tmp/plugin.sprx"))
{
bool couldLoad = GamePatching::StartSprx("/dev_hdd0/tmp/plugin.sprx");
if (couldLoad)
vsh::ShowNavigationMessage(L"Successfully loaded /dev_hdd0/tmp/plugin.sprx into process");
else
vsh::ShowNavigationMessage(L"You are not in game");
}
else
{
vsh::ShowNavigationMessage(L"File does not exist");
}
});
g_Menu.Option(L"Unload /dev_hdd0/tmp/plugin.sprx from game process").Action([]
{
if (FileExist("/dev_hdd0/tmp/plugin.sprx"))
{
sys_pid_t processId = vsh::GetGameProcessId();
if (processId)
{
sys_prx_id_t prxId = GamePatching::GetProcessModuleIdByFilePath(processId, "/dev_hdd0/tmp/plugin.sprx");
if (prxId)
{
ps3mapi_unload_process_modules(vsh::GetGameProcessId(), prxId);
vsh::ShowNavigationMessage(L"Successfully unloaded /dev_hdd0/tmp/plugin.sprx from process");
}
else
vsh::ShowNavigationMessage(L"sprx is not loaded into game");
}
else
vsh::ShowNavigationMessage(L"You are not in game");
}
else
{
vsh::ShowNavigationMessage(L"File does not exist");
}
});
static uint64_t pageTable[2]{};
g_Menu.Option(L"Load /dev_hdd0/tmp/payload.bin into game process").Action([]
{
const char* fileName = "/dev_hdd0/tmp/payload.bin";
if (FileExist(fileName))
{
// I need to find a way to get file size on disk; see https://imgur.com/a/bSFHbGT
CellFsStat st;
cellFsStat(fileName, &st);
uint64_t fileSize = st.st_size;
uint64_t blockSize = st.st_blksize;
uint64_t payloadPadding = 0x4000; // https://imgur.com/a/aFEfVIM
uint64_t fileSizeOnDisk = fileSize + (4 * blockSize);
uint64_t fileSizeOnDisk2 = fileSize + payloadPadding;
vsh::printf("fileSize = %d | blockSize = %d | payloadPadding = %d | fileSizeOnDisk = %d | fileSizeOnDisk2 = %d\n", fileSize, blockSize, payloadPadding, fileSizeOnDisk, fileSizeOnDisk2);
if (GamePatching::StartPayload(fileName, KB(4), 0x7D0, 0x4000, pageTable))
{
vsh::printf("Payload injected at table[0] = 0x%016llX\n", pageTable[0]);
vsh::printf("Payload injected at table[1] = 0x%016llX\n", pageTable[1]);
vsh::ShowNavigationMessage(L"Successfully loaded /dev_hdd0/tmp/payload.bin into process");
}
}
else
{
vsh::ShowNavigationMessage(L"File does not exist");
}
});
g_Menu.Option(L"Unload /dev_hdd0/tmp/payload.bin from game process").Action([]
{
sys_pid_t processId = vsh::GetGameProcessId();
if (processId)
{
if (pageTable[0] && pageTable[1])
{
int ret = ps3mapi_process_page_free(processId, 0x2F, pageTable);
vsh::memset(pageTable, 0, sizeof(pageTable));
if (ret == SUCCEEDED)
vsh::ShowNavigationMessage(L"page sucessfully free'd");
else
{
vsh::printf("failed to free page 0x%X\n", ret);
vsh::ShowNavigationMessage(L"failed to free page");
}
}
else
{
vsh::ShowNavigationMessage(L"page has not been allocated");
}
}
else
vsh::ShowNavigationMessage(L"You are not in game");
});
}

@TheRouletteBoi TheRouletteBoi added the enhancement New feature or request label Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant