Show errors at runtime if game capture files are blocked by AV
This commit is contained in:
parent
9977a22646
commit
ec4ef87b30
@ -321,6 +321,35 @@ void GraphicsCaptureSource::BeginScene()
|
||||
AttemptCapture();
|
||||
}
|
||||
|
||||
BOOL GraphicsCaptureSource::CheckFileIntegrity(LPCTSTR strDLL)
|
||||
{
|
||||
HANDLE hFileTest = CreateFile(strDLL, GENERIC_READ | GENERIC_EXECUTE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
||||
if (hFileTest == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
String strWarning;
|
||||
|
||||
DWORD err = GetLastError();
|
||||
if (err == ERROR_FILE_NOT_FOUND)
|
||||
strWarning = TEXT("Important game capture files have been deleted. This is likely due to anti-virus software. Please make sure the OBS folder is excluded or ignored from any anti-virus / security software and re-install OBS.");
|
||||
else if (err == ERROR_ACCESS_DENIED)
|
||||
strWarning = TEXT("Important game capture files can not be loaded. This is likely due to anti-virus or security software. Please make sure the OBS folder is excluded / ignored from any anti-virus / security software.");
|
||||
else
|
||||
strWarning = FormattedString(TEXT("Important game capture files can not be loaded (error %d). This is likely due to anti-virus or security software. Please make sure the OBS folder is excluded / ignored from any anti-virus / security software."), err);
|
||||
|
||||
Log(TEXT("GraphicsCaptureSource::CheckFileIntegrity: Error %d while accessing %s"), err, strDLL);
|
||||
|
||||
//not sure if we should be using messagebox here, but probably better than "help why do i have black screen"
|
||||
OBSMessageBox(API->GetMainWindow(), strWarning.Array(), NULL, MB_ICONERROR | MB_OK);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHandle(hFileTest);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicsCaptureSource::AttemptCapture()
|
||||
{
|
||||
//Log(TEXT("attempting to capture.."));
|
||||
@ -338,7 +367,7 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
targetThreadID = GetWindowThreadProcessId(hwndTarget, &targetProcessID);
|
||||
if (!targetThreadID || !targetProcessID)
|
||||
{
|
||||
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: GetWindowThreadProcessId failed, GetLastError = %u"), GetLastError());
|
||||
AppWarning(TEXT("GraphicsCaptureSource::AttemptCapture: GetWindowThreadProcessId failed, GetLastError = %u"), GetLastError());
|
||||
bErrorAcquiring = true;
|
||||
return;
|
||||
}
|
||||
@ -425,8 +454,7 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
if(Is64BitWindows())
|
||||
IsWow64Process(hProcess, &b32bit);
|
||||
|
||||
if (bSameBit && !useSafeHook)
|
||||
{
|
||||
//verify the hook DLL is accessible
|
||||
String strDLL;
|
||||
DWORD dwDirSize = GetCurrentDirectory(0, NULL);
|
||||
strDLL.SetLength(dwDirSize);
|
||||
@ -434,15 +462,20 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
|
||||
strDLL << TEXT("\\plugins\\GraphicsCapture\\GraphicsCaptureHook");
|
||||
|
||||
BOOL b32bit = TRUE;
|
||||
if (Is64BitWindows())
|
||||
IsWow64Process(hProcess, &b32bit);
|
||||
|
||||
if (!b32bit)
|
||||
strDLL << TEXT("64");
|
||||
|
||||
strDLL << TEXT(".dll");
|
||||
|
||||
if (!CheckFileIntegrity(strDLL.Array()))
|
||||
{
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (bSameBit && !useSafeHook)
|
||||
{
|
||||
if (InjectLibrary(hProcess, strDLL))
|
||||
{
|
||||
captureWaitCount = 0;
|
||||
@ -450,16 +483,12 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
}
|
||||
else
|
||||
{
|
||||
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, GetLastError = %u"), GetLastError());
|
||||
|
||||
CloseHandle(hProcess);
|
||||
hProcess = NULL;
|
||||
AppWarning(TEXT("GraphicsCaptureSource::AttemptCapture: Failed to inject library, GetLastError = %u"), GetLastError());
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
String strDLLPath;
|
||||
DWORD dwDirSize = GetCurrentDirectory(0, NULL);
|
||||
strDLLPath.SetLength(dwDirSize);
|
||||
@ -470,6 +499,12 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
String strHelper = strDLLPath;
|
||||
strHelper << ((b32bit) ? TEXT("\\injectHelper.exe") : TEXT("\\injectHelper64.exe"));
|
||||
|
||||
if (!CheckFileIntegrity(strHelper.Array()))
|
||||
{
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
String strCommandLine;
|
||||
strCommandLine << TEXT("\"") << strHelper << TEXT("\" ");
|
||||
if (useSafeHook)
|
||||
@ -510,17 +545,19 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
}
|
||||
else
|
||||
{
|
||||
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, error code = %d"), exitCode);
|
||||
AppWarning(TEXT("GraphicsCaptureSource::AttemptCapture: Failed to inject library, error code = %d"), exitCode);
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Could not create inject helper, GetLastError = %u"), GetLastError());
|
||||
AppWarning(TEXT("GraphicsCaptureSource::AttemptCapture: Could not create inject helper, GetLastError = %u"), GetLastError());
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CloseHandle(hProcess);
|
||||
hProcess = NULL;
|
||||
@ -533,7 +570,7 @@ void GraphicsCaptureSource::AttemptCapture()
|
||||
}
|
||||
else
|
||||
{
|
||||
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: OpenProcess failed, GetLastError = %u"), GetLastError());
|
||||
AppWarning(TEXT("GraphicsCaptureSource::AttemptCapture: OpenProcess failed, GetLastError = %u"), GetLastError());
|
||||
bErrorAcquiring = true;
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class GraphicsCaptureSource : public ImageSource
|
||||
void EndCapture();
|
||||
|
||||
void AttemptCapture();
|
||||
BOOL CheckFileIntegrity(LPCTSTR path);
|
||||
|
||||
static void STDCALL CaptureHotkey(DWORD hotkey, GraphicsCaptureSource *capture, bool bDown);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user