Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Pointer Hacking  (Read 1454 times)

Fenrir

  • Guest
Pointer Hacking
« on: February 04, 2008, 04:00:00 pm »

I'm working on a mod, and I would like to change the name of a workshop in dwarfort.exe. Unfortunately, the name I want to give it is a bit longer than the one it has. I've severely limited knowledge regarding hex editing, but from what I've heard I could do something with pointers somewhere to make this happen. If you understand what I'm saying, is there a way to do this?
Logged

Sean Mirrsen

  • Bay Watcher
  • Bearer of the Psionic Flame
    • View Profile
Re: Pointer Hacking
« Reply #1 on: February 04, 2008, 04:31:00 pm »

I don't know...

You could try disassembly...

Why'd you need to change a building's name, anyways?

Logged
Multiworld Madness Archive:
Game One, Discontinued at World 3.
Game Two, Discontinued at World 1.

"Europe has to grow out of the mindset that Europe's problems are the world's problems, but the world's problems are not Europe's problems."
- Subrahmanyam Jaishankar, Minister of External Affairs, India

Fenrir

  • Guest
Re: Pointer Hacking
« Reply #2 on: February 04, 2008, 04:37:00 pm »

I don't need to change it. Since I can only make reactions that take place in the smelter, I was going to change the name of it to something more general.

[ February 04, 2008: Message edited by: Fenrir ]

Logged

Fenrir

  • Guest
Re: Pointer Hacking
« Reply #3 on: February 04, 2008, 05:02:00 pm »

Okay, I dissasembled it. Holy carp, that's a lot of letters and numbers. I get that feeling that this is beyond me. I thought I could just find all the references to "Smelter", but I can't find the word "Smelter" anywhere, only "SMELTER".
Logged

Fenrir

  • Guest
Re: Pointer Hacking
« Reply #4 on: February 04, 2008, 05:37:00 pm »

Oh okay, I found the problem. I replaced the "Smelter" with the name I want, but that does me absolutely no good if I can't put this goddamn thing back together. How do I cram this 74,997 KB text file back into an exe? I suppose I'll need an assembler, right?
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Pointer Hacking
« Reply #5 on: February 04, 2008, 06:08:00 pm »

If your text has the same size it might work. But at this rate you'd better just edit the .exe with a hexeditor.
Logged

Fenrir

  • Guest
Re: Pointer Hacking
« Reply #6 on: February 04, 2008, 06:13:00 pm »

Will reassembling the disassembled dwarfort.exe be more work than disassembling it was?
Logged

Sean Mirrsen

  • Bay Watcher
  • Bearer of the Psionic Flame
    • View Profile
Re: Pointer Hacking
« Reply #7 on: February 04, 2008, 06:22:00 pm »

Exactly what are you using to disassemble?

edit: okay, if you fiddle with the data a bit, you can safely add two letters to "smelter". I successfully renamed it to "smelteror", for example. A bit more fiddling could, theoretically, add up to four more letters by moving the "farm plot" reference. I'm not very proficient in this thing myself. Only started a week or so ago, mostly to try and disable the world rejection.   :)

[ February 04, 2008: Message edited by: Sean Mirrsen ]

edit2: alright, "safely" was bit too optimistic of me. Hell if I know how to "safely" update the executable with the patches done by debugger. The "smelteror" example worked as long as it was temporary code change run through the debugger. When I overwrote the initial hex data with what I got, the "smelter" name disappeared entirely.  :)

[ February 04, 2008: Message edited by: Sean Mirrsen ]

Logged
Multiworld Madness Archive:
Game One, Discontinued at World 3.
Game Two, Discontinued at World 1.

"Europe has to grow out of the mindset that Europe's problems are the world's problems, but the world's problems are not Europe's problems."
- Subrahmanyam Jaishankar, Minister of External Affairs, India

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Pointer Hacking
« Reply #8 on: February 05, 2008, 12:16:00 am »

You can add some letters as long as the padding is right. The problem is that it's very likely that some parts of the source looks like:

#define SMELTER "smelter"

function(SMELTER, sizeof(SMELTER));

you'd have to update all the sizeof(SMELTER), which you have no insurance of finding automatically.

Logged

0x517A5D

  • Bay Watcher
  • Hex Editor‬‬
    • View Profile
Re: Pointer Hacking
« Reply #9 on: February 05, 2008, 01:42:00 am »

quote:
Originally posted by Fenrir:
<STRONG>Will reassembling the disassembled dwarfort.exe be more work than disassembling it was?</STRONG>

Oh God yes.  Don't even try it.

The assembler would need to make exactly the same decisions as the original compiler, for each instruction and each item of data.  Layout, alignment, instruction choice, jump distance, jump-table location, more.

It is, essentially, impossible to re-assemble a disassembly unless everything has been correctly figured out.

I did it once on a 10K executable.  10 kilobytes.  And it was hard.

Do not even attempt it.

Hexedits are the way.

Logged

Sean Mirrsen

  • Bay Watcher
  • Bearer of the Psionic Flame
    • View Profile
Re: Pointer Hacking
« Reply #10 on: February 05, 2008, 02:03:00 am »

I dunno, it worked alright through the ollydbg thing. I used some of the padding of the farm plot, and added two letters to the smelter (that has no excess padding) by starting the string entry two bytes prior to the original. There were only three references to the smelter string, so I shifted them by two bytes, and that seemed to work.

It did fail to work in normal conditions, though less spectacularly than I'd expect, but I intend to write it off to my inexperience, and the fact that Vista cannot read the supplied help file.

Logged
Multiworld Madness Archive:
Game One, Discontinued at World 3.
Game Two, Discontinued at World 1.

"Europe has to grow out of the mindset that Europe's problems are the world's problems, but the world's problems are not Europe's problems."
- Subrahmanyam Jaishankar, Minister of External Affairs, India

darkfred

  • Bay Watcher
    • View Profile
Re: Pointer Hacking
« Reply #11 on: February 05, 2008, 06:15:00 pm »

Dissassembly -> Patch/Reassembled executable requires Legendary skill in coding.

I have done this with some well understood small, 15 year old games.
DF on the other hand is a large, data driven modern application, (even if the graphics don't show it).
And perhaps worst than that it is written by a confessed non-pro. So even if you had the knowledge to understand a modern game in disassembly, it would be worthless.
And finally, Patching is frowned upon. Most disassembly and patching is done because the game is no longer working, and abandoned by the original developer. Toady is still trying to make this the best game possibly. As a game programmer I would find this insulting if it was done to my current project.

OTOH -
If you really want to learn to do this right, you need Ida (interactive disassembler). And a good working knowledge of what your own programs look like disassembled. The best way is to write a small game in C or C++ then disassemble it and try making changes. (Assuming you have real world experience with C and assembly, otherwise aim for fluent C and ASM programming first.)
Once you have this, changing strings, (yes to any arbitrary length even), becomes trivial. But logic will still require tedious hours of program diagramming.

[ February 05, 2008: Message edited by: darkfred ]

Logged

Hague

  • Bay Watcher
  • How do I shot web?
    • View Profile
Re: Pointer Hacking
« Reply #12 on: February 05, 2008, 06:19:00 pm »

Ah, can someone hex edit wooden blocks into wooden boards then? I never understood the idea of a wooden block floor... besides, they have the same number of characters so it should be relatively simple, yeah? :P
Logged

Sean Mirrsen

  • Bay Watcher
  • Bearer of the Psionic Flame
    • View Profile
Re: Pointer Hacking
« Reply #13 on: February 05, 2008, 06:30:00 pm »

Like I said elsewhere, I seek no easy route.  :)

And I don't intend to patch or hack anything permanently, I just want to experiment with generating a world that is otherwise impossible to get. So far I have failed miserably.  :) I've no idea what's the difference between JNB, JE, and some other conditional "jumps", or indeed what's the difference between "step in" and "step over" on the toolbar.  :p You could say I'm doing it for the fun of the challenge more than anything.

Logged
Multiworld Madness Archive:
Game One, Discontinued at World 3.
Game Two, Discontinued at World 1.

"Europe has to grow out of the mindset that Europe's problems are the world's problems, but the world's problems are not Europe's problems."
- Subrahmanyam Jaishankar, Minister of External Affairs, India

Fenrir

  • Guest
Re: Pointer Hacking
« Reply #14 on: February 05, 2008, 06:33:00 pm »

Okay, it's waaay to much work just to change a few letters. Thanks!
Logged
Pages: [1] 2