├── module
├── META-INF
│ └── com
│ │ └── google
│ │ └── android
│ │ ├── updater-script
│ │ └── update-binary
├── module.prop
├── app_replace_list.txt
├── post-fs-data.sh
├── system
│ └── etc
│ │ └── sysconfig
│ │ └── pixel_2016_exclusive.xml
├── fgp.json
├── customize.sh
├── example.fgp.prop
└── common_setup.sh
├── .idea
├── .gitignore
├── compiler.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── vcs.xml
├── deploymentTargetDropDown.xml
├── migrations.xml
├── misc.xml
└── gradle.xml
├── app
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ ├── cpp
│ │ ├── CMakeLists.txt
│ │ ├── zygisk.hpp
│ │ └── main.cpp
│ │ └── java
│ │ └── com
│ │ └── rev4n
│ │ └── unlimitedphotos
│ │ ├── CustomProvider.java
│ │ ├── CustomPackageInfoCreator.java
│ │ ├── EntryPointVending.java
│ │ ├── CustomKeyStoreSpi.java
│ │ └── EntryPoint.java
├── proguard-rules.pro
└── build.gradle.kts
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── update.json
├── .gitignore
├── .gitmodules
├── settings.gradle.kts
├── CHANGELOG.md
├── .github
├── FUNDING.yml
└── workflows
│ └── android.yml
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/module/META-INF/com/google/android/updater-script:
--------------------------------------------------------------------------------
1 | #MAGISK
2 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Rev4N1/GPhotosUnlimited/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/update.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "v1",
3 | "versionCode": 10000,
4 | "zipUrl": "https://github.com/Rev4N1/GPhotosUnlimited/releases/download/v1/GPhotosUnlimited-v1.zip",
5 | "changelog": "https://raw.githubusercontent.com/Rev4N1/GPhotosUnlimited/main/CHANGELOG.md"
6 | }
7 |
--------------------------------------------------------------------------------
/.idea/deploymentTargetDropDown.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4 | networkTimeout=10000
5 | validateDistributionUrl=true
6 | zipStoreBase=GRADLE_USER_HOME
7 | zipStorePath=wrapper/dists
8 |
--------------------------------------------------------------------------------
/.idea/migrations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/module/module.prop:
--------------------------------------------------------------------------------
1 | id=unlimitedphotos
2 | name=Google Photos Unlimited Backup
3 | version=v1
4 | versionCode=10000
5 | author=Rev4N - Credits to osm0sis & chiteroman
6 | description=Google Photos Unlimited Backup by Spoofing into Pixel XL.
7 | updateJson=https://raw.githubusercontent.com/Rev4N1/GPhotosUnlimited/main/update.json
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .cxx
3 | .DS_Store
4 | .externalNativeBuild
5 | .gradle
6 | .idea/assetWizardSettings.xml
7 | .idea/caches
8 | .idea/libraries
9 | .idea/modules.xml
10 | .idea/navEditor.xml
11 | .idea/workspace.xml
12 | build/
13 | local.properties
14 | module/classes.dex
15 | module/fgp.json
16 | module/zygisk/
17 | out/
18 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | -keep class com.rev4n.unlimitedphotos.EntryPoint {public ;}
2 | -keep class com.rev4n.unlimitedphotos.EntryPointVending {public ;}
3 | -keep class com.rev4n.unlimitedphotos.CustomProvider
4 | -keep class com.rev4n.unlimitedphotos.CustomKeyStoreSpi
5 | -keep class com.rev4n.unlimitedphotos.CustomPackageInfoCreator
--------------------------------------------------------------------------------
/module/app_replace_list.txt:
--------------------------------------------------------------------------------
1 | # Rename to custom.app_replace_list.txt once customized
2 | #
3 | # Add conflicting custom ROM injection app folder/file paths to this list
4 | # and they will be replaced/hidden systemlessly to disable them
5 |
6 | # helluvaOS
7 | /system_ext/app/HelluvaProductSpt
8 |
9 | # hentaiOS
10 | /system_ext/app/HentaiProductSpt
--------------------------------------------------------------------------------
/module/post-fs-data.sh:
--------------------------------------------------------------------------------
1 | MODPATH="${0%/*}"
2 |
3 | if [ -d "$MODPATH/zygisk" ]; then
4 | # Remove Google Photos from Magisk DenyList when set to Enforce in normal mode
5 | if magisk --denylist status; then
6 | magisk --denylist rm com.google.android.apps.photos
7 | fi
8 | # Run common tasks for installation and boot-time
9 | . $MODPATH/common_setup.sh
10 | fi
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Dobby"]
2 | path = app/src/main/cpp/Dobby
3 | url = https://github.com/JingMatrix/Dobby
4 | [submodule "local_cxa_atexit_finalize_impl"]
5 | path = app/src/main/cpp/local_cxa_atexit_finalize_impl
6 | url = https://github.com/5ec1cff/local_cxa_atexit_finalize_impl
7 | [submodule "json"]
8 | path = app/src/main/cpp/json
9 | url = https://github.com/nlohmann/json
10 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google()
4 | mavenCentral()
5 | gradlePluginPortal()
6 | }
7 | }
8 | dependencyResolutionManagement {
9 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
10 | repositories {
11 | google()
12 | mavenCentral()
13 | }
14 | }
15 |
16 | rootProject.name = "GPhotosUnlimited"
17 | include(":app")
18 |
--------------------------------------------------------------------------------
/module/system/etc/sysconfig/pixel_2016_exclusive.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.22.1)
2 |
3 | project(unlimitedphotos)
4 |
5 | find_package(cxx REQUIRED CONFIG)
6 |
7 | link_libraries(cxx::cxx)
8 |
9 | add_library(${CMAKE_PROJECT_NAME} SHARED main.cpp local_cxa_atexit_finalize_impl/atexit.cpp)
10 |
11 | add_subdirectory(Dobby)
12 |
13 | SET_OPTION(Plugin.Android.BionicLinkerUtil ON)
14 |
15 | target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE log dobby_static)
16 |
--------------------------------------------------------------------------------
/module/fgp.json:
--------------------------------------------------------------------------------
1 | {
2 | // Build Fields
3 | "MANUFACTURER": "Google",
4 | "MODEL": "Pixel XL",
5 | "FINGERPRINT": "google/marlin/marlin:9/PPR1.180610.009/4898911:user/release-keys",
6 | "SECURITY_PATCH": "2018-08-05",
7 | "DEVICE_INITIAL_SDK_INT": "25",
8 |
9 | // Advanced Settings
10 | "spoofBuild": "1",
11 | "spoofProps": "0",
12 | "spoofProvider": "0",
13 | "spoofSignature": "0",
14 | "verboseLogs": "0"
15 | }
16 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## Google Photos Unlimited v1
2 | - Full rebase module into PIFork
3 | - Now you can make a custom spoofing
4 | - Fix retaining disabled ROM apps through module updates in some scenarios
5 | - Copy any supported custom files to updated module
6 | - Warn if potentially conflicting modules are installed
7 | - Remove Google Photos from Magisk denyList if needed
8 | - Fix compatiblility with lastest hOS version
9 |
10 | _[Previous changelogs](https://github.com/Rev4N1/GPhotosUnlimited/releases)_
11 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: Rev4N1 # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: https://www.paypal.me/Rev4N1 # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/module/META-INF/com/google/android/update-binary:
--------------------------------------------------------------------------------
1 | #!/sbin/sh
2 |
3 | #################
4 | # Initialization
5 | #################
6 |
7 | umask 022
8 |
9 | # echo before loading util_functions
10 | ui_print() { echo "$1"; }
11 |
12 | require_new_magisk() {
13 | ui_print "*******************************"
14 | ui_print " Please install Magisk v20.4+! "
15 | ui_print "*******************************"
16 | exit 1
17 | }
18 |
19 | #########################
20 | # Load util_functions.sh
21 | #########################
22 |
23 | OUTFD=$2
24 | ZIPFILE=$3
25 |
26 | mount /data 2>/dev/null
27 |
28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29 | . /data/adb/magisk/util_functions.sh
30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31 |
32 | install_module
33 | exit 0
34 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rev4n/unlimitedphotos/CustomProvider.java:
--------------------------------------------------------------------------------
1 | package com.rev4n.unlimitedphotos;
2 |
3 | import java.security.Provider;
4 |
5 | public final class CustomProvider extends Provider {
6 |
7 | CustomProvider(Provider provider) {
8 | super(provider.getName(), provider.getVersion(), provider.getInfo());
9 | putAll(provider);
10 | this.put("KeyStore.AndroidKeyStore", CustomKeyStoreSpi.class.getName());
11 | }
12 |
13 | @Override
14 | public synchronized Service getService(String type, String algorithm) {
15 | if (EntryPoint.getVerboseLogs() > 2) EntryPoint.LOG(String.format("Service: Caller type '%s' with algorithm '%s'", type, algorithm));
16 | if (EntryPoint.getSpoofBuildEnabled() > 0) {
17 | if (type.equals("KeyStore")) EntryPoint.spoofDevice();
18 | }
19 | return super.getService(type, algorithm);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/module/customize.sh:
--------------------------------------------------------------------------------
1 | # Copy any disabled app files to updated module
2 | if [ -d /data/adb/modules/unlimitedphotos/system ]; then
3 | ui_print "- Restoring disabled configuration"
4 | cp -afL /data/adb/modules/unlimitedphotos/system $MODPATH
5 | fi
6 |
7 | # Copy any supported custom files to updated module
8 | for FILE in custom.app_replace_list.txt custom.fgp.json custom.fgp.prop uninstall.sh; do
9 | if [ -f "/data/adb/modules/unlimitedphotos/$FILE" ]; then
10 | ui_print "- Restoring $FILE"
11 | cp -af /data/adb/modules/unlimitedphotos/$FILE $MODPATH/$FILE
12 | fi
13 | done
14 |
15 | # Warn if potentially conflicting modules are installed
16 | for MODULE in Pixelify PixelifyPhotos unlimitedgpics ; do
17 | if [ -d /data/adb/modules/$MODULE ]; then
18 | ui_print "! $MODULE module may cause issues with this module"
19 | fi
20 | done
21 |
22 | # Run common tasks for installation and boot-time
23 | if [ -d "$MODPATH/zygisk" ]; then
24 | . $MODPATH/common_setup.sh
25 | fi
--------------------------------------------------------------------------------
/module/example.fgp.prop:
--------------------------------------------------------------------------------
1 | # Rename to custom.fgp.prop once completed
2 | #
3 | # These are the current suggested defaults but you may add as many other fields/properties as needed
4 | #
5 | # See android.os.Build source for all fields and field values' corresponding properties:
6 | # https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/os/Build.java
7 |
8 | # Build Fields
9 | MANUFACTURER=
10 | MODEL=
11 | FINGERPRINT=
12 | BRAND=
13 | PRODUCT=
14 | DEVICE=
15 | RELEASE=
16 | ID=
17 | INCREMENTAL=
18 | TYPE=
19 | TAGS=
20 | SECURITY_PATCH=
21 | DEVICE_INITIAL_SDK_INT=
22 |
23 | # System Properties
24 | *.build.id= # for ro.build.id
25 | *.security_patch= # for ro.build.version.security_patch
26 | *api_level= # for ro.board.api_level, ro.board.first_api_level, ro.product.first_api_level and ro.vendor.api_level
27 |
28 | # Advanced Settings
29 | spoofBuild=1
30 | spoofProps=1
31 | spoofProvider=1
32 | spoofSignature=0
33 | spoofVendingFinger=0
34 | spoofVendingSdk=0
35 | verboseLogs=0
36 |
--------------------------------------------------------------------------------
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on:
4 | workflow_dispatch:
5 | push:
6 | branches: main
7 | paths-ignore: '**.md'
8 | pull_request:
9 | branches: main
10 | paths-ignore: '**.md'
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: macos-26
16 |
17 | steps:
18 | - name: Check out
19 | uses: actions/checkout@v5
20 | with:
21 | submodules: 'recursive'
22 | fetch-depth: 0
23 |
24 | - name: Set up JDK
25 | uses: actions/setup-java@v5
26 | with:
27 | distribution: 'temurin'
28 | java-version: 21
29 |
30 | - name: Grant execute permission for gradlew
31 | run: chmod +x gradlew
32 |
33 | - name: Build with Gradle
34 | run: ./gradlew --warning-mode all assembleRelease
35 |
36 | - name: Upload CI module zip as artifact zip
37 | uses: actions/upload-artifact@v5
38 | with:
39 | name: GPhotosUnlimited-CI_#${{ github.run_number }}
40 | path: 'module/*'
41 | compression-level: 9
42 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Enable the configuration cache persistently
8 | org.gradle.configuration-cache=true
9 | # Specifies the JVM arguments used for the daemon process.
10 | # The setting is particularly useful for tweaking memory settings.
11 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
12 | # When configured, Gradle will run in incubating parallel mode.
13 | # This option should only be used with decoupled projects. More details, visit
14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
15 | # org.gradle.parallel=true
16 | # AndroidX package structure to make it clearer which packages are bundled with the
17 | # Android operating system, and which are packaged with your app's APK
18 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
19 | android.useAndroidX=true
20 | # Enables namespacing of each library's R class so that its R class includes only the
21 | # resources declared in the library itself and none from the library's dependencies,
22 | # thereby reducing the size of the R class for that library
23 | android.nonTransitiveRClass=true
24 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rev4n/unlimitedphotos/CustomPackageInfoCreator.java:
--------------------------------------------------------------------------------
1 | package com.rev4n.unlimitedphotos;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.Signature;
5 | import android.os.Build;
6 | import android.os.Parcel;
7 | import android.os.Parcelable;
8 |
9 | public class CustomPackageInfoCreator implements Parcelable.Creator {
10 | private final Parcelable.Creator originalCreator;
11 | private final Signature spoofedSignature;
12 |
13 | public CustomPackageInfoCreator(Parcelable.Creator originalCreator, Signature spoofedSignature) {
14 | this.originalCreator = originalCreator;
15 | this.spoofedSignature = spoofedSignature;
16 | }
17 |
18 | @Override
19 | @SuppressWarnings("deprecation")
20 | public PackageInfo createFromParcel(Parcel source) {
21 | PackageInfo packageInfo = originalCreator.createFromParcel(source);
22 | if (packageInfo.packageName.equals("android")) {
23 | if (packageInfo.signatures != null && packageInfo.signatures.length > 0) {
24 | packageInfo.signatures[0] = spoofedSignature;
25 | }
26 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
27 | if (packageInfo.signingInfo != null) {
28 | Signature[] signaturesArray = packageInfo.signingInfo.getApkContentsSigners();
29 | if (signaturesArray != null && signaturesArray.length > 0) {
30 | signaturesArray[0] = spoofedSignature;
31 | }
32 | }
33 | }
34 | }
35 | return packageInfo;
36 | }
37 |
38 | @Override
39 | public PackageInfo[] newArray(int size) {
40 | return originalCreator.newArray(size);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.android.application")
3 | }
4 |
5 | android {
6 | namespace = "com.rev4n.unlimitedphotos"
7 | compileSdk = 36
8 | ndkVersion = "29.0.14206865"
9 | buildToolsVersion = "36.1.0"
10 |
11 | buildFeatures {
12 | prefab = true
13 | }
14 |
15 | packaging {
16 | jniLibs {
17 | excludes += "**/liblog.so"
18 | excludes += "**/libdobby.so"
19 | }
20 | }
21 |
22 | defaultConfig {
23 | applicationId = "com.rev4n.unlimitedphotos"
24 | minSdk = 26
25 | targetSdk = 36
26 | versionCode = 1
27 | versionName = "1.0"
28 |
29 | externalNativeBuild {
30 | cmake {
31 | arguments += "-DANDROID_STL=none"
32 | arguments += "-DCMAKE_BUILD_TYPE=Release"
33 |
34 | cppFlags += "-std=c++23"
35 | cppFlags += "-fno-exceptions"
36 | cppFlags += "-fno-rtti"
37 | cppFlags += "-fvisibility=hidden"
38 | cppFlags += "-fvisibility-inlines-hidden"
39 | }
40 | }
41 | }
42 |
43 | buildTypes {
44 | release {
45 | isMinifyEnabled = true
46 | isShrinkResources = true
47 | proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
48 | }
49 | }
50 |
51 | compileOptions {
52 | sourceCompatibility = JavaVersion.VERSION_21
53 | targetCompatibility = JavaVersion.VERSION_21
54 | }
55 |
56 | externalNativeBuild {
57 | cmake {
58 | path = file("src/main/cpp/CMakeLists.txt")
59 | version = "3.22.1"
60 | }
61 | }
62 | }
63 |
64 | dependencies {
65 | implementation("org.lsposed.libcxx:libcxx:28.1.13356709")
66 | implementation("org.lsposed.hiddenapibypass:hiddenapibypass:6.1")
67 | }
68 |
69 | tasks.register("copyFiles") {
70 | val moduleFolder = project.rootDir.resolve("module")
71 | val dexFile = project.layout.buildDirectory.get().asFile.resolve("intermediates/dex/release/minifyReleaseWithR8/classes.dex")
72 | val soDir = project.layout.buildDirectory.get().asFile.resolve("intermediates/stripped_native_libs/release/stripReleaseDebugSymbols/out/lib")
73 |
74 | doLast {
75 | dexFile.copyTo(moduleFolder.resolve("classes.dex"), overwrite = true)
76 |
77 | soDir.walk().filter { it.isFile && it.extension == "so" }.forEach { soFile ->
78 | val abiFolder = soFile.parentFile.name
79 | val destination = moduleFolder.resolve("zygisk/$abiFolder.so")
80 | soFile.copyTo(destination, overwrite = true)
81 | }
82 | }
83 | }
84 |
85 | tasks.register("zip") {
86 | dependsOn("copyFiles")
87 |
88 | archiveFileName.set("GPhotosUnlimited.zip")
89 | destinationDirectory.set(project.rootDir.resolve("out"))
90 |
91 | from(project.rootDir.resolve("module"))
92 | }
93 |
94 | afterEvaluate {
95 | tasks["assembleRelease"].finalizedBy("copyFiles", "zip")
96 | }
97 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rev4n/unlimitedphotos/EntryPointVending.java:
--------------------------------------------------------------------------------
1 | package com.rev4n.unlimitedphotos;
2 |
3 | import android.annotation.SuppressLint;
4 | import android.os.Build;
5 | import java.lang.reflect.Field;
6 | import android.util.Log;
7 |
8 | public final class EntryPointVending {
9 |
10 | private static void LOG(String msg) {
11 | Log.d("FGP/Java:PS", msg);
12 | }
13 |
14 | @SuppressLint("DefaultLocale")
15 | public static void init(int verboseLogs, int spoofVendingFinger, int spoofVendingSdk, String vendingFingerprintValue) {
16 | // Only spoof FINGERPRINT to Play Store if not forcing Android <13 Play Integrity verdict
17 | if (spoofVendingSdk < 1) {
18 | if (spoofVendingFinger < 1) return;
19 | String oldValue;
20 | try {
21 | Field field = Build.class.getDeclaredField("FINGERPRINT");
22 | field.setAccessible(true);
23 | oldValue = String.valueOf(field.get(null));
24 | if (oldValue.equals(vendingFingerprintValue)) {
25 | if (verboseLogs > 2) LOG(String.format("[FINGERPRINT]: %s (unchanged)", oldValue));
26 | field.setAccessible(false);
27 | return;
28 | }
29 | field.set(null, vendingFingerprintValue);
30 | field.setAccessible(false);
31 | LOG(String.format("[FINGERPRINT]: %s -> %s", oldValue, vendingFingerprintValue));
32 | } catch (NoSuchFieldException e) {
33 | LOG("FINGERPRINT field not found: " + e);
34 | } catch (SecurityException | IllegalAccessException | IllegalArgumentException |
35 | NullPointerException | ExceptionInInitializerError e) {
36 | LOG("FINGERPRINT field not accessible: " + e);
37 | }
38 | } else {
39 | int requestSdk = spoofVendingSdk == 1 ? 32 : spoofVendingSdk;
40 | int targetSdk = Math.min(Build.VERSION.SDK_INT, requestSdk);
41 | int oldValue;
42 | try {
43 | Field field = Build.VERSION.class.getDeclaredField("SDK_INT");
44 | field.setAccessible(true);
45 | oldValue = field.getInt(null);
46 | if (oldValue == targetSdk) {
47 | if (verboseLogs > 2) LOG(String.format("[SDK_INT]: %d (unchanged)", oldValue));
48 | field.setAccessible(false);
49 | return;
50 | }
51 | field.set(null, targetSdk);
52 | field.setAccessible(false);
53 | LOG(String.format("[SDK_INT]: %d -> %d", oldValue, targetSdk));
54 | } catch (NoSuchFieldException e) {
55 | LOG("SDK_INT field not found: " + e);
56 | } catch (SecurityException | IllegalAccessException | IllegalArgumentException |
57 | NullPointerException | ExceptionInInitializerError e) {
58 | LOG("SDK_INT field not accessible: " + e);
59 | }
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 | @rem SPDX-License-Identifier: Apache-2.0
17 | @rem
18 |
19 | @if "%DEBUG%"=="" @echo off
20 | @rem ##########################################################################
21 | @rem
22 | @rem Gradle startup script for Windows
23 | @rem
24 | @rem ##########################################################################
25 |
26 | @rem Set local scope for the variables with windows NT shell
27 | if "%OS%"=="Windows_NT" setlocal
28 |
29 | set DIRNAME=%~dp0
30 | if "%DIRNAME%"=="" set DIRNAME=.
31 | @rem This is normally unused
32 | set APP_BASE_NAME=%~n0
33 | set APP_HOME=%DIRNAME%
34 |
35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
37 |
38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
40 |
41 | @rem Find java.exe
42 | if defined JAVA_HOME goto findJavaFromJavaHome
43 |
44 | set JAVA_EXE=java.exe
45 | %JAVA_EXE% -version >NUL 2>&1
46 | if %ERRORLEVEL% equ 0 goto execute
47 |
48 | echo. 1>&2
49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50 | echo. 1>&2
51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52 | echo location of your Java installation. 1>&2
53 |
54 | goto fail
55 |
56 | :findJavaFromJavaHome
57 | set JAVA_HOME=%JAVA_HOME:"=%
58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
59 |
60 | if exist "%JAVA_EXE%" goto execute
61 |
62 | echo. 1>&2
63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64 | echo. 1>&2
65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66 | echo location of your Java installation. 1>&2
67 |
68 | goto fail
69 |
70 | :execute
71 | @rem Setup the command line
72 |
73 |
74 |
75 | @rem Execute Gradle
76 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
77 |
78 | :end
79 | @rem End local scope for the variables with windows NT shell
80 | if %ERRORLEVEL% equ 0 goto mainEnd
81 |
82 | :fail
83 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
84 | rem the _cmd.exe /c_ return code!
85 | set EXIT_CODE=%ERRORLEVEL%
86 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
87 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
88 | exit /b %EXIT_CODE%
89 |
90 | :mainEnd
91 | if "%OS%"=="Windows_NT" endlocal
92 |
93 | :omega
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Google Photos Unlimited
2 | A Zygisk module which gives unlimited Google Photos storage.
3 |
4 | To use this module you must have one of the following (latest versions):
5 |
6 | - [Magisk](https://github.com/topjohnwu/Magisk) with Zygisk enabled
7 | - [KernelSU](https://github.com/tiann/KernelSU) with [Zygisk Next](https://github.com/Dr-TSNG/ZygiskNext) or [ReZygisk](https://github.com/PerformanC/ReZygisk) module installed
8 | - [KernelSU Next](https://github.com/KernelSU-Next/KernelSU-Next) with [Zygisk Next](https://github.com/Dr-TSNG/ZygiskNext) or [ReZygisk](https://github.com/PerformanC/ReZygisk) module installed
9 | - [APatch](https://github.com/bmax121/APatch) with [Zygisk Next](https://github.com/Dr-TSNG/ZygiskNext) or [ReZygisk](https://github.com/PerformanC/ReZygisk) module installed
10 |
11 | ## About module
12 |
13 | It injects a classes.dex file to modify fields in the android.os.Build class. Also, it creates a hook in the native code to modify system properties. These are spoofed only into Google Photos.
14 |
15 | ## About 'custom.app_replace.list' file
16 |
17 | You can customize the included default [example.app_replace.list](https://raw.githubusercontent.com/Rev4N1/GPhotos-Unlimited/main/example.app_replace.list) from the module directory (/data/adb/modules/unlimitedphotos) then rename it to custom.app_replace.list to systemlessly replace any additional conflicting custom ROM spoof injection app paths to disable them.
18 |
19 | ## Troubleshooting
20 |
21 | Make sure Google Photos (com.google.android.apps.photos) is NOT on the Magisk DenyList if Enforce DenyList is enabled since this interferes with the module; the module does prevent this using scripts but it only happens once during each reboot.
22 |
23 | ### Failing to work (on KernelSU/APatch)
24 |
25 | - Disable Zygisk Next
26 | - Reboot
27 | - Enable Zygisk Next
28 | - Reboot again
29 |
30 | ### Read module logs
31 |
32 | You can read module logs using one of these commands directly after boot:
33 |
34 | `adb shell "logcat | grep 'FGP/'"` or `su -c "logcat | grep 'FGP/'"`
35 |
36 | Add a "verboseLogs" entry with a value of "0", "1", "2", "3" or "100" to your custom.fgp.json to enable higher logging levels; "100" will dump all Build fields, and all the system properties that Photos is checking.
37 |
38 | ## About spoofing Advanced Settings
39 |
40 | The advanced spoofing options add granular control over what exactly gets spoofed, allowing one to disable the parts that may conflict with other kinds of spoofing modules. See more in the Details area below.
41 |
42 |
43 | Details
44 |
45 | - Other than for the "verboseLogs" entry (see above), they are all 0 (disabled) or 1 (enabled).
46 |
47 | - The "spoofBuild" entry (default 1) controls spoofing the Build Fields from the fingerprint; the "spoofProps" entry (default 1) controls spoofing the System Properties from the fingerprint; the "spoofProvider" entry (default 1) controls spoofing the Keystore Provider, and the "spoofSignature" entry (default 0) controls spoofing the ROM Signature.
48 |
49 |
50 |
51 |
52 | ## Credits
53 |
54 | Module scripts were adapted from those of osm0sis's Play Integrity Fork (PIFork) module, please see the commit history of [osm0sis's Play Integrity Fork](https://github.com/osm0sis/PlayIntegrityFork) for proper attribution.
--------------------------------------------------------------------------------
/module/common_setup.sh:
--------------------------------------------------------------------------------
1 | # Replace/hide conflicting Pixel Configurations files to disable them
2 | directory="/system/product/etc/sysconfig"
3 | for APP in $directory/pixel_experience_*; do
4 | # Extract the year from the APP name
5 | year="${APP#*pixel_experience_}"
6 | year="${year:0:4}"
7 |
8 | # Check if the year is higher than 2019
9 | if [ "$year" -gt 2019 ]; then
10 | case $APP in
11 | /system/*) ;;
12 | *) PREFIX=/system;;
13 | esac
14 | HIDEPATH=$MODPATH$PREFIX$APP
15 | mkdir -p $(dirname $HIDEPATH)
16 | if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
17 | mknod $HIDEPATH c 0 0
18 | else
19 | touch $HIDEPATH
20 | fi
21 | fi
22 | done
23 |
24 |
25 | # Replace/hide conflicting custom ROM injection app folders/files to disable them
26 | LIST=$MODPATH/app_replace_list.txt
27 | [ -f "$MODPATH/custom.app_replace_list.txt" ] && LIST=$MODPATH/custom.app_replace_list.txt
28 | for APP in $(grep -v '^#' $LIST); do
29 | if [ -e "$APP" ]; then
30 | case $APP in
31 | /system/*) ;;
32 | *) PREFIX=/system;;
33 | esac
34 | HIDEPATH=$MODPATH$PREFIX$APP
35 | if [ -d "$APP" ]; then
36 | mkdir -p $HIDEPATH
37 | if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
38 | setfattr -n trusted.overlay.opaque -v y $HIDEPATH
39 | else
40 | touch $HIDEPATH/.replace
41 | fi
42 | else
43 | mkdir -p $(dirname $HIDEPATH)
44 | if [ "$KSU" = "true" -o "$APATCH" = "true" ]; then
45 | mknod $HIDEPATH c 0 0
46 | else
47 | touch $HIDEPATH
48 | fi
49 | fi
50 | case $APP in
51 | */overlay/*)
52 | CFG=$(echo $APP | grep -oE '.*/overlay')/config/config.xml
53 | if [ -f "$CFG" ]; then
54 | if [ -d "$APP" ]; then
55 | APK=$(readlink -f $APP/*.apk);
56 | elif [[ "$APP" = *".apk" ]]; then
57 | APK=$(readlink -f $APP);
58 | fi
59 | if [ -s "$APK" ]; then
60 | PKGNAME=$(unzip -p $APK AndroidManifest.xml | tr -d '\0' | grep -oE 'android.*overlay' | strings | tr -d '\n' | sed -e 's/^android//' -e 's/application//' -e 's;*http.*res/android;;' -e 's/manifest//' -e 's/overlay$//' | grep -oE '[[:alnum:].-_].*overlay' | cut -d\ -f2)
61 | if [ "$PKGNAME" ] && grep -q "overlay package=\"$PKGNAME" $CFG; then
62 | HIDECFG=$MODPATH$PREFIX$CFG
63 | if [ ! -f "$HIDECFG" ]; then
64 | mkdir -p $(dirname $HIDECFG)
65 | cp -af $CFG $HIDECFG
66 | fi
67 | sed -i 's;;;' $HIDECFG
68 | fi
69 | fi
70 | fi
71 | ;;
72 | esac
73 | if [[ -d "$APP" || "$APP" = *".apk" ]]; then
74 | ui_print "! $(basename $APP .apk) ROM app disabled, please uninstall any user app versions/updates after next reboot"
75 | [ "$HIDECFG" ] && ui_print "! + $PKGNAME entry commented out in copied overlay config"
76 | fi
77 | fi
78 | done
--------------------------------------------------------------------------------
/app/src/main/java/com/rev4n/unlimitedphotos/CustomKeyStoreSpi.java:
--------------------------------------------------------------------------------
1 | package com.rev4n.unlimitedphotos;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.io.OutputStream;
6 | import java.security.Key;
7 | import java.security.KeyStoreException;
8 | import java.security.KeyStoreSpi;
9 | import java.security.NoSuchAlgorithmException;
10 | import java.security.UnrecoverableKeyException;
11 | import java.security.cert.Certificate;
12 | import java.security.cert.CertificateException;
13 | import java.util.Date;
14 | import java.util.Enumeration;
15 | import java.util.Locale;
16 |
17 | public final class CustomKeyStoreSpi extends KeyStoreSpi {
18 | public static volatile KeyStoreSpi keyStoreSpi;
19 |
20 | @Override
21 | public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException {
22 | return keyStoreSpi.engineGetKey(alias, password);
23 | }
24 |
25 | @Override
26 | public Certificate[] engineGetCertificateChain(String alias) {
27 | for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
28 | if (e.getClassName().toLowerCase(Locale.ROOT).contains("droidguard")) {
29 | EntryPoint.LOG("DroidGuard detected!");
30 | throw new UnsupportedOperationException();
31 | }
32 | }
33 | return keyStoreSpi.engineGetCertificateChain(alias);
34 | }
35 |
36 | @Override
37 | public Certificate engineGetCertificate(String alias) {
38 | return keyStoreSpi.engineGetCertificate(alias);
39 | }
40 |
41 | @Override
42 | public Date engineGetCreationDate(String alias) {
43 | return keyStoreSpi.engineGetCreationDate(alias);
44 | }
45 |
46 | @Override
47 | public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException {
48 | keyStoreSpi.engineSetKeyEntry(alias, key, password, chain);
49 | }
50 |
51 | @Override
52 | public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException {
53 | keyStoreSpi.engineSetKeyEntry(alias, key, chain);
54 | }
55 |
56 | @Override
57 | public void engineSetCertificateEntry(String alias, Certificate cert) throws KeyStoreException {
58 | keyStoreSpi.engineSetCertificateEntry(alias, cert);
59 | }
60 |
61 | @Override
62 | public void engineDeleteEntry(String alias) throws KeyStoreException {
63 | keyStoreSpi.engineDeleteEntry(alias);
64 | }
65 |
66 | @Override
67 | public Enumeration engineAliases() {
68 | return keyStoreSpi.engineAliases();
69 | }
70 |
71 | @Override
72 | public boolean engineContainsAlias(String alias) {
73 | return keyStoreSpi.engineContainsAlias(alias);
74 | }
75 |
76 | @Override
77 | public int engineSize() {
78 | return keyStoreSpi.engineSize();
79 | }
80 |
81 | @Override
82 | public boolean engineIsKeyEntry(String alias) {
83 | return keyStoreSpi.engineIsKeyEntry(alias);
84 | }
85 |
86 | @Override
87 | public boolean engineIsCertificateEntry(String alias) {
88 | return keyStoreSpi.engineIsCertificateEntry(alias);
89 | }
90 |
91 | @Override
92 | public String engineGetCertificateAlias(Certificate cert) {
93 | return keyStoreSpi.engineGetCertificateAlias(cert);
94 | }
95 |
96 | @Override
97 | public void engineStore(OutputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException {
98 | keyStoreSpi.engineStore(stream, password);
99 | }
100 |
101 | @Override
102 | public void engineLoad(InputStream stream, char[] password) throws CertificateException, IOException, NoSuchAlgorithmException {
103 | keyStoreSpi.engineLoad(stream, password);
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # SPDX-License-Identifier: Apache-2.0
19 | #
20 |
21 | ##############################################################################
22 | #
23 | # Gradle start up script for POSIX generated by Gradle.
24 | #
25 | # Important for running:
26 | #
27 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
28 | # noncompliant, but you have some other compliant shell such as ksh or
29 | # bash, then to run this script, type that shell name before the whole
30 | # command line, like:
31 | #
32 | # ksh Gradle
33 | #
34 | # Busybox and similar reduced shells will NOT work, because this script
35 | # requires all of these POSIX shell features:
36 | # * functions;
37 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
38 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
39 | # * compound commands having a testable exit status, especially «case»;
40 | # * various built-in commands including «command», «set», and «ulimit».
41 | #
42 | # Important for patching:
43 | #
44 | # (2) This script targets any POSIX shell, so it avoids extensions provided
45 | # by Bash, Ksh, etc; in particular arrays are avoided.
46 | #
47 | # The "traditional" practice of packing multiple parameters into a
48 | # space-separated string is a well documented source of bugs and security
49 | # problems, so this is (mostly) avoided, by progressively accumulating
50 | # options in "$@", and eventually passing that to Java.
51 | #
52 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
53 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
54 | # see the in-line comments for details.
55 | #
56 | # There are tweaks for specific operating systems such as AIX, CygWin,
57 | # Darwin, MinGW, and NonStop.
58 | #
59 | # (3) This script is generated from the Groovy template
60 | # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
61 | # within the Gradle project.
62 | #
63 | # You can find Gradle at https://github.com/gradle/gradle/.
64 | #
65 | ##############################################################################
66 |
67 | # Attempt to set APP_HOME
68 |
69 | # Resolve links: $0 may be a link
70 | app_path=$0
71 |
72 | # Need this for daisy-chained symlinks.
73 | while
74 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
75 | [ -h "$app_path" ]
76 | do
77 | ls=$( ls -ld "$app_path" )
78 | link=${ls#*' -> '}
79 | case $link in #(
80 | /*) app_path=$link ;; #(
81 | *) app_path=$APP_HOME$link ;;
82 | esac
83 | done
84 |
85 | # This is normally unused
86 | # shellcheck disable=SC2034
87 | APP_BASE_NAME=${0##*/}
88 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89 | APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 |
118 |
119 | # Determine the Java command to use to start the JVM.
120 | if [ -n "$JAVA_HOME" ] ; then
121 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
122 | # IBM's JDK on AIX uses strange locations for the executables
123 | JAVACMD=$JAVA_HOME/jre/sh/java
124 | else
125 | JAVACMD=$JAVA_HOME/bin/java
126 | fi
127 | if [ ! -x "$JAVACMD" ] ; then
128 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
129 |
130 | Please set the JAVA_HOME variable in your environment to match the
131 | location of your Java installation."
132 | fi
133 | else
134 | JAVACMD=java
135 | if ! command -v java >/dev/null 2>&1
136 | then
137 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
138 |
139 | Please set the JAVA_HOME variable in your environment to match the
140 | location of your Java installation."
141 | fi
142 | fi
143 |
144 | # Increase the maximum file descriptors if we can.
145 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
146 | case $MAX_FD in #(
147 | max*)
148 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
149 | # shellcheck disable=SC2039,SC3045
150 | MAX_FD=$( ulimit -H -n ) ||
151 | warn "Could not query maximum file descriptor limit"
152 | esac
153 | case $MAX_FD in #(
154 | '' | soft) :;; #(
155 | *)
156 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
157 | # shellcheck disable=SC2039,SC3045
158 | ulimit -n "$MAX_FD" ||
159 | warn "Could not set maximum file descriptor limit to $MAX_FD"
160 | esac
161 | fi
162 |
163 | # Collect all arguments for the java command, stacking in reverse order:
164 | # * args from the command line
165 | # * the main class name
166 | # * -classpath
167 | # * -D...appname settings
168 | # * --module-path (only if needed)
169 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
170 |
171 | # For Cygwin or MSYS, switch paths to Windows format before running java
172 | if "$cygwin" || "$msys" ; then
173 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
174 |
175 | JAVACMD=$( cygpath --unix "$JAVACMD" )
176 |
177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
178 | for arg do
179 | if
180 | case $arg in #(
181 | -*) false ;; # don't mess with options #(
182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
183 | [ -e "$t" ] ;; #(
184 | *) false ;;
185 | esac
186 | then
187 | arg=$( cygpath --path --ignore --mixed "$arg" )
188 | fi
189 | # Roll the args list around exactly as many times as the number of
190 | # args, so each arg winds up back in the position where it started, but
191 | # possibly modified.
192 | #
193 | # NB: a `for` loop captures its iteration list before it begins, so
194 | # changing the positional parameters here affects neither the number of
195 | # iterations, nor the values presented in `arg`.
196 | shift # remove old arg
197 | set -- "$@" "$arg" # push replacement arg
198 | done
199 | fi
200 |
201 |
202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204 |
205 | # Collect all arguments for the java command:
206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207 | # and any embedded shellness will be escaped.
208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209 | # treated as '${Hostname}' itself on the command line.
210 |
211 | set -- \
212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
213 | -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
214 | "$@"
215 |
216 | # Stop when "xargs" is not available.
217 | if ! command -v xargs >/dev/null 2>&1
218 | then
219 | die "xargs is not available"
220 | fi
221 |
222 | # Use "xargs" to parse quoted args.
223 | #
224 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
225 | #
226 | # In Bash we could simply go:
227 | #
228 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
229 | # set -- "${ARGS[@]}" "$@"
230 | #
231 | # but POSIX shell has neither arrays nor command substitution, so instead we
232 | # post-process each arg (as a line of input to sed) to backslash-escape any
233 | # character that might be a shell metacharacter, then use eval to reverse
234 | # that process (while maintaining the separation between arguments), and wrap
235 | # the whole thing up as a single "set" statement.
236 | #
237 | # This will of course break if any of these variables contains a newline or
238 | # an unmatched quote.
239 | #
240 |
241 | eval "set -- $(
242 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
243 | xargs -n1 |
244 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
245 | tr '\n' ' '
246 | )" '"$@"'
247 |
248 | exec "$JAVACMD" "$@"
249 |
--------------------------------------------------------------------------------
/app/src/main/java/com/rev4n/unlimitedphotos/EntryPoint.java:
--------------------------------------------------------------------------------
1 | package com.rev4n.unlimitedphotos;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.PackageManager;
5 | import android.content.pm.Signature;
6 | import android.os.Build;
7 | import android.os.Parcel;
8 | import android.os.Parcelable;
9 | import android.util.Base64;
10 | import android.util.JsonReader;
11 | import android.util.Log;
12 |
13 | import org.lsposed.hiddenapibypass.HiddenApiBypass;
14 |
15 | import java.io.IOException;
16 | import java.io.StringReader;
17 | import java.lang.reflect.Field;
18 | import java.lang.reflect.Method;
19 | import java.security.KeyStore;
20 | import java.security.KeyStoreException;
21 | import java.security.KeyStoreSpi;
22 | import java.security.Provider;
23 | import java.security.Security;
24 | import java.util.HashMap;
25 | import java.util.Map;
26 |
27 | public final class EntryPoint {
28 | private static Integer verboseLogs = 0;
29 | private static Integer spoofBuildEnabled = 1;
30 |
31 | private static final String signatureData = "MIIFyTCCA7GgAwIBAgIVALyxxl+zDS9SL68SzOr48309eAZyMA0GCSqGSIb3DQEBCwUAMHQxCzAJ\n" +
32 | "BgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQw\n" +
33 | "EgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAg\n" +
34 | "Fw0yMjExMDExODExMzVaGA8yMDUyMTEwMTE4MTEzNVowdDELMAkGA1UEBhMCVVMxEzARBgNVBAgT\n" +
35 | "CkNhbGlmb3JuaWExFjAUBgNVBAcTDU1vdW50YWluIFZpZXcxFDASBgNVBAoTC0dvb2dsZSBJbmMu\n" +
36 | "MRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMIICIjANBgkqhkiG9w0BAQEFAAOC\n" +
37 | "Ag8AMIICCgKCAgEAsqtalIy/nctKlrhd1UVoDffFGnDf9GLi0QQhsVoJkfF16vDDydZJOycG7/kQ\n" +
38 | "ziRZhFdcoMrIYZzzw0ppBjsSe1AiWMuKXwTBaEtxN99S1xsJiW4/QMI6N6kMunydWRMsbJ6aAxi1\n" +
39 | "lVq0bxSwr8Sg/8u9HGVivfdG8OpUM+qjuV5gey5xttNLK3BZDrAlco8RkJZryAD40flmJZrWXJmc\n" +
40 | "r2HhJJUnqG4Z3MSziEgW1u1JnnY3f/BFdgYsA54SgdUGdQP3aqzSjIpGK01/vjrXvifHazSANjvl\n" +
41 | "0AUE5i6AarMw2biEKB2ySUDp8idC5w12GpqDrhZ/QkW8yBSa87KbkMYXuRA2Gq1fYbQx3YJraw0U\n" +
42 | "gZ4M3fFKpt6raxxM5j0sWHlULD7dAZMERvNESVrKG3tQ7B39WAD8QLGYc45DFEGOhKv5Fv8510h5\n" +
43 | "sXK502IvGpI4FDwz2rbtAgJ0j+16db5wCSW5ThvNPhCheyciajc8dU1B5tJzZN/ksBpzne4Xf9gO\n" +
44 | "LZ9ZU0+3Z5gHVvTS/YpxBFwiFpmL7dvGxew0cXGSsG5UTBlgr7i0SX0WhY4Djjo8IfPwrvvA0QaC\n" +
45 | "FamdYXKqBsSHgEyXS9zgGIFPt2jWdhaS+sAa//5SXcWro0OdiKPuwEzLgj759ke1sHRnvO735dYn\n" +
46 | "5whVbzlGyLBh3L0CAwEAAaNQME4wDAYDVR0TBAUwAwEB/zAdBgNVHQ4EFgQUU1eXQ7NoYKjvOQlh\n" +
47 | "5V8jHQMoxA8wHwYDVR0jBBgwFoAUU1eXQ7NoYKjvOQlh5V8jHQMoxA8wDQYJKoZIhvcNAQELBQAD\n" +
48 | "ggIBAHFIazRLs3itnZKllPnboSd6sHbzeJURKehx8GJPvIC+xWlwWyFO5+GHmgc3yh/SVd3Xja/k\n" +
49 | "8Ud59WEYTjyJJWTw0Jygx37rHW7VGn2HDuy/x0D+els+S8HeLD1toPFMepjIXJn7nHLhtmzTPlDW\n" +
50 | "DrhiaYsls/k5Izf89xYnI4euuOY2+1gsweJqFGfbznqyqy8xLyzoZ6bvBJtgeY+G3i/9Be14HseS\n" +
51 | "Na4FvI1Oze/l2gUu1IXzN6DGWR/lxEyt+TncJfBGKbjafYrfSh3zsE4N3TU7BeOL5INirOMjre/j\n" +
52 | "VgB1YQG5qLVaPoz6mdn75AbBBm5a5ahApLiKqzy/hP+1rWgw8Ikb7vbUqov/bnY3IlIU6XcPJTCD\n" +
53 | "b9aRZQkStvYpQd82XTyxD/T0GgRLnUj5Uv6iZlikFx1KNj0YNS2T3gyvL++J9B0Y6gAkiG0EtNpl\n" +
54 | "z7Pomsv5pVdmHVdKMjqWw5/6zYzVmu5cXFtR384Ti1qwML1xkD6TC3VIv88rKIEjrkY2c+v1frh9\n" +
55 | "fRJ2OmzXmML9NgHTjEiJR2Ib2iNrMKxkuTIs9oxKZgrJtJKvdU9qJJKM5PnZuNuHhGs6A/9gt9Oc\n" +
56 | "cetYeQvVSqeEmQluWfcunQn9C9Vwi2BJIiVJh4IdWZf5/e2PlSSQ9CJjz2bKI17pzdxOmjQfE0JS\n" +
57 | "F7Xt\n";
58 |
59 | private static final Map map = new HashMap<>();
60 |
61 | public static Integer getVerboseLogs() {
62 | return verboseLogs;
63 | }
64 |
65 | public static Integer getSpoofBuildEnabled() {
66 | return spoofBuildEnabled;
67 | }
68 |
69 | public static void init(int logLevel, int spoofBuildVal, int spoofProviderVal, int spoofSignatureVal) {
70 | verboseLogs = logLevel;
71 | spoofBuildEnabled = spoofBuildVal;
72 | if (verboseLogs > 99) logFields();
73 | if (spoofProviderVal > 0) spoofProvider();
74 | if (spoofBuildVal > 0) spoofDevice();
75 | if (spoofSignatureVal > 0) spoofPackageManager();
76 | }
77 |
78 | public static void receiveJson(String data) {
79 | try (JsonReader reader = new JsonReader(new StringReader(data))) {
80 | reader.beginObject();
81 | while (reader.hasNext()) {
82 | map.put(reader.nextName(), reader.nextString());
83 | }
84 | reader.endObject();
85 | } catch (IOException|IllegalStateException e) {
86 | LOG("Couldn't read JSON from Zygisk: " + e);
87 | map.clear();
88 | return;
89 | }
90 | }
91 |
92 | private static void spoofProvider() {
93 | final String KEYSTORE = "AndroidKeyStore";
94 |
95 | try {
96 | Provider provider = Security.getProvider(KEYSTORE);
97 | KeyStore keyStore = KeyStore.getInstance(KEYSTORE);
98 |
99 | Field f = keyStore.getClass().getDeclaredField("keyStoreSpi");
100 | f.setAccessible(true);
101 | CustomKeyStoreSpi.keyStoreSpi = (KeyStoreSpi) f.get(keyStore);
102 | f.setAccessible(false);
103 |
104 | CustomProvider customProvider = new CustomProvider(provider);
105 | Security.removeProvider(KEYSTORE);
106 | Security.insertProviderAt(customProvider, 1);
107 |
108 | LOG("Spoof KeyStoreSpi and Provider done!");
109 |
110 | } catch (KeyStoreException e) {
111 | LOG("Couldn't find KeyStore: " + e);
112 | } catch (NoSuchFieldException e) {
113 | LOG("Couldn't find field: " + e);
114 | } catch (IllegalAccessException e) {
115 | LOG("Couldn't change access of field: " + e);
116 | }
117 | }
118 |
119 | static void spoofDevice() {
120 | for (String key : map.keySet()) {
121 | setField(key, map.get(key));
122 | }
123 | }
124 |
125 | private static void spoofPackageManager() {
126 | Signature spoofedSignature = new Signature(Base64.decode(signatureData, Base64.DEFAULT));
127 | Parcelable.Creator originalCreator = PackageInfo.CREATOR;
128 | Parcelable.Creator customCreator = new CustomPackageInfoCreator(originalCreator, spoofedSignature);
129 |
130 | try {
131 | Field creatorField = findField(PackageInfo.class, "CREATOR");
132 | creatorField.setAccessible(true);
133 | creatorField.set(null, customCreator);
134 | } catch (Exception e) {
135 | LOG("Couldn't replace PackageInfoCreator: " + e);
136 | }
137 |
138 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
139 | HiddenApiBypass.addHiddenApiExemptions("Landroid/os/Parcel;", "Landroid/content/pm", "Landroid/app");
140 | }
141 |
142 | try {
143 | Field cacheField = findField(PackageManager.class, "sPackageInfoCache");
144 | cacheField.setAccessible(true);
145 | Object cache = cacheField.get(null);
146 | Method clearMethod = cache.getClass().getMethod("clear");
147 | clearMethod.invoke(cache);
148 | } catch (Exception e) {
149 | LOG("Couldn't clear PackageInfoCache: " + e);
150 | }
151 |
152 | try {
153 | Field creatorsField = findField(Parcel.class, "mCreators");
154 | creatorsField.setAccessible(true);
155 | Map, ?> mCreators = (Map, ?>) creatorsField.get(null);
156 | mCreators.clear();
157 | } catch (Exception e) {
158 | LOG("Couldn't clear Parcel mCreators: " + e);
159 | }
160 |
161 | try {
162 | Field creatorsField = findField(Parcel.class, "sPairedCreators");
163 | creatorsField.setAccessible(true);
164 | Map, ?> sPairedCreators = (Map, ?>) creatorsField.get(null);
165 | sPairedCreators.clear();
166 | } catch (Exception e) {
167 | LOG("Couldn't clear Parcel sPairedCreators: " + e);
168 | }
169 | }
170 |
171 | private static Field findField(Class> currentClass, String fieldName) throws NoSuchFieldException {
172 | while (currentClass != null && !currentClass.equals(Object.class)) {
173 | try {
174 | return currentClass.getDeclaredField(fieldName);
175 | } catch (NoSuchFieldException e) {
176 | currentClass = currentClass.getSuperclass();
177 | }
178 | }
179 | throw new NoSuchFieldException("Field '" + fieldName + "' not found in class hierarchy of " + currentClass.getName());
180 | }
181 |
182 | private static boolean classContainsField(Class className, String fieldName) {
183 | for (Field field : className.getDeclaredFields()) {
184 | if (field.getName().equals(fieldName)) return true;
185 | }
186 | return false;
187 | }
188 |
189 | private static void setField(String name, String value) {
190 | if (value.isEmpty()) {
191 | LOG(String.format("%s is empty, skipping", name));
192 | return;
193 | }
194 |
195 | Field field = null;
196 | String oldValue = null;
197 | Object newValue = null;
198 |
199 | try {
200 | if (classContainsField(Build.class, name)) {
201 | field = Build.class.getDeclaredField(name);
202 | } else if (classContainsField(Build.VERSION.class, name)) {
203 | field = Build.VERSION.class.getDeclaredField(name);
204 | } else {
205 | if (verboseLogs > 1) LOG(String.format("Couldn't determine '%s' class name", name));
206 | return;
207 | }
208 | } catch (NoSuchFieldException e) {
209 | LOG(String.format("Couldn't find '%s' field name: " + e, name));
210 | return;
211 | }
212 | field.setAccessible(true);
213 | try {
214 | oldValue = String.valueOf(field.get(null));
215 | } catch (IllegalAccessException e) {
216 | LOG(String.format("Couldn't access '%s' field value: " + e, name));
217 | return;
218 | }
219 | if (value.equals(oldValue)) {
220 | if (verboseLogs > 2) LOG(String.format("[%s]: %s (unchanged)", name, value));
221 | return;
222 | }
223 | Class> fieldType = field.getType();
224 | if (fieldType == String.class) {
225 | newValue = value;
226 | } else if (fieldType == int.class) {
227 | newValue = Integer.parseInt(value);
228 | } else if (fieldType == long.class) {
229 | newValue = Long.parseLong(value);
230 | } else if (fieldType == boolean.class) {
231 | newValue = Boolean.parseBoolean(value);
232 | } else {
233 | LOG(String.format("Couldn't convert '%s' to '%s' type", value, fieldType));
234 | return;
235 | }
236 | try {
237 | field.set(null, newValue);
238 | } catch (IllegalAccessException e) {
239 | LOG(String.format("Couldn't modify '%s' field value: " + e, name));
240 | return;
241 | }
242 | field.setAccessible(false);
243 | LOG(String.format("[%s]: %s -> %s", name, oldValue, value));
244 | }
245 |
246 | private static String logParseField(Field field) {
247 | Object value = null;
248 | String type = field.getType().getName();
249 | String name = field.getName();
250 | try {
251 | value = field.get(null);
252 | } catch (IllegalAccessException|NullPointerException e) {
253 | return String.format("Couldn't access '%s' field value: " + e, name);
254 | }
255 | return String.format("<%s> %s: %s", type, name, String.valueOf(value));
256 | }
257 |
258 | private static void logFields() {
259 | for (Field field : Build.class.getDeclaredFields()) {
260 | LOG("Build " + logParseField(field));
261 | }
262 | for (Field field : Build.VERSION.class.getDeclaredFields()) {
263 | LOG("Build.VERSION " + logParseField(field));
264 | }
265 | }
266 |
267 | static void LOG(String msg) {
268 | Log.d("FGP/Java:DG", msg);
269 | }
270 | }
271 |
--------------------------------------------------------------------------------
/app/src/main/cpp/zygisk.hpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2022-2023 John "topjohnwu" Wu
2 | *
3 | * Permission to use, copy, modify, and/or distribute this software for any
4 | * purpose with or without fee is hereby granted.
5 | *
6 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
7 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
8 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
9 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
11 | * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
12 | * PERFORMANCE OF THIS SOFTWARE.
13 | */
14 |
15 | // This is the public API for Zygisk modules.
16 | // DO NOT MODIFY ANY CODE IN THIS HEADER.
17 |
18 | #pragma once
19 |
20 | #include
21 |
22 | #define ZYGISK_API_VERSION 2
23 |
24 | /*
25 |
26 | ***************
27 | * Introduction
28 | ***************
29 |
30 | On Android, all app processes are forked from a special daemon called "Zygote".
31 | For each new app process, zygote will fork a new process and perform "specialization".
32 | This specialization operation enforces the Android security sandbox on the newly forked
33 | process to make sure that 3rd party application code is only loaded after it is being
34 | restricted within a sandbox.
35 |
36 | On Android, there is also this special process called "system_server". This single
37 | process hosts a significant portion of system services, which controls how the
38 | Android operating system and apps interact with each other.
39 |
40 | The Zygisk framework provides a way to allow developers to build modules and run custom
41 | code before and after system_server and any app processes' specialization.
42 | This enable developers to inject code and alter the behavior of system_server and app processes.
43 |
44 | Please note that modules will only be loaded after zygote has forked the child process.
45 | THIS MEANS ALL OF YOUR CODE RUNS IN THE APP/SYSTEM_SERVER PROCESS, NOT THE ZYGOTE DAEMON!
46 |
47 | *********************
48 | * Development Guide
49 | *********************
50 |
51 | Define a class and inherit zygisk::ModuleBase to implement the functionality of your module.
52 | Use the macro REGISTER_ZYGISK_MODULE(className) to register that class to Zygisk.
53 |
54 | Example code:
55 |
56 | static jint (*orig_logger_entry_max)(JNIEnv *env);
57 | static jint my_logger_entry_max(JNIEnv *env) { return orig_logger_entry_max(env); }
58 |
59 | class ExampleModule : public zygisk::ModuleBase {
60 | public:
61 | void onLoad(zygisk::Api *api, JNIEnv *env) override {
62 | this->api = api;
63 | this->env = env;
64 | }
65 | void preAppSpecialize(zygisk::AppSpecializeArgs *args) override {
66 | JNINativeMethod methods[] = {
67 | { "logger_entry_max_payload_native", "()I", (void*) my_logger_entry_max },
68 | };
69 | api->hookJniNativeMethods(env, "android/util/Log", methods, 1);
70 | *(void **) &orig_logger_entry_max = methods[0].fnPtr;
71 | }
72 | private:
73 | zygisk::Api *api;
74 | JNIEnv *env;
75 | };
76 |
77 | REGISTER_ZYGISK_MODULE(ExampleModule)
78 |
79 | -----------------------------------------------------------------------------------------
80 |
81 | Since your module class's code runs with either Zygote's privilege in pre[XXX]Specialize,
82 | or runs in the sandbox of the target process in post[XXX]Specialize, the code in your class
83 | never runs in a true superuser environment.
84 |
85 | If your module require access to superuser permissions, you can create and register
86 | a root companion handler function. This function runs in a separate root companion
87 | daemon process, and an Unix domain socket is provided to allow you to perform IPC between
88 | your target process and the root companion process.
89 |
90 | Example code:
91 |
92 | static void example_handler(int socket) { ... }
93 |
94 | REGISTER_ZYGISK_COMPANION(example_handler)
95 |
96 | */
97 |
98 | namespace zygisk {
99 |
100 | struct Api;
101 | struct AppSpecializeArgs;
102 | struct ServerSpecializeArgs;
103 |
104 | class ModuleBase {
105 | public:
106 |
107 | // This method is called as soon as the module is loaded into the target process.
108 | // A Zygisk API handle will be passed as an argument.
109 | virtual void onLoad([[maybe_unused]] Api *api, [[maybe_unused]] JNIEnv *env) {}
110 |
111 | // This method is called before the app process is specialized.
112 | // At this point, the process just got forked from zygote, but no app specific specialization
113 | // is applied. This means that the process does not have any sandbox restrictions and
114 | // still runs with the same privilege of zygote.
115 | //
116 | // All the arguments that will be sent and used for app specialization is passed as a single
117 | // AppSpecializeArgs object. You can read and overwrite these arguments to change how the app
118 | // process will be specialized.
119 | //
120 | // If you need to run some operations as superuser, you can call Api::connectCompanion() to
121 | // get a socket to do IPC calls with a root companion process.
122 | // See Api::connectCompanion() for more info.
123 | virtual void preAppSpecialize([[maybe_unused]] AppSpecializeArgs *args) {}
124 |
125 | // This method is called after the app process is specialized.
126 | // At this point, the process has all sandbox restrictions enabled for this application.
127 | // This means that this method runs with the same privilege of the app's own code.
128 | virtual void postAppSpecialize([[maybe_unused]] const AppSpecializeArgs *args) {}
129 |
130 | // This method is called before the system server process is specialized.
131 | // See preAppSpecialize(args) for more info.
132 | virtual void preServerSpecialize([[maybe_unused]] ServerSpecializeArgs *args) {}
133 |
134 | // This method is called after the system server process is specialized.
135 | // At this point, the process runs with the privilege of system_server.
136 | virtual void postServerSpecialize([[maybe_unused]] const ServerSpecializeArgs *args) {}
137 | };
138 |
139 | struct AppSpecializeArgs {
140 | // Required arguments. These arguments are guaranteed to exist on all Android versions.
141 | jint &uid;
142 | jint &gid;
143 | jintArray &gids;
144 | jint &runtime_flags;
145 | jint &mount_external;
146 | jstring &se_info;
147 | jstring &nice_name;
148 | jstring &instruction_set;
149 | jstring &app_data_dir;
150 |
151 | // Optional arguments. Please check whether the pointer is null before de-referencing
152 | jboolean *const is_child_zygote;
153 | jboolean *const is_top_app;
154 | jobjectArray *const pkg_data_info_list;
155 | jobjectArray *const whitelisted_data_info_list;
156 | jboolean *const mount_data_dirs;
157 | jboolean *const mount_storage_dirs;
158 |
159 | AppSpecializeArgs() = delete;
160 | };
161 |
162 | struct ServerSpecializeArgs {
163 | jint &uid;
164 | jint &gid;
165 | jintArray &gids;
166 | jint &runtime_flags;
167 | jlong &permitted_capabilities;
168 | jlong &effective_capabilities;
169 |
170 | ServerSpecializeArgs() = delete;
171 | };
172 |
173 | namespace internal {
174 | struct api_table;
175 | template void entry_impl(api_table *, JNIEnv *);
176 | }
177 |
178 | // These values are used in Api::setOption(Option)
179 | enum Option : int {
180 | // Force Magisk's denylist unmount routines to run on this process.
181 | //
182 | // Setting this option only makes sense in preAppSpecialize.
183 | // The actual unmounting happens during app process specialization.
184 | //
185 | // Set this option to force all Magisk and modules' files to be unmounted from the
186 | // mount namespace of the process, regardless of the denylist enforcement status.
187 | FORCE_DENYLIST_UNMOUNT = 0,
188 |
189 | // When this option is set, your module's library will be dlclose-ed after post[XXX]Specialize.
190 | // Be aware that after dlclose-ing your module, all of your code will be unmapped from memory.
191 | // YOU MUST NOT ENABLE THIS OPTION AFTER HOOKING ANY FUNCTIONS IN THE PROCESS.
192 | DLCLOSE_MODULE_LIBRARY = 1,
193 | };
194 |
195 | // Bit masks of the return value of Api::getFlags()
196 | enum StateFlag : uint32_t {
197 | // The user has granted root access to the current process
198 | PROCESS_GRANTED_ROOT = (1u << 0),
199 |
200 | // The current process was added on the denylist
201 | PROCESS_ON_DENYLIST = (1u << 1),
202 | };
203 |
204 | // All API methods will stop working after post[XXX]Specialize as Zygisk will be unloaded
205 | // from the specialized process afterwards.
206 | struct Api {
207 |
208 | // Connect to a root companion process and get a Unix domain socket for IPC.
209 | //
210 | // This API only works in the pre[XXX]Specialize methods due to SELinux restrictions.
211 | //
212 | // The pre[XXX]Specialize methods run with the same privilege of zygote.
213 | // If you would like to do some operations with superuser permissions, register a handler
214 | // function that would be called in the root process with REGISTER_ZYGISK_COMPANION(func).
215 | // Another good use case for a companion process is that if you want to share some resources
216 | // across multiple processes, hold the resources in the companion process and pass it over.
217 | //
218 | // The root companion process is ABI aware; that is, when calling this method from a 32-bit
219 | // process, you will be connected to a 32-bit companion process, and vice versa for 64-bit.
220 | //
221 | // Returns a file descriptor to a socket that is connected to the socket passed to your
222 | // module's companion request handler. Returns -1 if the connection attempt failed.
223 | int connectCompanion();
224 |
225 | // Get the file descriptor of the root folder of the current module.
226 | //
227 | // This API only works in the pre[XXX]Specialize methods.
228 | // Accessing the directory returned is only possible in the pre[XXX]Specialize methods
229 | // or in the root companion process (assuming that you sent the fd over the socket).
230 | // Both restrictions are due to SELinux and UID.
231 | //
232 | // Returns -1 if errors occurred.
233 | int getModuleDir();
234 |
235 | // Set various options for your module.
236 | // Please note that this method accepts one single option at a time.
237 | // Check zygisk::Option for the full list of options available.
238 | void setOption(Option opt);
239 |
240 | // Get information about the current process.
241 | // Returns bitwise-or'd zygisk::StateFlag values.
242 | uint32_t getFlags();
243 |
244 | // Hook JNI native methods for a class
245 | //
246 | // Lookup all registered JNI native methods and replace it with your own methods.
247 | // The original function pointer will be saved in each JNINativeMethod's fnPtr.
248 | // If no matching class, method name, or signature is found, that specific JNINativeMethod.fnPtr
249 | // will be set to nullptr.
250 | void hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int numMethods);
251 |
252 | // Hook functions in the PLT (Procedure Linkage Table) of ELFs loaded in memory.
253 | //
254 | // Parsing /proc/[PID]/maps will give you the memory map of a process. As an example:
255 | //
256 | //
257 | // 56b4346000-56b4347000 r-xp 00002000 fe:00 235 /system/bin/app_process64
258 | // (More details: https://man7.org/linux/man-pages/man5/proc.5.html)
259 | //
260 | // For ELFs loaded in memory with pathname matching `regex`, replace function `symbol` with `newFunc`.
261 | // If `oldFunc` is not nullptr, the original function pointer will be saved to `oldFunc`.
262 | void pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc);
263 |
264 | // For ELFs loaded in memory with pathname matching `regex`, exclude hooks registered for `symbol`.
265 | // If `symbol` is nullptr, then all symbols will be excluded.
266 | void pltHookExclude(const char *regex, const char *symbol);
267 |
268 | // Commit all the hooks that was previously registered.
269 | // Returns false if an error occurred.
270 | bool pltHookCommit();
271 |
272 | private:
273 | internal::api_table *tbl;
274 | template friend void internal::entry_impl(internal::api_table *, JNIEnv *);
275 | };
276 |
277 | // Register a class as a Zygisk module
278 |
279 | #define REGISTER_ZYGISK_MODULE(clazz) \
280 | void zygisk_module_entry(zygisk::internal::api_table *table, JNIEnv *env) { \
281 | zygisk::internal::entry_impl(table, env); \
282 | }
283 |
284 | // Register a root companion request handler function for your module
285 | //
286 | // The function runs in a superuser daemon process and handles a root companion request from
287 | // your module running in a target process. The function has to accept an integer value,
288 | // which is a Unix domain socket that is connected to the target process.
289 | // See Api::connectCompanion() for more info.
290 | //
291 | // NOTE: the function can run concurrently on multiple threads.
292 | // Be aware of race conditions if you have globally shared resources.
293 |
294 | #define REGISTER_ZYGISK_COMPANION(func) \
295 | void zygisk_companion_entry(int client) { func(client); }
296 |
297 | /*********************************************************
298 | * The following is internal ABI implementation detail.
299 | * You do not have to understand what it is doing.
300 | *********************************************************/
301 |
302 | namespace internal {
303 |
304 | struct module_abi {
305 | long api_version;
306 | ModuleBase *impl;
307 |
308 | void (*preAppSpecialize)(ModuleBase *, AppSpecializeArgs *);
309 | void (*postAppSpecialize)(ModuleBase *, const AppSpecializeArgs *);
310 | void (*preServerSpecialize)(ModuleBase *, ServerSpecializeArgs *);
311 | void (*postServerSpecialize)(ModuleBase *, const ServerSpecializeArgs *);
312 |
313 | module_abi(ModuleBase *module) : api_version(ZYGISK_API_VERSION), impl(module) {
314 | preAppSpecialize = [](auto m, auto args) { m->preAppSpecialize(args); };
315 | postAppSpecialize = [](auto m, auto args) { m->postAppSpecialize(args); };
316 | preServerSpecialize = [](auto m, auto args) { m->preServerSpecialize(args); };
317 | postServerSpecialize = [](auto m, auto args) { m->postServerSpecialize(args); };
318 | }
319 | };
320 |
321 | struct api_table {
322 | // Base
323 | void *impl;
324 | bool (*registerModule)(api_table *, module_abi *);
325 |
326 | void (*hookJniNativeMethods)(JNIEnv *, const char *, JNINativeMethod *, int);
327 | void (*pltHookRegister)(const char *, const char *, void *, void **);
328 | void (*pltHookExclude)(const char *, const char *);
329 | bool (*pltHookCommit)();
330 | int (*connectCompanion)(void * /* impl */);
331 | void (*setOption)(void * /* impl */, Option);
332 | int (*getModuleDir)(void * /* impl */);
333 | uint32_t (*getFlags)(void * /* impl */);
334 | };
335 |
336 | template
337 | void entry_impl(api_table *table, JNIEnv *env) {
338 | static Api api;
339 | api.tbl = table;
340 | static T module;
341 | ModuleBase *m = &module;
342 | static module_abi abi(m);
343 | if (!table->registerModule(table, &abi)) return;
344 | m->onLoad(&api, env);
345 | }
346 |
347 | } // namespace internal
348 |
349 | inline int Api::connectCompanion() {
350 | return tbl->connectCompanion ? tbl->connectCompanion(tbl->impl) : -1;
351 | }
352 | inline int Api::getModuleDir() {
353 | return tbl->getModuleDir ? tbl->getModuleDir(tbl->impl) : -1;
354 | }
355 | inline void Api::setOption(Option opt) {
356 | if (tbl->setOption) tbl->setOption(tbl->impl, opt);
357 | }
358 | inline uint32_t Api::getFlags() {
359 | return tbl->getFlags ? tbl->getFlags(tbl->impl) : 0;
360 | }
361 | inline void Api::hookJniNativeMethods(JNIEnv *env, const char *className, JNINativeMethod *methods, int numMethods) {
362 | if (tbl->hookJniNativeMethods) tbl->hookJniNativeMethods(env, className, methods, numMethods);
363 | }
364 | inline void Api::pltHookRegister(const char *regex, const char *symbol, void *newFunc, void **oldFunc) {
365 | if (tbl->pltHookRegister) tbl->pltHookRegister(regex, symbol, newFunc, oldFunc);
366 | }
367 | inline void Api::pltHookExclude(const char *regex, const char *symbol) {
368 | if (tbl->pltHookExclude) tbl->pltHookExclude(regex, symbol);
369 | }
370 | inline bool Api::pltHookCommit() {
371 | return tbl->pltHookCommit != nullptr && tbl->pltHookCommit();
372 | }
373 |
374 | } // namespace zygisk
375 |
376 | extern "C" {
377 |
378 | [[gnu::visibility("default"), maybe_unused]]
379 | void zygisk_module_entry(zygisk::internal::api_table *, JNIEnv *);
380 |
381 | [[gnu::visibility("default"), maybe_unused]]
382 | void zygisk_companion_entry(int);
383 |
384 | } // extern "C"
385 |
--------------------------------------------------------------------------------
/app/src/main/cpp/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "zygisk.hpp"
6 | #include "json/single_include/nlohmann/json.hpp"
7 | #include "dobby.h"
8 |
9 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, "FGP/Native", __VA_ARGS__)
10 |
11 | #define DEX_FILE_PATH "/data/adb/modules/unlimitedphotos/classes.dex"
12 |
13 | #define PROP_FILE_PATH "/data/adb/modules/unlimitedphotos/fgp.prop"
14 | #define CUSTOM_PROP_FILE_PATH "/data/adb/modules/unlimitedphotos/custom.fgp.prop"
15 |
16 | #define JSON_FILE_PATH "/data/adb/modules/unlimitedphotos/fgp.json"
17 | #define CUSTOM_JSON_FILE_PATH "/data/adb/modules/unlimitedphotos/custom.fgp.json"
18 |
19 | #define VENDING_PACKAGE "com.android.vending"
20 | #define DROIDGUARD_PACKAGE "com.google.android.gms.unstable"
21 |
22 | static int verboseLogs = 0;
23 | static int spoofBuild = 1;
24 | static int spoofProps = 1;
25 | static int spoofProvider = 1;
26 | static int spoofSignature = 0;
27 | static int spoofVendingFinger = 0;
28 | static int spoofVendingSdk = 0;
29 |
30 | static std::map jsonProps;
31 |
32 | typedef void (*T_Callback)(void *, const char *, const char *, uint32_t);
33 |
34 | static std::map callbacks;
35 |
36 | static void modify_callback(void *cookie, const char *name, const char *value, uint32_t serial) {
37 | if (cookie == nullptr || name == nullptr || value == nullptr || !callbacks.contains(cookie)) return;
38 |
39 | const char *oldValue = value;
40 |
41 | std::string prop(name);
42 |
43 | if (jsonProps.count(prop)) {
44 | // Exact property match
45 | value = jsonProps[prop].c_str();
46 | } else {
47 | // Leading * wildcard property match
48 | for (const auto &p: jsonProps) {
49 | if (p.first.starts_with("*") && prop.ends_with(p.first.substr(1))) {
50 | value = p.second.c_str();
51 | break;
52 | }
53 | }
54 | }
55 |
56 | if (oldValue == value) {
57 | if (verboseLogs > 99) LOGD("[%s]: %s (unchanged)", name, oldValue);
58 | } else {
59 | LOGD("[%s]: %s -> %s", name, oldValue, value);
60 | }
61 |
62 | return callbacks[cookie](cookie, name, value, serial);
63 | }
64 |
65 | static void (*o_system_property_read_callback)(const prop_info *, T_Callback, void *);
66 |
67 | static void my_system_property_read_callback(const prop_info *pi, T_Callback callback, void *cookie) {
68 | if (pi == nullptr || callback == nullptr || cookie == nullptr) {
69 | return o_system_property_read_callback(pi, callback, cookie);
70 | }
71 | callbacks[cookie] = callback;
72 | return o_system_property_read_callback(pi, modify_callback, cookie);
73 | }
74 |
75 | static void doHook() {
76 | void *handle = DobbySymbolResolver(nullptr, "__system_property_read_callback");
77 | if (handle == nullptr) {
78 | LOGD("Couldn't find '__system_property_read_callback' handle");
79 | return;
80 | }
81 | LOGD("Found '__system_property_read_callback' handle at %p", handle);
82 | DobbyHook(handle, reinterpret_cast(my_system_property_read_callback),
83 | reinterpret_cast(&o_system_property_read_callback));
84 | }
85 |
86 | class GPhotosUnlimited : public zygisk::ModuleBase {
87 | public:
88 | void onLoad(zygisk::Api *api, JNIEnv *env) override {
89 | this->api = api;
90 | this->env = env;
91 | }
92 |
93 | void preAppSpecialize(zygisk::AppSpecializeArgs *args) override {
94 | bool isPhotos = false, isDroidGuardOrVending = false;
95 |
96 | auto rawProcess = env->GetStringUTFChars(args->nice_name, nullptr);
97 | auto rawDir = env->GetStringUTFChars(args->app_data_dir, nullptr);
98 |
99 | // Prevent crash on apps with no data dir
100 | if (rawDir == nullptr) {
101 | env->ReleaseStringUTFChars(args->nice_name, rawProcess);
102 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
103 | return;
104 | }
105 |
106 | pkgName = rawProcess;
107 | std::string_view dir(rawDir);
108 |
109 | isPhotos = dir.ends_with("/com.google.android.apps.photos");
110 | isDroidGuardOrVending = pkgName == DROIDGUARD_PACKAGE || pkgName == VENDING_PACKAGE;
111 |
112 | env->ReleaseStringUTFChars(args->nice_name, rawProcess);
113 | env->ReleaseStringUTFChars(args->app_data_dir, rawDir);
114 |
115 | if (!isPhotos) {
116 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
117 | return;
118 | }
119 |
120 | // We are in Google Photos now, force unmount
121 | api->setOption(zygisk::FORCE_DENYLIST_UNMOUNT);
122 |
123 | if (!isDroidGuardOrVending) {
124 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
125 | return;
126 | }
127 |
128 | std::vector configVector;
129 | long dexSize = 0, configSize = 0;
130 |
131 | int fd = api->connectCompanion();
132 |
133 | read(fd, &dexSize, sizeof(long));
134 | read(fd, &configSize, sizeof(long));
135 |
136 | if (dexSize < 1) {
137 | close(fd);
138 | LOGD("Couldn't read dex file");
139 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
140 | return;
141 | }
142 |
143 | if (configSize < 1) {
144 | close(fd);
145 | LOGD("Couldn't read config file");
146 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
147 | return;
148 | }
149 |
150 | LOGD("Read from file descriptor for 'dex' -> %ld bytes", dexSize);
151 | LOGD("Read from file descriptor for 'config' -> %ld bytes", configSize);
152 |
153 | dexVector.resize(dexSize);
154 | read(fd, dexVector.data(), dexSize);
155 |
156 | configVector.resize(configSize);
157 | read(fd, configVector.data(), configSize);
158 |
159 | close(fd);
160 |
161 | std::string configString(configVector.cbegin(), configVector.cend());
162 |
163 | if (!nlohmann::json::accept(configString, true)) {
164 | LOGD("Converting config from prop format to JSON format");
165 |
166 | configString.erase(std::remove(configString.begin(), configString.end(), '\r'), configString.end());
167 |
168 | std::string jsonString = "{";
169 | char propDelimiter = '=';
170 | char commentDelimiter = '#';
171 | size_t beginPos = 0, endPos = 0;
172 | while ((endPos = configString.find('\n', beginPos)) != std::string::npos) {
173 | std::string line = configString.substr(beginPos, endPos - beginPos);
174 | beginPos = endPos + 1;
175 | if (line.empty() || line[0] == '#') continue;
176 | std::string name, value;
177 | size_t propDelimiterPos = line.find(propDelimiter);
178 | if (propDelimiterPos != std::string::npos) {
179 | name = line.substr(0, propDelimiterPos);
180 | value = line.substr(propDelimiterPos + 1);
181 | } else {
182 | LOGD("Invalid prop entry, skipping");
183 | continue;
184 | }
185 | size_t commentDelimiterPos = value.find(commentDelimiter);
186 | if (commentDelimiterPos != std::string::npos) {
187 | value = value.substr(0, commentDelimiterPos);
188 | size_t lastPos = value.find_last_not_of(" ");
189 | if (lastPos != std::string::npos) value.resize(lastPos + 1);
190 | }
191 | jsonString += "\n\"" + name + "\": \"" + value + "\",";
192 | }
193 | if (jsonString.back() == ',') jsonString.pop_back();
194 | jsonString += "\n}\n";
195 |
196 | configString = jsonString;
197 |
198 | jsonString.clear();
199 | }
200 |
201 | json = nlohmann::json::parse(configString, nullptr, false, true);
202 |
203 | configVector.clear();
204 | configString.clear();
205 | }
206 |
207 | void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
208 | if (dexVector.empty() || json.empty()) return;
209 |
210 | readJson();
211 |
212 | if (pkgName == VENDING_PACKAGE) spoofBuild = spoofProps = spoofProvider = spoofSignature = 0;
213 | else spoofVendingFinger = spoofVendingSdk = 0;
214 |
215 | if (spoofProps > 0) doHook();
216 | if (spoofBuild + spoofProvider + spoofSignature + spoofVendingFinger + spoofVendingSdk > 0) inject();
217 |
218 | dexVector.clear();
219 | json.clear();
220 | }
221 |
222 | void preServerSpecialize(zygisk::ServerSpecializeArgs *args) override {
223 | api->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
224 | }
225 |
226 | private:
227 | zygisk::Api *api = nullptr;
228 | JNIEnv *env = nullptr;
229 | std::vector dexVector;
230 | nlohmann::json json;
231 | std::string pkgName;
232 | std::string vendingFingerprintValue;
233 |
234 | void readJson() {
235 | LOGD("JSON contains %d keys!", static_cast(json.size()));
236 |
237 | // Verbose logging level
238 | if (json.contains("verboseLogs")) {
239 | if (!json["verboseLogs"].is_null() && json["verboseLogs"].is_string() && json["verboseLogs"] != "") {
240 | verboseLogs = stoi(json["verboseLogs"].get());
241 | if (verboseLogs > 0) LOGD("Verbose logging (level %d) enabled!", verboseLogs);
242 | } else {
243 | LOGD("Error parsing verboseLogs!");
244 | }
245 | json.erase("verboseLogs");
246 | }
247 |
248 | // Vending advanced spoofing settings
249 | if (json.contains("spoofVendingSdk")) {
250 | if (!json["spoofVendingSdk"].is_null() && json["spoofVendingSdk"].is_string() && json["spoofVendingSdk"] != "") {
251 | spoofVendingSdk = stoi(json["spoofVendingSdk"].get());
252 | if (verboseLogs > 0) LOGD("Spoofing SDK Level in Play Store %s!", (spoofVendingSdk > 0) ? "enabled" : "disabled");
253 | } else {
254 | LOGD("Error parsing spoofVendingSdk!");
255 | }
256 | json.erase("spoofVendingSdk");
257 | }
258 | if (json.contains("spoofVendingFinger")) {
259 | if (!json["spoofVendingFinger"].is_null() && json["spoofVendingFinger"].is_string() && json["spoofVendingFinger"] != "") {
260 | if (json["spoofVendingFinger"].get().find_first_not_of("01") != std::string::npos) {
261 | spoofVendingFinger = 1;
262 | vendingFingerprintValue = json["spoofVendingFinger"].get();
263 | } else if (json.contains("FINGERPRINT") && !json["FINGERPRINT"].is_null() && json["FINGERPRINT"].is_string() && json["FINGERPRINT"] != "") {
264 | spoofVendingFinger = stoi(json["spoofVendingFinger"].get());
265 | vendingFingerprintValue = json["FINGERPRINT"].get();
266 | } else {
267 | LOGD("Error parsing spoofVendingFinger or FINGERPRINT field!");
268 | }
269 | if (verboseLogs > 0) LOGD("Spoofing Fingerprint in Play Store %s!", (spoofVendingFinger > 0) ? "enabled" : "disabled");
270 | } else {
271 | LOGD("Error parsing spoofVendingFinger!");
272 | }
273 | json.erase("spoofVendingFinger");
274 | }
275 | if (pkgName == VENDING_PACKAGE) {
276 | json.clear();
277 | return;
278 | }
279 |
280 | // DroidGuard advanced spoofing settings
281 | if (json.contains("spoofBuild")) {
282 | if (!json["spoofBuild"].is_null() && json["spoofBuild"].is_string() && json["spoofBuild"] != "") {
283 | spoofBuild = stoi(json["spoofBuild"].get());
284 | if (verboseLogs > 0) LOGD("Spoofing Build Fields %s!", (spoofBuild > 0) ? "enabled" : "disabled");
285 | } else {
286 | LOGD("Error parsing spoofBuild!");
287 | }
288 | json.erase("spoofBuild");
289 | }
290 | if (json.contains("spoofProps")) {
291 | if (!json["spoofProps"].is_null() && json["spoofProps"].is_string() && json["spoofProps"] != "") {
292 | spoofProps = stoi(json["spoofProps"].get());
293 | if (verboseLogs > 0) LOGD("Spoofing System Properties %s!", (spoofProps > 0) ? "enabled" : "disabled");
294 | } else {
295 | LOGD("Error parsing spoofProps!");
296 | }
297 | json.erase("spoofProps");
298 | }
299 | if (json.contains("spoofProvider")) {
300 | if (!json["spoofProvider"].is_null() && json["spoofProvider"].is_string() && json["spoofProvider"] != "") {
301 | spoofProvider = stoi(json["spoofProvider"].get());
302 | if (verboseLogs > 0) LOGD("Spoofing Keystore Provider %s!", (spoofProvider > 0) ? "enabled" : "disabled");
303 | } else {
304 | LOGD("Error parsing spoofProvider!");
305 | }
306 | json.erase("spoofProvider");
307 | }
308 | if (json.contains("spoofSignature")) {
309 | if (!json["spoofSignature"].is_null() && json["spoofSignature"].is_string() && json["spoofSignature"] != "") {
310 | spoofSignature = stoi(json["spoofSignature"].get());
311 | if (verboseLogs > 0) LOGD("Spoofing ROM Signature %s!", (spoofSignature > 0) ? "enabled" : "disabled");
312 | } else {
313 | LOGD("Error parsing spoofSignature!");
314 | }
315 | json.erase("spoofSignature");
316 | }
317 |
318 | std::vector eraseKeys;
319 | for (auto &jsonList: json.items()) {
320 | if (verboseLogs > 1) LOGD("Parsing %s", jsonList.key().c_str());
321 | if (jsonList.key().find_first_of("*.") != std::string::npos) {
322 | // Name contains . or * (wildcard) so assume real property name
323 | if (!jsonList.value().is_null() && jsonList.value().is_string()) {
324 | if (jsonList.value() == "") {
325 | LOGD("%s is empty, skipping", jsonList.key().c_str());
326 | } else {
327 | if (verboseLogs > 0) LOGD("Adding '%s' to properties list", jsonList.key().c_str());
328 | jsonProps[jsonList.key()] = jsonList.value();
329 | }
330 | } else {
331 | LOGD("Error parsing %s!", jsonList.key().c_str());
332 | }
333 | eraseKeys.push_back(jsonList.key());
334 | }
335 | }
336 | // Remove properties from parsed JSON
337 | for (auto key: eraseKeys) {
338 | if (json.contains(key)) json.erase(key);
339 | }
340 | }
341 |
342 | void inject() {
343 | const char* niceName = pkgName == VENDING_PACKAGE ? "PS" : "DG";
344 |
345 | LOGD("JNI %s: Getting system classloader", niceName);
346 | auto clClass = env->FindClass("java/lang/ClassLoader");
347 | auto getSystemClassLoader = env->GetStaticMethodID(clClass, "getSystemClassLoader", "()Ljava/lang/ClassLoader;");
348 | auto systemClassLoader = env->CallStaticObjectMethod(clClass, getSystemClassLoader);
349 |
350 | LOGD("JNI %s: Creating module classloader", niceName);
351 | auto dexClClass = env->FindClass("dalvik/system/InMemoryDexClassLoader");
352 | auto dexClInit = env->GetMethodID(dexClClass, "", "(Ljava/nio/ByteBuffer;Ljava/lang/ClassLoader;)V");
353 | auto buffer = env->NewDirectByteBuffer(dexVector.data(), static_cast(dexVector.size()));
354 | auto dexCl = env->NewObject(dexClClass, dexClInit, buffer, systemClassLoader);
355 |
356 | LOGD("JNI %s: Loading module class", niceName);
357 | auto loadClass = env->GetMethodID(clClass, "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;");
358 | const char* className = pkgName == VENDING_PACKAGE ? "com.rev4n.unlimitedphotos.EntryPointVending" : "com.rev4n.unlimitedphotos.EntryPoint";
359 | auto entryClassName = env->NewStringUTF(className);
360 | auto entryClassObj = env->CallObjectMethod(dexCl, loadClass, entryClassName);
361 |
362 | auto entryClass = (jclass) entryClassObj;
363 |
364 | if (pkgName == VENDING_PACKAGE) {
365 | LOGD("JNI %s: Calling EntryPointVending.init", niceName);
366 | auto entryInit = env->GetStaticMethodID(entryClass, "init", "(IIILjava/lang/String;)V");
367 | auto javaStr = env->NewStringUTF(vendingFingerprintValue.c_str());
368 | env->CallStaticVoidMethod(entryClass, entryInit, verboseLogs, spoofVendingFinger, spoofVendingSdk, javaStr);
369 | env->DeleteLocalRef(javaStr);
370 | } else {
371 | LOGD("JNI %s: Sending JSON", niceName);
372 | auto receiveJson = env->GetStaticMethodID(entryClass, "receiveJson", "(Ljava/lang/String;)V");
373 | auto javaStr = env->NewStringUTF(json.dump().c_str());
374 | env->CallStaticVoidMethod(entryClass, receiveJson, javaStr);
375 |
376 | LOGD("JNI %s: Calling EntryPoint.init", niceName);
377 | auto entryInit = env->GetStaticMethodID(entryClass, "init", "(IIII)V");
378 | env->CallStaticVoidMethod(entryClass, entryInit, verboseLogs, spoofBuild, spoofProvider, spoofSignature);
379 | env->DeleteLocalRef(javaStr);
380 | }
381 | env->DeleteLocalRef(clClass);
382 | env->DeleteLocalRef(systemClassLoader);
383 | env->DeleteLocalRef(dexClClass);
384 | env->DeleteLocalRef(buffer);
385 | env->DeleteLocalRef(dexCl);
386 | env->DeleteLocalRef(entryClassName);
387 | env->DeleteLocalRef(entryClassObj);
388 | }
389 | };
390 |
391 | static void companion(int fd) {
392 | long dexSize = 0, configSize = 0;
393 | std::vector dexVector, configVector;
394 |
395 | FILE *dex = fopen(DEX_FILE_PATH, "rb");
396 |
397 | if (dex) {
398 | fseek(dex, 0, SEEK_END);
399 | dexSize = ftell(dex);
400 | fseek(dex, 0, SEEK_SET);
401 |
402 | dexVector.resize(dexSize);
403 | fread(dexVector.data(), 1, dexSize, dex);
404 |
405 | fclose(dex);
406 | }
407 |
408 | FILE *config = fopen(CUSTOM_PROP_FILE_PATH, "r");
409 | if (!config)
410 | config = fopen(CUSTOM_JSON_FILE_PATH, "r");
411 | if (!config)
412 | config = fopen(PROP_FILE_PATH, "r");
413 | if (!config)
414 | config = fopen(JSON_FILE_PATH, "r");
415 |
416 | if (config) {
417 | fseek(config, 0, SEEK_END);
418 | configSize = ftell(config);
419 | fseek(config, 0, SEEK_SET);
420 |
421 | configVector.resize(configSize);
422 | fread(configVector.data(), 1, configSize, config);
423 |
424 | fclose(config);
425 | }
426 |
427 | write(fd, &dexSize, sizeof(long));
428 | write(fd, &configSize, sizeof(long));
429 |
430 | write(fd, dexVector.data(), dexSize);
431 | write(fd, configVector.data(), configSize);
432 |
433 | dexVector.clear();
434 | configVector.clear();
435 | }
436 |
437 | REGISTER_ZYGISK_MODULE(GPhotosUnlimited)
438 |
439 | REGISTER_ZYGISK_COMPANION(companion)
440 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------