I made a simple Android HelloWorld app using Xamarin Studio 4.2.3 that doesn't do anything except it prints out some message if a random number is greater than 0.5. It works just great on a Nexus 4 and a Nexus 5.
我用Xamarin Studio 4.2.3做了一个简单的Android HelloWorld应用,它什么都不做,只在随机数大于0.5时打印出一些消息。它在Nexus 4和Nexus 5上都很好用。
The next thing I'm doing is to extract the .dll with the code from the app's apk (from the assemblies folder) using 7Zip. Using .Net Reflector and Reflexil I'm modifying a single instruction, usually the brfalse.s that gets generated by the IF statement in "if(rand.nextDouble()>0.5){doStuff()}" such that it branches to the instruction right in front of the call to doStuff(), thereby effectively making the IF statement useless and ensuring the method always gets called.
接下来我要做的是使用7Zip从app的apk(程序集文件夹)中提取.dll代码。使用。net Reflector和Reflexil,我修改了一条指令,通常是brfalse。在“IF (rand.nextDouble()>0.5){doStuff()}”中由IF语句生成的,以便将其分支到调用doStuff()之前的指令,从而有效地使IF语句无效,并确保方法总是被调用。
Next I'm saving the patched .dll, replacing the original one in the .apk with the patched one, sign and zipalign the .apk and finally I'm installing it using adb.
接下来,我将保存已补丁的.dll,将.apk中的原始文件替换为已补丁的文件,并对.apk进行签名和zipalign,最后使用adb进行安装。
When I'm launching the app on my phones it crashes directly and LogCat shows the following:
当我在手机上启动这个应用程序时,它会直接崩溃,LogCat显示如下内容:
03-20 10:12:08.709: I/ActivityManager(764): Start proc HelloMonoLVL.HelloMonoLVL for activity HelloMonoLVL.HelloMonoLVL/hellomonolvl.hellomonolvl.TrialSplashScreen: pid=23099 uid=10128 gids={50128}
03-20 10:12:08.729: D/dalvikvm(23099): Trying to load lib /data/app-lib/HelloMonoLVL.HelloMonoLVL-1/libmonodroid.so 0x427154a0
03-20 10:12:08.729: D/dalvikvm(23099): Added shared lib /data/app-lib/HelloMonoLVL.HelloMonoLVL-1/libmonodroid.so 0x427154a0
03-20 10:12:08.739: W/libc(23099): WARNING: generic atexit() called from legacy shared library
03-20 10:12:08.759: W/monodroid-gc(23099): GREF GC Threshold: 46800
03-20 10:12:08.769: A/monodroid-assembly(23099): Coult not load assembly 'HelloMonoLVL' during startup registration.
03-20 10:12:08.769: A/monodroid-assembly(23099): This might be due to an invalid debug instalation.
03-20 10:12:08.769: A/monodroid-assembly(23099): A common cause is to 'adb install' the app directly instead of doing from the IDE.
03-20 10:12:08.789: I/ActivityManager(764): Process HelloMonoLVL.HelloMonoLVL (pid 23099) has died.
03-20 10:12:08.789: W/ActivityManager(764): Force removing ActivityRecord{42752a50 u0 HelloMonoLVL.HelloMonoLVL/hellomonolvl.hellomonolvl.TrialSplashScreen t238}: app died, no saved state
Since this didn't work I used the C# port of the LVL. Built the LVL sample app, deployed and it works on the phones. I again extracted the .dll with the license verification code, using Reflexil I changed the code of a method, injected the patched .dll in the apk, signed and zipaligned the apk. Again it doesn't work but crashes on launch and I now get:
由于这不起作用,我使用LVL的c#端口。构建LVL示例应用程序,部署并在手机上运行。我再次用许可证验证代码提取了.dll,使用条件反射我修改了一个方法的代码,在apk中注入了补丁的.dll,对apk进行了签名和zipalign。同样,它不起作用,但在发射时崩溃了,我现在得到:
03-20 10:21:19.049: D/dalvikvm(23507): Trying to load lib /data/app-lib/de.marius.lvl-1/libmonodroid.so 0x42711448
03-20 10:21:19.049: D/dalvikvm(23507): Added shared lib /data/app-lib/de.marius.lvl-1/libmonodroid.so 0x42711448
03-20 10:21:19.069: A/MonoDroid(23507): No assemblies found in '/data/data/de.marius.lvl/files/.__override__' or '/storage/emulated/0/Android/data/de.marius.lvl/files/.__override__'. Assuming this is part of Fast Deployment. Exiting...
03-20 10:21:19.079: I/ActivityManager(764): Process de.marius.lvl (pid 23507) has died.
03-20 10:21:19.079: W/ActivityManager(764): Force removing ActivityRecord{42bc3c60 u0 de.marius.lvl/.TrialSplashScreen t239}: app died, no saved state
It doesn't seem to make any difference if I'm using the apk that Xamarin generates in Release mode or Debug mode. I tried both using the apk versions from the bin folder of the project and the ones I pulled from the phone with adb pull.
如果我使用Xamarin在发布模式或调试模式中生成的apk,似乎没有什么区别。我尝试使用项目的bin文件夹中的apk版本和使用adb pull从电话中提取的版本。
I'm new to Xamarin so maybe my approach is naive. Is there something like a hash check that my patched .dlls don't pass? I saw that Reflexil has an option to remove StrongNames, I tried that but it didn't seem to make any difference (but I must admit I don't really know how those work).
我对海蓝宝石很陌生,所以我的方法可能很天真。有什么东西像散列检查,我修补过的。dll不能通过?我看到了条件反射有删除强名称的选项,我试过了,但似乎没有什么区别(但我必须承认我真的不知道这些强名称是如何工作的)。
Is it even possible what I'm trying to do? Any help is much appreciate.
我想做的事情有可能吗?任何帮助都是非常感谢的。
1 个解决方案
#1
-1
Uninstall all the packages installed in your project including android support libraries like Android.Support.v4 support libraries and clean the solution.
卸载您的项目中安装的所有软件包,包括android支持库,比如android . support。v4支持库并清理解决方案。
Then again reinstall all the required packages and support libraries and rebuild your solution. It may help you sort out your query.
然后再重新安装所有必需的包并支持库并重新构建解决方案。它可以帮助您对查询进行分类。
#1
-1
Uninstall all the packages installed in your project including android support libraries like Android.Support.v4 support libraries and clean the solution.
卸载您的项目中安装的所有软件包,包括android支持库,比如android . support。v4支持库并清理解决方案。
Then again reinstall all the required packages and support libraries and rebuild your solution. It may help you sort out your query.
然后再重新安装所有必需的包并支持库并重新构建解决方案。它可以帮助您对查询进行分类。