summaryrefslogtreecommitdiff
path: root/utils/dx_proxy
diff options
context:
space:
mode:
Diffstat (limited to 'utils/dx_proxy')
-rw-r--r--utils/dx_proxy/dx_proxy.cpp380
-rw-r--r--utils/dx_proxy/dx_proxy.sln38
-rw-r--r--utils/dx_proxy/dx_proxy_all.vgc31
-rw-r--r--utils/dx_proxy/dx_proxy_base.vpc74
-rw-r--r--utils/dx_proxy/dx_proxy_dx10_v00_pc.vpc14
-rw-r--r--utils/dx_proxy/dx_proxy_dx9_v00_pc.vpc14
-rw-r--r--utils/dx_proxy/dx_proxy_dx9_v00_x360.vpc14
-rw-r--r--utils/dx_proxy/dx_proxy_dx9_v30_pc.vpc14
-rw-r--r--utils/dx_proxy/dxincludeimpl.h52
-rw-r--r--utils/dx_proxy/filememcache.cpp117
-rw-r--r--utils/dx_proxy/filememcache.h76
11 files changed, 824 insertions, 0 deletions
diff --git a/utils/dx_proxy/dx_proxy.cpp b/utils/dx_proxy/dx_proxy.cpp
new file mode 100644
index 0000000..d9b4b91
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy.cpp
@@ -0,0 +1,380 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Proxy for D3DX routines
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//
+
+#include <windows.h>
+#include <vector>
+
+// Aux function prototype
+const char * WINAPI GetDllVersion( void );
+
+
+#ifdef _DEBUG
+#define D3D_DEBUG_INFO 1
+#endif
+
+
+//
+// DX9_V00_PC
+//
+// D3DX static library
+// MSFT file version: 5.3.0000001.0904
+//
+#ifdef DX9_V00_PC
+
+#ifdef DX_PROXY_INC_CONFIG
+# error "DX9_V00_PC: Multiple DX_PROXY configurations disallowed!"
+#endif
+#define DX_PROXY_INC_CONFIG
+#pragma message ( "Compiling DX_PROXY for DX9_V00_PC" )
+
+#if _MSC_VER >= 1900
+#pragma comment ( lib, "../../lib/common/win32/2015/release/d3dx9" )
+#else
+#pragma comment ( lib, "../../dx9sdk/lib/d3dx9" )
+#endif
+#include "../../dx9sdk/include/d3dx9shader.h"
+
+#endif // #ifdef DX9_V00_PC
+
+
+//
+// DX9_X360
+//
+// D3DX win32 static library
+// MSFT X360 SDK
+//
+#ifdef DX9_V00_X360
+
+#ifdef DX_PROXY_INC_CONFIG
+# error "DX9_V00_X360: Multiple DX_PROXY configurations disallowed!"
+#endif
+#define DX_PROXY_INC_CONFIG
+#pragma message ( "Compiling DX_PROXY for DX9_V00_X360" )
+
+// Avoid including XBOX math stuff
+#define _NO_XBOXMATH
+#define __D3DX9MATH_INL__
+
+/*#ifdef _DEBUG
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/d3d9d" )
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/d3dx9d" )
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/xgraphicsd" )
+#else*/
+#if _MSC_VER >= 1900
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/d3d9" )
+#pragma comment ( lib, "../../lib/common/win32/2015/release/d3dx9" )
+#else
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/d3d9" )
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/d3dx9" )
+#pragma comment ( lib, "../../x360xdk/lib/win32/vs2005/xgraphics" )
+#endif
+
+#include "../../x360xdk/include/win32/vs2005/d3dx9shader.h"
+
+#endif // #ifdef DX9_V00_X360
+
+
+//
+// DX9_V30_PC
+//
+// 1. D3DX static import library
+// 2. resource dynamic library d3dx9_33.dll
+//
+// MSFT file version: 9.16.843.0000
+// Distribution: Dec 2006 DirectX SDK
+//
+// Implementation note: need to delayload d3dx9_33
+// because the module should be extracted from resources first.
+// Make sure "/DELAYLOAD:d3dx9_33.dll" is passed to linker.
+//
+#ifdef DX9_V30_PC
+
+#ifdef DX_PROXY_INC_CONFIG
+# error "DX9_V30_PC: Multiple DX_PROXY configurations disallowed!"
+#endif
+#define DX_PROXY_INC_CONFIG
+#pragma message ( "Compiling DX_PROXY for DX9_V30_PC" )
+
+#pragma comment( lib, "delayimp" )
+
+#pragma comment ( lib, "../../dx10sdk/lib/x86/d3dx9" )
+#include "../../dx10sdk/include/d3dx9shader.h"
+
+#endif // #ifdef DX9_V30_PC
+
+
+//
+// DX10_V00_PC
+//
+// 1. D3DX static import library
+// 2. resource dynamic library d3dx10.dll
+//
+// MSFT file version: 9.16.843.0000
+// Distribution: Dec 2006 DirectX SDK
+//
+// Implementation note: need to delayload d3dx10
+// because the module should be extracted from resources first.
+// Make sure "/DELAYLOAD:d3dx10.dll" is passed to linker.
+//
+#ifdef DX10_V00_PC
+
+#ifdef DX_PROXY_INC_CONFIG
+# error "DX10_V00_PC: Multiple DX_PROXY configurations disallowed!"
+#endif
+#define DX_PROXY_INC_CONFIG
+#pragma message ( "Compiling DX_PROXY for DX10_V00_PC" )
+
+#pragma comment( lib, "delayimp" )
+
+#pragma comment ( lib, "../../dx10sdk/lib/x86/d3dx10" )
+#include "../../dx10sdk/include/d3dx10.h"
+
+typedef D3D10_SHADER_MACRO D3DXMACRO;
+typedef LPD3D10INCLUDE LPD3DXINCLUDE;
+typedef ID3D10Include ID3DXInclude;
+typedef D3D10_INCLUDE_TYPE D3DXINCLUDE_TYPE;
+typedef ID3D10Blob* LPD3DXBUFFER;
+typedef void* LPD3DXCONSTANTTABLE;
+
+#endif // #ifdef DX10_V00_PC
+
+
+//
+// No DX configuration
+#ifndef DX_PROXY_INC_CONFIG
+# error "DX9_PC or DX9_X360 must be defined!"
+#endif // #ifndef DX_PROXY_INC_CONFIG
+
+
+
+//
+// ExtractDependencies
+//
+// Retrieves all the additional required binaries from the resources and
+// places them to a temporary location. Then the binaries are mapped into
+// the address space of the calling process.
+//
+static BOOL ExtractDependencies( void )
+{
+ return TRUE;
+/*
+ BOOL bResult = TRUE;
+ char chSyncName[0x30];
+ char const *szDllVersion = GetDllVersion();
+ sprintf( chSyncName, "%s_MTX", szDllVersion );
+
+ HANDLE hMutex = ::CreateMutex( NULL, FALSE, chSyncName );
+ if ( !hMutex )
+ return FALSE;
+
+ DWORD dwWaitResult = ::WaitForSingleObject( hMutex, INFINITE );
+ if ( dwWaitResult != WAIT_OBJECT_0 )
+ return FALSE;
+
+ // Now we own the mutex
+ char chExtractPath[0x100] = { 0 };
+ if ( char const *pszTemp = getenv( "TEMP" ) )
+ sprintf( chExtractPath, "%s\\", pszTemp );
+ else if ( char const *pszTmp = getenv( "TMP" ) )
+ sprintf( chExtractPath, "%s\\", pszTmp );
+ else
+ bResult = FALSE;
+
+ if ( bResult )
+ {
+ sprintf( chExtractPath + strlen( chExtractPath ), "%s", szDllVersion );
+ bResult = ::CreateDirectory( chExtractPath, NULL );
+
+ if ( bResult )
+ {
+ sprintf( chExtractPath + strlen( chExtractPath ), "\\" );
+
+ char const * const arrNames[] = {
+#ifdef DX9_V33_PC
+ "d3dx9_33.dll", MAKEINTRESOURCE( 1 ),
+#else
+#endif
+ NULL
+ };
+
+ // Now loop over the names
+ for ( int k = 0; k < sizeof( arrNames ) / ( 2 * sizeof( arrNames[0] ) ); ++ k )
+ {
+ char const * const &szName = arrNames[ 2 * k ];
+ char const * const &szResource = 1[ &szName ];
+
+ char chCreateFileName[0x200];
+ sprintf( chCreateFileName, "%s%s", chExtractPath, szName );
+
+ HANDLE hFile = CreateFile( chCreateFileName, FILE_ALL_ACCESS, FILE_SHARE_READ, NULL, CREATE_NEW,
+ FILE_ATTRIBUTE_HIDDEN | FILE_FLAG_DELETE_ON_CLOSE, NULL );
+ #error "This is how you can create temp needed resources"
+ }
+ }
+ }
+
+ ::ReleaseMutex( hMutex );
+ ::CloseHandle( hMutex );
+
+ return bResult;
+*/
+}
+
+
+// DLL entry point: DllMain
+BOOL WINAPI DllMain(
+ HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved
+ )
+{
+ /*UNUSED_ALWAYS*/( hinstDLL );
+ /*UNUSED_ALWAYS*/( lpvReserved );
+
+ switch ( fdwReason )
+ {
+ case DLL_PROCESS_ATTACH:
+ // Process is attaching - make sure it can find the dependencies
+ return ExtractDependencies();
+ }
+
+ return TRUE;
+}
+
+
+
+
+// Obtain DLL version
+#pragma comment(linker, "/EXPORT:GetDllVersionLong=?GetDllVersionLong@@YGPBDXZ")
+const char * WINAPI GetDllVersionLong( void )
+{
+#if defined( DX9_V00_PC ) && defined( _DEBUG )
+ return "{DX_PROXY for DX9_V00_PC DEBUG}";
+#endif
+
+#if defined( DX9_V00_PC ) && defined( NDEBUG )
+ return "{DX_PROXY for DX9_V00_PC RELEASE}";
+#endif
+
+#if defined( DX9_V00_X360 ) && defined( _DEBUG )
+ return "{DX_PROXY for DX9_V00_X360 DEBUG}";
+#endif
+
+#if defined( DX9_V00_X360 ) && defined( NDEBUG )
+ return "{DX_PROXY for DX9_V00_X360 RELEASE}";
+#endif
+
+#if defined( DX9_V30_PC ) && defined( _DEBUG )
+ return "{DX_PROXY for DX9_V30_PC DEBUG}";
+#endif
+
+#if defined( DX9_V30_PC ) && defined( NDEBUG )
+ return "{DX_PROXY for DX9_V30_PC RELEASE}";
+#endif
+
+#if defined( DX10_V00_PC ) && defined( _DEBUG )
+ return "{DX_PROXY for DX10_V00_PC DEBUG}";
+#endif
+
+#if defined( DX10_V00_PC ) && defined( NDEBUG )
+ return "{DX_PROXY for DX10_V00_PC RELEASE}";
+#endif
+}
+
+
+#pragma comment(linker, "/EXPORT:GetDllVersion=?GetDllVersion@@YGPBDXZ")
+const char * WINAPI GetDllVersion( void )
+{
+#if defined( DX9_V00_PC ) && defined( _DEBUG )
+ return "DXPRX_DX9_V00_PC_d";
+#endif
+
+#if defined( DX9_V00_PC ) && defined( NDEBUG )
+ return "DXPRX_DX9_V00_PC_r";
+#endif
+
+#if defined( DX9_V00_X360 ) && defined( _DEBUG )
+ return "DXPRX_DX9_V00_X360_d";
+#endif
+
+#if defined( DX9_V00_X360 ) && defined( NDEBUG )
+ return "DXPRX_DX9_V00_X360_r";
+#endif
+
+#if defined( DX9_V30_PC ) && defined( _DEBUG )
+ return "DXPRX_DX9_V30_PC_d";
+#endif
+
+#if defined( DX9_V30_PC ) && defined( NDEBUG )
+ return "DXPRX_DX9_V30_PC_r";
+#endif
+
+#if defined( DX10_V00_PC ) && defined( _DEBUG )
+ return "DXPRX_DX10_V00_PC_d";
+#endif
+
+#if defined( DX10_V00_PC ) && defined( NDEBUG )
+ return "DXPRX_DX10_V00_PC_r";
+#endif
+}
+
+
+
+#include "filememcache.h"
+#include "dxincludeimpl.h"
+
+char s_dummyBuffer[ 512 ];
+
+
+// Proxied routines
+HRESULT WINAPI
+Proxy_D3DXCompileShaderFromFile(
+ LPCSTR pSrcFile,
+ CONST D3DXMACRO* pDefines,
+ LPD3DXINCLUDE pInclude,
+ LPCSTR pFunctionName,
+ LPCSTR pProfile,
+ DWORD Flags,
+ LPD3DXBUFFER* ppShader,
+ LPD3DXBUFFER* ppErrorMsgs,
+ LPD3DXCONSTANTTABLE* ppConstantTable )
+{
+ if ( !pInclude )
+ pInclude = &s_incDxImpl;
+
+ // Open the top-level file via our include interface
+ LPCVOID lpcvData;
+ UINT numBytes;
+ HRESULT hr = pInclude->Open( ( D3DXINCLUDE_TYPE ) 0, pSrcFile, NULL, &lpcvData, &numBytes
+#if defined( DX9_V00_X360 )
+ , s_dummyBuffer, sizeof( s_dummyBuffer )
+#endif
+ );
+ if ( FAILED( hr ) )
+ return hr;
+
+ LPCSTR pShaderData = ( LPCSTR ) lpcvData;
+
+#if defined( DX9_V00_PC ) || defined( DX9_V30_PC ) || defined( DX9_V00_X360 )
+ #pragma comment(linker, "/EXPORT:Proxy_D3DXCompileShaderFromFile=?Proxy_D3DXCompileShaderFromFile@@YGJPBDPBU_D3DXMACRO@@PAUID3DXInclude@@00KPAPAUID3DXBuffer@@3PAPAUID3DXConstantTable@@@Z")
+ hr = D3DXCompileShader( pShaderData, numBytes, pDefines, pInclude, pFunctionName, pProfile, Flags, ppShader, ppErrorMsgs, ppConstantTable );
+#endif
+
+#if defined( DX10_V00_PC )
+ #pragma comment(linker, "/EXPORT:Proxy_D3DXCompileShaderFromFile=?Proxy_D3DXCompileShaderFromFile@@YGJPBDPBU_D3D10_SHADER_MACRO@@PAUID3D10Include@@00KPAPAUID3D10Blob@@3PAPAX@Z")
+ hr = D3DX10CompileFromMemory( pShaderData, numBytes, pSrcFile, pDefines, pInclude, pFunctionName, pProfile, Flags, 0, NULL, ppShader, ppErrorMsgs, NULL );
+#endif
+
+ // Close the file
+ pInclude->Close( lpcvData );
+ return hr;
+}
+
+
+
diff --git a/utils/dx_proxy/dx_proxy.sln b/utils/dx_proxy/dx_proxy.sln
new file mode 100644
index 0000000..11603ef
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy.sln
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DX_Proxy (DX9_V00_PC)", "dx_proxy_dx9_v00_pc.vcproj", "{59757E2C-5229-4929-8989-186DDD99DCF6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DX_Proxy (DX9_V00_X360)", "dx_proxy_dx9_v00_x360.vcproj", "{8EFE726E-8EFE-4B7A-B12C-93977B91AE19}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DX_Proxy (DX9_V30_PC)", "dx_proxy_dx9_v30_pc.vcproj", "{2DE42B19-937C-4846-8443-5E218178188D}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DX_Proxy (DX10_V00_PC)", "dx_proxy_dx10_v00_pc.vcproj", "{B6D2F326-F501-4FE5-B303-B5C24D28CDC1}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {59757E2C-5229-4929-8989-186DDD99DCF6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {59757E2C-5229-4929-8989-186DDD99DCF6}.Debug|Win32.Build.0 = Debug|Win32
+ {59757E2C-5229-4929-8989-186DDD99DCF6}.Release|Win32.ActiveCfg = Release|Win32
+ {59757E2C-5229-4929-8989-186DDD99DCF6}.Release|Win32.Build.0 = Release|Win32
+ {8EFE726E-8EFE-4B7A-B12C-93977B91AE19}.Debug|Win32.ActiveCfg = Debug|Win32
+ {8EFE726E-8EFE-4B7A-B12C-93977B91AE19}.Debug|Win32.Build.0 = Debug|Win32
+ {8EFE726E-8EFE-4B7A-B12C-93977B91AE19}.Release|Win32.ActiveCfg = Release|Win32
+ {8EFE726E-8EFE-4B7A-B12C-93977B91AE19}.Release|Win32.Build.0 = Release|Win32
+ {2DE42B19-937C-4846-8443-5E218178188D}.Debug|Win32.ActiveCfg = Debug|Win32
+ {2DE42B19-937C-4846-8443-5E218178188D}.Debug|Win32.Build.0 = Debug|Win32
+ {2DE42B19-937C-4846-8443-5E218178188D}.Release|Win32.ActiveCfg = Release|Win32
+ {2DE42B19-937C-4846-8443-5E218178188D}.Release|Win32.Build.0 = Release|Win32
+ {B6D2F326-F501-4FE5-B303-B5C24D28CDC1}.Debug|Win32.ActiveCfg = Debug|Win32
+ {B6D2F326-F501-4FE5-B303-B5C24D28CDC1}.Debug|Win32.Build.0 = Debug|Win32
+ {B6D2F326-F501-4FE5-B303-B5C24D28CDC1}.Release|Win32.ActiveCfg = Release|Win32
+ {B6D2F326-F501-4FE5-B303-B5C24D28CDC1}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/utils/dx_proxy/dx_proxy_all.vgc b/utils/dx_proxy/dx_proxy_all.vgc
new file mode 100644
index 0000000..92e64cb
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_all.vgc
@@ -0,0 +1,31 @@
+
+$Project "dx_proxy_dx9_v00_pc"
+{
+ "utils\dx_proxy\dx_proxy_dx9_v00_pc.vpc" [$WIN32]
+}
+
+$Project "dx_proxy_dx9_v30_pc"
+{
+ "utils\dx_proxy\dx_proxy_dx9_v30_pc.vpc" [$WIN32]
+}
+
+$Project "dx_proxy_dx9_v00_x360"
+{
+ "utils\dx_proxy\dx_proxy_dx9_v00_x360.vpc" [$WIN32]
+}
+
+$Project "dx_proxy_dx10_v00_pc"
+{
+ "utils\dx_proxy\dx_proxy_dx10_v00_pc.vpc" [$WIN32]
+}
+
+
+$Group "dx_proxy" "source" "everything"
+{
+ "dx_proxy_dx10_v00_pc"
+
+ "dx_proxy_dx9_v00_pc"
+ "dx_proxy_dx9_v30_pc"
+
+ "dx_proxy_dx9_v00_x360"
+}
diff --git a/utils/dx_proxy/dx_proxy_base.vpc b/utils/dx_proxy/dx_proxy_base.vpc
new file mode 100644
index 0000000..4a6e19d
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_base.vpc
@@ -0,0 +1,74 @@
+//
+// dx_proxy_base.vpc
+//
+// Base script for generating dx_proxy.dll for different
+// versions of Microsoft DirectX SDK
+//
+
+$MacroRequired "SRCDIR"
+$MacroRequired "OUTBINDIR"
+$MacroRequired "DX_SDK_VER"
+
+$Macro OUTBINNAME "dx_proxy"
+
+$Include "$SRCDIR\vpc_scripts\source_dll_base.vpc"
+
+$Configuration "Debug"
+{
+ $General
+ {
+ $OutputDirectory ".\Debug_$DX_SDK_VER"
+ $IntermediateDirectory ".\Debug_$DX_SDK_VER"
+ }
+
+ $Linker
+ {
+ $IgnoreSpecificLibrary "libcp.lib; libcmt.lib;"
+ }
+}
+
+$Configuration "Release"
+{
+ $General
+ {
+ $OutputDirectory ".\Release_$DX_SDK_VER"
+ $IntermediateDirectory ".\Release_$DX_SDK_VER"
+ }
+
+ $Linker
+ {
+ $IgnoreSpecificLibrary "libcpd.lib libcmtd.lib;"
+ }
+}
+
+$Configuration
+{
+ $General
+ {
+ $AdditionalProjectDependencies "$BASE;vstdlib;tier1;tier0"
+ }
+
+ $Compiler
+ {
+ $PreprocessorDefinitions "$BASE;DX_PROXY_EXPORTS;$DX_SDK_VER"
+ $EnableC++Exceptions "Yes (/EHsc)"
+ }
+}
+
+$Project "DX_Proxy ($DX_SDK_VER)"
+{
+ $Folder "Source Files"
+ {
+ -$File "$SRCDIR\public\tier0\memoverride.cpp"
+
+ $File "dx_proxy.cpp"
+ $File "filememcache.cpp"
+ }
+
+ $Folder "Header Files"
+ {
+ $File "$SRCDIR\common\dx_proxy\dx_proxy.h"
+ $File "dxincludeimpl.h"
+ $File "filememcache.h"
+ }
+}
diff --git a/utils/dx_proxy/dx_proxy_dx10_v00_pc.vpc b/utils/dx_proxy/dx_proxy_dx10_v00_pc.vpc
new file mode 100644
index 0000000..d39b6d8
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_dx10_v00_pc.vpc
@@ -0,0 +1,14 @@
+//
+// dx_proxy_dx10_v00_pc.vpc
+//
+// Base script for generating dx_proxy.dll for specific
+// version of Microsoft DirectX SDK:
+// DirectX10 from April 2007 SDK
+//
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\dx10sdk\utilities\dx10_40"
+$Macro DX_SDK_VER "DX10_V00_PC"
+
+$Include "dx_proxy_base.vpc"
+
diff --git a/utils/dx_proxy/dx_proxy_dx9_v00_pc.vpc b/utils/dx_proxy/dx_proxy_dx9_v00_pc.vpc
new file mode 100644
index 0000000..255dc2f
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_dx9_v00_pc.vpc
@@ -0,0 +1,14 @@
+//
+// dx_proxy_dx9_v00_pc.vpc
+//
+// Base script for generating dx_proxy.dll for specific
+// version of Microsoft DirectX SDK:
+// DirectX9 - oldest legacy version
+//
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\dx9sdk\utilities"
+$Macro DX_SDK_VER "DX9_V00_PC"
+
+$Include "dx_proxy_base.vpc"
+
diff --git a/utils/dx_proxy/dx_proxy_dx9_v00_x360.vpc b/utils/dx_proxy/dx_proxy_dx9_v00_x360.vpc
new file mode 100644
index 0000000..743240b
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_dx9_v00_x360.vpc
@@ -0,0 +1,14 @@
+//
+// dx_proxy_dx9_v00_x360.vpc
+//
+// Base script for generating dx_proxy.dll for specific
+// version of Microsoft DirectX SDK:
+// DirectX9 XBox 360 XDK
+//
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\x360xdk\bin\win32"
+$Macro DX_SDK_VER "DX9_V00_X360"
+
+$Include "dx_proxy_base.vpc"
+
diff --git a/utils/dx_proxy/dx_proxy_dx9_v30_pc.vpc b/utils/dx_proxy/dx_proxy_dx9_v30_pc.vpc
new file mode 100644
index 0000000..ed1b1e4
--- /dev/null
+++ b/utils/dx_proxy/dx_proxy_dx9_v30_pc.vpc
@@ -0,0 +1,14 @@
+//
+// dx_proxy_dx9_v30_pc.vpc
+//
+// Base script for generating dx_proxy.dll for specific
+// version of Microsoft DirectX SDK:
+// DirectX9 ver 33 from April 2007 SDK
+//
+
+$Macro SRCDIR "..\.."
+$Macro OUTBINDIR "$SRCDIR\dx10sdk\utilities\dx9_30"
+$Macro DX_SDK_VER "DX9_V30_PC"
+
+$Include "dx_proxy_base.vpc"
+
diff --git a/utils/dx_proxy/dxincludeimpl.h b/utils/dx_proxy/dxincludeimpl.h
new file mode 100644
index 0000000..1c67c62
--- /dev/null
+++ b/utils/dx_proxy/dxincludeimpl.h
@@ -0,0 +1,52 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#ifndef DXINCLUDEIMPL_H
+#define DXINCLUDEIMPL_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+FileCache s_incFileCache;
+
+struct DxIncludeImpl : public ID3DXInclude
+{
+ STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData, LPCVOID *ppData, UINT *pBytes)
+ {
+ CachedFileData *pFileData = s_incFileCache.Get( pFileName );
+ if ( !pFileData || !pFileData->IsValid() )
+ return E_FAIL;
+
+ *ppData = pFileData->GetDataPtr();
+ *pBytes = pFileData->GetDataLen();
+
+ pFileData->UpdateRefCount( +1 );
+
+ return S_OK;
+ }
+
+ STDMETHOD(Open)(THIS_ D3DXINCLUDE_TYPE IncludeType, LPCSTR pFileName, LPCVOID pParentData,
+ LPCVOID *ppData, UINT *pBytes,
+ /* OUT */ LPSTR pFullPath, DWORD cbFullPath)
+ {
+ if ( pFullPath && cbFullPath ) strncpy( pFullPath, pFileName, cbFullPath );
+ return Open( IncludeType, pFileName, pParentData, ppData, pBytes );
+ }
+
+ STDMETHOD(Close)(THIS_ LPCVOID pData)
+ {
+ if ( CachedFileData *pFileData = CachedFileData::GetByDataPtr( pData ) )
+ pFileData->UpdateRefCount( -1 );
+
+ return S_OK;
+ }
+};
+
+DxIncludeImpl s_incDxImpl;
+
+#endif // #ifndef DXINCLUDEIMPL_H
diff --git a/utils/dx_proxy/filememcache.cpp b/utils/dx_proxy/filememcache.cpp
new file mode 100644
index 0000000..d39febf
--- /dev/null
+++ b/utils/dx_proxy/filememcache.cpp
@@ -0,0 +1,117 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#include "filememcache.h"
+
+namespace {
+unsigned long s_ulCachedFileSignature = 0xCACEF11E;
+};
+
+
+//
+// Cached file data implementation
+//
+
+CachedFileData * CachedFileData::Create( char const *szFilename )
+{
+ FILE *f = fopen( szFilename, "rb" );
+
+ int nSize = -1;
+ if ( f )
+ {
+ fseek( f, 0, SEEK_END );
+ nSize = ftell( f );
+ fseek( f, 0, SEEK_SET );
+ }
+
+ CachedFileData *pData = ( CachedFileData * ) malloc( eHeaderSize + max( nSize, 0 ) );
+ strcpy( pData->m_chFilename, szFilename );
+ pData->m_numRefs = 0;
+ pData->m_numDataBytes = nSize;
+ pData->m_signature = s_ulCachedFileSignature;
+
+ if ( f )
+ {
+ fread( pData->m_data, 1, nSize, f );
+ fclose( f );
+ }
+
+ return pData;
+}
+
+void CachedFileData::Free( void )
+{
+ free( this );
+}
+
+CachedFileData *CachedFileData::GetByDataPtr( void const *pvDataPtr )
+{
+ unsigned char const *pbBuffer = reinterpret_cast< unsigned char const * >( pvDataPtr );
+ // Assert( pbBuffer );
+
+ CachedFileData const *pData = reinterpret_cast< CachedFileData const * >( pbBuffer - eHeaderSize );
+ // Assert( pData->m_signature == s_ulCachedFileSignature );
+
+ return const_cast< CachedFileData * >( pData );
+}
+
+char const * CachedFileData::GetFileName() const
+{
+ return m_chFilename;
+}
+
+void const * CachedFileData::GetDataPtr() const
+{
+ return m_data;
+}
+
+int CachedFileData::GetDataLen() const
+{
+ return max( m_numDataBytes, 0 );
+}
+
+bool CachedFileData::IsValid() const
+{
+ return ( m_numDataBytes >= 0 );
+}
+
+
+//
+// File cache implementation
+//
+
+FileCache::FileCache()
+{
+ NULL;
+}
+
+CachedFileData * FileCache::Get( char const *szFilename )
+{
+ // Search the cache first
+ Mapping::iterator it = m_map.find( szFilename );
+ if ( it != m_map.end() )
+ return it->second;
+
+ // Create the cached file data
+ CachedFileData *pData = CachedFileData::Create( szFilename );
+ if ( pData )
+ m_map.insert( Mapping::value_type( pData->GetFileName(), pData ) );
+
+ return pData;
+}
+
+void FileCache::Clear()
+{
+ for ( Mapping::iterator it = m_map.begin(), itEnd = m_map.end(); it != itEnd; ++ it )
+ {
+ it->second->Free();
+ }
+
+ m_map.clear();
+}
+
diff --git a/utils/dx_proxy/filememcache.h b/utils/dx_proxy/filememcache.h
new file mode 100644
index 0000000..36d5bf7
--- /dev/null
+++ b/utils/dx_proxy/filememcache.h
@@ -0,0 +1,76 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+#ifndef FILEMEMCACHE_H
+#define FILEMEMCACHE_H
+#ifdef _WIN32
+#pragma once
+#endif
+
+#include "tier0/platform.h"
+#include "tier1/generichash.h"
+#include <unordered_map>
+
+#pragma warning ( disable : 4200 )
+
+class CachedFileData
+{
+ friend class FileCache;
+
+protected: // Constructed by FileCache
+ CachedFileData() {}
+ static CachedFileData *Create( char const *szFilename );
+ void Free( void );
+
+public:
+ static CachedFileData *GetByDataPtr( void const *pvDataPtr );
+
+ char const * GetFileName() const;
+ void const * GetDataPtr() const;
+ int GetDataLen() const;
+
+ int UpdateRefCount( int iDeltaRefCount ) { return m_numRefs += iDeltaRefCount; }
+
+ bool IsValid() const;
+
+protected:
+ enum { eHeaderSize = 256 };
+ char m_chFilename[256 - 12];
+ int m_numRefs;
+ int m_numDataBytes;
+ int m_signature;
+ unsigned char m_data[0]; // file data spans further
+};
+
+class FileCache
+{
+public:
+ FileCache();
+ ~FileCache() { Clear(); }
+
+public:
+ CachedFileData *Get( char const *szFilename );
+ void Clear( void );
+
+protected:
+ struct eqstr {
+ inline size_t operator()( const char *s ) const {
+ if ( !s )
+ return 0;
+ return HashString( s );
+ }
+ inline bool operator()( const char *s1, const char *s2 ) const {
+ return _stricmp( s1, s2 ) < 0;
+ }
+ };
+
+ typedef std::unordered_map< const char *, CachedFileData *, eqstr, eqstr > Mapping;
+ Mapping m_map;
+};
+
+#endif // #ifndef FILEMEMCACHE_H