win-capture: Improve reading from get-graphics-offsets

Increase the buffer size to read the response in one call if possible,
and cause an error condition with log message if the offsets string is
empty.
This commit is contained in:
Richard Stanway
2019-01-27 16:18:53 +01:00
parent 33ff46a10e
commit f48b210d61
+8 -2
View File
@@ -161,7 +161,7 @@ bool load_graphics_offsets(bool is32bit, const char *config_path)
struct dstr str = {0};
os_process_pipe_t *pp;
bool success = false;
char data[128];
char data[2048];
#ifndef _WIN64
if (!is32bit && !is_64_bit_windows()) {
@@ -181,13 +181,19 @@ bool load_graphics_offsets(bool is32bit, const char *config_path)
}
for (;;) {
size_t len = os_process_pipe_read(pp, (uint8_t*)data, 128);
size_t len = os_process_pipe_read(pp, (uint8_t*)data, sizeof(data));
if (!len)
break;
dstr_ncat(&str, data, len);
}
if (dstr_is_empty(&str)) {
blog(LOG_INFO, "load_graphics_offsets: Failed to read "
"from '%s'", offset_exe.array);
goto error;
}
dstr_copy(&config_ini, config_path);
dstr_cat(&config_ini, is32bit ? "32.ini" : "64.ini");