Merge pull request #1871 from VodBox/game-window-check
win-capture: Fix hook collisions with multiple game captures
This commit is contained in:
commit
0f214bcce6
@ -1251,8 +1251,13 @@ static inline enum capture_result init_capture_data(struct game_capture *gc)
|
|||||||
|
|
||||||
CloseHandle(gc->hook_data_map);
|
CloseHandle(gc->hook_data_map);
|
||||||
|
|
||||||
gc->hook_data_map = open_map_plus_id(gc, SHMEM_TEXTURE,
|
wchar_t name[64];
|
||||||
gc->global_hook_info->map_id);
|
_snwprintf(name, 64, L"%s_%d_", SHMEM_TEXTURE,
|
||||||
|
(uint32_t)(uintptr_t)gc->window);
|
||||||
|
|
||||||
|
gc->hook_data_map =
|
||||||
|
open_map_plus_id(gc, name, gc->global_hook_info->map_id);
|
||||||
|
|
||||||
if (!gc->hook_data_map) {
|
if (!gc->hook_data_map) {
|
||||||
DWORD error = GetLastError();
|
DWORD error = GetLastError();
|
||||||
if (error == 2) {
|
if (error == 2) {
|
||||||
|
@ -490,10 +490,11 @@ static inline void unlock_shmem_tex(int id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool init_shared_info(size_t size)
|
static inline bool init_shared_info(size_t size, HWND window)
|
||||||
{
|
{
|
||||||
wchar_t name[64];
|
wchar_t name[64];
|
||||||
_snwprintf(name, 64, L"%s%u", SHMEM_TEXTURE, ++shmem_id_counter);
|
_snwprintf(name, 64, L"%s_%d_%u", SHMEM_TEXTURE,
|
||||||
|
(uint32_t)(uintptr_t)window, ++shmem_id_counter);
|
||||||
|
|
||||||
shmem_file_handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
|
shmem_file_handle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
|
||||||
PAGE_READWRITE, 0, (DWORD)size,
|
PAGE_READWRITE, 0, (DWORD)size,
|
||||||
@ -519,7 +520,7 @@ bool capture_init_shtex(struct shtex_data **data, HWND window, uint32_t base_cx,
|
|||||||
uint32_t base_cy, uint32_t cx, uint32_t cy,
|
uint32_t base_cy, uint32_t cx, uint32_t cy,
|
||||||
uint32_t format, bool flip, uintptr_t handle)
|
uint32_t format, bool flip, uintptr_t handle)
|
||||||
{
|
{
|
||||||
if (!init_shared_info(sizeof(struct shtex_data))) {
|
if (!init_shared_info(sizeof(struct shtex_data), window)) {
|
||||||
hlog("capture_init_shtex: Failed to initialize memory");
|
hlog("capture_init_shtex: Failed to initialize memory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -700,7 +701,7 @@ bool capture_init_shmem(struct shmem_data **data, HWND window, uint32_t base_cx,
|
|||||||
uint32_t total_size = aligned_header + aligned_tex * 2 + 32;
|
uint32_t total_size = aligned_header + aligned_tex * 2 + 32;
|
||||||
uintptr_t align_pos;
|
uintptr_t align_pos;
|
||||||
|
|
||||||
if (!init_shared_info(total_size)) {
|
if (!init_shared_info(total_size, window)) {
|
||||||
hlog("capture_init_shmem: Failed to initialize memory");
|
hlog("capture_init_shmem: Failed to initialize memory");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user