You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
fix: Web UI not loading
This commit fixes the issue where the Web UI doesn't load by properly implementing the saving of the status of ReZygisk so that it can be displayed easily, which wasn't properly implemented before.
This commit is contained in:
@@ -708,6 +708,29 @@ static char post_section[1024];
|
||||
} \
|
||||
}
|
||||
|
||||
#define WRITE_STATUS_FILE(suffix) \
|
||||
if (status ## suffix.supported) { \
|
||||
fprintf(state_file, "Daemon" # suffix ": "); \
|
||||
if (status ## suffix.daemon_running) { \
|
||||
fprintf(state_file, "running"); \
|
||||
\
|
||||
if (status ## suffix.daemon_info != NULL) \
|
||||
fprintf(state_file, " (%s)", status ## suffix.daemon_info); \
|
||||
} else { \
|
||||
fprintf(state_file, "crashed"); \
|
||||
\
|
||||
if (status ## suffix.daemon_error_info != NULL) \
|
||||
fprintf(state_file, " (%s)", status ## suffix.daemon_error_info); \
|
||||
} \
|
||||
\
|
||||
fprintf(state_file, "\nZygote" # suffix ": "); \
|
||||
if (tracing_state != TRACING) fprintf(state_file, "unknown"); \
|
||||
else if (status ## suffix.zygote_injected) fprintf(state_file, "injected"); \
|
||||
else fprintf(state_file, "not injected"); \
|
||||
\
|
||||
fprintf(state_file, "\n"); \
|
||||
}
|
||||
|
||||
static void updateStatus() {
|
||||
FILE *prop = fopen(prop_path, "w");
|
||||
char status_text[1024] = "monitor: ";
|
||||
@@ -744,6 +767,29 @@ static void updateStatus() {
|
||||
fprintf(prop, "%s[%s] %s", pre_section, status_text, post_section);
|
||||
|
||||
fclose(prop);
|
||||
|
||||
char state_file_path[PATH_MAX];
|
||||
snprintf(state_file_path, sizeof(state_file_path), "%s/%s", zygiskd::GetTmpPath().c_str(), "status");
|
||||
|
||||
FILE *state_file = fopen(state_file_path, "w");
|
||||
if (state_file == NULL) {
|
||||
PLOGE("failed to open state file");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(state_file, "Version: %s\n", ZKSU_VERSION);
|
||||
fprintf(state_file, "Tracing: %d", tracing_state);
|
||||
if (tracing_state != TRACING && monitor_stop_reason[0] != '\0') {
|
||||
fprintf(state_file, " (%s)\n", monitor_stop_reason);
|
||||
} else {
|
||||
fprintf(state_file, "\n");
|
||||
}
|
||||
|
||||
WRITE_STATUS_FILE(64)
|
||||
WRITE_STATUS_FILE(32)
|
||||
|
||||
fclose(state_file);
|
||||
}
|
||||
|
||||
static bool prepare_environment() {
|
||||
|
||||
@@ -60,96 +60,110 @@ export function setErrorData(errorLog) {
|
||||
let zygote64_status = EXPECTED
|
||||
let zygote32_status = EXPECTED
|
||||
|
||||
const ptrace64Cmd = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace64 info')
|
||||
const catCmd = await exec('/system/bin/cat /data/adb/rezygisk/status')
|
||||
|
||||
if (ptrace64Cmd.errno === 0) {
|
||||
const [ version_line, _, process_line, daemon_running_or_root_impl_line, daemon_running_line, zygote_injected, tracing_state, module_amount_line ] = ptrace64Cmd.stdout.split('\n')
|
||||
let modules_amount = module_amount_line.split(': ')[1]
|
||||
if (catCmd.errno === 0) {
|
||||
const [ Version, Tracing, Daemon64, Zygote64 ] = catCmd.stdout.split('\n')
|
||||
/* TODO: Show the tracing state */
|
||||
/* TODO: Show if daemon is running */
|
||||
|
||||
/* INFO: Root implementation and ReZygisk version parsing */
|
||||
if (daemon_running_line) {
|
||||
code_version.innerHTML = version_line.split('Tracer ')[1].split('-')[0]
|
||||
root_impl.innerHTML = daemon_running_or_root_impl_line.split(': ')[1]
|
||||
code_version.innerHTML = Version.split(': ')[1]
|
||||
|
||||
if (daemon_running_line.split(': ')[1] === 'yes') {
|
||||
if (Daemon64 && Daemon64.startsWith('Daemon64:')) {
|
||||
/* INFO: Daemon64 is supported */
|
||||
let daemon64_status = Daemon64.split(': ').slice(1).join(': ')
|
||||
let daemon64_info = null
|
||||
if (daemon64_status.split(' ')[1]) {
|
||||
daemon64_info = daemon64_status.split(' ').slice(1).join(' ')
|
||||
daemon64_status = daemon64_status.split(' ')[0]
|
||||
|
||||
root_impl.innerHTML = daemon64_info.split('Root: ')[1].split(',')[0]
|
||||
|
||||
const modules = daemon64_info.split('Modules: ')[1].split(')')[0].split(', ')
|
||||
if (modules[0] !== 'None') modules_64.push(...modules)
|
||||
}
|
||||
|
||||
const zygote64_status = Zygote64.split(': ')[1]
|
||||
|
||||
/* TODO: add handling for unknown status */
|
||||
if (zygote64_status === 'injected') {
|
||||
zygote64_status_div.innerHTML = translations.page.home.info.zygote.injected
|
||||
} else {
|
||||
zygote64_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
|
||||
zygote64_status = UNEXPECTED_FAIL
|
||||
}
|
||||
} else {
|
||||
zygote64_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
|
||||
zygote64_status = UNEXPECTED_FAIL
|
||||
}
|
||||
const [ _u1, _u2, _u3, _u4, Daemon32, Zygote32 ] = catCmd.stdout.split('\n')
|
||||
if (Daemon32 && Daemon32.startsWith('Daemon32:')) {
|
||||
/* INFO: Daemon32 is supported */
|
||||
let daemon32_status = Daemon32.split(': ').slice(1).join(': ')
|
||||
let daemon32_info = null
|
||||
if (daemon32_status.split(' ')[1]) {
|
||||
daemon32_info = daemon32_status.split(' ').slice(1).join(' ')
|
||||
daemon32_status = daemon32_status.split(' ')[0]
|
||||
|
||||
const lines = ptrace64Cmd.stdout.split('\n')
|
||||
root_impl.innerHTML = daemon32_info.split('Root: ')[1].split(',')[0]
|
||||
|
||||
if (modules_amount !== 'N/A') {
|
||||
modules_amount = parseInt(modules_amount)
|
||||
const modules = daemon32_info.split('Modules: ')[1].split(')')[0].split(', ')
|
||||
if (modules[0] !== 'None') modules_32.push(...modules)
|
||||
}
|
||||
|
||||
for (let i = 0; i < modules_amount; i++) {
|
||||
const module = lines[6 + i].split(' - ')[1]
|
||||
const zygote32_status = Zygote32.split(': ')[1]
|
||||
|
||||
modules_32.push(module)
|
||||
}
|
||||
if (zygote32_status === 'injected') {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.injected
|
||||
} else {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
|
||||
document.getElementById('modules_list_not_avaliable').style.display = 'none'
|
||||
}
|
||||
} else if (ptrace64Cmd.stderr.includes('cannot execute binary file: Exec format error')) {
|
||||
zygote64_div.style.display = 'none'
|
||||
daemon64_div.style.display = 'none'
|
||||
} else {
|
||||
setError('ptrace64', `Error while executing zygisk-ptrace64 (${ptrace64Cmd.errno}): ${ptrace64Cmd.stderr}`)
|
||||
|
||||
zygote64_status = UNEXPECTED_FAIL
|
||||
}
|
||||
|
||||
const ptrace32Cmd = await exec('/data/adb/modules/zygisksu/bin/zygisk-ptrace32 info')
|
||||
|
||||
if (ptrace32Cmd.errno === 0) {
|
||||
const [ version_line, _, process_line, daemon_running_or_root_impl_line, daemon_running_line, zygote_injected, tracing_state, module_amount_line ] = ptrace32Cmd.stdout.split('\n')
|
||||
let modules_amount = module_amount_line.split(': ')[1]
|
||||
|
||||
/* INFO: Root implementation and ReZygisk version parsing -- Necessary if 64-bit fails */
|
||||
if (daemon_running_line) {
|
||||
code_version.innerHTML = version_line.split('Tracer ')[1].split('-')[0]
|
||||
root_impl.innerHTML = daemon_running_or_root_impl_line.split(': ')[1]
|
||||
|
||||
if (daemon_running_line.split(': ')[1] === 'yes') {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.injected
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
} else {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
/* INFO: This should never happen */
|
||||
|
||||
zygote32_div.style.display = 'none'
|
||||
daemon32_div.style.display = 'none'
|
||||
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
} else {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
/* INFO: Daemon64 is not supported */
|
||||
zygote64_div.style.display = 'none'
|
||||
daemon64_div.style.display = 'none'
|
||||
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
zygote64_status = UNEXPECTED_FAIL
|
||||
|
||||
const lines = ptrace32Cmd.stdout.split('\n')
|
||||
if (Daemon32 && Daemon32.startsWith('Daemon32:')) {
|
||||
/* INFO: Daemon32 is supported */
|
||||
let daemon32_status = Daemon32.split(': ').slice(1).join(': ')
|
||||
let daemon32_info = null
|
||||
if (daemon32_status.split(' ')[1]) {
|
||||
daemon32_info = daemon32_status.split(' ').slice(1).join(' ')
|
||||
daemon32_status = daemon32_status.split(' ')[0]
|
||||
|
||||
if (modules_amount !== 'N/A') {
|
||||
modules_amount = parseInt(modules_amount)
|
||||
root_impl.innerHTML = daemon32_info.split('Root: ')[1].split(',')[0]
|
||||
|
||||
const modules = daemon32_info.split('Modules: ')[1].split(')')[0].split(', ')
|
||||
if (modules[0] !== 'None') modules_32.push(...modules)
|
||||
}
|
||||
|
||||
for (let i = 0; i < modules_amount; i++) {
|
||||
const module = lines[6 + i].split(' - ')[1]
|
||||
const zygote32_status = Zygote32.split(': ')[1]
|
||||
|
||||
modules_64.push(module)
|
||||
if (zygote32_status === 'injected') {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.injected
|
||||
} else {
|
||||
zygote32_status_div.innerHTML = translations.page.home.info.zygote.notInjected
|
||||
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
} else {
|
||||
/* INFO: This should never happen */
|
||||
zygote32_div.style.display = 'none'
|
||||
daemon32_div.style.display = 'none'
|
||||
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
|
||||
document.getElementById('modules_list_not_avaliable').style.display = 'none'
|
||||
}
|
||||
} else if (ptrace32Cmd.stderr.includes('not executable: 32-bit ELF file')) {
|
||||
zygote32_div.style.display = 'none'
|
||||
daemon32_div.style.display = 'none'
|
||||
} else {
|
||||
setError('ptrace32', `Error while executing zygisk-ptrace32 (${ptrace32Cmd.errno}): ${ptrace32Cmd.stderr}`)
|
||||
|
||||
zygote32_status = UNEXPECTED_FAIL
|
||||
}
|
||||
}
|
||||
|
||||
if (zygote32_status === EXPECTED && zygote64_status === EXPECTED) {
|
||||
@@ -166,29 +180,32 @@ export function setErrorData(errorLog) {
|
||||
rezygisk_state.innerHTML = translations.page.home.status.notWorking
|
||||
}
|
||||
|
||||
const modules_64_32 = []
|
||||
const all_modules = []
|
||||
|
||||
modules_64.forEach((module) => modules_64_32.push({
|
||||
modules_64.forEach((module) => all_modules.push({
|
||||
name: module,
|
||||
bitsUsed: [ '64 bit' ]
|
||||
}))
|
||||
|
||||
modules_32.forEach((module) => {
|
||||
const module_index = modules_64_32.findIndex((module_64_32) => module_64_32.name === module)
|
||||
const module_index = all_modules.findIndex((module_64_32) => module_64_32.name === module)
|
||||
|
||||
if (module_index !== -1) modules_64_32[module_index].bitsUsed.push('32 bit')
|
||||
else modules_64_32.push({
|
||||
if (module_index !== -1) all_modules[module_index].bitsUsed.push('32 bit')
|
||||
else all_modules.push({
|
||||
name: module,
|
||||
bitsUsed: [ '32 bit' ]
|
||||
})
|
||||
})
|
||||
|
||||
if (all_modules.length !== 0)
|
||||
document.getElementById('modules_list_not_avaliable').style.display = 'none'
|
||||
|
||||
const modules_list = document.getElementById('modules_list')
|
||||
|
||||
/* INFO: This hides the throbber screen */
|
||||
loading_screen.style.display = 'none'
|
||||
|
||||
modules_64_32.forEach((module) => {
|
||||
all_modules.forEach((module) => {
|
||||
modules_list.innerHTML +=
|
||||
`<div class="dim card" style="padding: 25px 15px; cursor: pointer;">
|
||||
<div class="dimc" style="font-size: 1.1em;">${module.name}</div>
|
||||
|
||||
@@ -10,20 +10,17 @@ let index = 0
|
||||
|
||||
async function setAvailableLanguage() {
|
||||
const availableLanguages = await getAvailableLanguages()
|
||||
const langKey = availableLanguages[index]
|
||||
|
||||
index += 1
|
||||
for (index; index < availableLanguages.length; index++) {
|
||||
const langCode = availableLanguages[index]
|
||||
const langData = await getTranslations(langCode)
|
||||
|
||||
getTranslations(langKey).then((data) => {
|
||||
document.getElementById('lang_modal_list').innerHTML += `
|
||||
<div lang-data="${langKey}" class="dim card card_animation" style="padding: 25px 15px; cursor: pointer;">
|
||||
<div lang-data="${langKey}" class="dimc" style="font-size: 1.1em;">${data.langName}</div>
|
||||
<div lang-data="${langCode}" class="dim card card_animation" style="padding: 25px 15px; cursor: pointer;">
|
||||
<div lang-data="${langCode}" class="dimc" style="font-size: 1.1em;">${langData.langName}</div>
|
||||
</div>
|
||||
`
|
||||
})
|
||||
.finally(() => {
|
||||
if (index !== avaliableLanguages.length) setAvailableLanguage()
|
||||
})
|
||||
}
|
||||
}
|
||||
setAvailableLanguage()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user