Line 63... |
Line 63... |
int i = 0;
|
int i = 0;
|
int breakpoint = 0;
|
int breakpoint = 0;
|
|
|
simgetstr(stackaddr, regparam);
|
simgetstr(stackaddr, regparam);
|
|
|
debug("simprintf: stackaddr: 0x%.8lx", stackaddr);
|
debug(6, "simprintf: stackaddr: 0x%.8lx\n", stackaddr);
|
if ((f = fopen("stdout.txt", "a+"))) {
|
if ((f = fopen("stdout.txt", "a+"))) {
|
unsigned long arg;
|
unsigned long arg;
|
unsigned long argaddr;
|
unsigned long argaddr;
|
unsigned char regstr[5];
|
unsigned char regstr[5];
|
char *fmtstrend;
|
char *fmtstrend;
|
Line 76... |
Line 76... |
#if STACK_ARGS
|
#if STACK_ARGS
|
argaddr = stackaddr;
|
argaddr = stackaddr;
|
#else
|
#else
|
argaddr = 3;
|
argaddr = 3;
|
#endif
|
#endif
|
debug("simprintf: %s", fmtstrpart);
|
debug(6, "simprintf: %s\n", fmtstrpart);
|
while(strlen(fmtstrpart)) {
|
while(strlen(fmtstrpart)) {
|
debug("simprintf(): 1");
|
debug(6, "simprintf(): 1");
|
if ((fmtstrend = strstr(fmtstrpart + 1, "%")))
|
if ((fmtstrend = strstr(fmtstrpart + 1, "%")))
|
*fmtstrend = '\0';
|
*fmtstrend = '\0';
|
debug(" 2");
|
debug(6," 2");
|
if (strstr(fmtstrpart, "%")) {
|
if (strstr(fmtstrpart, "%")) {
|
debug(" 3");
|
debug(6, " 3");
|
#if STACK_ARGS
|
#if STACK_ARGS
|
arg = eval_mem32(argaddr,&breakpoint);
|
arg = eval_mem32(argaddr,&breakpoint);
|
argaddr += 4;
|
argaddr += 4;
|
#else
|
#else
|
sprintf(regstr, "r%u", ++argaddr);
|
sprintf(regstr, "r%u", ++argaddr);
|
arg = eval_reg(regstr);
|
arg = eval_reg(regstr);
|
#endif
|
#endif
|
debug(" 4: fmtstrpart=%p fmtstrpart=%s arg=%p", fmtstrpart, fmtstrpart, arg);
|
debug(6, " 4: fmtstrpart=%p fmtstrpart=%s arg=%p\n", fmtstrpart, fmtstrpart, arg);
|
if (strncmp(fmtstrpart, "%s", 2) == 0) {
|
if (strncmp(fmtstrpart, "%s", 2) == 0) {
|
int len = 0;
|
int len = 0;
|
char *str;
|
char *str;
|
for(; eval_mem8(arg++,&breakpoint); len++);
|
for(; eval_mem8(arg++,&breakpoint); len++);
|
len++; /* for null char */
|
len++; /* for null char */
|
Line 103... |
Line 103... |
str = (char *)malloc(len);
|
str = (char *)malloc(len);
|
len = 0;
|
len = 0;
|
for(; eval_mem8(arg,&breakpoint); len++)
|
for(; eval_mem8(arg,&breakpoint); len++)
|
*(str+len) = eval_mem8(arg++,&breakpoint);
|
*(str+len) = eval_mem8(arg++,&breakpoint);
|
*(str+len) = eval_mem8(arg,&breakpoint); /* null ch */
|
*(str+len) = eval_mem8(arg,&breakpoint); /* null ch */
|
/* debug("4a: len=%d str=%s\n", len, str);
|
debug(6, "4a: len=%d str=%s\n", len, str);
|
debug("4b:"); */
|
debug(6, "4b:");
|
fprintf(f, fmtstrpart, str);
|
fprintf(f, fmtstrpart, str);
|
free(str);
|
free(str);
|
} else
|
} else
|
fprintf(f, fmtstrpart, arg);
|
fprintf(f, fmtstrpart, arg);
|
} else {
|
} else {
|
debug(" 5");
|
debug(6, " 5");
|
fprintf(f, fmtstrpart);
|
fprintf(f, fmtstrpart);
|
debug(fmtstrpart);
|
debug(6, fmtstrpart);
|
}
|
}
|
if (!fmtstrend)
|
if (!fmtstrend)
|
break;
|
break;
|
debug(" 6");
|
debug(6, " 6");
|
fmtstrpart = fmtstrend;
|
fmtstrpart = fmtstrend;
|
*fmtstrpart = '%';
|
*fmtstrpart = '%';
|
debug(" 7");
|
debug(6, " 7");
|
}
|
}
|
|
|
debug(" 8");
|
debug(6," 8\n");
|
if (fclose(f))
|
if (fclose(f))
|
perror(strerror(errno));
|
perror(strerror(errno));
|
}
|
}
|
else
|
else
|
perror(strerror(errno));
|
perror(strerror(errno));
|