Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ BinPackParameters: false
BinPackArguments: false
KeepEmptyLinesAtTheStartOfBlocks: false
EmptyLineAfterAccessModifier: Never
BraceWrapping:
AfterExternBlock: false
IndentExternBlock: NoIndent
...
4 changes: 2 additions & 2 deletions common/HDE/HDE64.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ extern "C"
{
#endif

/* __cdecl */
unsigned int hde64_disasm(const void* code, hde64s* hs);
/* __cdecl */
unsigned int hde64_disasm(const void* code, hde64s* hs);

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions common/HDE/Table64.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
extern "C"
{
#endif
// clang-format off
// clang-format off
unsigned char hde64_table[] = {
0xa5,0xaa,0xa5,0xb8,0xa5,0xaa,0xa5,0xaa,0xa5,0xb8,0xa5,0xb8,0xa5,0xb8,0xa5,
0xb8,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xac,0xc0,0xcc,0xc0,0xa1,0xa1,
Expand Down Expand Up @@ -79,7 +79,7 @@ extern "C"
0x00,0xb4,0xff,0x00,0xb5,0xff,0x00,0xc3,0x01,0x00,0xc7,0xff,0xbf,0xe7,0x08,
0x00,0xf0,0x02,0x00
};
// clang-format on
// clang-format on

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion common/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <stdint.h>

#if defined(__cplusplus)
extern "C"
extern "C"
{
#endif

Expand Down
2 changes: 1 addition & 1 deletion common/ini.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ typedef struct
} INIFile;

#if defined(__cplusplus)
extern "C"
extern "C"
{
#endif

Expand Down
10 changes: 5 additions & 5 deletions common/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,17 +590,17 @@ static void CaveBlockInit(void)
if (!once)
{
const int pid = getpid();
//sceKernelMprotect(cavePad, cavePadSize, 7);
// sceKernelMprotect(cavePad, cavePadSize, 7);
static const uint8_t m[] = {0xB8, 0x01, 0x00, 0x00, 0x00, 0xC3};
sys_proc_rw(pid, (uintptr_t)cavePadFunc, m, sizeof(m), 1);
int (*test)(void);
test = (void*)cavePadFunc;
//memcpy(cavePad, m, sizeof(m));
// memcpy(cavePad, m, sizeof(m));
final_printf("checking executable code, it returned %d\n", test());
sys_proc_memset(pid, (uintptr_t)cavePadFunc, 0xcc, MAX_CAVE_SIZE);
//memset(cavePad, 0xcc, cavePadSize);
// DWORD temp = caveInstSize = 0;
// VirtualProtect(cavePad, cavePadSize, PAGE_EXECUTE_WRITECOPY, &temp);
// memset(cavePad, 0xcc, cavePadSize);
// DWORD temp = caveInstSize = 0;
// VirtualProtect(cavePad, cavePadSize, PAGE_EXECUTE_WRITECOPY, &temp);
once = true;
printf("cavePad setup at 0x%p! Size %ld\n", (void*)cavePadFunc, MAX_CAVE_SIZE);
}
Expand Down
3 changes: 1 addition & 2 deletions common/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

#include "cave.inc.c"

#define _countof(a) sizeof(a) / sizeof(*a)
#define _countof_1(a) (_countof(a) - 1)
#include "plugin_common.h"

/*
* @brief Scan for a given byte pattern on a module
Expand Down
6 changes: 6 additions & 0 deletions common/path.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

// clang-format off

#define BASE_PATH "/data/hen"
#define USER_PLUGIN_PATH BASE_PATH "/plugins"
#define HEN_INI "hen.ini"
Expand All @@ -16,3 +18,7 @@

#define SHELLUI_DATA_PATH BASE_PATH "/shellui_data"
#define SHELLUI_HEN_SETTINGS SHELLUI_DATA_PATH "/hen_settings.xml"
#define SHELLUI_ICONS_PATH SHELLUI_DATA_PATH "/icons"
#define SHELLUI_HEN_SETTINGS_ICON_PATH SHELLUI_ICONS_PATH "/hen_settings_icon.png"

// clang-format on
3 changes: 3 additions & 0 deletions common/plugin_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@

// Writes null term to copied string
#define strncpy0(d, s, sz) strncpy(d, s, sz), d[sz - 1] = '\0'

#define _countof(a) sizeof(a) / sizeof(*a)
#define _countof_1(a) (_countof(a) - 1)
53 changes: 28 additions & 25 deletions common/stringid.h
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
#pragma once

// https://github.com/icemesh/StringId/blob/main/StringId64/main.c

#include <stdint.h>
#include <wchar.h>

static
#if defined(__cplusplus)
constexpr
#define CXX_CONSTEXPR constexpr
#else
#define CXX_CONSTEXPR
#endif
// https://github.com/icemesh/StringId/blob/main/StringId64/main.c
uint64_t ToStringId64A(const char* str)

static CXX_CONSTEXPR uint64_t ToStringId64A(const char* str)
{
uint64_t base = 0xCBF29CE484222325;
if(*str)
{
do{
base = 0x100000001B3 * (base ^ *str++);
}while(*str);
}
return base;
uint64_t base = 0xCBF29CE484222325;
if (*str)
{
do
{
base = 0x100000001B3 * (base ^ *str++);
} while (*str);
}
return base;
}

static
#if defined(__cplusplus)
constexpr
#endif
uint64_t ToStringId64W(const wchar_t* str)
static CXX_CONSTEXPR uint64_t ToStringId64W(const wchar_t* str)
{
uint64_t base = 0xCBF29CE484222325;
if(*str)
{
do{
base = 0x100000001B3 * (base ^ *str++);
}while(*str);
}
return base;
uint64_t base = 0xCBF29CE484222325;
if (*str)
{
do
{
base = 0x100000001B3 * (base ^ *str++);
} while (*str);
}
return base;
}

#undef CXX_CONSTEXPR

#define SID(x) ToStringId64A(x)
#define wSID(x) ToStringId64W(x)
41 changes: 21 additions & 20 deletions plugin_loader/source/lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ static void loadPlugins(SceEntry* args)
"m_titleid %s\n"
"m_category %s\n"
"m_appver %s\n",
info.pid, curr_pid,
info.pid,
curr_pid,
info.m_titleid,
info.m_category,
info.m_appver);
Expand All @@ -109,23 +110,23 @@ static void loadPlugins(SceEntry* args)

extern "C"
{
attr_public const char* g_pluginName = "plugin_loader";
attr_public const char* g_pluginDesc = "Plugin loader.";
attr_public const char* g_pluginAuth = "illusiony";
attr_public const char* g_pluginVersion = "Git Commit: " GIT_COMMIT
"\n"
"Git Branch: " GIT_VER
"\n"
"Git Commit Number: " GIT_NUM_STR
"\n"
"Built: " BUILD_DATE; // 1.00
attr_public int plugin_load(SceEntry* args, const void* atexit_handler)
{
loadPlugins(args);
return 0;
}
attr_public int plugin_unload(SceEntry* args, const void* atexit_handler)
{
return 0;
}
attr_public const char* g_pluginName = "plugin_loader";
attr_public const char* g_pluginDesc = "Plugin loader.";
attr_public const char* g_pluginAuth = "illusiony";
attr_public const char* g_pluginVersion = "Git Commit: " GIT_COMMIT
"\n"
"Git Branch: " GIT_VER
"\n"
"Git Commit Number: " GIT_NUM_STR
"\n"
"Built: " BUILD_DATE; // 1.00
attr_public int plugin_load(SceEntry* args, const void* atexit_handler)
{
loadPlugins(args);
return 0;
}
attr_public int plugin_unload(SceEntry* args, const void* atexit_handler)
{
return 0;
}
}
1 change: 1 addition & 0 deletions plugin_mono/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ endif

bundle_data:
xxd -i data/hen_settings.xml | sed 's/^unsigned /static const unsigned /' > source/hen_settings.inc.c
xxd -i data/hen_settings_icon.png | sed 's/^unsigned /static const unsigned /' > source/hen_settings_icon.inc.c

$(INTDIR):
mkdir -p $(INTDIR)
Expand Down
Binary file added plugin_mono/data/hen_settings_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 26 additions & 7 deletions plugin_mono/source/lib.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
extern "C"
{

#include "../../common/entry.h"

#include <stdint.h>
Expand All @@ -22,6 +21,7 @@ extern "C"

#include "patches.h"

#include "hen_settings_icon.inc.c"
#include "hen_settings.inc.c"
#include "../../common/file.h"

Expand Down Expand Up @@ -77,8 +77,6 @@ void PrintTimeTick(void)
static bool once = false;
if (!once)
{
Root_Domain = mono_get_root_domain();
if (Root_Domain)
{
void* app_exe = mono_get_image("/app0/psm/Application/app.exe");
if (app_exe)
Expand All @@ -92,8 +90,6 @@ void PrintTimeTick(void)
}
}
UploadNewCorelibStreamReader();
UploadNewPkgInstallerPath(App_Exe);
UploadOnBranch(App_Exe);
MainThreadCheck();
}
once = true;
Expand Down Expand Up @@ -173,6 +169,28 @@ static int sceKernelLoadStartModuleInternalForMono_Hook(const char* param_1, voi
RunPost(md);
test = true;
}
else if (test)
{
static bool once = false;
if (!once)
{
if (!Root_Domain)
{
Root_Domain = mono_get_root_domain();
}
if (Root_Domain)
{
App_Exe = mono_get_image("/app0/psm/Application/app.exe");
if (App_Exe)
{
ffinal_printf("app_exe: 0x%p\n", App_Exe);
UploadNewPkgInstallerPath(App_Exe);
UploadOnBranch(App_Exe);
once = true;
}
}
}
}
return md;
}

Expand All @@ -193,11 +211,13 @@ static void UploadMonoCall(void)

attr_public int plugin_load(struct SceEntry* args)
{
open_console();
mkdir(BASE_PATH, 0777);
mkdir(SHELLUI_DATA_PATH, 0777);
mkdir(SHELLUI_ICONS_PATH, 0777);
mkdir(USER_PLUGIN_PATH, 0777);
write_file(SHELLUI_HEN_SETTINGS, data_hen_settings_xml, data_hen_settings_xml_len);
open_console();
write_file(SHELLUI_HEN_SETTINGS_ICON_PATH, data_hen_settings_icon_png, data_hen_settings_icon_png_len);
printf("====\n\nHello from mono module\n\n====\n");
if (0 && file_exists_temp(g_pluginName) == 0)
{
Expand All @@ -209,5 +229,4 @@ attr_public int plugin_load(struct SceEntry* args)
UploadMonoCall();
return 0;
}

}
2 changes: 1 addition & 1 deletion plugin_mono/source/mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ MonoString* Mono_Add_String(MonoString* monoStr, const char* cStr)
{
MonoString* exc_str = mono_object_to_string(exc, NULL);
char* utf8 = mono_string_to_utf8(exc_str);
final_printf( "Exception: %s\n", utf8);
final_printf("Exception: %s\n", utf8);
mono_free(utf8);
return NULL;
}
Expand Down
Loading