#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
unsigned long phystart, length, pagecnt, virtstart;
volatile unsigned long *virtptr;
char *ultoa(unsigned long num, char *str, int radix) {
char sign = 0;
char temp[33]; //an int can only be 32 bits long
//at radix 2 (binary) the string
//is at most 16 + 1 null long.
int temp_loc = 0;
int digit;
int str_loc = 0;
//save sign for radix 10 conversion
if (radix == 10 && num < 0) {
sign = 1;
num = -num;
}
//construct a backward string of the number.
do {
digit = num % radix;
if (digit < 10)
temp[temp_loc++] = digit + '0';
else
temp[temp_loc++] = digit - 10 + 'A';
num /= radix;
} while (num > 0);
//now add the sign for radix 10
if (radix == 10 && sign) {
temp[temp_loc] = '-';
} else {
temp_loc--;
}
//now reverse the string.
while ( temp_loc >=0 ) {// while there are still chars
str[str_loc++] = temp[temp_loc--];
}
str[str_loc] = 0; // add null termination.
return str;
}
int main(int argc, char *argv[])
{
unsigned long physend, i, j;
int fd;
char buf1[33], buf2[33];
phystart = strtoul(argv[1], NULL, 16);
length = strtoul(argv[2], NULL, 16);
physend = phystart + length - 1;
pagecnt = ((physend - phystart) >> 12) + 1;
fd = open("/dev/mem", O_RDWR|O_SYNC);
if(fd<0){
printf("Error open /dev/mem!");
return -1;
}
virtstart = (unsigned long)mmap(NULL, 4096 * pagecnt, PROT_READ, MAP_SHARED, fd, phystart&~0x00000fff);
if(virtstart<0){
printf("Unable to mmap %08x!\n", phystart);
return -1;
}
virtptr = (unsigned long*)(virtstart + (phystart&0x00000fff));
for (i=phystart; i<physend; i+=4)
{
printf("0x%08X(%08X) ", i, *virtptr);
memset(buf2, 0, 33);
ultoa(*virtptr, buf1, 2);
memset(buf2, '0', 32 - strlen(buf1));
strcat(buf2, buf1);
for (j=0; j<32; j+=4)
{
printf("%c%c%c%c ", buf2[j], buf2[j+1], buf2[j+2], buf2[j+3]);
}
printf("\n");
virtptr++;
}
munmap(virtstart, 4096 * pagecnt);
close(fd);
return 0;
}
M8 android dump内存工具
4星 · 超过85%的资源 需积分: 50 21 浏览量
2012-08-12
11:33:54
上传
评论
收藏 264KB RAR 举报
物联Bill
- 粉丝: 258
- 资源: 22
最新资源
- 2%EF%BC%9A%E9%99%95%E8%A5%BF%E
- yyspdz62_944.apk
- SAP公司间采购EDI配置-如何触发自动MIRO.docx
- python197基于图像识别的仪表实时监控系统.rar
- I2C驱动SHT30温湿度传感器和LCD12864使用例程(RSCG12864B)
- python193中学地理-中国的江河湖泊教学网(django).rar
- python191基于时间序列分析的大气污染预测软件(django).rar
- python190基于人脸识别智能化小区门禁管理系统.rar
- python189某医院体检挂号系统.rar
- python179的企业物流管理系统(django).rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈