Hook简述以及Hook AMS 实现统一登录

Hook系统的AMS服务 Hook系统的AMS服务,拦截应用启动流程 立即下载
什么是hook?

hook 翻译成中文是 名词钩子、挂钩,动词 钩住的意思。

在程序中 Hook 是一种技术,也成为钩子函数。

实际上,一个处理消息的程序段,通过系统的调用,把它挂入系统。 在系统没有调用到该函数之前,钩子程序先捕获该消息,先得到控制权,然后加工处理,然后再扔给系统做后续的处理。

比如说,有一辆货车 每天从A仓库拉货(一个集装箱的苹果) 到 B 水果分发站。 我们的钩子函数的呢,就是在 该货车拉 集装箱之前,打开集装箱 做一些自己的操作,比如把苹果换成其他的水果。然后再把集装箱放回原地,让货车拉走。 对于这个过程 货车是无法感知到的。

上面的例子比较… 但可以帮助理解hook技术。

hook的作用?

在我们开发过程中,有时候某些API 不能满足我们的需求时,我们就可以使用Hook 来进而改变一个 系统api 的原有功能。
比如通过hook AMS 实现统一登录等。

如何hook?

我们这里介绍一下 java层的hook 方式。有两种:

1.利用系统内部提供的接口,通过实现该接口,然后注入自己的操作逻辑 (只在特定的场景下适用)

2.动态代理(所有场景)

如何查找hook点:

找到hook 点: 静态的变量或者单例,生命周期跨度较长,不会轻易重新创建。

Hook 过程

  • 找到要Hook的点,通过反射或者其他方式 拿到该引用。
  • 选择合适的方式处理逻辑,动态代理 或者 接口方式。
  • 用我们修改过的对象,替换原来的对象(即上面提到的,把集装箱放回原位置,等货车拉走)

ok,这里只是简述一下 hook 相关的概念

Hook AMS 实现应用统一登录

整体思路:

1 . 我们使用动态代理的方式 hook 到 AMS 中的startActivity() 方法。当外部启动页面时,比如,启动购物车页面(未在AndroidManifest中注册)时。我们在代理的 invoke 方法中, 替换准备启动的 Intent对象为 空壳Activity(已在AndroidManifest中注册),并把启动购物车的Intent 传递过去, 然后让系统做后续的启动操作。

2 . hook 到 ActivityThread 中的 mH(Handler,负责系统消息的处理) ,并给他设置 CallBack, 在 callback 中 我们便可以 获取到启动 Activity的消息 LAUNCH_ACTIVITY 即100, 然后我们可以取出 intent 替换为我们想要启动的购物车界面, 当然可以在其中加入一些判断登录的逻辑来实现统一的登录校验.

上面的思路,可能稍微有些抽象,下面我们来上代码:

我们先添加一些基本的页面以及简单的跳转操作代码:

/**
     *  跳转到购物车界面
     * @param view
     */
    public void toCartPage(View view) {

        startActivity(new Intent(MainActivity.this,CartPageActivity.class));
    }

    /**
     *  跳转到我的界面
     * @param view
     */
    public void toMinePage(View view) {

        startActivity(new Intent(MainActivity.this,MinePageActivity.class));
    }

上面的 CartPageActivity 、 MinePageActivity 界面均未在AndroidManifest.xml 中注册。

我们需要添加一个 空壳页面, 这个页面呢,没有任何的实际作用,只是为了能让 未注册的页面可以正常的通过系统的检查。

public class ProxyActivity extends Activity{
   
   

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R
Monocle2拟时轨迹基因模块的GO富集解析 本文详细解析了如何对Monocle2拟时分析中得到的基因表达模块进行GO富集分析。通过从热图对象中提取聚类模块,并利用clusterProfiler等工具进行功能注释,将抽象的基因表达时序模式转化为可解释的生物学功能主题,如免疫应答、细胞外基质组织等,从而深入理解细胞命运转变的驱动机制。 阅读详情

相关推荐

Win11 24H2家庭版共享打印机失败?别慌,一个批处理脚本搞定所有设置

本文提供了Win11 24H2家庭版共享打印机失败的解决方案,通过一个批处理脚本自动修复所有设置问题。脚本包含安装组策略组件、修改关键注册表项等操作,帮助用户快速恢复打印机共享功能,适用于普通家庭用户。

weixin_30632089的博客 420

LinuxCNC开发实战:从安装到EtherCAT配置全解析

本文详细解析LinuxCNC开发实战,从系统安装到EtherCAT总线配置全流程。涵盖实时内核优化、伺服驱动器PDO映射、HAL配置及自定义运动学开发,帮助开发者快速搭建工业级数控系统,提升运动控制精度与稳定性。

rgv234567的博客 353

制作Ubuntu22.04启动盘

现在越来越多程序代码都需要运行在linux环境下,运行这些代码的前提是安装一个稳定的linux操作系统。本文选择Ubuntu 22.04去制作系统启动盘。本文主要对ubuntu22.04的启动盘制作过程进行了详细的说明,希望能帮助到有需要的朋友。

lyx_ok的博客 1万+

站在评审的角度写国自然基金本子,搭配这5条AI提示词,帮你一键提升本子中标率

多数同仁的选题失败,不是因为你的idea不好,而是你的逻辑没有立起来,你必须让评审看到,你是怎么从问题走向方法的。请你按照“同行做到哪、瓶颈卡在哪、我该怎么破”的逻辑,将我的创新点进行重构:【粘贴你原始的创新点描述】,要求:表达需结构化、可量化、可验证,突出对比后的实质性突破。与其等着评审指出问题,等着本子被拒,不如让AI提前模拟评审,帮你从可行性、创新性、国家价值、团队能力四个维度给你打分,并指出项目的致命破绽,提示词这样设计。创新点如果写不好,本子往往也会被拒,而评审一般喜欢的创新点都是有固定结构的。

智能AI让学术科研更容易 1241

使用蒙特卡洛模拟方法在MATLAB中估算居里温度: 一个详细而通俗的指南

居里温度是磁性材料失去磁性的温度。但是,计算机模拟为我们提供了一个在理论和实验之间的桥梁,使我们能够在不进行实际测量的情况下估计这一重要参数。在下一部分,我们将详细介绍蒙特卡洛迭代的核心代码,以及如何使用它来模拟磁性材料中原子的行为。在估算居里温度的上下文中,我们将使用蒙特卡洛方法来模拟磁性材料中的原子或分子的行为。通过使用蒙特卡洛方法,我们可以在MATLAB中估算居里温度,从而为理论研究和实验设计提供有价值的信息。:我们使用的是一个有限的尺寸的网格模型,这可能导致一些大小效应,特别是在接近居里温度时。

qq_38334677的博客 978

uniapp - 解决uni.getLocation定位不准有偏差,定位经纬度不准确有几百米误差、获取地图定位有偏差怎么办,已配置高精确度但依旧不精准(uni.getLocation定位不准如何解决)

uni.getLocation,获取当前的地理位置、速度。已经设置altitude高精度,uniapp API获取定位有差异问题解决,获取定位有几百米偏差,uni.getLocation(OBJECT)中使用默认type ”wgs84“会导致定位不准的问题,gcj02,uni.getLocation地图定位不准,获取经纬度错误偏移了几十公里,经纬度的精确度误差,怎么消除经纬度偏差,解决 uniapp uni.getLocation 定位经纬度不准问题,使用定位不准,定位不准误差问题,解决定位不准问题,高德地

✅ 精选推荐文章 1万+

AIO-1126-JD4(RV1126)蓝牙通讯(BLE)

AIO-1126-JD4采用了正基科技推出的一款集成WiFi、蓝牙功能的模组AP6236,支持高速(HS)功能的蓝牙 4.0,集成了 1.5 类功率放大器(PA),并支持低功耗蓝牙(BLE)。提到正基就不得不提下博通。博通和正基是芯片技术与模块制造方面的合作关系,正基科技是中国台湾的公司,在无线通信模块领域有一定的市场份额,博通则是全球领先的有线和无线通信半导体公司。正基把包含博通关键IP的核心芯片和自家的射频部分等封装在一起,即SIP(System In Package)。

w1820020635的博客 1123

云原生之容器编排实践-在K8S集群中使用Registry2搭建私有镜像仓库

基于前面搭建的3节点 Kubernetes 集群,今天我们使用 Registry2 搭建私有镜像仓库,这在镜像安全性以及离线环境下运维等方面具有重要意义。作为测试环境,本次使用 Registry2 搭建了私有镜像仓库,实际生产环境建议使用 Harbor;创建了一个 local-storage 的 StorageClass ,并使用本地磁盘的方式创建使用 PV ,实际建议使用 NFS 。

Heartsuit的博客 2462

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

上一篇: 自定义注解
下一篇: Activity 启动流程
派派的生活
博客等级 码龄11年 9粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值