安卓逆向学习——Dalvik虚拟机与Smali代码

首先我们要清楚JAVA虚拟机和Dalvik虚拟机的关系,我们想要我们的android程序运行在Dalvik虚拟机上首先需要选择一种语言执行的环境,Android开发目前最多用的就是JAVA语言,凯特琳语言也在飞速发展,也许以后可能就要取代Java在安卓开发的地位。JAVA代码想要运行在Java虚拟机上首先要编译成Class文件,Java虚拟机才可以识别程序命令运行程序。想要在Dalvik虚拟机上运行,还需要将Java虚拟机内的代码提取出来转换成Dalvik所能识别的机器指令并进行打包成Dex文件,所以需要进一步将Class文件转换成Dex文件,才能运行在Dalvik上。这种Dalvik可以识别的字节码符号就是Smali代码。
Dex文件相比Class文件更小,因为Dalvik虚拟机的文件结构已经被谷歌公司所优化过,Java虚拟机运行是依赖栈结构的,而Dalvik虚拟机是基于寄存器传递的。(栈的存储介质是内存肯定不如直接相连于CPU上的寄存器快了)
在这里插入图片描述
有趣的是,虽然它们都是依赖于虚拟机的语言,但是它们并没有进行编译成可执行程序,它们编译后的代码更类似于脚本语言。(脚本语言都是依赖对应的一个调用脚本语言的解释器,我们实际上写的脚本都只是符号,不可以直接运行,需要这些解释器进行解析,将这些符号替换成解释器里早就设置好的各种调用接口,通过这些调用接口进一步进行系统调用,才能看到我们想要的执行效果)解释一步就执行一步,所以调试起来比正常的EXE困难。而JAVA语言就更加有趣,他不同于脚本的是需要首先将代码编译成虚拟机可以识别的字节码符号,然后虚拟机通过编译后的符号进行解释,这种介于编译和解释之间的操作还是很有趣的。
下图是整个安卓程序的运行框架。
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Android虚拟机Dalvik完整源码,宝贵资源,欢迎下载! This directory contains the Dalvik virtual machine and core class library, as well as related tools, libraries, and tests. A note about the licenses and header comments --------------------------------------------- Much of the code under this directory originally came from the Apache Harmony project, and as such contains the standard Apache header comment. Some of the code was written originally for the Android project, and as such contains the standard Android header comment. Some files contain code from both projects. In these cases, the header comment is a combination of the other two, and the portions of the code from Harmony are identified as indicated in the comment. Here is the combined header comment: /* * Copyright (C) The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ---------- * * Portions of the code surrounded by "// BEGIN Harmony code" and * "// END Harmony code" are copyrighted and licensed separately, as * follows: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Native SH call bridge --------------------- Native SH call bridge is written by Shin-ichiro KAWASAKI and Contributed to Android by Hitachi, Ltd. and Renesas Solutions Corp.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值