Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RusJJ committed Nov 30, 2023
1 parent e3103a3 commit 98360ce
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 54 deletions.
2 changes: 1 addition & 1 deletion ARMPatch
2 changes: 1 addition & 1 deletion curl
Submodule curl updated 250 files
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
}

/* Must Have for mods */
modlist->AddMod(amlmodinfo, 0, NULL);
modlist->AddMod(amlmodinfo, 0, "localpath (core)");
interfaces->Register("AMLInterface", aml);
interfaces->Register("AMLConfig", icfg);
InitCURL();
Expand Down
2 changes: 2 additions & 0 deletions mod/amlmod.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@

#ifdef __arm__
#define AML32
#define BYBIT(__32val, __64val) (__32val)
#elif defined __aarch64__
#define AML64
#define BYBIT(__32val, __64val) (__64val)
#else
#error This lib is supposed to work on ARM only!
#endif
Expand Down
2 changes: 1 addition & 1 deletion mod/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ bool Config::GetBool(const char* szKey, bool bDefaultValue, const char* szSectio

rgba_t Config::GetColor(const char* szKey, rgba_t clr, const char* szSection)
{
if(!m_bInitialized) return NULL;
if(!m_bInitialized) return rgba_t {0,0,0,0};
ConfigEntry entry; ConfigEntry* pRet = &entry;
pRet->m_pBoundCfg = this;
strxcpy(pRet->m_szMySection, szSection, sizeof(pRet->m_szMySection));
Expand Down
2 changes: 1 addition & 1 deletion modslist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void ModsList::PrintModsList(std::ofstream& logfile)
desc = item->pModDesc;

logfile << info->Name() << " (" << info->Author() << ", version " << info->VersionString() << ")\n";
logfile << " - GUID: " << info->GUID() << " | Path: " << desc->m_szLibPath << "\n";
logfile << " - GUID: " << info->GUID() << " | Base: 0x" << std::hex << std::uppercase << (uintptr_t)desc->m_pHandle << " | Path: " << desc->m_szLibPath << "\n";
}
}

Expand Down
83 changes: 37 additions & 46 deletions signal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,11 @@
#include <aml.h>
#include "xunwind.h"

#ifdef __arm__
#define AML32
#elif defined __aarch64__
#define AML64
#else
#error This lib is supposed to work on ARM only!
#endif

#define STACKDUMP_SIZE 1024
std::ofstream g_pLogFile;

struct sigaction newSigaction[7];
struct sigaction oldSigaction[7];
#ifdef IO_GITHUB_HEXHACKING_XUNWIND
static uintptr_t g_frames[128];
static size_t g_frames_sz = 0;
#endif
extern bool g_bSimplerCrashLog, g_bNoSPInLog, g_bNoModsInLog;

int SignalInnerId(int code)
Expand Down Expand Up @@ -202,7 +190,7 @@ void Handler(int sig, siginfo_t *si, void *ptr)

char path[320], pathText[320];
sprintf(path, "%s/aml_crashlog.txt", aml->GetAndroidDataRootPath());
sprintf(pathText, "Application has been crashed!\n\nCrashlog has been saved in %s", path);
sprintf(pathText, "Application has been crashed!\n\nCrashlog should be saved in %s", path);
g_pLogFile.open(path, std::ios::out | std::ios::trunc);

// Java doesnt work here and so crashing again and again?
Expand All @@ -215,7 +203,7 @@ void Handler(int sig, siginfo_t *si, void *ptr)

g_pLogFile << "Exception Signal " << sig << " - " << SignalEnum(sig) << " (" << CodeEnum(sig, si->si_code) << ")" << std::endl;
g_pLogFile << "Fault address: 0x" << std::hex << std::uppercase << faultAddr << std::nouppercase << std::endl;
g_pLogFile << "An overall reason of the crash: ";
g_pLogFile << "An overall reason of the crash:\n- ";
switch(sig)
{
case SIGABRT:
Expand Down Expand Up @@ -273,36 +261,36 @@ void Handler(int sig, siginfo_t *si, void *ptr)
g_pLogFile << std::endl;
}

g_pLogFile << std::endl << "Registers:" << std::endl;
g_pLogFile << "\n----------------------------------------------------\nRegisters:" << std::endl;
#ifdef AML32
g_pLogFile << "R0: " << std::dec << mcontext->arm_r0 << " 0x" << std::hex << std::uppercase << mcontext->arm_r0 << std::endl;
g_pLogFile << "R1: " << std::dec << mcontext->arm_r1 << " 0x" << std::hex << std::uppercase << mcontext->arm_r1 << std::endl;
g_pLogFile << "R2: " << std::dec << mcontext->arm_r2 << " 0x" << std::hex << std::uppercase << mcontext->arm_r2 << std::endl;
g_pLogFile << "R3: " << std::dec << mcontext->arm_r3 << " 0x" << std::hex << std::uppercase << mcontext->arm_r3 << std::endl;
g_pLogFile << "R4: " << std::dec << mcontext->arm_r4 << " 0x" << std::hex << std::uppercase << mcontext->arm_r4 << std::endl;
g_pLogFile << "R5: " << std::dec << mcontext->arm_r5 << " 0x" << std::hex << std::uppercase << mcontext->arm_r5 << std::endl;
g_pLogFile << "R6: " << std::dec << mcontext->arm_r6 << " 0x" << std::hex << std::uppercase << mcontext->arm_r6 << std::endl;
g_pLogFile << "R7: " << std::dec << mcontext->arm_r7 << " 0x" << std::hex << std::uppercase << mcontext->arm_r7 << std::endl;
g_pLogFile << "R8: " << std::dec << mcontext->arm_r8 << " 0x" << std::hex << std::uppercase << mcontext->arm_r8 << std::endl;
g_pLogFile << "R9: " << std::dec << mcontext->arm_r9 << " 0x" << std::hex << std::uppercase << mcontext->arm_r9 << std::endl;
g_pLogFile << "R10: " << std::dec << mcontext->arm_r10 << " 0x" << std::hex << std::uppercase << mcontext->arm_r10 << std::endl;
g_pLogFile << "R11: " << std::dec << mcontext->arm_fp << " 0x" << std::hex << std::uppercase << mcontext->arm_fp << std::endl;
g_pLogFile << "R12: " << std::dec << mcontext->arm_ip << " 0x" << std::hex << std::uppercase << mcontext->arm_ip << std::endl;
g_pLogFile << "SP: " << std::dec << mcontext->arm_sp << " 0x" << std::hex << std::uppercase << mcontext->arm_sp << std::endl;
g_pLogFile << "LR: " << std::dec << mcontext->arm_lr << " 0x" << std::hex << std::uppercase << mcontext->arm_lr << std::endl;
g_pLogFile << "PC: " << std::dec << mcontext->arm_pc << " 0x" << std::hex << std::uppercase << mcontext->arm_pc << std::endl;
g_pLogFile << "R0: " << std::dec << mcontext->arm_r0 << " 0x" << std::hex << std::uppercase << mcontext->arm_r0 << std::endl;
g_pLogFile << "R1: " << std::dec << mcontext->arm_r1 << " 0x" << std::hex << std::uppercase << mcontext->arm_r1 << std::endl;
g_pLogFile << "R2: " << std::dec << mcontext->arm_r2 << " 0x" << std::hex << std::uppercase << mcontext->arm_r2 << std::endl;
g_pLogFile << "R3: " << std::dec << mcontext->arm_r3 << " 0x" << std::hex << std::uppercase << mcontext->arm_r3 << std::endl;
g_pLogFile << "R4: " << std::dec << mcontext->arm_r4 << " 0x" << std::hex << std::uppercase << mcontext->arm_r4 << std::endl;
g_pLogFile << "R5: " << std::dec << mcontext->arm_r5 << " 0x" << std::hex << std::uppercase << mcontext->arm_r5 << std::endl;
g_pLogFile << "R6: " << std::dec << mcontext->arm_r6 << " 0x" << std::hex << std::uppercase << mcontext->arm_r6 << std::endl;
g_pLogFile << "R7: " << std::dec << mcontext->arm_r7 << " 0x" << std::hex << std::uppercase << mcontext->arm_r7 << std::endl;
g_pLogFile << "R8: " << std::dec << mcontext->arm_r8 << " 0x" << std::hex << std::uppercase << mcontext->arm_r8 << std::endl;
g_pLogFile << "R9: " << std::dec << mcontext->arm_r9 << " 0x" << std::hex << std::uppercase << mcontext->arm_r9 << std::endl;
g_pLogFile << "R10: " << std::dec << mcontext->arm_r10 << " 0x" << std::hex << std::uppercase << mcontext->arm_r10 << std::endl;
g_pLogFile << "R11: " << std::dec << mcontext->arm_fp << " 0x" << std::hex << std::uppercase << mcontext->arm_fp << std::endl;
g_pLogFile << "R12: " << std::dec << mcontext->arm_ip << " 0x" << std::hex << std::uppercase << mcontext->arm_ip << std::endl;
g_pLogFile << "SP: " << std::dec << mcontext->arm_sp << " 0x" << std::hex << std::uppercase << mcontext->arm_sp << std::endl;
g_pLogFile << "LR: " << std::dec << mcontext->arm_lr << " 0x" << std::hex << std::uppercase << mcontext->arm_lr << std::endl;
g_pLogFile << "PC: " << std::dec << mcontext->arm_pc << " 0x" << std::hex << std::uppercase << mcontext->arm_pc << std::endl;
g_pLogFile << "CPSR: " << std::dec << mcontext->arm_cpsr << " 0x" << std::hex << std::uppercase << mcontext->arm_cpsr << std::endl;
#else
g_pLogFile << "X0: " << std::dec << mcontext->regs[0] << " 0x" << std::hex << std::uppercase << mcontext->regs[0] << std::endl;
g_pLogFile << "X1: " << std::dec << mcontext->regs[1] << " 0x" << std::hex << std::uppercase << mcontext->regs[1] << std::endl;
g_pLogFile << "X2: " << std::dec << mcontext->regs[2] << " 0x" << std::hex << std::uppercase << mcontext->regs[2] << std::endl;
g_pLogFile << "X3: " << std::dec << mcontext->regs[3] << " 0x" << std::hex << std::uppercase << mcontext->regs[3] << std::endl;
g_pLogFile << "X4: " << std::dec << mcontext->regs[4] << " 0x" << std::hex << std::uppercase << mcontext->regs[4] << std::endl;
g_pLogFile << "X5: " << std::dec << mcontext->regs[5] << " 0x" << std::hex << std::uppercase << mcontext->regs[5] << std::endl;
g_pLogFile << "X6: " << std::dec << mcontext->regs[6] << " 0x" << std::hex << std::uppercase << mcontext->regs[6] << std::endl;
g_pLogFile << "X7: " << std::dec << mcontext->regs[7] << " 0x" << std::hex << std::uppercase << mcontext->regs[7] << std::endl;
g_pLogFile << "X8: " << std::dec << mcontext->regs[8] << " 0x" << std::hex << std::uppercase << mcontext->regs[8] << std::endl;
g_pLogFile << "X9: " << std::dec << mcontext->regs[9] << " 0x" << std::hex << std::uppercase << mcontext->regs[9] << std::endl;
g_pLogFile << "X0: " << std::dec << mcontext->regs[0] << " 0x" << std::hex << std::uppercase << mcontext->regs[0] << std::endl;
g_pLogFile << "X1: " << std::dec << mcontext->regs[1] << " 0x" << std::hex << std::uppercase << mcontext->regs[1] << std::endl;
g_pLogFile << "X2: " << std::dec << mcontext->regs[2] << " 0x" << std::hex << std::uppercase << mcontext->regs[2] << std::endl;
g_pLogFile << "X3: " << std::dec << mcontext->regs[3] << " 0x" << std::hex << std::uppercase << mcontext->regs[3] << std::endl;
g_pLogFile << "X4: " << std::dec << mcontext->regs[4] << " 0x" << std::hex << std::uppercase << mcontext->regs[4] << std::endl;
g_pLogFile << "X5: " << std::dec << mcontext->regs[5] << " 0x" << std::hex << std::uppercase << mcontext->regs[5] << std::endl;
g_pLogFile << "X6: " << std::dec << mcontext->regs[6] << " 0x" << std::hex << std::uppercase << mcontext->regs[6] << std::endl;
g_pLogFile << "X7: " << std::dec << mcontext->regs[7] << " 0x" << std::hex << std::uppercase << mcontext->regs[7] << std::endl;
g_pLogFile << "X8: " << std::dec << mcontext->regs[8] << " 0x" << std::hex << std::uppercase << mcontext->regs[8] << std::endl;
g_pLogFile << "X9: " << std::dec << mcontext->regs[9] << " 0x" << std::hex << std::uppercase << mcontext->regs[9] << std::endl;
g_pLogFile << "X10: " << std::dec << mcontext->regs[10] << " 0x" << std::hex << std::uppercase << mcontext->regs[10] << std::endl;
g_pLogFile << "X11: " << std::dec << mcontext->regs[11] << " 0x" << std::hex << std::uppercase << mcontext->regs[11] << std::endl;
g_pLogFile << "X12: " << std::dec << mcontext->regs[12] << " 0x" << std::hex << std::uppercase << mcontext->regs[12] << std::endl;
Expand All @@ -324,9 +312,9 @@ void Handler(int sig, siginfo_t *si, void *ptr)
g_pLogFile << "X28: " << std::dec << mcontext->regs[28] << " 0x" << std::hex << std::uppercase << mcontext->regs[28] << std::endl;
g_pLogFile << "X29: " << std::dec << mcontext->regs[29] << " 0x" << std::hex << std::uppercase << mcontext->regs[29] << std::endl;
g_pLogFile << "X30: " << std::dec << mcontext->regs[30] << " 0x" << std::hex << std::uppercase << mcontext->regs[30] << std::endl;
g_pLogFile << "SP: " << std::dec << mcontext->sp << " 0x" << std::hex << std::uppercase << mcontext->sp << std::endl;
g_pLogFile << "PC: " << std::dec << mcontext->pc << " 0x" << std::hex << std::uppercase << mcontext->pc << std::endl;
g_pLogFile << "CPSR: " << std::dec << mcontext->pstate << " 0x" << std::hex << std::uppercase << mcontext->pstate << std::endl;
g_pLogFile << "SP: " << std::dec << mcontext->sp << " 0x" << std::hex << std::uppercase << mcontext->sp << std::endl;
g_pLogFile << "PC: " << std::dec << mcontext->pc << " 0x" << std::hex << std::uppercase << mcontext->pc << std::endl;
g_pLogFile << "CPSR: " << std::dec << mcontext->pstate << " 0x" << std::hex << std::uppercase << mcontext->pstate << std::endl;
#endif

#ifdef AML32
Expand All @@ -337,14 +325,14 @@ void Handler(int sig, siginfo_t *si, void *ptr)

if(!g_bNoSPInLog)
{
g_pLogFile << "\nPrinting " << std::dec << STACKDUMP_SIZE << " bytes of stack:" << std::endl;
g_pLogFile << "\n----------------------------------------------------\nPrinting " << std::dec << STACKDUMP_SIZE << " bytes of stack:" << std::endl;
g_pLogFile << std::hex << std::uppercase;
for(int i = 1; i <= STACKDUMP_SIZE; ++i)
{
g_pLogFile << " " << std::setfill('0') << std::setw(2) << (int)(stack[i - 1]);
if(i % 16 == 0)
{
g_pLogFile << " (SP+0x" << 16 * ((i / 16) - 1) << ") [";
g_pLogFile << " (SP+0x" << std::setfill('0') << std::setw(3) << 16 * ((i / 16) - 1) << ") [";
int endv = i;
for(int j = i-16; j < endv && j < STACKDUMP_SIZE; ++j)
{
Expand All @@ -370,6 +358,9 @@ void Handler(int sig, siginfo_t *si, void *ptr)
}
#endif

g_pLogFile << "\n----------------------------------------------------\n\t\tEND OF REPORT\n----------------------------------------------------\n\n";
g_pLogFile << "If you`re having problems using official mods, please report about this problem on our OFFICIAL server:\n\t\thttps://discord.gg/2MY7W39kBg\nPlease follow the rules and head to the #help section!";

skip_logging:
logger->Info("Notifying mods about the crash...");
modlist->ProcessCrash(dlInfo.dli_fname ? GetFilenamePart(dlInfo.dli_fname) : "", sig, si->si_code, (uintptr_t)dlInfo.dli_fbase, mcontext);
Expand Down
2 changes: 1 addition & 1 deletion vtable_hooker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
void* vtablez[MAX_VTABLE_FUNCS] = {NULL};
int vtablez_offset = 0;

// This function is not gonna work correctly if vtable has "holes"
// This function is not gonna work correctly if vtable has "holes" (incomplete virtual class)
void HookVtableFunc(void* ptr, unsigned int funcNum, void* func, void** original, bool instantiate)
{
if(!ptr || !func || funcNum < 0) return;
Expand Down
2 changes: 1 addition & 1 deletion wolfssl
Submodule wolfssl updated 125 files
2 changes: 1 addition & 1 deletion zlib

0 comments on commit 98360ce

Please sign in to comment.