Add rnx and rnx_mitm service

This commit is contained in:
Sandla Honerla 2019-06-04 12:29:08 +05:30
parent f29ab6d0f3
commit 74a64ead81
5 changed files with 57 additions and 21 deletions

View File

@ -0,0 +1,10 @@
// Just a stub to get reinx only apps launching
#include <svc.h>
int main(){
// This should do nothing but hang forever
while(1){
//Do nothing
svcSleepThread(100000000);
};
};

View File

@ -34,11 +34,9 @@ static FsFileSystem g_HblFileSystem = {};
static std::vector<u64> g_created_titles;
static bool g_has_initialized_fs_dev = false;
/* Default to Key R, hold disables override, HBL at atmosphere/hbl.nsp. */
static bool g_mounted_hbl_nsp = false;
static char g_hbl_sd_path[FS_MAX_PATH+1] = "@Sdcard:/atmosphere/hbl.nsp\x00";
static OverrideKey g_default_override_key = {
.key_combination = KEY_L,
.override_by_default = true
@ -105,7 +103,6 @@ Result ContentManagement::MountCode(u64 tid, FsStorageId sid) {
if (R_FAILED(rc = fsldrOpenCodeFileSystem(tid, path, &g_CodeFileSystem))) {
return rc;
}
fsdevMountDevice("code", g_CodeFileSystem);
TryMountHblNspOnSd();
return rc;
@ -419,7 +416,6 @@ static bool ShouldOverrideContents(OverrideKey *cfg) {
bool keys_triggered = (R_SUCCEEDED(HidManagement::GetKeysHeld(&kDown)) && ((kDown & cfg->key_combination) != 0));
return g_has_initialized_fs_dev && (cfg->override_by_default ^ keys_triggered);
}
bool ContentManagement::ShouldOverrideContentsWithHBL(u64 tid) {
if (g_mounted_hbl_nsp && tid >= TitleId_AppletStart && HasCreatedTitle(TitleId_AppletQlaunch)) {
/* Return whether we should override contents with HBL. */
@ -429,23 +425,11 @@ bool ContentManagement::ShouldOverrideContentsWithHBL(u64 tid) {
return false;
}
}
bool ContentManagement::ShouldOverrideContentsWithSD(u64 tid) {
if (g_has_initialized_fs_dev) {
if (tid >= TitleId_AppletStart && HasCreatedTitle(TitleId_AppletQlaunch)) {
/* Check whether we should override with non-HBL. */
OverrideKey title_cfg = GetTitleOverrideKey(tid);
return ShouldOverrideContents(&title_cfg);
} else {
/* Always redirect before qlaunch. */
return true;
}
} else {
/* Never redirect before we can do so. */
return false;
}
bool ContentManagement::ShouldOverrideContentsWithSD(u64 tid){
// Aliases
Result rc = ContentManagement::ShouldOverrideContentsWithHBL(tid);
return rc;
}
/* SetExternalContentSource extension */
ContentManagement::ExternalContentSource *ContentManagement::GetExternalContentSource(u64 tid) {
auto i = g_external_content_sources.find(tid);

View File

@ -26,7 +26,8 @@
#include "ldr_process_manager.hpp"
#include "ldr_debug_monitor.hpp"
#include "ldr_shell.hpp"
// For stub rnx service
#include "ldr_rei.hpp"
extern "C" {
extern u32 __start__;
@ -113,6 +114,7 @@ int main(int argc, char **argv)
static auto s_server_manager = WaitableManager<LoaderServerOptions>(1);
/* Add services to manager. */
s_server_manager.AddWaitable(new ServiceServer<RNXService>("rnx", 1));
s_server_manager.AddWaitable(new ServiceServer<ProcessManagerService>("ldr:pm", 1));
s_server_manager.AddWaitable(new ServiceServer<ShellService>("ldr:shel", 3));
s_server_manager.AddWaitable(new ServiceServer<DebugMonitorService>("ldr:dmnt", 2));

View File

@ -0,0 +1,19 @@
#include <switch.h>
#include <stratosphere.hpp>
#include <switch.h>
#include <stratosphere.hpp>
#include <stdio.h>
#include "ldr_rei.hpp"
u64 HbOverrideTid = 0x010000000000100D;
Result RNXService::GetReiNXVersion(Out<u32> maj, Out<u32> min) {
// PASS IN 2 and 4 to trick reinx appls. This is to trick apps into working with ams
*maj.GetPointer() = 2;
*min.GetPointer() = 4;
return 0;
}
// For deltalaunch
Result RNXService::SetHbTidForDelta(u64 tid) {
// Hardcode the tid
HbOverrideTid = tid;
return 0;
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <switch.h>
#include <stratosphere.hpp>
#include "ldr_content_management.hpp"
enum RNXServiceCmd {
RNX_CMD_GetReiNXVersion = 0,
RNX_CMD_SetHbTidForDelta = 1,
};
class RNXService final : public IServiceObject {
private:
/* Actual commands. */
Result GetReiNXVersion(Out<u32> maj, Out<u32> min);
Result SetHbTidForDelta(u64 tid);
public:
DEFINE_SERVICE_DISPATCH_TABLE {
MakeServiceCommandMeta<RNX_CMD_GetReiNXVersion, &RNXService::GetReiNXVersion>(),
MakeServiceCommandMeta<RNX_CMD_SetHbTidForDelta, &RNXService::SetHbTidForDelta>(),
};
};