android 测试读取LEB数据的函数
16lz
2021-01-23
#include <stdio.h>//android 读取LEB数据 int readUnsignedLeb128(const int ** pStream) { const int * ptr = *pStream; int result = *(ptr++); if (result > 0x7f) { int cur = *(ptr++); result = (result & 0x7f) | ((cur & 0x7f) << 7); if (cur > 0x7f) { cur = *(ptr++); result |= (cur & 0x7f) << 14; if (cur > 0x7f) { cur = *(ptr++); result |= (cur & 0x7f) << 21; if (cur > 0x7f) { /* * Note: We don't check to see if cur is out of * range here, meaning we tolerate garbage in the * high four-order bits. */ cur = *(ptr++); result |= cur << 28; } } } } *pStream = ptr; return result;} int readSignedLeb128(const int** pStream) { const int* ptr = *pStream; int result = *(ptr++); if (result <= 0x7f) { result = (result << 25) >> 25; } else { int cur = *(ptr++); result = (result & 0x7f) | ((cur & 0x7f) << 7); if (cur <= 0x7f) { result = (result << 18) >> 18; } else { cur = *(ptr++); result |= (cur & 0x7f) << 14; if (cur <= 0x7f) { result = (result << 11) >> 11; } else { cur = *(ptr++); result |= (cur & 0x7f) << 21; if (cur <= 0x7f) { result = (result << 4) >> 4; } else { /* * Note: We don't check to see if cur is out of * range here, meaning we tolerate garbage in the * high four-order bits. */ cur = *(ptr++); result |= cur << 28; } } } } *pStream = ptr; return result;}void main(){//const int a=0xc0839225;//没有权限读取0xc0839225地址;int c=readUnsignedLeb128((const int **)0xc0839225);printf("%d\n",c);c=readSignedLeb128((const int **)0xd1c2b340);printf("%d\n",c);}
更多相关文章
- android中在切换fragment时,怎样做到无需重复加载数据的方法。
- android API文档下载地址
- Android 将一个数据对象保存到本地以及读取的方法
- 自定义progressBar显示静态数据
- 关于android Ip地址的获取
- android之解析json数据格式详解
- android 本地存取复杂数据
- android 系统数据库