Commit Graph

228 Commits (6f13605e7bedfe887cc6bac27823341f88ed147c)

Author SHA1 Message Date
Richard Stanway d2e9e47bb4 graphics-hook: Account for sizeof(wchar_t) in len 2017-02-25 17:18:55 +01:00
Cam 8a6491c9bf win-capture: Add hook exception for theHunter: COTW
Adds an exception to skip d3d10 checks for theHunter: Call of the Wild,
which fixes incompatibility with game capture.

Closes jp9000/obs-studio#801
2017-02-25 06:42:36 -08:00
jp9000 5b8a0a2777 win-capture: Blacklist chrome/firefox from game capture 2017-02-21 23:05:49 -08:00
jp9000 eb90b7dfff win-capture: Fall back to GetWindow if FindWindowEx fails
When kaspersky is installed on windows 7, FindWindowEx will fail to find
any windows due to apparently being blocked by kaspersky, so detect when
that happens, and fall back to GetWindow instead if it does.
2017-02-21 00:42:14 -08:00
jp9000 839e593e77 Revert "Revert "win-capture: Use FindWindowEx to traverse window list""
This reverts commit f4d7f0cbba.

Never thought a revert of a revert would happen.
2017-01-18 20:18:28 -08:00
jp9000 c30d4f5075 win-capture: Fix game capture size bug when rehooking
When rehooking, even if scaling is off, it'll unintentionally overwrite
the game's backbuffer texture size with the scale size.
2017-01-16 04:19:16 -08:00
jp9000 f4d7f0cbba Revert "win-capture: Use FindWindowEx to traverse window list"
This reverts commit bd67c18c02.

Causes performance issues when the window isn't found.  The situation it
fixes is also very rare anyway.
2017-01-16 03:22:12 -08:00
jp9000 21d70fa207 win-capture: Don't use FindWindow for game capture keepalive
Using and creating a window can use issues in game capture if multiple
game captures are active, so revert back to using a mutex, and just
ignore the keepalive check failure if injected inside a UWP program
(only check to see if GetLastError reports that it's not found -- if it
returns access denied or any other error, assume it's in a UWP program,
and ignore the keepalive check).
2017-01-15 09:15:45 -08:00
Gol-D-Ace 6223ed6520 Update translations from Crowdin 2017-01-07 00:23:16 +01:00
Gol-D-Ace 69f0bc244a Update translations from Crowdin 2016-12-23 20:46:47 +01:00
jp9000 21be33805d win-capture: Release backbuffers immediately upon init
There's no need to keep a reference to the backbuffers.  That and the
backbuffer references weren't being released anyway, so that fixes that
bug.
2016-12-23 08:07:26 -08:00
jp9000 74a5bdf993 win-capture: If backbuffer count is 1, disable dxgi 1.4 use
Executing the dxgi 1.4 code causes it to cycle through backbuffers,
backbuffers which may not exist if in discard mode.
2016-12-23 08:02:35 -08:00
jp9000 414ff5ba14 win-capture: Refactor DX12 backbuffer code
It was undesirable to pass arrays via function parameters, so a
structure should be used instead.

Also increases total allowable backbuffers to 8.
2016-12-23 08:02:30 -08:00
jp9000 a4143be052 win-capture: Fix possible access of array beyond size
If the backbuffer count is larger than 3, it could still try to assign
backbuffers to pointers beyond the variable's array size when calling
swap->GetBuffer.
2016-12-23 07:49:13 -08:00
jp9000 2da7f3cb0e win-capture: Add a few new blacklisted game capture exes 2016-12-23 02:17:14 -08:00
jp9000 ad72194090 win-capture: Do not add certain windows to window lists
Due to using FindWindowEx to search for certain windows, certain windows
will show up that aren't usable/capturable.  Prevent these windows from
showing up in the window lists.
2016-12-23 02:15:59 -08:00
jp9000 4fe2ca0f75 win-capture: Fix possible null pointer dereference 2016-12-23 02:04:26 -08:00
jp9000 bd67c18c02 win-capture: Use FindWindowEx to traverse window list
For some unknown reason, GetWindow will not traverse the entire window
tree.  It could be due to Microsoft purposely hiding certain UWP
windows, though the reason is unknown.  For some equally unknown reason
FindWindowEx does work in its place.

This fixes the issue of not being able to find/capture certain windows,
such as halo 5: forge.
2016-12-23 01:53:44 -08:00
jp9000 3b5a30ce97 win-capture: Capture all D3D12 backbuffers
D3D12 capture does not take in to account when multiple backbuffers are
in used.  With previous versions of Direct3D there was no need to do
this, but with D3D12 you must explicitly capture each specific
backbuffer currently in use.
2016-12-23 01:53:15 -08:00
jp9000 68a8a5bf2b win-capture: Do not fall back to other windows for UWP windows
If capturing a UWP window, do not fall back to matching windows with the
same window class if the exact window is not found, as this will get any
other UWP window on the system (due to the fact that they all have the
same window class name).
2016-12-16 14:06:05 -08:00
jp9000 4f4aea4562 win-capture: Add debug messages when hooking
These are helpful for debugging UWP capture issues.
2016-12-16 14:06:04 -08:00
jp9000 61773bcbf2 win-capture: Fix cursor not painting with UWP windows
Because the hook cannot get the window handle of UWP windows, fall back
to using the window handle stored in the game capture source itself if
it's unavailable from the hook.
2016-12-16 14:06:03 -08:00
jp9000 b3119e0a8d win-capture: Don't hard fail if thread ID not found
Under certain circumstances, the program may not be able to acquire the
window thread ID for a UWP process, but will be able to acquire the
process ID.  In this case, it should soft fail and retry, rather than
assume it's unacquirable and stop trying to reacquire.
2016-12-16 14:06:02 -08:00
jp9000 a5337605cd win-capture: Add ApplicationFrameHost to game capture blacklist
The ApplicationFrameHost process is a sandbox process, and should not be
hooked.
2016-12-16 14:06:01 -08:00
jp9000 480d0e986f win-capture: Fix "attempting to hook [executable]" message
The "attempting to hook [executable]" message would not display the
correct executable if it's fallen back to a different window with the
same window class.
2016-12-16 14:06:00 -08:00
jp9000 209bcda1f4 win-capture: Wait a few frames for hook to load
Now that the game capture hook creates and controls all the
synchronization objects, it's no longer possible to expect that the hook
is fully loaded by the time game capture tries to initialize it.  In
that case, allow game capture to retry the hook for a few frames before
assuming something failed.
2016-12-16 14:05:59 -08:00
jp9000 bddd9766ac win-capture: Don't hook suspended processes
Remote threads in suspended processes will also start up suspended, so
do not attempt to hook suspended processes.
2016-12-16 14:05:58 -08:00
jp9000 e29638ebf9 win-capture: Log plugin-side when capture successful/lost 2016-12-16 14:05:57 -08:00
jp9000 d4a99e062b win-capture: Output hook debug messages if addresses missing 2016-12-16 14:05:57 -08:00
jp9000 926b9c5f96 win-capture: Open UWP named objects with helper functions
This detects whether the target process is a UWP process, and then uses
the open_app_* functions for mutexes/events/mapping.  Also slightly
refactors named object open functions.
2016-12-16 14:05:56 -08:00
jp9000 aeb1d7ae1b win-capture: Add ability to open UWP named kernel objects
The only way to open named kernel objects within a UWP "app" is to get
the AppContainer SID, and then open the objects with their full
system namespace names via undocumented NT functions.
2016-12-16 14:05:55 -08:00
jp9000 b5f216ef88 win-capture: Use wide strings for named objects
Prevents from having to mix ansi/wide string usage for opening UWP
programs.
2016-12-16 02:21:10 -08:00
jp9000 c63bb17b08 win-capture: Remove redundant function
This function now already exists elsewhere -- open_event_plus_id.
2016-12-16 02:21:09 -08:00
jp9000 ec4c05f406 win-capture: Don't use "Local\" for game capture shared mem
The "Local\" prefix effectively does nothing.
2016-12-16 02:21:08 -08:00
jp9000 ab9bda52e0 win-capture: Create all named objects within hook
All named objects (including file mapped shared memory) need to be
created within the hook itself due to the fact that UWP programs cannot
access named objects outside of the UWP process.

Because shared memory needs to be created within the hook, the capture
loop cannot start until the shared memory has been filled with valid
data.  Creating an additional "initialize" event fixes this issue.

Additionally, changed the way that named kernel objects are
opened/created.  Before, there were functions that would first try to
open named objects and then implicitly create them if opening failed
(assuming that if the hook didn't create it first, game capture would),
now it's been changed so that you can only either explicitly open or
create.
2016-12-16 02:21:07 -08:00
jp9000 d19342442f win-capture: Use window for keepalive check
To check to make sure game capture is still active in the capture
program, it currently uses a named event, and then it checks to see if
that named event exists.  However with UWP programs, you can't open a
named event outside of the UWP process.  FindWindow on the other hand
does work, so instead of checking to see if a named kernel object
exists, create a window and check to see if that window exists.
2016-12-16 02:21:06 -08:00
jp9000 1e48b522fa win-capture: Fix getting proper UWP window handles
The "main" windows detected for UWP programs are basically to help
sandbox the programs -- they run in the ApplicationFrameHost process and
help reduce the possibility of other programs trying to access the
actual process window, which is a child window.

To bypass this, go through the list of child windows for the
ApplicationFrameHost window, and then find the one that's attached to
a different process; that different process will always be the target,
and will allows us to open the actual process of the UWP program.
2016-12-16 02:21:05 -08:00
jp9000 4ec1033741 win-capture: Do not require pipe/mutex within hook
Named pipes cannot be used within UWP programs, so make them optional.
2016-12-15 13:03:44 -08:00
jp9000 746061fb3a win-capture: Always use minimal access rights within hook
This prevents issues with opening handles to objects within UWP
programs, which have increased security limitations.
2016-12-15 13:03:42 -08:00
jp9000 e148087636 win-capture: Only duplicate to get cur thread handle
Instead of calling OpenThread, use DuplicateHandle with the minimal
access rights (SYNCHRONIZE) to be able to get the current thread handle
within a UWP program.
2016-12-12 08:10:06 -08:00
jp9000 ca607f8b35 cmake: Add _CRT_SECURE_NO_WARNINGS to all projects
This prevents issues with using standard C functions, where microsoft
would otherwise spit out pointless warnings to encourage using
microsoft-specific functions instead.
2016-12-08 03:27:36 -08:00
jp9000 2f305cb550 win-capture: Use static runtimes for hooks/helpers
(Note: This commit also modifies the ipc-util/seg-service modules)

When compiling the final project, always compile
ipc-util/get-graphics-offsets/graphics-hook/inject-helper/seg-service
with static MSVC runtimes to prevent the need of requiring the MSVC
runtimes for both architectures.
2016-11-23 06:03:00 -08:00
Gol-D-Ace 90e805ad9b Update translations from CrowdIn 2016-11-16 00:32:47 +01:00
jp9000 eaa32c20be win-capture: Defer hook offset loading to separate thread
Boosts startup time significantly to defer this to a separate thread.
2016-11-14 17:34:44 -08:00
jp9000 35285a26b7 win-capture: Do not load 64bit hook offsets on 32bit systems 2016-11-14 17:34:32 -08:00
jp9000 ed85b22534 Update translations from CrowdIn 2016-11-03 13:32:52 -07:00
jp9000 0b27b51294 win-capture: Add D3D12 capture support
Currently only supports shared texture capture, and doesn't support
rescaling.
2016-11-03 12:13:42 -07:00
jp9000 f49065b1e6 win-capture: Use IUnknown for getting swap backbuffers
Using IDXGIResource doesn't work with D3D12.  D3D12 textures are not a
subclass of that class.
2016-11-03 09:28:32 -07:00
jp9000 81ab13a2a4 win-capture: Cache cursor textures to prevent reallocation
Whenever a cursor is captured and the cursor icon changes, it creates a
new texture.  This isn't particularly optimal, so instead just store a
cache of cursor textures (based on size), and make the textures dynamic.
Doing this will prevent unnecessary texture reallocation.
2016-11-03 09:23:25 -07:00
Gol-D-Ace aadc7263c0 Update translations from Crowdin 2016-09-28 01:17:24 +02:00