├── .gitattributes ├── .gitignore ├── Injector ├── Helper.cpp ├── Helper.h ├── Injector.vcxproj ├── Injector.vcxproj.filters └── Main.cpp ├── README.md ├── ScreenCapture.sln └── ScreenCapture ├── D3D9Hook.cpp ├── D3D9Hook.h ├── Hook.cpp ├── Hook.h ├── Main.cpp ├── ScreenCapture.cpp ├── ScreenCapture.h ├── ScreenCapture.vcxproj └── ScreenCapture.vcxproj.filters /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | 98 | # NuGet Packages Directory 99 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 100 | #packages/ 101 | 102 | # Windows Azure Build Output 103 | csx 104 | *.build.csdef 105 | 106 | # Windows Store app package directory 107 | AppPackages/ 108 | 109 | # Others 110 | sql/ 111 | *.Cache 112 | ClientBin/ 113 | [Ss]tyle[Cc]op.* 114 | ~$* 115 | *~ 116 | *.dbmdl 117 | *.[Pp]ublish.xml 118 | *.pfx 119 | *.publishsettings 120 | 121 | # RIA/Silverlight projects 122 | Generated_Code/ 123 | 124 | # Backup & report files from converting an old project file to a newer 125 | # Visual Studio version. Backup files are not needed, because we have git ;-) 126 | _UpgradeReport_Files/ 127 | Backup*/ 128 | UpgradeLog*.XML 129 | UpgradeLog*.htm 130 | 131 | # SQL Server files 132 | App_Data/*.mdf 133 | App_Data/*.ldf 134 | 135 | 136 | #LightSwitch generated files 137 | GeneratedArtifacts/ 138 | _Pvt_Extensions/ 139 | ModelManifest.xml 140 | 141 | # ========================= 142 | # Windows detritus 143 | # ========================= 144 | 145 | # Windows image file caches 146 | Thumbs.db 147 | ehthumbs.db 148 | 149 | # Folder config file 150 | Desktop.ini 151 | 152 | # Recycle Bin used on file shares 153 | $RECYCLE.BIN/ 154 | 155 | # Mac desktop service store files 156 | .DS_Store 157 | -------------------------------------------------------------------------------- /Injector/Helper.cpp: -------------------------------------------------------------------------------- 1 | #include "Helper.h" 2 | 3 | DWORD Helper::GetProcessID(std::string name) 4 | { 5 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 6 | 7 | if (!hSnapshot) 8 | return 0; 9 | 10 | PROCESSENTRY32 pe32; 11 | pe32.dwSize = sizeof(PROCESSENTRY32); 12 | 13 | DWORD processID = 0; 14 | 15 | if (Process32First(hSnapshot, &pe32)) 16 | { 17 | do 18 | { 19 | if (std::string(pe32.szExeFile) == name) 20 | { 21 | processID = pe32.th32ProcessID; 22 | break; 23 | } 24 | } 25 | while (Process32Next(hSnapshot, &pe32)); 26 | } 27 | 28 | CloseHandle(hSnapshot); 29 | 30 | if (processID) 31 | return processID; 32 | 33 | return 0; 34 | } -------------------------------------------------------------------------------- /Injector/Helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class Helper 9 | { 10 | public: 11 | static DWORD GetProcessID(std::string name); 12 | }; -------------------------------------------------------------------------------- /Injector/Injector.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {79715C77-67F5-47C0-A3FB-A44AB21CACD7} 15 | Win32Proj 16 | Injector 17 | 18 | 19 | 20 | Application 21 | true 22 | v120 23 | MultiByte 24 | 25 | 26 | Application 27 | false 28 | v120 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 55 | 56 | 57 | Console 58 | true 59 | 60 | 61 | 62 | 63 | Level3 64 | 65 | 66 | MaxSpeed 67 | true 68 | true 69 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 70 | 71 | 72 | Console 73 | true 74 | true 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Injector/Injector.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /Injector/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "Helper.h" 5 | 6 | using namespace std; 7 | 8 | int main(int argc, char const *argv[]) 9 | { 10 | //TODO Find the dll path dynamically 11 | const char* dllPath = "C:\\Users\\UnTra_000\\Source\\Repos\\ScreenCapture\\Debug\\ScreenCapture.dll"; 12 | 13 | /* Find Process ID */ 14 | int processID = Helper::GetProcessID("Terraria.exe"); 15 | cout << "Processs ID found: " << processID << endl; 16 | 17 | /* Inject the DLL to the remote process */ 18 | HANDLE procHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID); 19 | LPVOID dllPathAddress = VirtualAllocEx(procHandle, 0, strlen(dllPath) + 1, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); 20 | WriteProcessMemory(procHandle, dllPathAddress, dllPath, strlen(dllPath), NULL); 21 | HMODULE kernelHandle = GetModuleHandle("kernel32.dll"); 22 | FARPROC func = GetProcAddress(kernelHandle, "LoadLibraryA"); 23 | HANDLE remoteThread = CreateRemoteThread(procHandle, NULL, 0, (LPTHREAD_START_ROUTINE)func, dllPathAddress, 0, NULL); 24 | WaitForSingleObject(remoteThread, INFINITE); 25 | DWORD remoteDllAddress = 0; 26 | GetExitCodeThread(remoteThread, &remoteDllAddress); 27 | 28 | /* Call Startup() on the injected DLL */ 29 | HMODULE localDllModule = LoadLibraryA(dllPath); 30 | FARPROC funcPointer = GetProcAddress(localDllModule, "Startup"); 31 | DWORD relativeAddress = (DWORD)funcPointer - (DWORD)localDllModule; 32 | DWORD addressInRemoteProcess = remoteDllAddress + relativeAddress; 33 | CreateRemoteThread(procHandle, NULL, 0, (LPTHREAD_START_ROUTINE)addressInRemoteProcess, NULL, 0, NULL); 34 | 35 | if (remoteThread == NULL) 36 | cout << "Error creating remote thread: " << GetLastError() << endl; 37 | else 38 | cout << "Injected" << endl; 39 | 40 | cout << "Press any key to continue..."; 41 | getchar(); 42 | 43 | return 0; 44 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ScreenCapture 2 | A small program for screen capturing in games using DirectX 3 | 4 | Let's you capture screenshots by hooking into DirectX API functions. This is a prototype not ready in any way. 5 | -------------------------------------------------------------------------------- /ScreenCapture.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2013 for Windows Desktop 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ScreenCapture", "ScreenCapture\ScreenCapture.vcxproj", "{27117B5D-E910-4768-8994-016761672153}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Injector", "Injector\Injector.vcxproj", "{79715C77-67F5-47C0-A3FB-A44AB21CACD7}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {27117B5D-E910-4768-8994-016761672153} = {27117B5D-E910-4768-8994-016761672153} 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Win32 = Debug|Win32 16 | Release|Win32 = Release|Win32 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {27117B5D-E910-4768-8994-016761672153}.Debug|Win32.ActiveCfg = Debug|Win32 20 | {27117B5D-E910-4768-8994-016761672153}.Debug|Win32.Build.0 = Debug|Win32 21 | {27117B5D-E910-4768-8994-016761672153}.Release|Win32.ActiveCfg = Release|Win32 22 | {27117B5D-E910-4768-8994-016761672153}.Release|Win32.Build.0 = Release|Win32 23 | {79715C77-67F5-47C0-A3FB-A44AB21CACD7}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {79715C77-67F5-47C0-A3FB-A44AB21CACD7}.Debug|Win32.Build.0 = Debug|Win32 25 | {79715C77-67F5-47C0-A3FB-A44AB21CACD7}.Release|Win32.ActiveCfg = Release|Win32 26 | {79715C77-67F5-47C0-A3FB-A44AB21CACD7}.Release|Win32.Build.0 = Release|Win32 27 | EndGlobalSection 28 | GlobalSection(SolutionProperties) = preSolution 29 | HideSolutionNode = FALSE 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ScreenCapture/D3D9Hook.cpp: -------------------------------------------------------------------------------- 1 | #include "D3D9Hook.h" 2 | #include "ScreenCapture.h" 3 | 4 | /* DirectX 9 Hooking */ 5 | 6 | //Hooks 7 | void EndScene_Hook(); 8 | void SetupHook(void* originalFunc, void* hookFunc); 9 | LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); 10 | 11 | void Hook_Initialize() 12 | { 13 | char* clsName = "test"; 14 | WNDCLASSEX wcex; 15 | 16 | wcex.cbSize = sizeof(WNDCLASSEX); 17 | wcex.style = CS_HREDRAW | CS_VREDRAW; 18 | wcex.lpfnWndProc = WndProc; 19 | wcex.cbClsExtra = 0; 20 | wcex.cbWndExtra = 0; 21 | wcex.hInstance = NULL; 22 | wcex.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_APPLICATION)); 23 | wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 24 | wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 25 | wcex.lpszMenuName = NULL; 26 | wcex.lpszClassName = clsName; 27 | wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); 28 | 29 | if (!RegisterClassEx(&wcex)) 30 | MessageBox(NULL, "Failed to register class. maybe the dll already injected into this process?", "DirectXHook", NULL); 31 | 32 | HWND hWnd = CreateWindow( 33 | clsName, 34 | "Temporary", 35 | WS_OVERLAPPEDWINDOW, 36 | CW_USEDEFAULT, CW_USEDEFAULT, 37 | 500, 100, 38 | NULL, 39 | NULL, 40 | NULL, 41 | NULL 42 | ); 43 | 44 | if (!hWnd) 45 | MessageBox(NULL, std::to_string(GetLastError()).c_str(), "DirectXHook: Call to CreateWindow failed!", NULL); 46 | 47 | UpdateWindow(hWnd); 48 | 49 | LPDIRECT3D9 d3d9Device = Direct3DCreate9(D3D_SDK_VERSION); 50 | LPDIRECT3DDEVICE9 pDevice = NULL; 51 | D3DPRESENT_PARAMETERS d3dpp; 52 | 53 | ZeroMemory(&d3dpp, sizeof(d3dpp)); 54 | d3dpp.Windowed = TRUE; 55 | d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; 56 | d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; 57 | 58 | IDirect3DDevice9* d3dDevice; 59 | 60 | d3d9Device->CreateDevice( 61 | D3DADAPTER_DEFAULT, 62 | D3DDEVTYPE_HAL, 63 | hWnd, 64 | D3DCREATE_HARDWARE_VERTEXPROCESSING, 65 | &d3dpp, 66 | &d3dDevice); 67 | 68 | DWORD* vTable = (DWORD*)*((DWORD*)d3dDevice); 69 | DWORD endSceneAddr = vTable[42]; //42 is the offset to the EndScene function in the vtable 70 | 71 | MessageBox(NULL, std::to_string(endSceneAddr).c_str(), "DirectXHook", NULL); 72 | 73 | SetupHook((void*)endSceneAddr, EndScene_Hook); 74 | 75 | DestroyWindow(hWnd); 76 | } 77 | 78 | LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 79 | { 80 | switch (message) 81 | { 82 | case WM_DESTROY: 83 | PostQuitMessage(0); 84 | break; 85 | } 86 | 87 | return DefWindowProc(hWnd, message, wParam, lParam); 88 | } 89 | 90 | DWORD address = 0; 91 | 92 | void SetupHook(void* originalFunc, void* hookFunc) 93 | { 94 | BYTE instruction[] = { 0xe9, 0x00, 0x00, 0x00, 0x00, 0x90, 0x90 }; 95 | DWORD relativeAddress = (DWORD)hookFunc - (DWORD)originalFunc - 5; // 5 = length of the jump instruction (jmp itself is one byte and 4 other bytes is the address) 96 | memcpy(&instruction[1], &relativeAddress, 4); 97 | DWORD oldProtection; 98 | VirtualProtect(originalFunc, 1024, PAGE_EXECUTE_READWRITE, &oldProtection); //1024 is an artibarary size, hope it's enough... 99 | WriteProcessMemory(GetCurrentProcess(), originalFunc, instruction, sizeof(instruction), NULL); 100 | address = (DWORD)originalFunc + sizeof(instruction); 101 | } 102 | 103 | bool first = true; 104 | ScreenCapture* screenCapture; 105 | 106 | 107 | __declspec(naked) void EndScene_Hook() 108 | { 109 | 110 | __asm 111 | { 112 | PUSH EAX 113 | MOV EAX, [ESP + 8] 114 | } 115 | 116 | IDirect3DDevice9* device; 117 | 118 | __asm 119 | { 120 | MOV device, EAX 121 | POP EAX 122 | } 123 | 124 | if (first) 125 | { 126 | ScreenCapture::ScreenShot(device); 127 | first = false; 128 | } 129 | 130 | __asm 131 | { 132 | PUSH 0x14 133 | MOV EAX, 0x718E6478 134 | JMP address 135 | } 136 | } -------------------------------------------------------------------------------- /ScreenCapture/D3D9Hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | void Hook_Initialize(); -------------------------------------------------------------------------------- /ScreenCapture/Hook.cpp: -------------------------------------------------------------------------------- 1 | #include "Hook.h" 2 | 3 | Hook::Hook(void* originalFunc, void* hookFunc) 4 | { 5 | m_OriginalFunction = originalFunc; 6 | m_HookFunction = hookFunc; 7 | m_IsHooked = false; 8 | 9 | memset(m_JmpInstruction, 0, sizeof(m_JmpInstruction)); 10 | m_JmpInstruction[0] = 0xe9; 11 | m_JmpInstruction[5] = 0xc3; 12 | 13 | DWORD relativeAddress = (DWORD)m_HookFunction - (DWORD)m_OriginalFunction - 5; // 5 = length of the jump instruction (jmp itself is one byte and 4 other bytes is the address) 14 | memcpy(&m_JmpInstruction[1], &relativeAddress, 4); 15 | DWORD oldProtection; 16 | VirtualProtect(m_OriginalFunction, 1024, PAGE_EXECUTE_READWRITE, &oldProtection); //1024 is an artibarary size, hope it's enough... 17 | ReadProcessMemory(GetCurrentProcess(), m_OriginalFunction, m_BackupInstruction, sizeof(m_BackupInstruction), NULL); 18 | } 19 | 20 | Hook::~Hook() 21 | { 22 | if (m_IsHooked) 23 | Remove(); 24 | } 25 | 26 | void Hook::Setup() 27 | { 28 | WriteProcessMemory(GetCurrentProcess(), m_OriginalFunction, m_JmpInstruction, sizeof(m_JmpInstruction), NULL); 29 | m_IsHooked = true; 30 | } 31 | 32 | void Hook::Remove() 33 | { 34 | WriteProcessMemory(GetCurrentProcess(), m_OriginalFunction, m_BackupInstruction, sizeof(m_BackupInstruction), NULL); 35 | m_IsHooked = false; 36 | } -------------------------------------------------------------------------------- /ScreenCapture/Hook.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Hook 7 | { 8 | public: 9 | Hook(void* originalFunc, void* hookFunc); 10 | ~Hook(); 11 | 12 | void Setup(); 13 | void Remove(); 14 | HRESULT DoOriginal(IDirect3DDevice9* device); 15 | private: 16 | void* m_OriginalFunction; 17 | void* m_HookFunction; 18 | bool m_IsHooked; 19 | BYTE m_JmpInstruction[6]; 20 | BYTE m_BackupInstruction[6]; 21 | }; -------------------------------------------------------------------------------- /ScreenCapture/Main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #define D3D_DEBUG_INFO 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "D3D9Hook.h" 9 | 10 | #pragma comment(lib, "d3d9.lib") 11 | #pragma comment(lib, "d3dx9.lib") 12 | #pragma comment(lib, "dxerr.lib") 13 | 14 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 15 | extern "C" __declspec(dllexport) void Startup(); 16 | 17 | BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) 18 | { 19 | switch (fdwReason) 20 | { 21 | case DLL_PROCESS_ATTACH: 22 | break; 23 | default: 24 | break; 25 | } 26 | 27 | return TRUE; 28 | } 29 | 30 | __declspec(dllexport) void Startup() 31 | { 32 | MessageBox(NULL, "Injected2", "DirectXHook", NULL); 33 | Hook_Initialize(); 34 | } -------------------------------------------------------------------------------- /ScreenCapture/ScreenCapture.cpp: -------------------------------------------------------------------------------- 1 | #include "ScreenCapture.h" 2 | #include 3 | 4 | void ScreenCapture::ScreenShot(IDirect3DDevice9* device) 5 | { 6 | IDirect3DSurface9* surface; 7 | HRESULT res = device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &surface); 8 | D3DXSaveSurfaceToFileA("filename.png", D3DXIFF_PNG, surface, NULL, NULL); 9 | } -------------------------------------------------------------------------------- /ScreenCapture/ScreenCapture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ScreenCapture 6 | { 7 | public: 8 | static void ScreenShot(IDirect3DDevice9* device); 9 | }; -------------------------------------------------------------------------------- /ScreenCapture/ScreenCapture.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {27117B5D-E910-4768-8994-016761672153} 15 | Win32Proj 16 | ScreenCapture 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v120 23 | MultiByte 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v120 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | true 44 | 45 | 46 | false 47 | 48 | 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 55 | D:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;%(AdditionalIncludeDirectories) 56 | 57 | 58 | Console 59 | true 60 | D:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;%(AdditionalLibraryDirectories) 61 | 62 | 63 | 64 | 65 | Level3 66 | 67 | 68 | MaxSpeed 69 | true 70 | true 71 | WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) 72 | D:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;%(AdditionalIncludeDirectories) 73 | 74 | 75 | Console 76 | true 77 | true 78 | true 79 | D:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;%(AdditionalLibraryDirectories) 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /ScreenCapture/ScreenCapture.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | --------------------------------------------------------------------------------