// Common function to handle all system calls - // decode the system call type and call an appropriate handler function. // Be sure to handle undefined system calls appropriately. void syscall(trapframe *tf) { // EAX register holds system call command/flags uint32_t cmd = tf->regs.eax; switch (cmd & SYS_TYPE) { case SYS_CPUTS: return do_cputs(tf, cmd); case SYS_PUT: return do_put(tf, cmd); case SYS_GET: return do_get(tf, cmd); case SYS_RET: return do_ret(tf, cmd); default: return; // handle as a regular trap } }
void parser() { int ab_code=4, x=line_ndx; int I; switch(token) { case 0: break; case 1: parse_let(); break; case 2: cls(); break; case 3: locate(); break; case 4: xstring_array(); get_prnstring(); break; case 5: go_to(); break; case 6: beep(); break; case 7: cls(); break; case 8: line_ndx = nrows; break; case 9: do_gs(); break; case 10: do_ret(); break; case 11: do_loop(); break; case 12: do_next(); break; case 13: do_iloop(); break; case 14: do_iloop(); break; case 15: return; break; case 16: return; break; case -1: break; default: printf("parser Inside DEFAULT\n"); printf("p_string = %s\n",p_string); a_bort(ab_code, x); break; } }
byte * _f_handler_inst_retn(byte * inst) { log_data("RETN reached"); do_ret(RADDR(inst),1); return 0; }
byte * _f_handler_inst_gen_1op(byte * inst) { dword rtype, arg1, arg2; MODREGDEC(inst+1,arg1,arg2,rtype); dword target; it_inner_entry *it; /* TODO embbed this on the mphash */ switch (arg2) { case INST_GEN_CALL: if (rtype == smod_reg_RR) { flux_staple(RADDR(inst),2); return inst+2; } target = *(dword*)(inst+2); log_debug("CALL to %X",target); if (!is_code(target,&it)) { if (it) { /* maybe examine here the arguments for ease of analysis? */ log_debug("External function (%s) (%s)",it->name,it->libname); if (!strcmp("ExitProcess",it->name)) { /* its an exit process, function ends here */ do_ret(RADDR(inst),6); log_debug("exit function reached"); return 0; } } } else { //return (byte*)target; /* queue function for analysis */ } flux_staple(RADDR(inst),6); return inst+6; case INST_GEN_JMP: target = *(dword*)(inst+2); it_inner_entry * it; if (!is_code(target,&it)) { log_debug("JMP to outside, assuming ret"); /* this is used normally to call external functions in a relloc fashion, assume RET here */ do_ret(RADDR(inst),6); return 0; } else { } flux_staple(RADDR(inst),6); return inst+6; case INST_GEN_JMPF: /* jmp far, let's check the target */ break; case INST_GEN_INC: case INST_GEN_DEC: case INST_GEN_CALLF: /* this is a register call, we must flag it, but we cannot know what was called right now */ case INST_GEN_PUSH: if (rtype == smod_reg_IR) { if (arg1 == mod_reg_EBP) { /* not really ebp here, but disp32 */ flux_staple(RADDR(inst),6); return inst+6; } if (arg1 == mod_reg_SIB) { MODREGDEC(inst+2,arg1,arg2,rtype); flux_staple(RADDR(inst),7); return inst+7; } flux_staple(RADDR(inst),2); return inst+2; } if (rtype == smod_reg_I8R) { flux_staple(RADDR(inst),3); return inst+3; } if (rtype == smod_reg_RR) { flux_staple(RADDR(inst),2); return inst+2; } flux_staple(RADDR(inst),6); return inst+6; break; } return inst; }