Browse Source

win-capture: Improve game capture messages

Tag debug output in the game process with "[OBS]" and mention that
graphics-hook.dll is ours.
jpark37 5 years ago
parent
commit
7cf148e013
1 changed files with 12 additions and 8 deletions
  1. 12 8
      plugins/win-capture/graphics-hook/graphics-hook.c

+ 12 - 8
plugins/win-capture/graphics-hook/graphics-hook.c

@@ -69,7 +69,7 @@ bool init_pipe(void)
 	sprintf(new_name, "%s%lu", PIPE_NAME, GetCurrentProcessId());
 
 	if (!ipc_pipe_client_open(&pipe, new_name)) {
-		DbgOut("Failed to open pipe\n");
+		DbgOut("[OBS] Failed to open pipe\n");
 		return false;
 	}
 
@@ -158,7 +158,10 @@ static inline void log_current_process(void)
 				       MAX_PATH);
 	if (len > 0) {
 		process_name[len] = 0;
-		hlog("Hooked to process: %s", process_name);
+		hlog("graphics-hook.dll loaded against process: %s",
+		     process_name);
+	} else {
+		hlog("graphics-hook.dll loaded");
 	}
 
 	hlog("(half life scientist) everything..  seems to be in order");
@@ -328,7 +331,7 @@ static inline bool attempt_hook(void)
 
 	if (!d3d9_hooked) {
 		if (!d3d9_hookable()) {
-			DbgOut("no D3D9 hook address found!\n");
+			DbgOut("[OBS] no D3D9 hook address found!\n");
 			d3d9_hooked = true;
 		} else {
 			d3d9_hooked = hook_d3d9();
@@ -340,7 +343,7 @@ static inline bool attempt_hook(void)
 
 	if (!dxgi_hooked) {
 		if (!dxgi_hookable()) {
-			DbgOut("no DXGI hook address found!\n");
+			DbgOut("[OBS] no DXGI hook address found!\n");
 			dxgi_hooked = true;
 		} else {
 			dxgi_hooked = hook_dxgi();
@@ -403,7 +406,7 @@ static inline void capture_loop(void)
 static DWORD WINAPI main_capture_thread(HANDLE thread_handle)
 {
 	if (!init_hook(thread_handle)) {
-		DbgOut("Failed to init hook\n");
+		DbgOut("[OBS] Failed to init hook\n");
 		free_hook();
 		return 0;
 	}
@@ -416,10 +419,11 @@ static inline void hlogv(const char *format, va_list args)
 {
 	char message[1024] = "";
 	int num = _vsprintf_p(message, 1024, format, args);
-	if (num) {
+	if (num > 0) {
 		if (!ipc_pipe_client_write(&pipe, message, (size_t)num + 1)) {
 			ipc_pipe_client_free(&pipe);
 		}
+		DbgOut("[OBS] ");
 		DbgOut(message);
 		DbgOut("\n");
 	}
@@ -836,7 +840,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID unused1)
 		dll_inst = hinst;
 
 		if (!init_dll()) {
-			DbgOut("Duplicate hook library");
+			DbgOut("[OBS] Duplicate hook library");
 			return false;
 		}
 
@@ -847,7 +851,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID unused1)
 					       SYNCHRONIZE, false, 0);
 
 		if (!success)
-			DbgOut("Failed to get current thread handle");
+			DbgOut("[OBS] Failed to get current thread handle");
 
 		if (!init_signals()) {
 			return false;