Page 1 of 1

How to: Use D3D7

Posted: 18. Dec 2009, 03:07
by di64
This was tested on Windows 2000, and should work on XP and pretty much everything ever too. The important part is that you have Guest Additions installed and 3D acceleration already working.

This is a long post. It's not worth it. Do it anyway, live on the edge.

Screenies at the end!

  • How we shall D3D7 the hell up
  • Grabbing the experimental ddraw.dll from the WineD3D on Windows project
  • Restoring original ddraw, renaming ddraw to fdraw
  • Modifying the DX7 game to look for fdraw not ddraw
How we shall D3D7 the hell up
The VBox D3D emulation stuff is based off (well, is almost entirely) WineD3D running on Windows itself. (This translates the DX calls to OpenGL calls, and then VBox does the rest from there.)

WineD3D is more or less focussed entirely on D3D8 and D3D9, unfortunately for those of us (like me) who want to play Typing Of The Dead, for instance. Tis a D3D7-based game.

Fortunately they have some unstable D3D7 bindings hanging about, that aren't shipped with the Guest Additions normally. We can install these separately.

Grabbing the experimental ddraw.dll from the WineD3D on Windows project

^^^^^^^^ grab the wined3d installer, and shove it on your desktop for later.

If you run the installer, you will find that it tells you to reboot into safe mode. In my honest opinion this is unnecessary on windows 2000 (if you haven't got the win2k cd in then it can't copy the files back over and replace your system32 shenanigans), but whatever. Reboot into safe mode and run the installer again.

Tick ONLY the box that mentions DX7 (i.e. untick the others), and follow the setup through.

Whether you want to reboot into normal mode or not now is up to you.

In any case, go into C:\WINNT\System32. Make sure nothing is selected, then quickly type 'ddraw' to take you the right place. Note that wined3d has left a backup of the old ddraw next to the new one -- called something like ddraw.dll.wine_d3d_installer_backup.

Restoring original ddraw, renaming ddraw to fdraw

Unfortunately, the 'new' WineD3D-version ddraw can't be left as it is. opengl32.dll (which all wined3d components, including the new ddraw, rely on) relies on ddraw, now potentially causing an infinite loop of failure. The solution is obvious.

Rename the 'new' wined3d ddraw.dll to fdraw.dll, and rename the ddraw.dll.blahblahblah to just ddraw.dll.

Now, find your chosen DX7 game (I shall be using Typing Of The Dead) and make a copy of the EXE file to work on.

Grab a hex editor. I highly recommend, as it is lightweight and simple.

Install frhed (or your hex editor) and use it to open your copied EXE. Punch Ctrl-F into your computer to summon the find dialog, and type just the five characters 'ddraw' and click OK.

Modifying the DX7 game to look for fdraw not ddraw

This next part is as much an art as a science. F4 is the 'find next' key.
Simply, the raw bytes are shown in the hex part of the display, and the right panel shows what letters these bytes represent.

Our goal is to make your EXE rely on fdraw, not ddraw. The rules are simple.

You cannot insert or delete characters, only overwrite them. (That's why we're called fdraw, not ddraw_rainbows_and_unicorns. We do not want to upset the offsets.)
If it looks like a C++ class name (e.g. CDisplayDriver::DDrawBlahBlah) then do not change the ddraw.
If it looks like a call into a function to do with ddraw (e.g. ddrawSomethingOrOther) then do not change the ddraw.
If it looks like an error message (e.g. Could not initialise DDraw due to ...) then it doesn't really matter what you do.

If it's buried towards the end of the file (>50% of the way down normally) and is around lots of function calls (e.g. .DSOUND.dll..WINMM.dll...DirectDrawCreateEx....DirectDrawEnumerateExA..DDRAW.dll.1.CreateEventA....GlobalFree..J.C...), you've found it. Change the D in DDRAW to an F and be on your way.

(Normally there are multiple references to a 'ddraw.dll', not just one 'DDRAW.dll' like there is in Typing of the Dead. What can I say , it was practically designed for this kind of thing.)

Now save the EXE and run it. If you messed up, copy back over from your back up. You'll know if you got it right, because you will be offered a mystifying choice between Hardware acceleration and Hardware acceleration with T&L. They both lag, so whatever.

Lags terribly? Sorry, I think it's supposed to do that. :P

Have fun!

Re: How to: Use D3D7

Posted: 8. Feb 2010, 16:09
by highfly22

Re: How to: Use D3D7

Posted: 9. Feb 2010, 16:47
by highfly22
I used this method to run DK4 on the guest Windows XP.
One experiment is that when you edit the right place, the dll depends will be the fdraw.dll instead of ddraw.dll.

It seems you should edit the import section of dll.