D2 Loader No CD

This is an unofficial, hacked version of D2Loader v1.10 to make it compatible
with Diablo II 1.11b. Most of the 1.10 parameters and what-not still work, so
please refer to the v1.10 D2Loader docs for more info about D2Loader.

Version numbering is now done completely by date to avoid confusion when there
is a Diablo II "v1.11b" and D2Loader "v1.11b02". When looking for the latest
release, look for the one with the latest date.

For the latest versions, please see http://d2loader.webhop.net/ which will
redirect you to a page which has (hopefully) safe versions of the latest
builds. I can't promise whoever hosts the files will not replace them with
trojans and such, so please be careful as with any D2 related executables.

Remove any existing v1.10 plugins - they will likely crash. Then copy the
.exe to your Diablo II directory and run it or whatever you want to do with
it. Below are some useful command line parameters you may wish to use:

-w             Run in windowed mode.
-ns            Disable sound (warning, can cause some crashes)
-nohide        Don't hide the Diablo II window when losing focus.
-res800        Start at 800x600 (avoids window moving off-centre on load)
-sleepy        Call sleep(1) to avoid D2 using 100% CPU time.
-altcolor      Change color of monster health bar.
-title "foo"   Set the Diablo II window title to foo.
-mpq foo.mpq   Load foo.mpq (useful for additional CD keys)
-skiptobnet    Skip straight to the BNet login screen.

Using NO CD:
From the Diablo 2 CD-Rom Copy the files called d2xvideo.mpq and d2xmusic.mpq and
paste them into your main Diablo 2 directory.  It should now run when you use D2 loader.
Change Log 
D2Loader v1.11b (Nov 11 2005)
Added -altcolor option for windowed mode, will use different colors when
drawing the monster name / hp box so it is more visible. Yes, this uses more
code patches, but I really hope Blizzard doesn't mind this accessibilty option
as it's pretty hard to see it in windowed mode without this fix.

D2Loader v1.11b (Oct 04 2005)
Fixed -sleepy behavior acting weird sometimes (ie high CPU usage / random D2
window 'freezing' on menu). I'm amazed this didn't actually crash since there
was a jump into the middle of an opcode (*blushes*) :D.

Bound the executable to Diablo II v1.11b and WinXP SP2 entry points for maybe
a slight improvement in load time.

D2Loader v1.11b (Sep 22 2005)
Patched the D2Lang.dll patches so -locale works again. Since I don't have a
Korean D2 or whatever, I can't test this actually works, but it looks like it
should - my D2 crashes looking for some Korean fonts with -locale Korean.

Added ability to read extra command line options. This allows further features
that would require a command line option. Such as...

-nohide command line option. If set, will subclass the main D2 window handle
and block WM_ACTIVATEAPP/0 from reaching D2, which will prevent the D2 window
from hiding when it loses focus. Diablo II usually gobbles up 100% CPU time
when not hidden (see below for a 'fix' for this), so running multiple windows
with -nohide could cause some significant slowdown. Don't use this in full
screen mode for obvious reasons.

-sleepy command line option. If set, will patch the arguments to sleep() in
D2Client and D2Win so they aren't zero. This results in the Diablo II process
using much less CPU time since it isn't stuck in such a tight loop. Note that
this *might* result in oh-so-barely lower FPS, but I don't think that's a
concern in D2 :-). The benefits of this should be apparent to anyone with a
fast system... and why Blizz are calling sleep(0) is beyond me :D. Note that
there are still some areas that use 100% CPU time regardless since they aren't
part of the menu / game loop.

Fixed a small jmp to the wrong place on the rare chance you had any plugins

Fixed VirtualProtect not restoring correct memory access options after
applying patches (yeah I suck at the x86 asm :P).

Fixed BNClient and other future patches being applied more than once when
re-entering the main menu.

Edited the PE header to provide the correct code size. This shuts up OllyDbg's
SFX warning so I don't get quite so frustrated each time I have to restart :).

Also a tip to any people who are making Diablo II hacks that install by
finding the D2 window: EnumWindows / GetClassName / GetWindowThreadProcessId
are your friends. Don't go enumerating the executable names as these aren't
100% reliable due to renaming. The D2 window classname is "Diablo II".

Small note, the last version recommended using '-nocleanup' to do a 'nice'
shutdown of D2 - a word of warning - don't use -nocleanup with -skiptobnet or
every time D2 tries to exit by going back to the menu, it will reconnect to
bnet and you'll be stuck in a rather nasty foreground-hogging infinite loop.

A forewarning, the next release may have another 2KB added on to the file size
as I'm running quite short on space in the current executable to continue
adding more features. It probably doesn't help that my code is so bloated :).

D2Loader v1.11b (Sep 15 2005)
Few fixes here, the first new hack I'd added I accidentally called XP SP2
DLL addresses instead of using the import table for the new error box stuff.
Oops. Now all Windows versions should get the error dialogs when there is
a problem initing. I also added a version check so that the executable won't
even run if it detects a new version of D2. Due to the amount of stuff that
Blizz seem to change each release, it's extremely unlikely that an old loader
version would work with a new patch.

This version also has EVERY ordinal fixed, even ones that were missing from
the original v1.11 loader. As such, obscure parameters such as -gamma, -lq
and -vsync now work correctly. I figured if Blizz release 1.11c anytime soon I
wouldn't want to go checking back three versions worth of changes :).

Point of interest: it seems -nocleanup works backwards, ie "no cleanup" is on
by default and if you specify -nocleanup, D2Loader will go through the normal
D2 shutdown procedures (close sound, unload DLLs, etc). Now that the cleanup
ordinals are mapped, -nocleanup works nicely and does a 'graceful' close of
Diablo II. While I don't want to change any defaults, I'd recommend you use
-nocleanup on your command line to do a graceful exit instead of ExitProcess.

This version is really what I wanted the last version to be when I released
it, but sadly I didn't have time to do all these things. I decided to just
get a version out there that worked with v1.11b to keep all the people happy
who depend on D2Loader to be able to play the game.

D2Loader v1.11b (Sep 14 2005)
Just to add further confusion, Blizz released v1.11b and a lot of people saw
the "v1.11b02" and thought it was for v1.11b. The b is for the build number.
I've changed how the version string is now written to reduce further mixups.
This version simply fixes the ordinals for v1.11b and again, D2Loader is back
in business. One small fix, if you Alt+F4 out of D2, the cache file handle is
properly closed and deleted. As usual, keep an eye on the D2Loader redirect -
http://d2loader.webhop.net/ for the latest versions.

D2Loader v1.11b02 Sep 09 2005
Added some code to the resource section to support extra hacks which wouldn't
fit in any other places. This may cause some virus scanners to go crazy since
code shouldn't be running from the resource section :). It's quite safe, just
heuristic scanners may give false positives. This new code section also makes
it much easier to extend D2Loader functionality at a later time if needed.

New in this build is a bnclient.dll patch to generate the bncache name based
on the PID of the D2Loader process. This prevents multiple D2s trying to lock
the file (and subsequently one of them dropping with C/I). If you missed the
point there, multiple D2Loaders can now run on bnet at the same time without
having to copy a ton of .exe/.dll files all over the place.

Also a few minor improvements, SetErrorMode is called on init to prevent the
annoying "No Disc In Drive / Continue/Try Again/Ignore" dialog boxes that can
occur if you run D2Loader with virtual CD and/or empty CD drives. Any fatal
errors such as missing MPQ files on startup are now shown in a message box so
you can actually see what the problem is rather than having the loader exit.
Finally, FlushInstructionCache is called after patches are done to ensure no
problems arise from not doing so.

A word of warning, "Warden" - Blizzard's new hack detection software - can
easily be updated (if it doesn't already) to detect D2Loader usage. You take
a risk as with any 3rd party hacks - while I personally would hope something
as simple as self-muling and running without the CD is fairly harmless, it's
ultimately up to Blizzard. This version of the loader is unable to load any
plugins so it can't be used to load any further hacks, but again, it's your
choice to run it.

D2Loader v1.11b01 Aug 01 2005
Hacked with love ;-)

Fixed up imports from D2 DLL ordinals and bam, it works with v1.11. Note that
the plugin system seems to work, but individual plugins will likely need many
changes to be compatible with 1.11. I strongly recommend you remove all v1.10
plugins before trying to use this. Enjoy.

Fullscreen/D3d UNTESTED, not recommended!