Skip to content
Snippets Groups Projects
Unverified Commit 98bd06eb authored by shìwēi nguyen's avatar shìwēi nguyen Committed by GitHub
Browse files

Handle reading file properly

parent b72efd6f
No related branches found
No related tags found
No related merge requests found
#include <android/log.h>
#include <sys/system_properties.h>
#include <unistd.h>
#include <stdlib.h>
#include "zygisk.hpp"
#include "shadowhook.h"
......@@ -214,26 +215,34 @@ private:
static void companion(int fd) {
FILE *dex = fopen(DEX_FILE_PATH, "rb");
long dexSize = 0;
char *dexBuffer = nullptr;
long jsonSize = 0;
char *jsonBuffer = nullptr;
fseek(dex, 0, SEEK_END);
long dexSize = ftell(dex);
fseek(dex, 0, SEEK_SET);
if (dex) {
fseek(dex, 0, SEEK_END);
dexSize = ftell(dex);
fseek(dex, 0, SEEK_SET);
char dexBuffer[dexSize];
fread(dexBuffer, 1, dexSize, dex);
dexBuffer = (char*)calloc(1, dexSize);
fread(dexBuffer, 1, dexSize, dex);
fclose(dex);
fclose(dex);
}
FILE *json = fopen(JSON_FILE_PATH, "r");
fseek(json, 0, SEEK_END);
long jsonSize = ftell(json);
fseek(json, 0, SEEK_SET);
if (json) {
fseek(json, 0, SEEK_END);
jsonSize = ftell(json);
fseek(json, 0, SEEK_SET);
char jsonBuffer[jsonSize];
fread(jsonBuffer, 1, jsonSize, json);
jsonBuffer = (char*)calloc(1, jsonSize);
fread(jsonBuffer, 1, jsonSize, json);
fclose(json);
fclose(json);
}
dexBuffer[dexSize] = 0;
jsonBuffer[jsonSize] = 0;
......@@ -243,9 +252,12 @@ static void companion(int fd) {
write(fd, &jsonSize, sizeof(long));
write(fd, jsonBuffer, jsonSize);
free(dexBuffer);
free(jsonBuffer);
}
REGISTER_ZYGISK_MODULE(PlayIntegrityFix)
REGISTER_ZYGISK_COMPANION(companion)
\ No newline at end of file
REGISTER_ZYGISK_COMPANION(companion)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment