Skip to content

Commit

Permalink
Refine readFile logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chiteroman committed Aug 17, 2024
1 parent 372be7e commit c4959bf
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions app/src/main/cpp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,27 +267,21 @@ class PlayIntegrityFix : public zygisk::ModuleBase {
};

static std::vector<uint8_t> readFile(const char *path) {
FILE *file = fopen(path, "rb");

std::vector<uint8_t> vector;
if (!file) return {};

FILE *file = fopen(path, "rb");
auto size = std::filesystem::file_size(path);

if (file) {
fseek(file, 0, SEEK_END);
long size = ftell(file);
fseek(file, 0, SEEK_SET);
std::vector<uint8_t> vector(size);

vector.resize(size);
fread(vector.data(), 1, size, file);
fclose(file);
} else {
LOGD("Couldn't read %s file!", path);
}
fread(vector.data(), 1, size, file);

fclose(file);

return vector;
}


static void companion(int fd) {

std::vector<uint8_t> dex, json;
Expand Down

0 comments on commit c4959bf

Please sign in to comment.