mirror of
https://github.com/Light-Speech/C-Android-Memory-Tool.git
synced 2024-10-23 09:33:45 +08:00
Threading errors and non decleared variables patch
There was error on Freeze threading part and one function was out of boundery which was causing the program to crash. Created working main.cpp file
This commit is contained in:
parent
a737348721
commit
b6f778f214
193
MemoryTool.cpp
193
MemoryTool.cpp
@ -1,4 +1,4 @@
|
||||
#include "MemoryTool.h"
|
||||
#include "MemoryTool.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -162,7 +162,8 @@ void MemoryTool::MaskSearch(char *def, int type) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -229,7 +230,8 @@ long int MemoryTool::GetModuleBase(char *module,char * flags,int MapSize) {
|
||||
if (strstr(buff, flags) != NULL && !feof(fp) && strstr(buff, module)) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -424,7 +426,8 @@ PMAPS MemoryTool::BaseAddressSearch_DWORD(DWORD value, ADDRESS BaseAddr, PMAPS p
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -462,7 +465,8 @@ PMAPS MemoryTool::BaseAddressSearch_DOUBLE(DOUBLE value, ADDRESS BaseAddr, PMAPS
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -499,7 +503,8 @@ PMAPS MemoryTool::BaseAddressSearch_FLOAT(FLOAT value, ADDRESS BaseAddr, PMAPS p
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -536,7 +541,8 @@ PMAPS MemoryTool::BaseAddressSearch_WORD(WORD value, ADDRESS BaseAddr, PMAPS pMa
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -573,7 +579,8 @@ PMAPS MemoryTool::BaseAddressSearch_QWORD(QWORD value, ADDRESS BaseAddr, PMAPS p
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -611,7 +618,8 @@ PMAPS MemoryTool::BaseAddressSearch_BYTE(BYTE value, ADDRESS BaseAddr, PMAPS pMa
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -750,7 +758,8 @@ PMAPS MemoryTool::RangeMemorySearch_DWORD(DWORD from_value, DWORD to_value, PMAP
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -795,7 +804,8 @@ PMAPS MemoryTool::RangeMemorySearch_FLOAT(FLOAT from_value, FLOAT to_value, PMAP
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -843,7 +853,8 @@ PMAPS MemoryTool::RangeMemorySearch_DOUBLE(DOUBLE from_value, DOUBLE to_value, P
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -891,7 +902,8 @@ PMAPS MemoryTool::RangeMemorySearch_WORD(WORD from_value, WORD to_value, PMAPS p
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -939,7 +951,8 @@ PMAPS MemoryTool::RangeMemorySearch_BYTE(BYTE from_value, BYTE to_value, PMAPS p
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -987,7 +1000,8 @@ PMAPS MemoryTool::RangeMemorySearch_QWORD(QWORD from_value, QWORD to_value, PMAP
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1114,7 +1128,8 @@ PMAPS MemoryTool::MemorySearch_DWORD(DWORD value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1159,7 +1174,8 @@ PMAPS MemoryTool::MemorySearch_FLOAT(FLOAT value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1207,7 +1223,8 @@ PMAPS MemoryTool::MemorySearch_DOUBLE(DOUBLE value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1255,7 +1272,8 @@ PMAPS MemoryTool::MemorySearch_WORD(WORD value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1303,7 +1321,8 @@ PMAPS MemoryTool::MemorySearch_BYTE(BYTE value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1351,7 +1370,8 @@ PMAPS MemoryTool::MemorySearch_QWORD(QWORD value, PMAPS pMap) {
|
||||
n->next = NULL;
|
||||
e = n;
|
||||
pBuff = n;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
n->next = NULL;
|
||||
e->next = n;
|
||||
e = n;
|
||||
@ -1430,7 +1450,8 @@ PMAPS MemoryTool::MemoryOffset_DWORD(DWORD value, OFFSET offset, PMAPS pBuff) {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1477,7 +1498,8 @@ PMAPS MemoryTool::MemoryOffset_FLOAT(FLOAT value, OFFSET offset, PMAPS pBuff) {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1523,7 +1545,8 @@ PMAPS MemoryTool::MemoryOffset_DOUBLE(DOUBLE value, OFFSET offset, PMAPS pBuff)
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1567,7 +1590,8 @@ PMAPS MemoryTool::MemoryOffset_WORD(WORD value, OFFSET offset, PMAPS pBuff) {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1612,7 +1636,8 @@ PMAPS MemoryTool::MemoryOffset_BYTE(BYTE value, OFFSET offset, PMAPS pBuff) {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1657,7 +1682,8 @@ PMAPS MemoryTool::MemoryOffset_QWORD(QWORD value, OFFSET offset, PMAPS pBuff) {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1756,7 +1782,8 @@ PMAPS MemoryTool::RangeMemoryOffset_DWORD(DWORD from_value, DWORD to_value, OFFS
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1802,7 +1829,8 @@ PMAPS MemoryTool::RangeMemoryOffset_FLOAT(FLOAT from_value, FLOAT to_value, OFFS
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1848,7 +1876,8 @@ PMAPS MemoryTool::RangeMemoryOffset_DOUBLE(DOUBLE from_value, DOUBLE to_value, O
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1895,7 +1924,8 @@ PMAPS MemoryTool::RangeMemoryOffset_WORD(WORD from_value, WORD to_value, OFFSET
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1941,7 +1971,8 @@ PMAPS MemoryTool::RangeMemoryOffset_BYTE(BYTE from_value, BYTE to_value, OFFSET
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -1987,7 +2018,8 @@ PMAPS MemoryTool::RangeMemoryOffset_QWORD(QWORD from_value, QWORD to_value, OFFS
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
BUFF = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -2032,7 +2064,7 @@ void MemoryTool::MemoryWrite(char *value, OFFSET offset, TYPE type) {
|
||||
}
|
||||
// ClearResults();//cleer list
|
||||
}
|
||||
int MemoryWrite_DWORD(DWORD value, PMAPS pBuff, OFFSET offset) {
|
||||
int MemoryTool::MemoryWrite_DWORD(DWORD value, PMAPS pBuff, OFFSET offset) {
|
||||
|
||||
PMAPS pTemp = NULL;
|
||||
pTemp = pBuff;
|
||||
@ -2180,7 +2212,8 @@ int MemoryTool::isapkinstalled(PACKAGENAME * bm) {
|
||||
dir = opendir(LJ);
|
||||
if (dir == NULL) {
|
||||
return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -2445,7 +2478,8 @@ void MemoryTool::FreezeThread() {
|
||||
PMAPS MemoryTool::GetResults() {
|
||||
if (Res == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return Res;
|
||||
}
|
||||
}
|
||||
@ -2523,7 +2557,8 @@ int MemoryTool::AddFreezeItem_DWORD(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_DWORD;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2546,7 +2581,8 @@ int MemoryTool::AddFreezeItem_FLOAT(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_FLOAT;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2569,7 +2605,8 @@ int MemoryTool::AddFreezeItem_DOUBLE(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_DOUBLE;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2592,7 +2629,8 @@ int MemoryTool::AddFreezeItem_WORD(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_WORD;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2615,7 +2653,8 @@ int MemoryTool::AddFreezeItem_BYTE(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_BYTE;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2638,7 +2677,8 @@ int MemoryTool::AddFreezeItem_QWORD(ADDRESS addr, char *value) {
|
||||
pNew->type = TYPE_QWORD;
|
||||
pNew->value = value;
|
||||
FreezeCount += 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew = (PFREEZE)malloc(FRE);
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
@ -2693,7 +2733,7 @@ int MemoryTool::StartFreeze() {
|
||||
//strcpy(Fbm, bm);
|
||||
Freeze = 1;
|
||||
//pthread_create(&pth, NULL, FreezeThread, NULL);
|
||||
thread th1(&MemoryTool::FreezeThread);
|
||||
thread th1(&MemoryTool::FreezeThread, this);
|
||||
//th1.join();
|
||||
return 0;
|
||||
}
|
||||
@ -2850,7 +2890,8 @@ PMAPS MemoryTool::readmaps_all() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp)) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -2859,7 +2900,8 @@ PMAPS MemoryTool::readmaps_all() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -2892,7 +2934,8 @@ PMAPS MemoryTool::readmaps_bad() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "kgsl-3d0")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -2901,7 +2944,8 @@ PMAPS MemoryTool::readmaps_bad() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -2934,7 +2978,8 @@ PMAPS MemoryTool::readmaps_c_alloc() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "[anon:libc_malloc]")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -2943,7 +2988,8 @@ PMAPS MemoryTool::readmaps_c_alloc() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -2976,7 +3022,8 @@ PMAPS MemoryTool::readmaps_c_bss() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "[anon:.bss]")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -2985,7 +3032,8 @@ PMAPS MemoryTool::readmaps_c_bss() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3018,7 +3066,8 @@ PMAPS MemoryTool::readmaps_c_data() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "/data/app/")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3027,7 +3076,8 @@ PMAPS MemoryTool::readmaps_c_data() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3060,7 +3110,8 @@ PMAPS MemoryTool::readmaps_c_heap() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "[heap]")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3069,7 +3120,8 @@ PMAPS MemoryTool::readmaps_c_heap() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3102,7 +3154,8 @@ PMAPS MemoryTool::readmaps_java_heap() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "/dev/ashmem/")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3111,7 +3164,8 @@ PMAPS MemoryTool::readmaps_java_heap() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3144,7 +3198,8 @@ PMAPS MemoryTool::readmaps_a_anonmyous() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && (strlen(buff) < 42)) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3153,7 +3208,8 @@ PMAPS MemoryTool::readmaps_a_anonmyous() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3186,7 +3242,8 @@ PMAPS MemoryTool::readmaps_code_system() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "/system")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3195,7 +3252,8 @@ PMAPS MemoryTool::readmaps_code_system() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3228,7 +3286,8 @@ PMAPS MemoryTool::readmaps_stack() {
|
||||
if (strstr(buff, "rw") != NULL && !feof(fp) && strstr(buff, "[stack]")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3237,7 +3296,8 @@ PMAPS MemoryTool::readmaps_stack() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3271,7 +3331,8 @@ PMAPS MemoryTool::readmaps_ashmem() {
|
||||
&& !strstr(buff, "dalvik")) {
|
||||
sscanf(buff, "%lx-%lx", &pNew->addr, &pNew->taddr);
|
||||
flag = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
flag = 0;
|
||||
}
|
||||
if (flag == 1) {
|
||||
@ -3280,7 +3341,8 @@ PMAPS MemoryTool::readmaps_ashmem() {
|
||||
pNew->next = NULL;
|
||||
pEnd = pNew;
|
||||
pHead = pNew;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
pNew->next = NULL;
|
||||
pEnd->next = pNew;
|
||||
pEnd = pNew;
|
||||
@ -3292,3 +3354,4 @@ PMAPS MemoryTool::readmaps_ashmem() {
|
||||
fclose(fp);
|
||||
return pHead;
|
||||
}
|
||||
|
||||
|
||||
@ -229,4 +229,3 @@ public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
20
main.cpp
20
main.cpp
@ -1,22 +1,22 @@
|
||||
#include <iostream>
|
||||
#include "MemoryTools.h"
|
||||
# include "MemoryTool.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int main(int arc, char argv[]) {
|
||||
/* 1. Package Name of the game
|
||||
2. ROOT_MODE (tells you are using rooted device (not reooted device not implimented yet))
|
||||
*/
|
||||
MemoryTools memoryTools("com.tencent.ig", MODE_ROOT);
|
||||
char game_package[] = "com.tencent.ig";
|
||||
MemoryTool memory_tool;
|
||||
memory_tool.initXMemoryTools(game_package, MODE_ROOT);
|
||||
|
||||
// Initialize the search range to global (check other ranges in header file of memory tool)
|
||||
memoryTools.SetSearchRange(ALL);
|
||||
memory_tool.SetSearchRange(ALL);
|
||||
// Search for 1 in whole memory of type byte
|
||||
memoryTools.MemorySearch("1", TYPE_BYTE);
|
||||
memory_tool.MemorySearch("1", TYPE_BYTE);
|
||||
// This is another usage if you want to write a value at given offset you can use below line else above line will write all the data in memory
|
||||
memoryTools.MemoryOffset("2", 2, /*offset*/ TYPE_BYTE);
|
||||
memory_tool.MemoryOffset("2", 2, /*offset*/ TYPE_BYTE);
|
||||
// Finally write the value to the memory
|
||||
memoryTools.MemoryWrite("0", 2, /*offset*/ TYPE_BYTE);
|
||||
memory_tool.MemoryWrite("0", 2, /*offset*/ TYPE_BYTE);
|
||||
// clear results function clean all the offsets/values from memory
|
||||
memoryTools.ClearResults();
|
||||
|
||||
memory_tool.ClearResults();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user