Skip to content

Commit ee7ae4b

Browse files
author
tracer
committed
> compile
forty Linux forty-virtual-machine 4.13.0-41-generic #46~16.04.1-Ubuntu SMP Thu May 3 10:06:03 UTC 2018 i686 i686 i686 GNU/Linux
1 parent cdca64f commit ee7ae4b

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

memhack.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ void setup()
8585
}
8686
return;
8787
}
88+
int hex_atoi(char* s)
89+
{
90+
int len = strlen(s); int ans = 0;
91+
for(int i = 0; i<len; i++){
92+
int digital = 0; int pow_result = 1;
93+
if(s[i]>47 && s[i]<58){
94+
digital = s[i] - 48;
95+
}
96+
else if(s[i]>96 && s[i]<103){
97+
digital = s[i] - 87;
98+
}
99+
for(int j = 0; j<i; j++){
100+
pow_result *= 16;
101+
}
102+
ans += digital*pow_result;
103+
}
104+
return ans;
105+
}
88106
void init(char* pid_c)
89107
{
90108
char filename[32];
@@ -143,7 +161,7 @@ void init(char* pid_c)
143161
}
144162
end[end_p] = '\0';
145163
printf("\033[44;33mstart:%s end:%s\033[0m\n",start, end);
146-
addr_start = atoi(start); addr_end = atoi(end);
164+
addr_start = hex_atoi(start); addr_end = hex_atoi(end);
147165
printf("\033[44;33mstart:0x%08x end:0x%08x\033[0m\n",addr_start, addr_end);
148166
}
149167
}

0 commit comments

Comments
 (0)