fixed game capture to work regardless of target application bit

This commit is contained in:
jp9000 2013-02-11 19:26:35 -07:00
parent fbe38de7df
commit 6a44eba695
21 changed files with 596 additions and 145 deletions

View File

@ -59,7 +59,7 @@ struct SharedTexData
{
UINT lastRendered;
LONGLONG frameTime;
HANDLE texHandles[2];
DWORD texHandles[2];
};
struct CaptureInfo
@ -67,10 +67,11 @@ struct CaptureInfo
UINT captureType;
DWORD format;
UINT cx, cy;
HWND hwndCapture;
BOOL bFlip;
UINT pitch;
UINT mapID;
DWORD mapSize;
DWORD hwndCapture;
};

View File

@ -31,21 +31,10 @@ HANDLE textureMutexes[2] = {NULL, NULL};
#define GRAPHICSCAPTURE_CLASSNAME TEXT("GraphicsCapture")
inline BOOL Is64BitWindows()
{
#if defined(_WIN64)
return TRUE;
#elif defined(_WIN32)
BOOL f64 = FALSE;
return IsWow64Process(GetCurrentProcess(), &f64) && f64;
#endif
}
struct WindowInfo
{
String strClass;
BOOL b64bit;
BOOL bRequiresAdmin;
};
@ -54,7 +43,6 @@ struct ConfigDialogData
XElement *data;
List<WindowInfo> windowData;
StringList adminWindows;
StringList opposingBitWindows;
UINT cx, cy;
@ -64,7 +52,6 @@ struct ConfigDialogData
windowData[i].strClass.Clear();
windowData.Clear();
adminWindows.Clear();
opposingBitWindows.Clear();
}
inline ~ConfigDialogData()
@ -79,11 +66,6 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
SendMessage(hwndCombobox, CB_RESETCONTENT, 0, 0);
configData.ClearData();
BOOL bWindows64bit = Is64BitWindows();
BOOL bCurrentProcessIsWow64 = FALSE;
IsWow64Process(GetCurrentProcess(), &bCurrentProcessIsWow64);
HWND hwndCurrent = GetWindow(GetDesktopWindow(), GW_CHILD);
do
{
@ -103,8 +85,6 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
strWindowName.SetLength(GetWindowTextLength(hwndCurrent));
GetWindowText(hwndCurrent, strWindowName, strWindowName.Length()+1);
bool b64bit = false;
//-------
DWORD processID;
@ -118,9 +98,6 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
HANDLE hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, processID);
if(hProcess)
{
BOOL bTargetProcessIsWow64 = FALSE;
IsWow64Process(hProcess, &bTargetProcessIsWow64);
DWORD dwSize = MAX_PATH;
QueryFullProcessImageName(hProcess, 0, fileName, &dwSize);
@ -129,7 +106,8 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
CloseHandle(hProcess);
BOOL bFoundModule = FALSE;
//note: this doesn't actually work cross-bit
/*BOOL bFoundModule = FALSE;
for(UINT i=0; i<moduleList.Num(); i++)
{
CTSTR moduleName = moduleList[i];
@ -146,30 +124,14 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
}
if (!bFoundModule)
continue;
//todo: remove later
if(bCurrentProcessIsWow64 != bTargetProcessIsWow64)
{
configData.opposingBitWindows << strWindowName;
continue;
}
b64bit = (bWindows64bit && !bTargetProcessIsWow64);
continue;*/
}
else
{
hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processID);
if(hProcess)
{
BOOL bTargetProcessIsWow64 = FALSE;
IsWow64Process(hProcess, &bTargetProcessIsWow64);
if(bCurrentProcessIsWow64 != bTargetProcessIsWow64)
configData.opposingBitWindows << strWindowName;
configData.adminWindows << strWindowName;
CloseHandle(hProcess);
}
@ -183,7 +145,6 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
String strText;
strText << TEXT("[") << GetPathFileName(strFileName);
strText << (b64bit ? TEXT("*64") : TEXT("*32"));
strText << TEXT("]: ") << strWindowName;
int id = (int)SendMessage(hwndCombobox, CB_ADDSTRING, 0, (LPARAM)strText.Array());
@ -196,7 +157,6 @@ void RefreshWindowList(HWND hwndCombobox, ConfigDialogData &configData)
WindowInfo &info = *configData.windowData.CreateNew();
info.strClass = strClassName;
info.b64bit = b64bit;
info.bRequiresAdmin = false; //todo: add later
}
}
@ -279,18 +239,6 @@ INT_PTR CALLBACK ConfigureDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPA
strInfoText << info->adminWindows[i] << TEXT("\r\n");
}
if(info->opposingBitWindows.Num())
{
#ifdef _WIN64
strInfoText << Str("Sources.GameCaptureSource.Requires32bit") << TEXT("\r\n");
#else
strInfoText << Str("Sources.GameCaptureSource.Requires64bit") << TEXT("\r\n");
#endif
for(UINT i=0; i<info->opposingBitWindows.Num(); i++)
strInfoText << TEXT(" * ") << info->opposingBitWindows[i] << TEXT("\r\n");
}
SetWindowText(GetDlgItem(hwnd, IDC_INFO), strInfoText);
}
break;

View File

@ -44,6 +44,18 @@ public:
//-----------------------------------------------------------
inline BOOL Is64BitWindows()
{
#if defined(_WIN64)
return TRUE;
#elif defined(_WIN32)
BOOL f64 = FALSE;
return IsWow64Process(GetCurrentProcess(), &f64) && f64;
#endif
}
//-----------------------------------------------------------
#include "MemoryCapture.h"
#include "SharedTexCapture.h"
#include "GraphicsCaptureSource.h"

View File

@ -84,7 +84,7 @@ void SetupD3D101(IDXGISwapChain *swapChain)
dxgiFormat = scd.BufferDesc.Format;
d3d101CaptureInfo.cx = scd.BufferDesc.Width;
d3d101CaptureInfo.cy = scd.BufferDesc.Height;
d3d101CaptureInfo.hwndCapture = scd.OutputWindow;
d3d101CaptureInfo.hwndCapture = (DWORD)scd.OutputWindow;
bIsMultisampled = scd.SampleDesc.Count > 1;
}
}
@ -367,8 +367,8 @@ HRESULT STDMETHODCALLTYPE D3D101SwapPresentHook(IDXGISwapChain *swap, UINT syncI
bHasTextures = true;
d3d101CaptureInfo.captureType = CAPTURETYPE_SHAREDTEX;
d3d101CaptureInfo.bFlip = FALSE;
texData->texHandles[0] = sharedHandles[0];
texData->texHandles[1] = sharedHandles[1];
texData->texHandles[0] = (DWORD)sharedHandles[0];
texData->texHandles[1] = (DWORD)sharedHandles[1];
memcpy(infoMem, &d3d101CaptureInfo, sizeof(CaptureInfo));
SetEvent(hSignalReady);

View File

@ -85,7 +85,7 @@ void SetupD3D10(IDXGISwapChain *swapChain)
dxgiFormat = scd.BufferDesc.Format;
d3d10CaptureInfo.cx = scd.BufferDesc.Width;
d3d10CaptureInfo.cy = scd.BufferDesc.Height;
d3d10CaptureInfo.hwndCapture = scd.OutputWindow;
d3d10CaptureInfo.hwndCapture = (DWORD)scd.OutputWindow;
bIsMultisampled = scd.SampleDesc.Count > 1;
}
}
@ -368,8 +368,8 @@ HRESULT STDMETHODCALLTYPE D3D10SwapPresentHook(IDXGISwapChain *swap, UINT syncIn
bHasTextures = true;
d3d10CaptureInfo.captureType = CAPTURETYPE_SHAREDTEX;
d3d10CaptureInfo.bFlip = FALSE;
texData->texHandles[0] = sharedHandles[0];
texData->texHandles[1] = sharedHandles[1];
texData->texHandles[0] = (DWORD)sharedHandles[0];
texData->texHandles[1] = (DWORD)sharedHandles[1];
memcpy(infoMem, &d3d10CaptureInfo, sizeof(CaptureInfo));
SetEvent(hSignalReady);

View File

@ -88,7 +88,7 @@ void SetupD3D11(IDXGISwapChain *swapChain)
dxgiFormat = scd.BufferDesc.Format;
d3d11CaptureInfo.cx = scd.BufferDesc.Width;
d3d11CaptureInfo.cy = scd.BufferDesc.Height;
d3d11CaptureInfo.hwndCapture = scd.OutputWindow;
d3d11CaptureInfo.hwndCapture = (DWORD)scd.OutputWindow;
bIsMultisampled = scd.SampleDesc.Count > 1;
}
}
@ -393,8 +393,8 @@ HRESULT STDMETHODCALLTYPE D3D11SwapPresentHook(IDXGISwapChain *swap, UINT syncIn
bHasTextures = true;
d3d11CaptureInfo.captureType = CAPTURETYPE_SHAREDTEX;
d3d11CaptureInfo.bFlip = FALSE;
texData->texHandles[0] = sharedHandles[0];
texData->texHandles[1] = sharedHandles[1];
texData->texHandles[0] = (DWORD)sharedHandles[0];
texData->texHandles[1] = (DWORD)sharedHandles[1];
memcpy(infoMem, &d3d11CaptureInfo, sizeof(CaptureInfo));
SetEvent(hSignalReady);

View File

@ -476,8 +476,8 @@ finishGPUHook:
bHasTextures = true;
d3d9CaptureInfo.captureType = CAPTURETYPE_SHAREDTEX;
d3d9CaptureInfo.bFlip = FALSE;
texData->texHandles[0] = sharedHandles[0];
texData->texHandles[1] = sharedHandles[1];
texData->texHandles[0] = (DWORD)sharedHandles[0];
texData->texHandles[1] = (DWORD)sharedHandles[1];
memcpy(infoMem, &d3d9CaptureInfo, sizeof(CaptureInfo));
SetEvent(hSignalReady);
@ -1019,7 +1019,7 @@ void SetupD3D9(IDirect3DDevice9 *device)
d3d9Format = pp.BackBufferFormat;
d3d9CaptureInfo.cx = pp.BackBufferWidth;
d3d9CaptureInfo.cy = pp.BackBufferHeight;
d3d9CaptureInfo.hwndCapture = pp.hDeviceWindow;
d3d9CaptureInfo.hwndCapture = (DWORD)pp.hDeviceWindow;
}
}
}

View File

@ -129,7 +129,7 @@ void QuickLog(LPCSTR lpText)
HANDLE hFile = CreateFile(TEXT("d:\\log.txt"), GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
DWORD bla;
SetFilePointer(hFile, 0, 0, FILE_END);
WriteFile(hFile, lpText, strlen(lpText), &bla, NULL);
WriteFile(hFile, lpText, (DWORD)strlen(lpText), &bla, NULL);
FlushFileBuffers(hFile);
CloseHandle(hFile);
}

View File

@ -144,7 +144,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
OutputFile="$(OutDir)\$(ProjectName)64.dll"
LinkIncremental="2"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\rundir\pdb64\$(TargetName).pdb"
@ -172,7 +172,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName).dll ..\..\rundir\plugins\GraphicsCapture"
CommandLine="copy $(OutDir)\$(ProjectName)64.dll ..\..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
<Configuration
@ -302,7 +302,7 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dxguid.lib"
OutputFile="$(OutDir)\$(ProjectName).dll"
OutputFile="$(OutDir)\$(ProjectName)64.dll"
LinkIncremental="1"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\rundir\pdb64\$(TargetName).pdb"
@ -332,7 +332,7 @@
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName).dll ..\..\rundir\plugins\GraphicsCapture"
CommandLine="copy $(OutDir)\$(ProjectName)64.dll ..\..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
</Configurations>

View File

@ -278,7 +278,7 @@ void DoGLCPUHook(RECT &rc)
{
bHasTextures = true;
glcaptureInfo.captureType = CAPTURETYPE_MEMORY;
glcaptureInfo.hwndCapture = hwndTarget;
glcaptureInfo.hwndCapture = (DWORD)hwndTarget;
glcaptureInfo.pitch = glcaptureInfo.cx*4;
glcaptureInfo.bFlip = TRUE;

View File

@ -20,60 +20,6 @@
#include "GraphicsCapture.h"
BOOL WINAPI InjectLibrary(HANDLE hProcess, CTSTR lpDLL)
{
UPARAM procAddress;
DWORD dwTemp,dwSize;
LPVOID lpStr = NULL;
BOOL bWorks,bRet=0;
HANDLE hThread = NULL;
SIZE_T writtenSize;
if(!hProcess) return 0;
dwSize = ssize((TCHAR*)lpDLL);
lpStr = (LPVOID)VirtualAllocEx(hProcess, NULL, dwSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if(!lpStr) goto end;
bWorks = WriteProcessMemory(hProcess, lpStr, (LPVOID)lpDLL, dwSize, &writtenSize);
if(!bWorks) goto end;
#ifdef UNICODE
procAddress = (UPARAM)GetProcAddress(GetModuleHandle(TEXT("KERNEL32")), "LoadLibraryW");
#else
procAddress = (UPARAM)GetProcAddress(GetModuleHandle(TEXT("KERNEL32")), "LoadLibraryA");
#endif
if(!procAddress) goto end;
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)procAddress, lpStr, 0, &dwTemp);
if(!hThread) goto end;
if(WaitForSingleObject(hThread, 200) == WAIT_OBJECT_0)
{
DWORD dw;
GetExitCodeThread(hThread, &dw);
bRet = dw != 0;
SetLastError(0);
}
end:
DWORD lastError;
if(!bRet)
lastError = GetLastError();
if(hThread)
CloseHandle(hThread);
if(lpStr)
VirtualFreeEx(hProcess, lpStr, 0, MEM_RELEASE);
if(!bRet)
SetLastError(lastError);
return bRet;
}
bool GraphicsCaptureSource::Init(XElement *data)
{
this->data = data;
@ -168,7 +114,7 @@ void GraphicsCaptureSource::NewCapture()
bFlip = info.bFlip != 0;
hwndCapture = info.hwndCapture;
hwndCapture = (HWND)info.hwndCapture;
if(info.captureType == CAPTURETYPE_MEMORY)
capture = new MemoryCapture;
@ -303,29 +249,61 @@ void GraphicsCaptureSource::AttemptCapture()
}
else
{
String strDLL;
String strDLLPath;
DWORD dwDirSize = GetCurrentDirectory(0, NULL);
strDLL.SetLength(dwDirSize);
GetCurrentDirectory(dwDirSize, strDLL);
strDLLPath.SetLength(dwDirSize);
GetCurrentDirectory(dwDirSize, strDLLPath);
strDLL << TEXT("\\plugins\\GraphicsCapture\\GraphicsCaptureHook.dll");
strDLLPath << TEXT("\\plugins\\GraphicsCapture");
if(InjectLibrary(hProcess, strDLL))
BOOL b32bit = TRUE;
if(Is64BitWindows())
IsWow64Process(hProcess, &b32bit);
String strHelper = strDLLPath;
strHelper << ((b32bit) ? TEXT("\\injectHelper.exe") : TEXT("\\injectHelper64.exe"));
String strCommandLine;
strCommandLine << strHelper << TEXT(" ") << UIntString(targetProcessID);
//---------------------------------------
PROCESS_INFORMATION pi;
STARTUPINFO si;
zero(&pi, sizeof(pi));
zero(&si, sizeof(si));
si.cb = sizeof(si);
if(CreateProcess(strHelper, strCommandLine, NULL, NULL, FALSE, 0, NULL, strDLLPath, &si, &pi))
{
DWORD exitCode = 0;
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, &exitCode);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
if(exitCode)
{
captureWaitCount = 0;
bCapturing = true;
}
else
{
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, GetLastError = %u"), GetLastError());
CloseHandle(hProcess);
hProcess = NULL;
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library"));
bErrorAcquiring = true;
}
}
else
{
AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Could not create inject helper, GetLastError = %u"), GetLastError());
bErrorAcquiring = true;
}
}
CloseHandle(hProcess);
hProcess = NULL;
}
else
{

View File

@ -67,7 +67,7 @@ bool SharedTexCapture::Init(CaptureInfo &info)
for(UINT i=0; i<2; i++)
{
sharedTextures[i] = GS->CreateTextureFromSharedHandle(info.cx, info.cy, (GSColorFormat)info.format, texData->texHandles[i]);
sharedTextures[i] = GS->CreateTextureFromSharedHandle(info.cx, info.cy, (GSColorFormat)info.format, (HANDLE)texData->texHandles[i]);
if(!sharedTextures[i])
{
AppWarning(TEXT("SharedTexCapture::Init: Could not create shared texture"));

View File

@ -29,6 +29,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsCapture", "Graphics
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GraphicsCaptureHook", "GraphicsCapture\GraphicsCaptureHook\GraphicsCaptureHook.vcproj", "{12111D5C-819C-4BAF-9783-E6AF8CBC2700}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "injectHelper", "injectHelper\injectHelper.vcproj", "{E03BF070-E830-46BB-8442-5771F7E5F301}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -101,6 +103,14 @@ Global
{12111D5C-819C-4BAF-9783-E6AF8CBC2700}.Release|Win32.Build.0 = Release|Win32
{12111D5C-819C-4BAF-9783-E6AF8CBC2700}.Release|x64.ActiveCfg = Release|x64
{12111D5C-819C-4BAF-9783-E6AF8CBC2700}.Release|x64.Build.0 = Release|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|Win32.ActiveCfg = Debug|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|Win32.Build.0 = Debug|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|x64.ActiveCfg = Debug|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|x64.Build.0 = Debug|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|Win32.ActiveCfg = Release|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|Win32.Build.0 = Release|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|x64.ActiveCfg = Release|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -71,7 +71,7 @@ extern TCHAR lpAppPath[MAX_PATH];
extern TCHAR lpAppDataPath[MAX_PATH];
#define OBS_VERSION 0x000470
#define OBS_VERSION_STRING_ANSI "Open Broadcaster Software v0.471b (test 1)"
#define OBS_VERSION_STRING_ANSI "Open Broadcaster Software v0.471b (test 2)"
#define OBS_VERSION_STRING TEXT(OBS_VERSION_STRING_ANSI)
#define OBS_TEST_BUILD 1 //define this if releasing a test build to disable the auto updater

133
injectHelper/injectHelper.c Normal file
View File

@ -0,0 +1,133 @@
/********************************************************************************
Copyright (C) 2012 Hugh Bailey <obs.jim@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
********************************************************************************/
#include <stdio.h>
#include <windows.h>
#include <shellapi.h>
#ifdef _WIN64
typedef unsigned __int64 UPARAM;
#else
typedef unsigned long UPARAM;
#endif
BOOL WINAPI InjectLibrary(HANDLE hProcess, const wchar_t *pDLL, DWORD dwLen)
{
DWORD dwTemp, dwSize, lastError;
BOOL bSuccess, bRet = 0;
HANDLE hThread = NULL;
LPVOID pStr = NULL;
UPARAM procAddress;
SIZE_T writtenSize;
if (!hProcess) return 0;
dwSize = (dwLen+1) * sizeof(wchar_t);
pStr = (LPVOID)VirtualAllocEx(hProcess, NULL, dwSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
if (!pStr) goto end;
bSuccess = WriteProcessMemory(hProcess, pStr, (LPVOID)pDLL, dwSize, &writtenSize);
if (!bSuccess) goto end;
procAddress = (UPARAM)GetProcAddress(GetModuleHandle(TEXT("KERNEL32")), "LoadLibraryW");
if (!procAddress) goto end;
hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)procAddress,
pStr, 0, &dwTemp);
if (!hThread) goto end;
if (WaitForSingleObject(hThread, 200) == WAIT_OBJECT_0)
{
DWORD dw;
GetExitCodeThread(hThread, &dw);
bRet = dw != 0;
SetLastError(0);
}
end:
if (!bRet)
lastError = GetLastError();
if (hThread)
CloseHandle(hThread);
if (pStr)
VirtualFreeEx(hProcess, pStr, 0, MEM_RELEASE);
if (!bRet)
SetLastError(lastError);
return bRet;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nShowCmd)
{
LPWSTR pCommandLineW = GetCommandLineW();
int bRetVal = 0;
DWORD procID = 0;
int numArgs = 0;
#ifdef _WIN64
const wchar_t pDLLName[] = L"GraphicsCaptureHook64.dll";
#else
const wchar_t pDLLName[] = L"GraphicsCaptureHook.dll";
#endif
/* -------------------------- */
LPWSTR *pCommandLineArgs = CommandLineToArgvW(pCommandLineW, &numArgs);
if (numArgs > 1)
{
procID = wcstoul(pCommandLineArgs[1], NULL, 10);
if (procID != 0)
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID);
if (hProcess)
{
UINT dirLen = GetCurrentDirectory(0, 0); /* includes null terminator */
const UINT fileNameLen = ((sizeof(pDLLName)-1) / sizeof(wchar_t));
UINT len = dirLen + fileNameLen + 1; /* 1 for '/' */
wchar_t *pPath;
/* -------------------------- */
if (dirLen)
{
pPath = (wchar_t*)malloc(len * sizeof(wchar_t));
memset(pPath, 0, len * sizeof(wchar_t));
GetCurrentDirectoryW(dirLen, pPath);
pPath[dirLen-1] = '\\';
wcsncpy(pPath+dirLen, pDLLName, fileNameLen);
bRetVal = (int)InjectLibrary(hProcess, pPath, len-1);
free(pPath);
}
CloseHandle(hProcess);
}
}
}
LocalFree(pCommandLineArgs);
return bRetVal;
}

View File

@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "injectHelper", "injectHelper.vcproj", "{E03BF070-E830-46BB-8442-5771F7E5F301}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|Win32.ActiveCfg = Debug|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|Win32.Build.0 = Debug|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|x64.ActiveCfg = Debug|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Debug|x64.Build.0 = Debug|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|Win32.ActiveCfg = Release|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|Win32.Build.0 = Release|Win32
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|x64.ActiveCfg = Release|x64
{E03BF070-E830-46BB-8442-5771F7E5F301}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,337 @@
<?xml version="1.0" encoding="shift_jis"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="injectHelper"
ProjectGUID="{E03BF070-E830-46BB-8442-5771F7E5F301}"
RootNamespace="injectHelper"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName).exe ..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)64.exe"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName)64.exe ..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName).exe ..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)\$(ProjectName)64.exe"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy $(OutDir)\$(ProjectName)64.exe ..\rundir\plugins\GraphicsCapture"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\injectHelper.c"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -4,3 +4,5 @@ copy ..\obsapi\debug\obsapi.dll .\
copy ..\dshowplugin\debug\dshowplugin.dll .\plugins
copy ..\graphicscapture\debug\graphicscapture.dll .\plugins
copy ..\graphicscapture\graphicscapturehook\debug\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\x64\debug\graphicscapturehook64.dll .\plugins\graphicscapture
copy ..\x264\libs\32bit\libx264-129.dll .\

View File

@ -3,4 +3,6 @@ copy ..\x64\debug\obs.exe .\
copy ..\obsapi\x64\debug\obsapi.dll .\
copy ..\dshowplugin\x64\debug\dshowplugin.dll .\plugins
copy ..\graphicscapture\x64\debug\graphicscapture.dll .\plugins
copy ..\graphicscapture\graphicscapturehook\x64\debug\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\debug\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\x64\debug\graphicscapturehook64.dll .\plugins\graphicscapture
copy ..\x264\libs\64bit\libx264-129.dll .\

View File

@ -4,4 +4,5 @@ copy ..\obsapi\release\obsapi.dll .\
copy ..\dshowplugin\release\dshowplugin.dll .\plugins
copy ..\graphicscapture\release\graphicscapture.dll .\plugins
copy ..\graphicscapture\graphicscapturehook\release\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\x64\release\graphicscapturehook64.dll .\plugins\graphicscapture
copy ..\x264\libs\32bit\libx264-129.dll .\

View File

@ -3,5 +3,6 @@ copy ..\x64\release\obs.exe .\
copy ..\obsapi\x64\release\obsapi.dll .\
copy ..\dshowplugin\x64\release\dshowplugin.dll .\plugins
copy ..\graphicscapture\x64\release\graphicscapture.dll .\plugins
copy ..\graphicscapture\graphicscapturehook\x64\release\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\release\graphicscapturehook.dll .\plugins\graphicscapture
copy ..\graphicscapture\graphicscapturehook\x64\release\graphicscapturehook64.dll .\plugins\graphicscapture
copy ..\x264\libs\64bit\libx264-129.dll .\