Skip to main content
GameDev.net gamedev.net
🔒 Locked

changing string literals in .exe

Started by szecs Jun 15, 2010 at 11:23 AM 13 replies 5.5k views
Original Post
szecs
szecs
Is it possible to change string literals in an .exe file?
I can change them if the replaced string has the same length as the replacing string. For example I can change "0123" to "blah", but if the strings differ in length, the .exe will have a runtime error (sorry, it's Hungarian, it's "invalid command" or something).

Is there a way or some editor to overcome this?
Before you ask: I want to hack my own program, because I don't have Borland C++ 2.0, or the necessary headers to rebuild the program, but I want to replace the Hungarian strings with English strings (ASCII, 16 bit, DOS). It's a finished game after all...
Antheus
Antheus
If strings are shorter, then it's fairly easy, just put a 0 at where it's supposed to end.

For longer, in a DOS app, it would require modifying assembly.

Anything is doable, people have modified far more complex things directly, it's might just be too much effort. It also depends on how exactly BC++ referenced these strings.
Nypyren
Nypyren
If it's a C/C++ exe, chances are the string literals are plain null-terminated strings like you'd expect anywhere else in C/C++.

If that's true, you can replace any of them (using a hexeditor or some other kind of binary file editor) with a string which has equal or lesser length as long as you put a new null-terminator on shorter strings.
Antheus
Antheus
Quote:
Original post by UltimaX
I have never tried it, but you could see if Resource Hacker works?
http://www.angusj.com/resourcehacker/

16-bit DOS applications don't have resources. Most of the time they are just an opaque blob of code mingled with data, since the OS didn't have concepts of relocation or other advanced concepts, so at best there would be some overlay files.

There's other issues, such as limits on continuous data of 64k, the overall <640k restrictions as well as many implicit assumptions on hardware and reliance on interrupts and BIOS.
szecs
szecs
Thanks for your replies so far.
Yes, there are no resources.

I know I can replace strings with shorter ones, but that's not always possible.
I thought that "readdressing" the stuff in the .exe, and modifying that table thingy in it is a straightforward thing. I mean I thought there's a simple tool for that. I'm searching on the net ATM, no luck yet.

Or is it a way, to emulate the DOS platform somehow in Visual studio? And get the used headers and libraries somehow (haven't found them).

Or maybe I could spend some euros on Borland C++ itself...
Antheus
Antheus
Quote:
Original post by szecs
I thought that "readdressing" the stuff in the .exe, and modifying that table thingy in it is a straightforward thing.

DOS executables do not have such tables.
szecs
szecs
Quote:
Original post by Antheus
Quote:
Original post by szecs
I thought that "readdressing" the stuff in the .exe, and modifying that table thingy in it is a straightforward thing.

DOS executables do not have such tables.


I think I mean relocation entries/tables. AFAIK exes have that, because they are bigger than 64k, so they need more than one pages on 16bit systems.
jwezorek
jwezorek
If you're dead set on some of the strings having english translations that are longer than the original strings, I'm wondering if it wouldn't be easier to port the entire application to SDL (or something).
nobodynews
nobodynews
Could you dissassemble the program, change the hardcoded strings to the new strings and then (re)assemble the program? If you only change hard-coded strings it shouldn't be too hard.
C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) ,
szecs
szecs
I want this stuff to be easy as possible. I took a look at the exe, I was happy that all string literals were in one place, so I thought I could simply change them, if not (because of the lengths) then there's a simple editor to do that. That's all.

I get Borland, get the libs, dig myself on the spaghetti hell (code) and recompile the stuff.
I don't think I'll have the mood to port it or something. I don't have the mood to learn SDL etc. It runs on XP just fine without DOS emulator.

Thanks for your replies.
szecs
szecs
Quote:
Original post by jwezorek
Quote:
Original post by szecs
I want this stuff to be easy as possible.

Then come up with english phrases that are shorter than the Hungarian. :)


Some quick Hungarian lecture:

on - be
off - ki
shoot - lő

Can't come up with shorter words for "off".
jwezorek
jwezorek
Quote:
Original post by szecs
Quote:
Original post by jwezorek
Quote:
Original post by szecs
I want this stuff to be easy as possible.

Then come up with english phrases that are shorter than the Hungarian. :)


Some quick Hungarian lecture:

on - be
off - ki
shoot - lő

Can't come up with shorter words for "off".


In context would yes and no make sense instead of on and off? Because then you can use Y and N or "OK" and "No". A two letter or less word for "shoot" is tough though -- don't think I can come up with one for that... Maybe "do" or "go"?
szecs
szecs
Quote:
Original post by jwezorek
Quote:
Original post by szecs
Quote:
Original post by jwezorek
Quote:
Original post by szecs
I want this stuff to be easy as possible.

Then come up with english phrases that are shorter than the Hungarian. :)


Some quick Hungarian lecture:

on - be
off - ki
shoot - lő

Can't come up with shorter words for "off".


In context would yes and no make sense instead of on and off? Because then you can use Y and N or "OK" and "No". A two letter or less word for "shoot" is tough though -- don't I can come up with one for that.
Thanks for your efforts, I have to get Borland C++ 2.0 somehow. (It appears to be harder than I expected.)

Or rewrite/port the stuff (*sigh*).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.