VOGONS


First post, by murrayman

User metadata
Rank Member
Rank
Member

I have a copy of MechWarrior 2 v1.1 retail that works great on my Packard Bell with Win95 and behaves well with my gameport-based Microsoft Sidewinder Precision Pro - no issues at all at any time. But I like to run the S3 patch files to make the best use of my S3 Virge GX. While running with the patched files, I can't get the throttle to go to absolute zero or max, and once every so often, while loading a level, the game will report back with an error on my joystick - not a fatal one, just a program-specific prompt that says there's a problem with the connection to the joystick, where it lets me choose to disable and continue with just the keyboard / mouse or close the program. The error seems to be level-specific, or level-config specific at least; I haven't been able to pinpoint the issue with certainty yet. In any case, v1.1 of MechWarrior 2 patched the very issues I'm having while running the v1.0 S3 patch files. One of the files that you have to replace is Mw2.dll, which contains some very basic code for the joystick. Using Win95 Quick View, I can see the difference between the two files and the change that I need to make. Problem is, I have no way of editing the file - everything I use to open it with comes back with uncompiled code, or if I try to open it with Notepad, it says the file is too large. And I haven't been able to find someone who has properly modified an S3 Mw2.dll file with the joystick changes from the v1.1 Mw2.dll out in the wild, or vice versa; it would be easy enough to edit one or the other to give me both S3 API usage and a reliable joystick.

If it isn't clear already, I have no experience with coding. I may be stepping on a landmine here, I'm really not sure, because when I did a Google search on how to edit a .dll file, the consensus seemed to be that .dll files, especially of yore, are coded in C and can't be simply edited as compiled, legible code. Is this true or no?

P3B-F 1.04, PIII 1k, 512MB PC133, GF DDR 32MB + DM3DII 12MB SLI, SB0100
P3B-F 1.03, PIII 700, 384MB PC100, V5 AGP, SB0160
CP 5170, PII 350, 256MB PC100, Rage LT 2MB, ESS 1869
PB M S610, PMMX 233, 128MB EDO66, DM3D 4MB, Aztech

Reply 1 of 10, by cyclone3d

User metadata
Rank l33t++
Rank
l33t++

Get a hex editor program.... Such as hexedit32.

Yamaha modified setupds and drivers
Yamaha XG repository
YMF7x4 Guide
Aopen AW744L II SB-LINK

Reply 2 of 10, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

And yes, it's probably not going to work. You can't just throw stuff in a dll and expect it to work. You can change things (keeping in the constraints of the unchanged file) but adding is mostly not going to work.

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for macOS (10.4-11.x ppc/intel 32/64bit) notarized for gatekeeper

Reply 3 of 10, by derSammler

User metadata
Rank l33t
Rank
l33t

Compiled code can not be edited. While you can change the file using a hex editor, it won't allow much, as you can not add or remove stuff, only overwrite bytes that are already there. If you add or remove even a single byte, the code will break and crash. You need to decompile it, make the changes, and compile a new DLL. That's actually not that hard, but probably undoable if you have no experience with coding.

Reply 4 of 10, by SirNickity

User metadata
Rank Oldbie
Rank
Oldbie

I feel the advice above is ... basically true, but an over-simplification. Here's the long version:

First, the .DLL file is going to be some mixture of any or all of the following: Compiled code (ergo, machine code - presumably opcodes that the CPU will execute verbatime); Headers and other metadata that tell Windows how to load and use the .DLL; Resources like images, data blobs, icons, sounds, etc.; Strings of text -- either as inline data that is used in the code, or as tables of data that is referenced by the code.

The advice to the effect that "you can't modify a DLL" is true in that the file will have bits and pieces that are expected to be in a given place. If you move them (by inserting or deleting any bytes before that block of code), then pointers to that code will be "off" and end up pointing to whatever happens to be at that location in the file. Windows may still try to execute those incorrect regions as code, and it is very unlikely to end well. This is what people mean when they say you can edit stuff or change it, but not add or delete anything. In a visual sense, you have to remove a blue marble and replace it with a red marble. If you take a marble out, or put one in, then you've broken everything.

That still gives you some leeway, though. Often it's used to change text or other resources, but you can actually change code. It's not trivial, since you have to essentially look at the code as CPU op-codes and figure out what it's doing and how to modify it to do what you want. You can even replace whole sections, so long as any entrances and exits to/from that code still work afterward. Not for a beginner, for sure.

But, what you CAN do, even without being an x86 ASM guru, is replace values. Often these are single bytes, or 16- or 32-bit words, that contain either a number or a series of flag bits that will be stored in CPU registers, and/or passed to other functions. Sometimes that's all you need to do, and so long as the number or flag you need to express is the same size (# of bytes) as the one you need to replace, you're good to go. If the comparison you looked at between those two files was a couple bytes, you may be in luck. And, as long as you have a backup of the original files, there's no harm in trying. Worst that will happen is it locks up the computer and you have to reboot and undo your change.

A hex editor is the tool for the job. There are many. I used XVI32 in the past, but you have your pick of dozens. It simply lists the file as a linear block of bytes, typically with the left half shown as hexidecimal values between 00 and FF, and the right half as a textual representation of the same data. The right half just helps you see patterns, namely readable text which is nearly inscrutable when displayed as ASCII numeric values on the left. The editor will let you type over any value with another, without changing the total number of bytes in the file, and thus without breaking the expected offsets of all the code regions and other resources.

Reply 5 of 10, by murrayman

User metadata
Rank Member
Rank
Member

Thanks to all, and notably SirNickity for all the details! I do, in fact, just need to replace some values, not add or subtract data, so this at least gives me enough incentive to give it a shot! I’ll take a whack at it sometime soon and see what comes of it. 😀

P3B-F 1.04, PIII 1k, 512MB PC133, GF DDR 32MB + DM3DII 12MB SLI, SB0100
P3B-F 1.03, PIII 700, 384MB PC100, V5 AGP, SB0160
CP 5170, PII 350, 256MB PC100, Rage LT 2MB, ESS 1869
PB M S610, PMMX 233, 128MB EDO66, DM3D 4MB, Aztech

Reply 6 of 10, by Jo22

User metadata
Rank l33t++
Rank
l33t++
SirNickity wrote on 2020-02-25, 19:09:

A hex editor is the tool for the job. There are many. I used XVI32 in the past, but you have your pick of dozens.

I used that, too. It has an unusual feature - an option to fix the 200MHz speed bug in Turbo Pascal 7 (?) programs, as far as I remember.
However, it doesn't work so well at splitting/merging binary files into odd/even parts.
A feature that is sometimes required in order to use dumps to physically re-create a device's firmware chips.
WinHex is better suited for this, I guess. 😀

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 7 of 10, by SirNickity

User metadata
Rank Oldbie
Rank
Oldbie

Oh yeah, I think I remember seeing that TP fix option. Sign of the times in which it was written, I guess! Otherwise it is a little bare-bones, but lightweight and IIRC doesn't even need an installer, which is nice.

Most of the time now I use Okteta for KDE, or Norton Disk Edit in DOS. I don't have quite as much use for hex editors in Windows these days. 😀

Reply 8 of 10, by Anapan

User metadata
Rank Newbie
Rank
Newbie

I have used the win32 software ResEdit before for simple changes to dll files. It helped to sort blocks of data and made it easy to export, edit, then replace stuff.

norefuge7.png
attitude1.png