android调用号和libc
调用号(以arm平台为例)在/bionic/libc/kernel/uapi/asm-arm/asm/unistd.h:
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __NR_restart_syscall (__NR_SYSCALL_BASE+ 0)
#define __NR_exit (__NR_SYSCALL_BASE+ 1)
#define __NR_fork (__NR_SYSCALL_BASE+ 2)
#define __NR_read (__NR_SYSCALL_BASE+ 3)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __NR_write (__NR_SYSCALL_BASE+ 4)
#define __NR_open (__NR_SYSCALL_BASE+ 5)
#define __NR_close (__NR_SYSCALL_BASE+ 6)
#define __NR_creat (__NR_SYSCALL_BASE+ 8)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __NR_link (__NR_SYSCALL_BASE+ 9)
#define __NR_unlink (__NR_SYSCALL_BASE+ 10)
#define __NR_execve (__NR_SYSCALL_BASE+ 11)
#define __NR_chdir (__NR_SYSCALL_BASE+ 12)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __NR_time (__NR_SYSCALL_BASE+ 13)
#define __NR_mknod (__NR_SYSCALL_BASE+ 14)
#define __NR_chmod (__NR_SYSCALL_BASE+ 15)
#define __NR_lchown (__NR_SYSCALL_BASE+ 16)
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
#define __NR_lseek (__NR_SYSCALL_BASE+ 19)
#define __NR_getpid (__NR_SYSCALL_BASE+ 20)
#define __NR_mount (__NR_SYSCALL_BASE+ 21)
#define __NR_umount (__NR_SYSCALL_BASE+ 22)
......
如何使用呢,以android5.0源码中的关机代码为例: /system/core/libcutils/android_reboot.c
#include <unistd.h>
#include <sys/reboot.h>
#include <sys/syscall.h> // bionic/libc/include/sys/syscall.h
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
......
int android_reboot(int cmd, int flags UNUSED, char *arg)
108{
......
switch (cmd) {
......
case ANDROID_RB_RESTART2:
ret = syscall(__NR_reboot, LINUX_REBOOT_MAGIC1, LINUX_REBOOT_MAGIC2, // /bionic/libc/arch-arm/bionic/syscall.S
LINUX_REBOOT_CMD_RESTART2, arg);
......
}
代码中直接syscall(_NR_reboot)来调用系统reboot函数,注意上面红色标注的代码。
(dannerWorking:要分析/bionic/libc/tools/gensyscalls.py这个文件啊还没做)
参考资料:
android调用号和libc的更多相关文章
- Android调用系统相册和拍照的Demo
最近我在群里看到有好几个人在交流说现在网上的一些Android调用系统相册和拍照的demo都有bug,有问题,没有一个完整的.确实是,我记得一个月前,我一同学也遇到了这样的问题,在低版本的系统中没问题 ...
- arm-eabi-addr2line工具跟踪Android调用堆栈
使用arm-eabi-addr2line工具跟踪Android调用堆栈作者:liangshengyang转自:http://www.linuxidc.com/Linux/2011-01/31803.h ...
- android 调用地图
有时候我们需要调用地图显示一下位置,这时候可能还需要导航,导航做起来有点麻烦,如果调用第三方的是不是很简单,本文就是写这个来的: 第一种方式:android Intent调用地图应用客户端 调用百度地 ...
- [转]JS调用Android里面的方法,Android调用JS里面的方法
FROM : http://blog.csdn.net/hj563308597/article/details/45197709 Android WebView 在公司Android的开发过程中遇到一 ...
- Android调用Web服务
现在大部分应用程序都把业务逻辑处理,数据调用等功能封装成了服务的形式,应用程序只需要调用这些web服务就好了,在这里就不赘述web服务的优点了.本文总结如何在android中调用Web服务,通过传递基 ...
- Android调用WebService(转)
Android调用WebService WebService是一种基于SOAP协议的远程调用标准,通过 webservice可以将不同操作系统平台.不同语言.不同技术整合到一块.在Android SD ...
- Android调用天气预报的WebService简单例子
下面例子改自网上例子:http://express.ruanko.com/ruanko-express_34/technologyexchange5.html 不过网上这个例子有些没有说明,有些情况不 ...
- Android调用.net的webservice服务器接收参数为空的情况
问题描述:安卓开发中,用Android调用.net开发的wenService时候,从Android客户端传递参数到服务器端,服务器端接收为空 解决方法: 1.设置envelope.dotNet = t ...
- Android调用Asp.net Web Service示例
WebService代码: using System; using System.Collections.Generic; using System.Linq; using System.Web; u ...
随机推荐
- 【转载】java类加载时机与过程
1 开门见山 以前曾经看到过一个java的面试题,当时觉得此题很简单,可是自己把代码运行起来,可是结果并不是自己想象的那样.题目如下: class SingleTon { private stati ...
- JVM 中的StringTable
是什么 字符串常量池是 JVM 中的一个重要结构,用于存储JVM运行时产生的字符串.在JDK7之前在方法区中,存储的是字符串常量.而字符串常量池在 JDK7 开始移入堆中,随之而来的是除了存储字符串常 ...
- FreeBSD 13 显卡支持
On FreeBSD 13, using drm-devel-kmod, support is the same as on Linux 5.4. This includes support for ...
- RSA典型非对称加密算法
私钥加密-->公钥解密,反之亦然,但不安全.也可以当做数字签名. public class RSACoder { //非对称加密算法 public static ...
- Matplotlib图例中文乱码
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签 plt.rcParams['axes.unicode_minus']=False #用来正 ...
- Joomla框架搭建&远程代码执行(RCE)漏洞复现
一.漏洞描述 Joomla是一套内容管理系统,是使用PHP语言加上MYSQL数据库所开发的软件系统,最新版本为3.9.8,官网: https://downloads.joomla.org/,漏洞位于根 ...
- Android Studio 之创建自定义控件
•前言 常用控件和布局的继承结构,如下图所示: 可以看到,我们所用的所有的控件都是直接或者间接的继承自View的: 所用的所有布局都是直接或者间接继承自ViewGroup的: View 是 Andro ...
- SpringCloud(六)分布式事务
在分布式系统中,分布式事务基本上是绕不开的, 分布式事务是指事务的参与者.支持事务的服务器.资源服务器以及事务管理器分别位于不同的分布式系统的不同节点之上 .其实就可以简单理解成在分布式系统中实现事务 ...
- HTML5本地存储 localStorage操作使用详解
1.html5几种存储形式 本地存储(localStorage && sessionStorage) 离线缓存(application cache) indexedDB 和 webSQ ...
- 手写无缝轮播banner
<div class="banner"> <ul class="clearfloat bannerul xin" id="xin&q ...