void native_func(char *in) { uint8_t mode = 0; if(in[1] == 'r') { // Reception on // "Er<x>" - where <x> is mode if (in[2]) fromdec(in+2, &mode); if (!mode || mode>MAX_MODES) { DS_P(PSTR("specify valid mode number\r\n")); return; } native_init(mode); } else if(in[1] == 'x') { // Reception off if (native_on) ccStrobe( CC1100_SIDLE ); native_on = 0; } DH2(native_on); DNL(); }
void monitor_init(HMODULE module_handle) { // Sends crashes to the process rather than showing error popup boxes etc. SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); config_t cfg; config_read(&cfg); // Required to be initialized before any logging starts. mem_init(); // Initialize capstone without our custom allocator as it is // not available yet. hook_init(module_handle); pipe_init(cfg.pipe_name); native_init(); // Re-initialize capstone with our custom allocator which is now // accessible after native_init(). hook_init2(); misc_init(module_handle, cfg.shutdown_mutex); misc_set_hook_library(&monitor_hook); diffing_init(cfg.hashes_path, cfg.diffing_enable); log_init(cfg.logpipe); ignore_init(); sleep_init(cfg.first_process, cfg.force_sleep_skip, cfg.startup_time); unhook_init_detection(cfg.first_process); hide_module_from_peb(module_handle); symbol_init(module_handle); // Should be the last as some of the other initialization routines extract // the image size, EAT pointers, etc while the PE header is still intact. destroy_pe_header(module_handle); misc_set_monitor_options(cfg.track, cfg.mode); }
int main() { pipe_init("\\\\.\\PIPE\\cuckoo", 0); hook_init(GetModuleHandle(NULL)); mem_init(); assert(native_init() == 0); uint8_t buf[16]; uint16_t val[2]; assert(utf8_encode(0x00000001, buf) == 1 && memcmp(buf, "\x01", 1) == 0); assert(utf8_encode(0x0000007f, buf) == 1 && memcmp(buf, "\x7f", 1) == 0); assert(utf8_encode(0x00000080, buf) == 2 && memcmp(buf, "\xc2\x80", 2) == 0); assert(utf8_encode(0x000007ff, buf) == 2 && memcmp(buf, "\xdf\xbf", 2) == 0); assert(utf8_encode(0x00000800, buf) == 3 && memcmp(buf, "\xe0\xa0\x80", 3) == 0); assert(utf8_encode(0x0000ffff, buf) == 3 && memcmp(buf, "\xef\xbf\xbf", 3) == 0); assert(utf8_encode(0x00010000, buf) == 4 && memcmp(buf, "\xf0\x90\x80\x80", 4) == 0); assert(utf8_encode(0x001fffff, buf) == 4 && memcmp(buf, "\xf7\xbf\xbf\xbf", 4) == 0); assert(utf8_encode(0x00200000, buf) == 5 && memcmp(buf, "\xf8\x88\x80\x80\x80", 5) == 0); assert(utf8_encode(0x03ffffff, buf) == 5 && memcmp(buf, "\xfb\xbf\xbf\xbf\xbf", 5) == 0); assert(utf8_encode(0x04000000, buf) == 6 && memcmp(buf, "\xfc\x84\x80\x80\x80\x80", 6) == 0); assert(utf8_encode(0x7fffffff, buf) == 6 && memcmp(buf, "\xfd\xbf\xbf\xbf\xbf\xbf", 6) == 0); // It's kind of a hassle to get utf8_wstring() to work here, so we'll just // do similar work with the byte count, which calculates the required // amount of bytes for a sequence. The following sequences represent the // various utf8 boundaries, i.e., their maximum values before needing an // extra byte etc. assert(utf8_bytecnt_unicode((val[0] = 0xd800, val[1] = 0xdc00, val), 2) == 1); assert(utf8_bytecnt_unicode((val[0] = 0xd801, val[1] = 0xdc00, val), 2) == 2); assert(utf8_bytecnt_unicode((val[0] = 0xd802, val[1] = 0xdc00, val), 2) == 3); assert(utf8_bytecnt_unicode((val[0] = 0xd840, val[1] = 0xdc00, val), 2) == 4); // We used to have some issues with signed chars and the MSB being set as // we wouldn't cast these as unsigned characters. This would result in // utf8_length(0xffffff81) returning -1, rather than utf8_length(0x81) // returning 2. Similarly to incorrect return values of utf8_length() we'd // also experience out-of-bounds writes as our buffer would be indexed by // -1, resulting in undefined behavior. assert(utf8_bytecnt_ascii("\x81", 1) == 2); assert(utf8_bytecnt_unicode(L"\u8081", 1) == 3); assert(memcmp(utf8_string("\x81", 1), "\x02\x00\x00\x00\xc2\x81", 6) == 0); assert(memcmp(utf8_wstring(L"\u8081", 1), "\x03\x00\x00\x00\xe8\x82\x81", 7) == 0); }
void lib_init() { clock_allocator = fixed_allocator_make(sizeof(struct Clock_), MAX_NUM_CLOCKS, "clock_allocator"); image_resource_allocator = fixed_allocator_make(sizeof(struct ImageResource_), MAX_NUM_IMAGES, "image_resource_allocator"); frame_allocator = stack_allocator_make(1024 * 1024, "frame_allocator"); command_allocator = fixed_allocator_make(sizeof(struct Command_), MAX_NUM_COMMANDS, "command_allocator"); render_queue = queue_make(); render_barrier = threadbarrier_make(2); native_init(); renderer_running = 1; pthread_create(&renderer_thread, NULL, renderer_exec, NULL); // let the renderer finish init renderer_enqueue_sync(renderer_init, NULL); // kick off the audio system audio_init(); scm_init(); }
static void gma_func0_init(struct device *dev) { u16 reg16; u32 reg32; /* IGD needs to be Bus Master */ reg32 = pci_read_config32(dev, PCI_COMMAND); reg32 |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY | PCI_COMMAND_IO; pci_write_config32(dev, PCI_COMMAND, reg32); /* configure GMBUSFREQ */ reg16 = pci_read_config16(dev_find_slot(0, PCI_DEVFN(0x2, 0)), 0xcc); reg16 &= ~0x1ff; reg16 |= 0xbc; pci_write_config16(dev_find_slot(0, PCI_DEVFN(0x2, 0)), 0xcc, reg16); if (IS_ENABLED(CONFIG_MAINBOARD_DO_NATIVE_VGA_INIT)) native_init(dev); else pci_dev_init(dev); }
static void global_init(){ /* locate the installation directory */ Global->blue_location = find_blue(); Global->blue_lib_location = find_blue_lib(); /* 0 = only main thread; >0 = multi-threaded */ Global->threads = 0; /* initialize basic object functionality */ object_init(); native_init(); Global->backtrace_key = create_string("__backtrace"); Global->constructor_key = create_string("_"); Global->destructor_key = create_string("__"); Link loc = create_string(Global->blue_location->data); Link loc_key = create_string("install_dir"); addAttr(Global->SYS_MODULE, loc , loc_key); link_free(loc); link_free(loc_key); }
JNIEXPORT jint JNICALL JNI_OnLoad( JavaVM *vm, void *pvt ) { testlib_init(); native_init(); audio_init(); return JNI_VERSION_1_6; }
int main() { pipe_init("\\\\.\\PIPE\\cuckoo", 0); hook_init(GetModuleHandle(NULL)); mem_init(); assert(native_init() == 0); dnq_t d1, d2, d3; uint32_t val1[] = { 1, 6, 4, 8, 13337, 42, 89, 9001, 90, }; uint32_t val1_sorted[] = { 1, 4, 6, 8, 42, 89, 90, 9001, 13337, }; dnq_init(&d1, val1, sizeof(uint32_t), sizeof(val1) / sizeof(uint32_t)); assert(memcmp(d1.list, val1_sorted, sizeof(val1_sorted)) == 0); assert(dnq_has32(&d1, 4) == 1); assert(dnq_has32(&d1, 0) == 0); assert(dnq_has32(&d1, 1) == 1); assert(dnq_has32(&d1, 2) == 0); assert(dnq_has32(&d1, 43) == 0); assert(dnq_has32(&d1, 91) == 0); assert(dnq_has32(&d1, 90) == 1); assert(dnq_has32(&d1, 9002) == 0); assert(dnq_has32(&d1, 9000) == 0); assert(dnq_has32(&d1, 13337) == 1); assert(dnq_has32(&d1, 13338) == 0); assert(dnq_has32(&d1, 13336) == 0); assert(dnq_has32(&d1, 88) == 0); assert(dnq_has32(&d1, 41) == 0); assert(dnq_has32(&d1, 42) == 1); uint64_t val2[] = { 1, 6, 4, 8, 13337, 42, 89, 9001, 90, }; uint64_t val2_sorted[] = { 1, 4, 6, 8, 42, 89, 90, 9001, 13337, }; dnq_init(&d2, val2, sizeof(uint64_t), sizeof(val2) / sizeof(uint64_t)); assert(memcmp(d2.list, val2_sorted, sizeof(val2_sorted)) == 0); assert(dnq_has64(&d2, 4) == 1); assert(dnq_has64(&d2, 0) == 0); assert(dnq_has64(&d2, 1) == 1); assert(dnq_has64(&d2, 2) == 0); assert(dnq_has64(&d2, 43) == 0); assert(dnq_has64(&d2, 91) == 0); assert(dnq_has64(&d2, 90) == 1); assert(dnq_has64(&d2, 9002) == 0); assert(dnq_has64(&d2, 9000) == 0); assert(dnq_has64(&d2, 13337) == 1); assert(dnq_has64(&d2, 13338) == 0); assert(dnq_has64(&d2, 13336) == 0); assert(dnq_has64(&d2, 88) == 0); assert(dnq_has64(&d2, 41) == 0); assert(dnq_has64(&d2, 42) == 1); uintptr_t val3[] = { 1, 6, 4, 8, 13337, 42, 89, 9001, 90, }; uintptr_t val3_sorted[] = { 1, 4, 6, 8, 42, 89, 90, 9001, 13337, }; dnq_init(&d3, val3, sizeof(uintptr_t), sizeof(val3) / sizeof(uintptr_t)); assert(memcmp(d3.list, val3_sorted, sizeof(val3_sorted)) == 0); assert(dnq_hasptr(&d3, 4) == 1); assert(dnq_hasptr(&d3, 0) == 0); assert(dnq_hasptr(&d3, 1) == 1); assert(dnq_hasptr(&d3, 2) == 0); assert(dnq_hasptr(&d3, 43) == 0); assert(dnq_hasptr(&d3, 91) == 0); assert(dnq_hasptr(&d3, 90) == 1); assert(dnq_hasptr(&d3, 9002) == 0); assert(dnq_hasptr(&d3, 9000) == 0); assert(dnq_hasptr(&d3, 13337) == 1); assert(dnq_hasptr(&d3, 13338) == 0); assert(dnq_hasptr(&d3, 13336) == 0); assert(dnq_hasptr(&d3, 88) == 0); assert(dnq_hasptr(&d3, 41) == 0); assert(dnq_hasptr(&d3, 42) == 1); assert(dnq_iter32(&d1)[4] == 42); assert(dnq_iter64(&d2)[4] == 42); assert(dnq_iterptr(&d3)[4] == 42); pipe("INFO:Test finished!"); return 0; }