/* Returns 1 if Data Execution Prevention is present and working */ static int AttemptToExecuteData() { int result; char *thunk_buffer = g_malloc(64); nacl_void_thunk thunk; /* d'b: small fixes */ if(thunk_buffer == NULL) return 0; thunk = GenerateThunk(thunk_buffer, 64); setup_signals(); if(0 == sigsetjmp(try_state, 1)) { thunk(); result = 0; } else { result = 1; } restore_signals(); g_free(thunk_buffer); return result; }
Lexeme *evalFuncArgs(Lexeme *tree, Lexeme *params, Lexeme *env) { if((tree == NULL && params == NULL) || areEqual(tree,params,NIL)) { //printf("Both nil\n"); return lexeme(NIL); } else if(tree == NULL || !strcmp(tree->type,NIL)) { //printf("tree nil\n"); fprintf(stderr,"Too few arguments for function call\n"); return lexeme(NIL); } else if(params == NULL || !strcmp(params->type,NIL)) { //printf("params nil\n"); fprintf(stderr,"Too many arguments for function call\n"); return lexeme(NIL); } else if(!strcmp(car(params)->type,OPAREN)) { //printf("thunk!\n"); //printf("thing to be delayed:\n"); //displayTree(car(tree),""); return cons(JOIN,thunk(car(tree),env),evalFuncArgs(cdr(tree),cdr(params),env)); } else if(!strcmp(car(params)->sval,"@")) { //printf("variadic\n"); Lexeme *list = evalExprList(tree,env); if(list == NULL || !strcmp(list->type,NIL)) { return lexeme(NIL); } else { return cons(JOIN,list,lexeme(NIL)); } } else { //printf("Normal shit\n"); return cons(JOIN,eval(car(tree),env),evalFuncArgs(cdr(tree),cdr(params),env)); } }
virtual void render_marker(image_rgba8 const& src, markers_dispatch_params const& params, agg::trans_affine const& marker_tr) { raster_marker_render_thunk thunk(src, marker_tr, params.opacity, comp_op_, params.snap_to_pixels); thunks_.emplace_back(std::move(thunk)); }
virtual void render_marker(svg_path_ptr const& src, svg_path_adapter & path, svg_attribute_type const& attrs, markers_dispatch_params const& params, agg::trans_affine const& marker_tr) { vector_marker_render_thunk thunk(src, attrs, marker_tr, params.opacity, comp_op_, params.snap_to_pixels); thunks_.emplace_back(std::move(thunk)); }
void render_thunk_extractor::extract_text_thunk(helper_ptr && helper, text_symbolizer const& sym) const { double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); text_render_thunk thunk(std::move(helper), opacity, comp_op, halo_rasterizer); thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); update_box(); }
void render_thunk_extractor::extract_text_thunk(text_symbolizer_helper & helper, text_symbolizer const& sym) const { double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); placements_list const& placements = helper.get(); text_render_thunk thunk(placements, opacity, comp_op, halo_rasterizer); thunks_.push_back(std::make_shared<render_thunk>(thunk)); update_box(); }
void render_thunk_extractor::operator()(point_symbolizer const& sym) const { composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); render_point_symbolizer( sym, feature_, prj_trans_, common_, [&](pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity) { point_render_thunk thunk(pos, marker, tr, opacity, comp_op); thunks_.push_back(std::make_shared<render_thunk>(std::move(thunk))); }); update_box(); }
/* * Returns 1 if Data Execution Prevention is present and working. */ int NaClAttemptToExecuteData() { int result; char *thunk_buffer = malloc(64); nacl_void_thunk thunk = NaClGenerateThunk(thunk_buffer, 64); setup_signals(); if (0 == sigsetjmp(try_state, 1)) { thunk(); result = 0; } else { result = 1; } restore_signals(); return result; }
void render_thunk_extractor::extract_text_thunk(text_symbolizer const& sym) const { auto placements(Helper::get( sym, feature_, vars_, prj_trans_, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clipping_extent_, agg::trans_affine::identity, common_.symbol_cache_)); double opacity = get<double>(sym, keys::opacity, feature_, common_.vars_, 1.0); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature_, common_.vars_, src_over); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature_, common_.vars_, HALO_RASTERIZER_FULL); base_text_render_thunk thunk(std::move(placements), opacity, comp_op, halo_rasterizer); thunks_.emplace_back(std::move(thunk)); update_box(); }
int NaClAttemptToExecuteDataAtAddr(char *thunk_buffer, size_t size) { int result; MachExceptionHandlerData saved_handlers; nacl_void_thunk thunk = NaClGenerateThunk(thunk_buffer, size); setup_signals(); DisableMachExceptionHandler(&saved_handlers); if (0 == sigsetjmp(try_state, 1)) { thunk(); result = 0; } else { result = 1; } EnableMachExceptionHandler(&saved_handlers); restore_signals(); return result; }
Timer delay(const Duration& duration, const PID<T>& pid, void (T::*method)()) { memory::shared_ptr<lambda::function<void(T*)> > thunk( new lambda::function<void(T*)>( lambda::bind(method, lambda::_1))); memory::shared_ptr<lambda::function<void(ProcessBase*)> > dispatcher( new lambda::function<void(ProcessBase*)>( lambda::bind(&internal::vdispatcher<T>, lambda::_1, thunk))); lambda::function<void(void)> dispatch = lambda::bind(internal::dispatch, pid, dispatcher, internal::canonicalize(method)); return Clock::timer(duration, dispatch); }
Timer delay(const Duration& duration, const PID<T>& pid, void (T::*method)()) { std::tr1::shared_ptr<std::tr1::function<void(T*)> > thunk( new std::tr1::function<void(T*)>( std::tr1::bind(method, std::tr1::placeholders::_1))); std::tr1::shared_ptr<std::tr1::function<void(ProcessBase*)> > dispatcher( new std::tr1::function<void(ProcessBase*)>( std::tr1::bind(&internal::vdispatcher<T>, std::tr1::placeholders::_1, thunk))); std::tr1::function<void(void)> dispatch = std::tr1::bind(internal::dispatch, pid, dispatcher, internal::canonicalize(method)); return Timer::create(duration, dispatch); }
void render_marker(agg::trans_affine const& marker_tr, double opacity) { vector_marker_render_thunk thunk(this->src_, this->attrs_, marker_tr, opacity, comp_op_, snap_to_pixels_); thunks_.push_back(std::make_unique<render_thunk>(std::move(thunk))); }
/* Emulate one VM insn. */ void vm_step(vm_context_t *ctx) { #include "vm_opcodes.switch.tab" vm_operand_t r0, r1; vm_operand_t buf[3]; uint8_t *pc = ctx->pc; unsigned ops_in, ops_out = 0; uint8_t opcode; opcode = *pc; DBGPRINT("vm_step: %08x -> %02x ", pc, opcode); pc += 1; ops_in = opcode >> 6; /* 2 highest bits make for operand count. */ opcode &= 0x3F; DBGPRINT("(%s / %d)\n", vm_insn_to_name[opcode], ops_in); vm_stack_pop3(ctx->dstack, buf, ops_in); goto *(&&op_invalid + offtab[opcode]); op_invalid: vm_panic("vm_step: unknown opcode."); op_ADD: r0 = ARG2 + ARG1; goto push_1; op_SUB: r0 = ARG2 - ARG1; goto push_1; op_MULU: { TARGET_MULU(ARG1, ARG2, r0, r1); goto push_2; } op_MULS: { TARGET_MULS(ARG1, ARG2, r0, r1); goto push_2; } op_DIVU: { TARGET_DIVU(ARG2, ARG1); goto push_2; } op_DIVS: { TARGET_DIVS(ARG2, ARG1); goto push_2; } op_AND: r0 = ARG1 & ARG2; goto push_1; op_OR: r0 = ARG1 | ARG2; goto push_1; op_XOR: r0 = ARG1 ^ ARG2; goto push_1; op_NOT: r0 = ~ARG1; goto push_1; op_LSL: r0 = ARG2 << ARG1; goto push_1; op_LSR: r0 = ((vm_uoperand_t)ARG2) >> ARG1; goto push_1; op_ASR: r0 = ((vm_soperand_t)ARG2) >> ARG1; goto push_1; op_CMP_LT: r0 = ((vm_soperand_t)ARG1) < ((vm_soperand_t)ARG2); goto push_1; op_CMP_GT: r0 = ((vm_soperand_t)ARG1) > ((vm_soperand_t)ARG2); goto push_1; op_CMP_B: r0 = ((vm_uoperand_t)ARG1) < ((vm_uoperand_t)ARG2); goto push_1; op_CMP_A: r0 = ((vm_uoperand_t)ARG1) > ((vm_uoperand_t)ARG2); goto push_1; op_CMP_EQ: r0 = ARG2 == ARG1; goto push_1; op_LDC_0: r0 = 0; goto push_1; op_LDC_1: r0 = 1; goto push_1; op_LDC_2: r0 = 2; goto push_1; op_LDC_UB: r0 = (vm_uoperand_t)*(uint8_t *)(pc); pc += 1; goto push_1; op_LDC_SB: r0 = (vm_soperand_t)*(int8_t *)(pc); pc += 1; goto push_1; op_LDC_W: r0 = vm_fetch32_ua(pc); pc += 4; goto push_1; op_LEA: r0 = vm_fetch32_ua(pc); DBGPRINT("vm_step: PCREL offset %08x -> ", r0); pc += 4; r0 += (vm_uoperand_t)pc; DBGPRINT("%08x\n", r0); goto push_1; op_LDM_UB: r0 = (vm_uoperand_t)*(uint8_t *)(ARG1); goto push_1; op_LDM_SB: r0 = (vm_soperand_t)*(int8_t *)(ARG1); goto push_1; op_LDM_UH: r0 = (vm_uoperand_t)*(uint16_t *)(ARG1); goto push_1; op_LDM_SH: r0 = (vm_soperand_t)*(int16_t *)(ARG1); goto push_1; op_LDM_W: r0 = *(vm_operand_t *)(ARG1); goto push_1; op_STM_B: *(uint8_t *)(ARG1) = (uint8_t)ARG2; DBGPRINT("vm_step: %08x -> %08x\n", ARG2, ARG1); goto push_none; op_STM_H: *(uint16_t *)(ARG1) = (uint16_t)ARG2; DBGPRINT("vm_step: %08x -> %08x\n", ARG2, ARG1); goto push_none; op_STM_W: *(vm_operand_t *)(ARG1) = ARG2; DBGPRINT("vm_step: %08x -> %08x\n", ARG2, ARG1); goto push_none; op_LOCALS: { uint8_t count = *(uint8_t *)(pc); pc += 1; ctx->locals = (vm_locals_t *)vm_alloc(sizeof(vm_locals_t) + (count - 1) * sizeof(vm_operand_t)); ctx->locals->count = count; goto push_none; } op_LDLOC: { uint8_t index = *(uint8_t *)(pc); pc += 1; if (!ctx->locals) { vm_panic("vm_step: accessing locals where none have been allocated."); } if (index >= ctx->locals->count) { vm_panic("vm_step: local index out of bounds."); } r0 = ctx->locals->data[index]; goto push_1; } op_STLOC: { uint8_t index = *(uint8_t *)(pc); pc += 1; if (!ctx->locals) { vm_panic("vm_step: accessing locals where none have been allocated."); } if (index >= ctx->locals->count) { vm_panic("vm_step: local index out of bounds."); } ctx->locals->data[index] = ARG1; goto push_none; } op_DUP: r1 = r0 = ARG1; goto push_2; op_SWAP: { r1 = ARG1; r0 = ARG2; goto push_2; } op_POP: goto push_none; op_BR: { int8_t offset = *(int8_t *)(pc); pc += 1; pc = pc + offset; goto push_none; } op_BR_T: { int8_t offset = *(int8_t *)(pc); pc += 1; if (ARG1) { pc = pc + offset; } goto push_none; } op_BR_F: { int8_t offset = *(int8_t *)(pc); pc += 1; if (!ARG1) { pc = pc + offset; } goto push_none; } op_CALL: { int32_t offset = (int32_t)vm_fetch32_ua(pc); pc += 4; vm_save_frame(ctx, pc); pc += offset; DBGPRINT("\n"); goto push_none; } op_RET: { vm_callframe_t *frame; vm_free(ctx->locals); frame = (vm_callframe_t *)vm_stack_pop(ctx->cstack); ctx->locals = frame->locals; pc = frame->return_pc; DBGPRINT("vm_step: stack balance on return: %d\n\n", frame->dstack_top - vm_stack_top(ctx->dstack)); vm_free(frame); goto push_none; } op_ICALL: { vm_save_frame(ctx, pc); pc = (uint8_t *)ARG1; goto push_none; } op_IJMP: { pc = (uint8_t *)ARG1; goto push_none; } op_NCALL: { int index = vm_fetch16_ua(pc); /* thunk index */ pc += 2; if (!ctx->module->ncalls_table) { vm_panic("vm_step: no ncalls defined, but a ncall insn encountered."); } vm_thunk_t thunk = (vm_thunk_t)ctx->module->ncalls_table[index]; DBGPRINT("vm_step: NCALL: calling %d @%08X\n", index, thunk); thunk(ctx); goto push_none; } push_2: vm_stack_push(ctx->dstack, r1); push_1: vm_stack_push(ctx->dstack, r0); push_none: ctx->pc = pc; return; }
INT_PTR CALLBACK Dialog::RunDlg(HWND parent, LPVOID param) { m_Parent = parent; Win32Thunk<DLGPROC, Dialog> thunk(&Dialog::DialogProc, this); return ::DialogBoxParam(NULL, MAKEINTRESOURCE(m_ItemID), parent, thunk.GetThunk(), (LPARAM) param); }
// Invokes this timer's thunk. void operator()() const { thunk(); }
void operator()()const { thunk(*this); }