A word on WC4 in Win2K - I'm working on a fix.

NStriker

Spaceman
So, after lurking about the forums here a bit, I found a few posts relating to a problem I have. Specifically, WC4 not working in Win2K, throwing the error "VirtualProtect() failed" but being just fine in WinXP and Win9X. No answers, though. So, I checked at the NTCompatible forums, and found a hint that sent me on a quest. It appears that WC4 runs on XP because it contains a compatibility fix 2K does not. Namely "HandleAPIExceptions". That makes some sense. Win9X is sloppy enough to let you get away with a slightly bad API call, but NT based OSes like 2K and XP are not...without the fix.

Getting MS to implement that fix in 2K would surely be talking to a brick wall, so I started hunting around the WC4 exe with a debugger, looking for the offending call to VirtualProtect that was failing. After many hours of weeding through far too much assembly code, I found it.

Now, on one hand I want to thank the Origin programmers for including so many fine error messages in their code so that they could know why the game bombed. A lot of developers would just have it crash to desktop with no message. So that's great and was very helpful. On the other hand, sometimes you just want to smack them for being so sloppy... And this is why:

VirtualProtect changes read/write protection on memory and requires four variables. The start of an area in memory, the number of bytes to change, the new protection value, and...AND...the address of a local variable to return the old protection value in. Wanna know what Origin put for that value? 0. Yup. Zero. They didn't forget to put in a value, they just put 0. The MSDN states that "If this parameter is NULL or does not point to a valid variable, the function fails."

Now, I'm not the biggest genius when it comes to this stuff, and honestly I've never used the VirtualProtect function because my real programming experience is actually kinda limited, but I believe that if I can change that value to the value of some local junk variable it should succeed.

I'll keep ya'll posted.

-NStriker
 
Well... The game started, but I'm not convinced it's stable.

See, the old command that placed 0 on the stack as an arguement, "push 0", is only two bytes. The opcode being 6a and the data part being 00. Obviously, that doesn't leave me enough room to put in a four byte memory address. I need three more bytes of space. I'll work on that, as there are some NOP commands nearby that I can maybe shift.

For now, though, I simply skipped the check to see if VirtualProtect worked. Loaded right up, but I don't trust it to be stable, as I said.

-NStriker
 
There we go. Got a local variable in and it's running fine, though I'm sure it could use some testing. I have the DVD version of WC4 so I guess I'll have to modify the regular exe as well for anyone with the CD version.

I've been told WC3 has a similar problem under Win2K, so I can probably repair that one, too. I'll get around to that a little later.

For now, anyone wanna be a test monkey? I can provide a small program to make the changes to the exe.

-NStriker
 
great work! sure, I can try both DVD & CD version...if you give me enough details I can try to modify the files myself...

edit: i just tried and the CD version is working normally in XP, without the compatibility set on, so I guess only the DVD version has this bug...
 
Sure. Here's the changes to the Win95 CD version :
0000FBCB: 68
0000FBCC: D4
0000FBCD: 40
0000FBCE: 4D
0000FBCF: 00
0000FBD0: 6A
0000FBD1: 40
0000FBD2: 50
0000FBD3: 68
0000FBD4: 64
0000FBD5: D8
0000FBD6: 48
0000FBD7: 00
0000FBD8: FF
0000FBD9: 15
0000FBDA: 6C
0000FBDB: E3
0000FBDC: 4D
0000FBDD: 00
0000FBDE: 85
0000FBDF: C0
0000FBE0: 75
0000FBE1: 0A
0000FBE3: 04
0000FBE4: E8
0000FBE5: 6A
0000FBE6: 7B
0000FBE7: 08
0000FBE8: 00
0000FBE9: 83
0000FBEA: C4
0000FBEB: 04
0000FBEC: 5B
0000FBED: C3

And this for the DVD version:
000767D5: 68
000767D6: 90
000767D7: 50
000767D8: 4C
000767D9: 00
000767DA: 2D
000767DB: B0
000767DC: 50
000767DD: 49
000767DE: 00
000767DF: 6A
000767E0: 40
000767E2: 68
000767E3: B0
000767E4: 50
000767E5: 49
000767E6: 00
000767E7: FF
000767E8: 15
000767E9: D0
000767EA: 44
000767EB: 4D
000767EC: 00
000767ED: 85
000767EE: C0
000767EF: 75
000767F0: 0A
000767F1: 6A
000767F2: 04
000767F3: E8
000767F4: FB
000767F5: A4
000767F6: 02
000767F7: 00
000767F8: 83
000767F9: C4
000767FA: 04
000767FB: C3

It's simpler than it looks, really, as it's just shifting part of a function down three bytes and changing one operation. I just included the full difference for ease of copy and paste. I'll have some programs soon to automatically make the fixes.

-NStriker
 
Well, I've got the patchers made for both versions, if you want them. They're tiny, but I don't have any puplic place to store them.

And they may not be the final version I want to release into the wild because it seems the joystick isn't working in Win2K. At least my USB one isn't working with WC4, anyway. So, this is just for testers. I can e-mail or ICQ the file to ya.

-NStriker
"Ever feel like you're talking to yourself?"
 
gulikoza said:
edit: i just tried and the CD version is working normally in XP, without the compatibility set on, so I guess only the DVD version has this bug...

Ah, but there's a trick. WinXP knows about WC4 and automatically applied the compatibility fix when the exe is launched whether or not you have it set to Win95 or 98 compatibility mode. At least, I think that's what it does.

Anyway, the CD version crashes on VirtualProtect as well. I can try and start the exe for it even without it installed, because it bombs well before it realizes is doesn't have the resource files for the game.

-NStriker
 
Haven't really thought of that :). I've renamed the exe file and you're right, it fails on VirtualProtect() error...applied your fix and it works again :D. This might not be big news to people running XP, but those still on W2K this is life saving :cool:
 
Okay, anyone intersted in this fix can visit gulikoza's page. You'll find links in both his and my sig. My patches are tiny. Something like 2 Kilobytes when zipped. You'll find patches for WC4 DVD, the alternate WC4 DVD gulikoza came across in his efforts to get them working, WC4 CD, and WC3 Kilrathi Saga.

With this patch, not only do the games work in Windows 2000, but they should actually run in Windows XP without compatibility mode even on. I've taken care of the offending baddness. ;)

Oh, and remember to make sure your exe that's getting patched isn't set to read only. Obviously, the patch will fail. Other than that, just drop my patcher in the proper folder and run it.

A warning - While my fix is really a simple thing, I haven't done extensive testing. It shouldn't cause any problems, but let me know. WC3 locked up on me, for example, but I don't think it's actually related to my patch.
 
Very Nice, thanx for the effort...
Lemme ask you something; does this patch fix that strange crash in WC3 KS in WinXP, or is it just for the vanilla version? I found that for me it is enough to Alt+tab to task manager and set the thread priority to low, but that doesn't work for everyone (and is pretty annoying)...
 
Edfilho said:
Lemme ask you something; does this patch fix that strange crash in WC3 KS in WinXP, or is it just for the vanilla version? I found that for me it is enough to Alt+tab to task manager and set the thread priority to low, but that doesn't work for everyone (and is pretty annoying)...

The patch soley fixes the VirtualProtect crash that happens in the KS version when run under Win2K (or under WinXP if you were to rename the exe). However, I am investigating the WC3 lockups.

I have a bit more elegant method of doing the same thing you do. Setting the game to run in low priority has been the only way to get it to run. What I did was make a file called wc3.bat in the WC3 folder. In that file I placed the command "start wc3w.exe /low %1 %2 %3 %4" but without the quotes of course. Running that will start the game as low priority from the get go. The %1 etc are just there so that you can still send along command line options like -no_interlace.

I've noticed when I start up WC3 normally, without changing priority, the music stops after seeing the first in-game movie. For example, leaving the hanger and going to the room where Hobbes is standing at the start of the game. If the music stops, the game WILL freeze the next time you click on something. If you set priority to low, though, the music never stops. I have to wonder if they're related.
 
Hmm... Ya know what? Come to think of it, if I do the same thing to WC4 DVD (set it to low priority on start, that is) my joystick works. I hadn't yet been able to get it to, though others like gulikoza told me they haven't had any problems. I know the WC4 CD exe was detecting it, but not the WC4 DVD exe.

Curiouser and curiouser... The question is, of course, "why?"
 
I have systems set up to play these games, but patches are always great to have available. Good job, and thanks.
 
Gret work :)
I'll try out your wc3.bat + the fix for my WC3 KS as soon as I'm back at my uni-town (don't have my KS here in my hometown :( ) If this patch works for my PCs, too, there are real good chances that it'll work for nearly everyone, I'd say :D
 
Thanks for the heads up. That will aslo help me include the command line options I didn't know how. Thanx again!
 
I finally had enough time to test your patch (and the cds nearby ^^). And neither the patch itself nor the command lines helped me to stop the instability :( That's really too bad. - It freezes after the second movie ends, so if it helps preventing the music stopping, that doesn'T stop teh crashes for me :(
If you know something else what I could test, I would be willing to do so. - I really want to get this bug fixed...
 
Well, I've been meaning to muck around in the code for a while, but haven't gotten around to it. Work, the new Thief game, and upgrading all have me preoccupied. :)

I'll get back around to taking a wack at it eventually.
 
I've fiddled arround some more with my KS WC3 and found out the following:
- although I run your bat file, which sets gamepriority to low, Windows still runs it at High Priority
- Using windowed mode (like someone here or in another Thread suggested) also didn't help me
- Whenever I ALT-Tab, or Alt+Ctrl+Del to the Task Manager, the game will stop at the end of the current movie (so switching to low priority afterwards doesn't work for me)
- If the game stops at a certain point, and I don't reboot, it always stops there (for example: after the origin log)

I hope that'll help somehow...

Oh, and here is the link to the main Kilrathi WC3 XP bug Thread:
http://www.crius.net/zone/showthread.php?t=8912
 
wc4 (dos) using windows 2000 patch

ive been having video & sound skips after using windows 2000 since im using windows xp.

my email is williamsjensen2000@yahoo.com if you can send a file that will work.

thank you,

William
 
You'll probably need to email him. NStriker hasn't logged in in a couple months. A lot of Wing Commander games have problems in Windows 2000 that have not ever been solved. He probably doesn't have any files or patches more developed than the ones that are online, and it doesn't look like he really developed anything to overcome general skips and glitches.
 
Back
Top