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; }
static int ep_parse_sampler_state_item(struct effect_parser *ep, struct ep_sampler *eps) { int ret; char *state = NULL; struct dstr value = {0}; ret = cf_next_name(&ep->cfp, &state, "state name", ";"); if (ret != PARSE_SUCCESS) goto fail; ret = cf_next_token_should_be(&ep->cfp, "=", ";", NULL); if (ret != PARSE_SUCCESS) goto fail; for (;;) { const char *cur_str; if (!cf_next_valid_token(&ep->cfp)) return PARSE_EOF; cur_str = ep->cfp.cur_token->str.array; if (*cur_str == ';') break; dstr_ncat(&value, cur_str, ep->cfp.cur_token->str.len); } if (value.len) { da_push_back(eps->states, &state); da_push_back(eps->values, &value.array); } return ret; fail: bfree(state); dstr_free(&value); return ret; }
void dstr_cat_strref(struct dstr *dst, const struct strref *str) { dstr_ncat(dst, str->array, str->len); }