The online racing simulator
DirectX 8.1 Proxy DLL programming problem
I have a problem. I am trying to make a proxy dll of d3d8.dll using a code from http://www.mikoweb.eu/ as a basis. I want to use function D3DXSaveSurfaceToFile which was introduced in dx8.1 and is present in 9.0. However i dont have directx8.1 sdk to use 8.1 version of the function and the only solution for me is to use 9.0 version. However I can not include "d3dx9tex.h" (where above function is delared) in my code because "d3d8.h" was included in "stdafx.h". When i try to include it i receive pierdylion errors from d3dx9math.h,d3dx9core.h,d3dx9mesh.h,... files, because their architecture is not compatible with "d3d8.h".
Is there a way to use dx9.0 functions in such proxy dll apps?
Try
#define DIRECT3D_VERSION 0x0800

before including any header. Maybe you could include "d3dx9tex.h" then.
Well, the easiest way was to write this function myself, so the problem doesnt exist now. However I have another one:

Does anybody knows why proxydll_9 example from mikoweb site does not work with DirectX9.0b and 9.0c games? Halo1 (uses 9.0b) says that the installed directx version is not >=9.0b so it can not run. The game runs perfectly fine without the proxy dll of course.

I suspect the architecture of d3d9 changed since 9.0a when the example was written, but does anyone can confirm that?
Yes. In 9.0c microsoft added some functions, that are exported from dll (only one function is exported in 9.0a, "d3ddeviceCreate" or a similar name). I had to add wrappers for these for Test Drive Unlimited. I don't remember the names now, I'll post them later. I wrote about it to the author of the original proxy, but I got no answer (he is busy person).
I added the following code into the proxydll.cpp:
__declspec(dllexport) void WINAPI D3DPERF_SetOptions( DWORD dwOptions ) {
if (!gl_hOriginalDll) LoadOriginalDll(); // looking for the "right d3d9.dll"

// Hooking IDirect3D Object from Original Library
typedef void (WINAPI* D3D9_Type)(DWORD dwOptions);
D3D9_Type D3DPERF_SetOptions_fn = (D3D9_Type) GetProcAddress(
gl_hOriginalDll, "D3DPERF_SetOptions");

// Debug
if (!D3DPERF_SetOptions_fn)
{
OutputDebugString("PROXYDLL: Pointer to original
D3DPERF_SetOptions function not received ERROR ****\r\n");
::ExitProcess(0); // exit the hard way
}
return (D3DPERF_SetOptions_fn (dwOptions));
}

The "__declspec(dllexport)" could be different four your compiler. I think, that the "D3DPERF_SetOptions" is not the only function missing. Look for "D3DPERF_SetOption" in d3d9.h (from DX9.0c SDK).
Thank you I have just found a tool to check what functions are exported by d3d9.dll and there are few. I will implement them soon and check if it works.

I also found out that games sometimes check versions of .dll files like d3d9.dll to determine what driectx version is installed. In properties of d3d9.dll there is "Version" section. There are some information like Internal Name, Version, Language etc. How can I set it up in my dll? I though about putting them into .def file, however it was not accepted by VC++. Does anyone knows how to set it up?
Thanks in advance.
Quote from himself :
I also found out that games sometimes check versions of .dll files like d3d9.dll to determine what driectx version is installed. In properties of d3d9.dll there is "Version" section. There are some information like Internal Name, Version, Language etc. How can I set it up in my dll? I though about putting them into .def file, however it was not accepted by VC++. Does anyone knows how to set it up?
Thanks in advance.

I'm using Dev-C++, these properties can be set from gui or they are in [VersionInfo] in the .dev file. I'm almost sure, that VC++ is able to set these, I have no idea how, though.
Thanks. I already set it up. Just Add Resource -> Version Resource.

I also found out that these additional functions are not really necessary for games to run.

If I have time I'll post updated version of these packages from mikoweb.
Ok, great. Note, before posting any code from mikoweb, contact the author. The code is not public domain.

FGED GREDG RDFGDR GSFDG