Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PlayIntegrityFix
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
PlayIntegrityFix
Commits
599c27e8
There was an error fetching the commit references. Please try again later.
Unverified
Commit
599c27e8
authored
1 year ago
by
chiteroman
Browse files
Options
Downloads
Patches
Plain Diff
Fix JSON parsing and reformat code
parent
8eaa0f24
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/cpp/main.cpp
+30
-12
30 additions, 12 deletions
app/src/main/cpp/main.cpp
with
30 additions
and
12 deletions
app/src/main/cpp/main.cpp
+
30
−
12
View file @
599c27e8
#include
<android/log.h>
#include
<sys/system_properties.h>
#include
<unistd.h>
#include
<stdlib.h>
#include
"zygisk.hpp"
#include
"shadowhook.h"
...
...
@@ -168,13 +167,31 @@ private:
std
::
string
data
(
propVector
.
cbegin
(),
propVector
.
cend
());
nlohmann
::
json
json
=
nlohmann
::
json
::
parse
(
data
,
nullptr
,
false
,
true
);
auto
getStringFromJson
=
[
&
json
](
const
std
::
string
&
key
)
{
return
json
.
contains
(
key
)
&&
!
json
[
key
].
is_null
()
?
json
[
key
].
get
<
std
::
string
>
()
:
"NULL"
;
};
if
(
json
.
contains
(
"SECURITY_PATCH"
))
{
if
(
json
[
"SECURITY_PATCH"
].
is_null
())
{
SECURITY_PATCH
=
"NULL"
;
}
else
if
(
json
[
"SECURITY_PATCH"
].
is_string
())
{
SECURITY_PATCH
=
json
[
"SECURITY_PATCH"
].
get
<
std
::
string
>
();
}
else
{
LOGD
(
"Error parsing SECURITY_PATCH!"
);
}
}
else
{
LOGD
(
"Key SECURITY_PATCH doesn't exist in JSON file!"
);
}
if
(
json
.
contains
(
"FIRST_API_LEVEL"
))
{
if
(
json
[
"FIRST_API_LEVEL"
].
is_null
())
{
FIRST_API_LEVEL
=
"NULL"
;
}
else
if
(
json
[
"FIRST_API_LEVEL"
].
is_string
())
{
FIRST_API_LEVEL
=
json
[
"FIRST_API_LEVEL"
].
get
<
std
::
string
>
();
}
else
{
LOGD
(
"Error parsing FIRST_API_LEVEL!"
);
}
}
else
{
LOGD
(
"Key FIRST_API_LEVEL doesn't exist in JSON file!"
);
}
SECURITY_PATCH
=
getStringFromJson
(
"SECURITY_PATCH"
);
FIRST_API_LEVEL
=
getStringFromJson
(
"FIRST_API_LEVEL"
);
json
.
clear
();
}
void
inject
()
{
...
...
@@ -214,18 +231,20 @@ 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
;
FILE
*
dex
=
fopen
(
DEX_FILE_PATH
,
"rb"
);
if
(
dex
)
{
fseek
(
dex
,
0
,
SEEK_END
);
dexSize
=
ftell
(
dex
);
fseek
(
dex
,
0
,
SEEK_SET
);
dexBuffer
=
(
char
*
)
calloc
(
1
,
dexSize
);
dexBuffer
=
static_cast
<
char
*>
(
calloc
(
1
,
dexSize
)
)
;
fread
(
dexBuffer
,
1
,
dexSize
,
dex
);
fclose
(
dex
);
...
...
@@ -238,7 +257,7 @@ static void companion(int fd) {
jsonSize
=
ftell
(
json
);
fseek
(
json
,
0
,
SEEK_SET
);
jsonBuffer
=
(
char
*
)
calloc
(
1
,
jsonSize
);
jsonBuffer
=
static_cast
<
char
*>
(
calloc
(
1
,
jsonSize
)
)
;
fread
(
jsonBuffer
,
1
,
jsonSize
,
json
);
fclose
(
json
);
...
...
@@ -254,7 +273,6 @@ static void companion(int fd) {
free
(
jsonBuffer
);
}
REGISTER_ZYGISK_MODULE
(
PlayIntegrityFix
)
REGISTER_ZYGISK_COMPANION
(
companion
)
REGISTER_ZYGISK_COMPANION
(
companion
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment