Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
don't alter allowProtected tehcneko 58 minutes ago
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcneko committed Jun 17, 2024
1 parent 8fa24bf commit 87e735e
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.util.Log;
import android.view.SurfaceControl;
import android.widget.Toast;

import androidx.annotation.NonNull;

Expand Down Expand Up @@ -224,7 +224,6 @@ private void hookWindowState(ClassLoader classLoader) throws ClassNotFoundExcept
}

private static Field captureSecureLayersField;
private static Field allowProtectedField;

@TargetApi(Build.VERSION_CODES.S)
private void hookScreenCapture(ClassLoader classLoader) throws ClassNotFoundException, NoSuchFieldException {
Expand All @@ -236,8 +235,6 @@ private void hookScreenCapture(ClassLoader classLoader) throws ClassNotFoundExce
"android.view.SurfaceControl$CaptureArgs");
captureSecureLayersField = captureArgsClazz.getDeclaredField("mCaptureSecureLayers");
captureSecureLayersField.setAccessible(true);
allowProtectedField = captureArgsClazz.getDeclaredField("mAllowProtected");
allowProtectedField.setAccessible(true);
hookMethods(screenCaptureClazz, ScreenCaptureHooker.class, "nativeCaptureDisplay");
hookMethods(screenCaptureClazz, ScreenCaptureHooker.class, "nativeCaptureLayers");
}
Expand Down Expand Up @@ -352,7 +349,6 @@ public static void before(@NonNull BeforeHookCallback callback) {
var captureArgs = callback.getArgs()[0];
try {
captureSecureLayersField.set(captureArgs, true);
allowProtectedField.set(captureArgs, true);
} catch (IllegalAccessException t) {
module.log("ScreenCaptureHooker failed", t);
}
Expand Down Expand Up @@ -428,9 +424,12 @@ private static class ToastHooker implements Hooker {
@BeforeInvocation
public static void before(@NonNull BeforeHookCallback callback) {
var activity = (Activity) callback.getThisObject();
assert activity != null;
Toast.makeText(activity, "DFS: Incorrect module usage, remove this app from scope.", Toast.LENGTH_LONG).show();
activity.finish();
new AlertDialog.Builder(activity)
.setTitle("Enable Screenshot")
.setMessage("Incorrect module usage, remove this app from scope.")
.setCancelable(false)
.setPositiveButton("OK", (dialog, which) -> System.exit(0))
.show();
}
}
}

0 comments on commit 87e735e

Please sign in to comment.