本文整理汇总了C++中r_egg_printf函数的典型用法代码示例。如果您正苦于以下问题:C++ r_egg_printf函数的具体用法?C++ r_egg_printf怎么用?C++ r_egg_printf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了r_egg_printf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: emit_branch
static void emit_branch(REgg *egg, char *b, char *g, char *e, char *n, int sz, const char *dst) {
char *p, str[64];
char *arg = NULL;
char *op = "beq";
/* NOTE that jb/ja are inverted to fit cmp opcode */
if (b) {
*b = '\0';
op = e?"bge":"bgt";
arg = b+1;
} else
if (g) {
*g = '\0';
op = e?"ble":"blt";
arg = g+1;
}
if (arg == NULL) {
if (e) {
arg = e+1;
op = "bne";
} else {
arg = "0";
op = n?"bne":"beq";
}
}
if (*arg=='=') arg++; /* for <=, >=, ... */
p = r_egg_mkvar (egg, str, arg, 0);
r_egg_printf (egg, " pop "R_AX"\n"); /* TODO: add support for more than one arg get arg0 */
r_egg_printf (egg, " cmp %s, "R_AX"\n", p);
// if (context>0)
r_egg_printf (egg, " %s %s\n", op, dst);
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:32,代码来源:emit_arm.c
示例2: emit_mathop
static void emit_mathop(REgg *egg, int ch, int vs, int type, const char *eq, const char *p) {
char *op;
switch(ch) {
case '^': op = "xor"; break;
case '&': op = "and"; break;
case '|': op = "or"; break;
case '-': op = "sub"; break;
case '+': op = "add"; break;
case '*': op = "mul"; break;
case '/': op = "div"; break;
default: op = "mov"; break;
}
if (attsyntax) {
if (eq == NULL) eq = "%"R_AX;
if (p == NULL) p = "%"R_AX;
r_egg_printf (egg, " %s%c %c%s, %s\n", op, vs, type, eq, p);
} else {
if (eq == NULL) eq = R_AX;
if (p == NULL) p = R_AX;
// TODO:
#if 0
eprintf ("TYPE = %c\n", type);
eprintf (" %s%c %c%s, %s\n", op, vs, type, eq, p);
eprintf (" %s %s, [%s]\n", op, p, eq);
#endif
if (type == '*') r_egg_printf (egg, " %s %s, [%s]\n", op, p, eq);
else r_egg_printf (egg, " %s %s, %s\n", op, p, eq);
}
}
开发者ID:0xroot,项目名称:radare2,代码行数:29,代码来源:emit_x86.c
示例3: emit_frame
static void emit_frame (REgg *egg, int sz) {
r_egg_printf (egg, " push {fp,lr}\n");
if (sz>0) r_egg_printf (egg,
//" mov "R_BP", "R_SP"\n"
" add fp, sp, $4\n" // size of arguments
" sub sp, $%d\n", sz); // size of stackframe 8, 16, ..
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:7,代码来源:emit_arm.c
示例4: parsedatachar
static int parsedatachar(REgg *egg, char c) {
static int inlinectr = 0;
char *str;
int i, j;
if (!dstval) {
return 0;
}
/* skip until '{' */
if (c == '{') { /* XXX: repeated code!! */
rcc_context (egg, 1);
if (++inlinectr==1)
return (ndstval = 0);
} else if (inlinectr == 0) {
/* capture value between parenthesis [email protected](NNN) { ... } */
if (c==')') {
stackframe = atoi (dstval);
ndstval = 0;
} else {
dstval[ndstval++] = c;
}
return 0;
}
/* capture body */
if (c == '}') { /* XXX: repeated code!! */
if (CTX< 2) {
inlinectr = 0;
rcc_context (egg, -1);
slurp = 0;
mode = NORMAL;
/* register */
if (dstval != NULL && dstvar != NULL) {
dstval[ndstval]='\0';
egg->remit->comment (egg, "data (%s)(%s)size=(%d)\n",
dstvar, dstval, stackframe);
r_egg_printf (egg, ".data\n");
for (str=dstval; is_space (*str); str++);
j = (stackframe)? stackframe: 1;
/* emit label */
r_egg_printf (egg, "%s:\n", dstvar);
for (i=1; i<=j; i++) {
if (*str=='"')
r_egg_printf (egg, ".ascii %s%s\n", dstval, (i==j)?"\"\\x00\"":"");
else r_egg_printf (egg, ".long %s\n", dstval);
}
r_egg_printf (egg, ".text\n");
R_FREE (dstvar);
R_FREE (dstval);
ndstval = 0;
CTX = 0;
return 1;
}
}
}
dstval[ndstval++] = c;
return 0;
}
开发者ID:EliaGeretto,项目名称:radare2,代码行数:57,代码来源:egg_lang.c
示例5: emit_comment
static void emit_comment(REgg *egg, const char *fmt, ...) {
va_list ap;
char buf[1024];
va_start (ap, fmt);
vsnprintf (buf, sizeof (buf), fmt, ap);
if (attsyntax) r_egg_printf (egg, " /* %s */\n", buf);
else r_egg_printf (egg, "# %s\n", buf);
va_end (ap);
}
开发者ID:0xroot,项目名称:radare2,代码行数:9,代码来源:emit_x86.c
示例6: emit_arg
static void emit_arg (REgg *egg, int xs, int num, const char *str) {
int d = atoi (str);
if (!attsyntax && (*str=='$'))
str = str +1;
switch (xs) {
case 0:
r_egg_printf (egg, " push %s\n", str);
break;
case '*':
if (attsyntax) r_egg_printf (egg, " push (%s)\n", str);
else r_egg_printf (egg, " push [%s]\n", str);
break;
case '&':
if (attsyntax) {
if (d != 0) r_egg_printf (egg, " addl $%d, %%"R_BP"\n", d);
r_egg_printf (egg, " pushl %%"R_BP"\n");
if (d != 0) r_egg_printf (egg, " subl $%d, %%"R_BP"\n", d);
} else {
if (d != 0) r_egg_printf (egg, " add "R_BP", %d\n", d);
r_egg_printf (egg, " push "R_BP"\n");
if (d != 0) r_egg_printf (egg, " sub "R_BP", %d\n", d);
}
break;
}
}
开发者ID:0xroot,项目名称:radare2,代码行数:25,代码来源:emit_x86.c
示例7: emit_branch
static void emit_branch(REgg *egg, char *b, char *g, char *e, char *n, int sz, const char *dst) {
char *p, str[64];
char *arg = NULL;
char *op = "jz";
int signed_value = 1; // XXX: add support for signed/unsigned variables
/* NOTE that jb/ja are inverted to fit cmp opcode */
if (b) {
*b = '\0';
if (signed_value) {
if (e) op = "jge";
else op = "jg";
} else {
if (e) op = "jae";
else op = "ja";
}
arg = b+1;
} else
if (g) {
*g = '\0';
if (signed_value) {
if (e) op = "jle";
else op = "jl";
} else {
if (e) op = "jbe";
else op = "jb";
}
arg = g+1;
}
if (arg == NULL) {
if (e) {
arg = e+1;
op = "jne";
} else {
arg = attsyntax? "$0": "0";
if (n) op = "jnz";
else op ="jz";
}
}
if (*arg=='=') arg++; /* for <=, >=, ... */
p = r_egg_mkvar (egg, str, arg, 0);
if (attsyntax) {
r_egg_printf (egg, " pop %%"R_AX"\n"); /* TODO: add support for more than one arg get arg0 */
r_egg_printf (egg, " cmp%c %s, %%"R_AX"\n", sz, p);
} else {
r_egg_printf (egg, " pop "R_AX"\n"); /* TODO: add support for more than one arg get arg0 */
r_egg_printf (egg, " cmp "R_AX", %s\n", p);
}
// if (context>0)
free (p);
r_egg_printf (egg, " %s %s\n", op, dst);
}
开发者ID:AmesianX,项目名称:radare2,代码行数:52,代码来源:emit_x86.c
示例8: emit_call
static void emit_call(REgg *egg, const char *str, int atr) {
int i;
//r_egg_printf (egg, " ARGS=%d CALL(%s,%d)\n", lastarg, str, atr);
for (i=0;i<lastarg;i++) {
r_egg_printf (egg, " ldr r%d, [%s]\n", lastarg-1-i, lastargs[i]);
lastargs[i][0] = 0;
}
if (atr) {
r_egg_printf (egg, " ldr r0, %s", str);
r_egg_printf (egg, " blx r0\n");
} else r_egg_printf (egg, " bl %s\n", str);
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:13,代码来源:emit_arm.c
示例9: emit_frame_end
static void emit_frame_end (REgg *egg, int sz, int ctx) {
if (sz>0) {
if (attsyntax) {
r_egg_printf (egg, " add $%d, %%"R_SP"\n", sz);
r_egg_printf (egg, " pop %%"R_BP"\n");
} else {
r_egg_printf (egg, " add "R_SP", %d\n", sz);
r_egg_printf (egg, " pop "R_BP"\n");
}
}
if (ctx>0)
r_egg_printf (egg, " ret\n");
}
开发者ID:0xroot,项目名称:radare2,代码行数:13,代码来源:emit_x86.c
示例10: emit_frame
static void emit_frame (REgg *egg, int sz) {
if (sz<1)
return;
if (attsyntax)
r_egg_printf (egg,
" push %%"R_BP"\n"
" mov %%"R_SP", %%"R_BP"\n"
" sub $%d, %%"R_SP"\n", sz);
else r_egg_printf (egg,
" push "R_BP"\n"
" mov "R_BP", "R_SP"\n"
" sub "R_SP", %d\n", sz);
}
开发者ID:0xroot,项目名称:radare2,代码行数:13,代码来源:emit_x86.c
示例11: emit_load_ptr
static void emit_load_ptr(REgg *egg, const char *dst) {
int d = atoi (dst);
if (d == 0) { // hack to handle stackvarptrz
char *p = strchr (dst, '+');
if (p) d = atoi (p+1);
}
//eprintf ("emit_load_ptr: HACK\n");
// XXX: 32/64bit care
//r_egg_printf (egg, "# DELTA IS (%s)\n", dst);
if (attsyntax) r_egg_printf (egg, " leal %d(%%"R_BP"), %%"R_AX"\n", d);
else r_egg_printf (egg, " lea "R_AX", ["R_BP"+%d]\n", d);
//r_egg_printf (egg, " movl %%"R_BP", %%"R_AX"\n");
//r_egg_printf (egg, " addl $%d, %%"R_AX"\n", d);
}
开发者ID:0xroot,项目名称:radare2,代码行数:14,代码来源:emit_x86.c
示例12: emit_syscall_args
static void emit_syscall_args(REgg *egg, int nargs) {
int j, k;
for (j=0; j<nargs; j++) {
k = j*R_SZ;
if (attsyntax)
r_egg_printf (egg, " mov %d(%%"R_SP"), %%%s\n", k, regs[j+1]);
else {
if (k>0)
r_egg_printf (egg, " mov %s, ["R_SP"+%d]\n", regs[j+1], k);
else if (k<0)
r_egg_printf (egg, " mov %s, ["R_SP"%d]\n", regs[j+1], k);
else r_egg_printf (egg, " mov %s, ["R_SP"]\n", regs[j+1]);
}
}
}
开发者ID:0xroot,项目名称:radare2,代码行数:15,代码来源:emit_x86.c
示例13: emit_syscall_args
static void emit_syscall_args(REgg *egg, int nargs) {
int j, k;
for (j=0; j<nargs; j++) {
k = j*R_SZ;
r_egg_printf (egg, " ldr %s, [sp, #%c%d]\n", regs[j+1], k>0?'+':' ', k);
}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:7,代码来源:emit_arm.c
示例14: emit_syscall_args
static void emit_syscall_args(REgg *egg, int nargs) {
int j, k;
for (j = 0; j < nargs; j++) {
k = j * R_SZ;
r_egg_printf (egg, " ldr %s, [sp, %d]\n",
regs[j+1], k?k+4:k+8);
}
}
开发者ID:13572293130,项目名称:radare2,代码行数:8,代码来源:emit_arm.c
示例15: emit_set_string
static void emit_set_string(REgg *egg, const char *dstvar, const char *str, int j) {
int rest, off = 0;
off = strlen (str)+1;
rest = (off%4);
if (rest) rest = 4-rest;
off += rest-8;
r_egg_printf (egg, " add pc, $%d\n", (off));
// XXX: does not handle \n and so on.. must use r_util
r_egg_printf (egg, ".string \"%s\"\n", str);
if (rest) r_egg_printf (egg, ".fill %d, 1, 0\n", (rest));
r_egg_printf (egg, " sub r0, pc, $%d\n", off+16);
{
char str[32], *p = r_egg_mkvar (egg, str, dstvar, 0);
//r_egg_printf (egg, "DSTVAR=%s --> %s\n", dstvar, p);
r_egg_printf (egg, " str r0, [%s]\n", p);
free (p);
}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:18,代码来源:emit_arm.c
示例16: emit_arg
static void emit_arg (REgg *egg, int xs, int num, const char *str) {
int d = atoi (str);
if (!attsyntax && (*str=='$'))
str++;
lastarg = num;
switch (xs) {
case 0:
if (strchr (str, ',')) {
//r_egg_printf (egg, ". str r0, [%s]\n", str);
strncpy (lastargs[num-1], str, sizeof(lastargs[0])-1);
} else {
if (!atoi (str)) eprintf ("WARNING: probably a bug?\n");
r_egg_printf (egg, " mov r0, $%s\n", str);
snprintf (lastargs[num-1], sizeof (lastargs[0]), "fp, $-%d", 8+(num*4));
r_egg_printf (egg, " str r0, [%s]\n", lastargs[num-1]);
}
break;
case '*':
r_egg_printf (egg, " push {%s}\n", str);
break;
case '&':
if (d) r_egg_printf (egg, " add "R_BP", %d\n", d);
r_egg_printf (egg, " push {"R_BP"}\n");
if (d) r_egg_printf (egg, " sub "R_BP", %d\n", d);
break;
}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:27,代码来源:emit_arm.c
示例17: emit_load
static void emit_load(REgg *egg, const char *dst, int sz) {
switch (sz) {
case 'l':
r_egg_printf (egg, " mov "R_AX", %s\n", dst);
r_egg_printf (egg, " mov "R_AX", ["R_AX"]\n");
break;
case 'b':
r_egg_printf (egg, " mov "R_AX", %s\n", dst);
r_egg_printf (egg, " movz "R_AX", ["R_AX"]\n");
break;
default:
// TODO: unhandled?!?
r_egg_printf (egg, " mov "R_AX", %s\n", dst);
r_egg_printf (egg, " mov "R_AX", ["R_AX"]\n");
}
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:16,代码来源:emit_arm.c
示例18: emit_while_end
static void emit_while_end (REgg *egg, const char *labelback) {
#if 0
if (attsyntax) {
r_egg_printf (egg, " pop %%"R_AX"\n");
r_egg_printf (egg, " cmp $0, %%"R_AX"\n"); // XXX MUST SUPPORT != 0 COMPARE HERE
r_egg_printf (egg, " jnz %s\n", labelback);
} else {
#endif
r_egg_printf (egg, " pop "R_AX"\n");
r_egg_printf (egg, " test "R_AX", "R_AX"\n"); // XXX MUST SUPPORT != 0 COMPARE HERE
r_egg_printf (egg, " jnz %s\n", labelback);
// }
}
// XXX: this is wrong
static void emit_get_var (REgg *egg, int type, char *out, int idx) {
switch (type) {
case 0: /* variable */
if (idx>0) sprintf (out, "["R_BP"+%d]", idx);
else if (idx<0) sprintf (out, "["R_BP"%d]", idx);
else strcpy (out, "["R_BP"]");
break;
case 1: /* argument */
// OMG WE CANT stuff found in relative address in stack in the stack
eprintf ("WARNING: Using stack vars in naked functions\n");
idx = 8; // HACK to make arg0, arg4, ... work
if (idx>0) sprintf (out, "["R_SP"+%d]", idx);
else if (idx<0) sprintf (out, "["R_SP"%d]", idx);
else strcpy (out, "["R_SP"]");
break;
case 2:
if (idx>0) sprintf (out, "["R_BP"+%d]", idx);
else if (idx<0) sprintf (out, "["R_BP"%d]", idx);
else strcpy (out, "["R_BP"]");
break;
}
}
static void emit_trap (REgg *egg) {
r_egg_printf (egg, " int3\n");
}
开发者ID:0xroot,项目名称:radare2,代码行数:41,代码来源:emit_x86.c
示例19: emit_jmp
static void emit_jmp(REgg *egg, const char *str, int atr) {
if (atr) {
r_egg_printf (egg, " ldr r0, %s", str);
r_egg_printf (egg, " bx r0\n");
} else r_egg_printf (egg, " b %s\n", str);
}
开发者ID:jody-frankowski,项目名称:radare2,代码行数:6,代码来源:emit_arm.c
示例20: emit_restore_stack
static void emit_restore_stack (REgg *egg, int size) {
if (attsyntax) r_egg_printf (egg, " add $%d, %%"R_SP" /* args */\n", size);
else r_egg_printf (egg, " add "R_SP", %d\n", size);
}
开发者ID:0xroot,项目名称:radare2,代码行数:4,代码来源:emit_x86.c
注:本文中的r_egg_printf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论