void save_font_list(void) { char *file_name = obs_module_config_path("font_data.bin"); uint32_t font_checksum = get_font_checksum(); int font_count = (int)font_list.num; struct serializer s; bool success = false; if (font_checksum) success = file_output_serializer_init_safe(&s, file_name, "tmp"); bfree(file_name); if (!success) return; success = write_var(&s, font_cache_ver); if (!success) return; success = write_var(&s, font_checksum); if (!success) return; success = write_var(&s, font_count); if (!success) return; #define do_write(var) \ success = write_var(&s, var); \ if (!success) break for (size_t i = 0; i < font_list.num; i++) { struct font_path_info *info = &font_list.array[i]; success = write_str(&s, info->face_and_style); if (!success) break; do_write(info->full_len); do_write(info->face_len); do_write(info->is_bitmap); do_write(info->num_sizes); success = write_data(&s, info->sizes, sizeof(int) * info->num_sizes); if (!success) break; do_write(info->bold); success = write_str(&s, info->path); if (!success) break; do_write(info->italic); do_write(info->index); } #undef do_write file_output_serializer_free(&s); }
bool load_cached_graphics_offsets(bool is32bit) { char *config_ini = NULL; bool success; config_ini = obs_module_config_path(is32bit ? "32.ini" : "64.ini"); success = load_offsets_from_file(is32bit ? &offsets32 : &offsets64, config_ini); if (!success) success = load_graphics_offsets(is32bit); bfree(config_ini); return success; }
bool load_graphics_offsets(bool is32bit) { char *offset_exe_path = NULL; struct dstr offset_exe = {0}; char *config_ini = NULL; struct dstr str = {0}; os_process_pipe_t *pp; bool success = false; char data[128]; dstr_copy(&offset_exe, "get-graphics-offsets"); dstr_cat(&offset_exe, is32bit ? "32.exe" : "64.exe"); offset_exe_path = obs_module_file(offset_exe.array); pp = os_process_pipe_create(offset_exe_path, "r"); if (!pp) { blog(LOG_INFO, "load_graphics_offsets: Failed to start '%s'", offset_exe.array); goto error; } for (;;) { size_t len = os_process_pipe_read(pp, (uint8_t*)data, 128); if (!len) break; dstr_ncat(&str, data, len); } config_ini = obs_module_config_path(is32bit ? "32.ini" : "64.ini"); os_quick_write_utf8_file_safe(config_ini, str.array, str.len, false, "tmp", NULL); bfree(config_ini); success = load_offsets_from_string(is32bit ? &offsets32 : &offsets64, str.array); if (!success) { blog(LOG_INFO, "load_graphics_offsets: Failed to load string"); } os_process_pipe_destroy(pp); error: bfree(offset_exe_path); dstr_free(&offset_exe); dstr_free(&str); return success; }
bool obs_module_load(void) { char *local_dir = obs_module_file(""); char *cache_dir = obs_module_config_path(""); if (cache_dir) { update_info = update_info_create( RTMP_SERVICES_LOG_STR, RTMP_SERVICES_VER_STR, RTMP_SERVICES_URL, local_dir, cache_dir, confirm_service_file, NULL); } bfree(local_dir); bfree(cache_dir); obs_register_service(&rtmp_common_service); obs_register_service(&rtmp_custom_service); return true; }
bool obs_module_load() { char *config_dir = obs_module_config_path(NULL); if (config_dir) { os_mkdirs(config_dir); bfree(config_dir); } FT_Init_FreeType(&ft2_lib); if (ft2_lib == NULL) { blog(LOG_WARNING, "FT2-text: Failed to initialize FT2."); return false; } if (!load_cached_os_font_list()) load_os_font_list(); obs_register_source(&freetype2_source_info); return true; }
bool cached_versions_match(void) { struct win_version_info d3d8_ver = {0}; struct win_version_info d3d9_ver = {0}; struct win_version_info dxgi_ver = {0}; bool ver_mismatch = false; config_t *config; char *ver_file; int ret; ver_mismatch |= !get_32bit_system_dll_ver(L"d3d8.dll", &d3d8_ver); ver_mismatch |= !get_32bit_system_dll_ver(L"d3d9.dll", &d3d9_ver); ver_mismatch |= !get_32bit_system_dll_ver(L"dxgi.dll", &dxgi_ver); ver_file = obs_module_config_path("version.ini"); if (!ver_file) return false; ret = config_open(&config, ver_file, CONFIG_OPEN_ALWAYS); if (ret != CONFIG_SUCCESS) goto failed; ver_mismatch |= config_ver_mismatch(config, "d3d8", &d3d8_ver); ver_mismatch |= config_ver_mismatch(config, "d3d9", &d3d9_ver); ver_mismatch |= config_ver_mismatch(config, "dxgi", &dxgi_ver); if (ver_mismatch) { write_config_ver(config, "d3d8", &d3d8_ver); write_config_ver(config, "d3d9", &d3d9_ver); write_config_ver(config, "dxgi", &dxgi_ver); config_save_safe(config, "tmp", NULL); } failed: bfree(ver_file); config_close(config); return !ver_mismatch; }
bool obs_module_load(void) { struct win_version_info ver; bool win8_or_above = false; char *config_dir; config_dir = obs_module_config_path(NULL); if (config_dir) { os_mkdirs(config_dir); bfree(config_dir); } get_win_ver(&ver); win8_or_above = ver.major > 6 || (ver.major == 6 && ver.minor >= 2); obs_enter_graphics(); if (win8_or_above && gs_get_device_type() == GS_DEVICE_DIRECT3D_11) obs_register_source(&duplicator_capture_info); else obs_register_source(&monitor_capture_info); obs_leave_graphics(); obs_register_source(&window_capture_info); if (/*cached_versions_match() &&*/ load_cached_graphics_offsets(IS32BIT)) { load_cached_graphics_offsets(!IS32BIT); obs_register_source(&game_capture_info); } else if (load_graphics_offsets(IS32BIT)) { load_graphics_offsets(!IS32BIT); obs_register_source(&game_capture_info); } return true; }
void BrowserManager::Impl::BrowserManagerEntry() { std::string bootstrapPath = getBootstrap(); bool thread_exit = false; PushEvent([] { CefMainArgs mainArgs; CefSettings settings; settings.log_severity = LOGSEVERITY_VERBOSE; settings.windowless_rendering_enabled = true; settings.no_sandbox = true; CefString(&settings.cache_path).FromASCII(obs_module_config_path("")); CefString(&settings.browser_subprocess_path) = getBootstrap(); CefRefPtr<BrowserApp> app(new BrowserApp()); CefExecuteProcess(mainArgs, app, nullptr); CefInitialize(mainArgs, settings, app, nullptr); CefRegisterSchemeHandlerFactory("http", "absolute", new BrowserSchemeHandlerFactory()); CefRunMessageLoop(); CefShutdown(); }); while (true) { if (os_event_timedwait(dispatchEvent, 10) != ETIMEDOUT) { pthread_mutex_lock(&dispatchLock); while (!queue.empty()) { auto event = queue[0]; event(); queue.erase(queue.begin()); } thread_exit = !threadAlive; pthread_mutex_unlock(&dispatchLock); if (thread_exit) { return; } } } }
bool load_cached_os_font_list(void) { char *file_name = obs_module_config_path("font_data.bin"); uint32_t old_checksum; uint32_t new_checksum; struct serializer s; uint32_t ver; bool success; success = file_input_serializer_init(&s, file_name); bfree(file_name); if (!success) return false; success = read_data(&s, &ver, sizeof(ver)); if (!success || ver != font_cache_ver) { success = false; goto finish; } success = s_read(&s, &old_checksum, sizeof(old_checksum)); new_checksum = get_font_checksum(); if (!success || old_checksum != new_checksum) { success = false; goto finish; } success = load_cached_font_list(&s); finish: file_input_serializer_free(&s); return success; }