提交 f1cb1a42 编写于 作者: J jp9000

win-capture: Try window handle 0 if actual handle fails

Certain UWP programs can't obtain a normal window handle from their API
for whatever reason (this was observed with minecraft win10 edition), so
if the normal window handle on the map fails, try window handle 0
instead.
上级 c76426c5
......@@ -1239,6 +1239,17 @@ static inline bool init_events(struct game_capture *gc)
enum capture_result { CAPTURE_FAIL, CAPTURE_RETRY, CAPTURE_SUCCESS };
static inline bool init_data_map(struct game_capture *gc, HWND window)
{
wchar_t name[64];
swprintf(name, 64, SHMEM_TEXTURE "_%" PRIu64 "_",
(uint64_t)(uintptr_t)window);
gc->hook_data_map =
open_map_plus_id(gc, name, gc->global_hook_info->map_id);
return !!gc->hook_data_map;
}
static inline enum capture_result init_capture_data(struct game_capture *gc)
{
gc->cx = gc->global_hook_info->cx;
......@@ -1252,15 +1263,17 @@ static inline enum capture_result init_capture_data(struct game_capture *gc)
CloseHandle(gc->hook_data_map);
wchar_t name[64];
swprintf(name, 64, SHMEM_TEXTURE "_%" PRIu64 "_",
(uint64_t)(uintptr_t)gc->window);
DWORD error = 0;
if (!init_data_map(gc, gc->window)) {
error = GetLastError();
gc->hook_data_map =
open_map_plus_id(gc, name, gc->global_hook_info->map_id);
/* if there's an error, try with 0 (for UWP programs) */
if (init_data_map(gc, NULL)) {
error = 0;
}
}
if (!gc->hook_data_map) {
DWORD error = GetLastError();
if (error == 2) {
return CAPTURE_RETRY;
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册