Skip to content

Commit

Permalink
Add mechanism for handling version differences and update for 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pixel-stuck committed May 24, 2022
1 parent 9422337 commit bac025d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 3 deletions.
3 changes: 2 additions & 1 deletion source/nn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@

#include "nn/fs.hpp"
#include "nn/os.hpp"
#include "nn/time.hpp"
#include "nn/time.hpp"
#include "nn/oe.hpp"
3 changes: 3 additions & 0 deletions source/nn/oe.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

#include "nn/oe/application_proxy.hpp"
13 changes: 13 additions & 0 deletions source/nn/oe/application_proxy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once

#include <nn/nn_common.hpp>

namespace nn::oe
{
typedef struct
{
char displayVersion[16];
} DisplayVersion;

void GetDisplayVersion(DisplayVersion *displayVersion);
}
31 changes: 29 additions & 2 deletions source/program/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,45 @@ MAKE_HOOK_T(Result, romMounted, (char const *path, void *romCache, unsigned long
return res;
);

typedef struct
{
uintptr_t crc64;
uintptr_t CFilePathStrIdCtor;
} functionOffsets;

/* Handle version differences */
void getVersionOffsets(functionOffsets *offsets)
{
nn::oe::DisplayVersion dispVer;
nn::oe::GetDisplayVersion(&dispVer);

if(strcmp(dispVer.displayVersion, "2.1.0") == 0)
{
offsets->crc64 = 0x1570;
offsets->CFilePathStrIdCtor = 0x166C8;
}
else /* 1.0.0 - 2.0.0 */
{
offsets->crc64 = 0x1570;
offsets->CFilePathStrIdCtor = 0x16624;
}
}

extern "C" void exl_main(void* x0, void* x1)
{
functionOffsets offsets;
/* Setup hooking enviroment. */
envSetOwnProcessHandle(exl::util::proc_handle::Get());
exl::hook::Initialize();

getVersionOffsets(&offsets);

/* Hook functions we care about */
INJECT_HOOK_T(0x16624, forceRomfs);
INJECT_HOOK_T(offsets.CFilePathStrIdCtor, forceRomfs);
INJECT_HOOK_T(nn::fs::MountRom, romMounted);

/* Get the address of dread's crc64 function */
crc64 = (u64 (*)(char const *, u64))exl::hook::GetTargetOffset(0x1570);
crc64 = (u64 (*)(char const *, u64))exl::hook::GetTargetOffset(offsets.crc64);
}

extern "C" NORETURN void exl_exception_entry()
Expand Down

0 comments on commit bac025d

Please sign in to comment.