Help understanding file offset conversion to memory address.

This forum is for discussions on how to edit what can not be edited through the txt files, needless to say this isn't about battle net hacking.

Moderators: Nefarius, Havvoric

Post Reply
Death Maestro
Posts: 5
Joined: Sat Apr 17, 2021 9:13 pm
United States of America

Help understanding file offset conversion to memory address.

Post by Death Maestro » Sat Apr 17, 2021 9:28 pm

I've been studying ASM vigorously recently. I don't know how I found this link https://d2mods.info/resources/diablo_ii ... 0v2.01.htm on these forums, but it is extremely helpful.

In all of the snags that I've hit, I can't seem to understand this portion of the tutorial, though:
Regardless of which file offset is the start of code, once the module is loaded into memory the memory offset to start of code is always 1000h. So that file offset of 72E74 will become memory address 6FDC3A74.
I'm not sure how adding 1000h to 72E74 makes 6FDC3A74. Even with trying to convert each item to some different form. Part of my struggle is that the tutorial is written for patch 1.11 (or so) and I am learning with patch 1.13c. It was a struggle at first to find the addresses mentioned in the tutorial but I think I'm getting the hang of it. I'm hoping to document my unraveling's of the code via Wikidpad, good practice I guess 8-O

Thanks!

User avatar
kain_abel_666
Posts: 68
Joined: Fri Apr 03, 2020 12:13 pm
Location: Canada
Canada

Re: Help understanding file offset conversion to memory address.

Post by kain_abel_666 » Sat Apr 17, 2021 10:21 pm

So the 1000h is the header of the file which once loaded into memory you can't rewrite - that is just telling you where the editable portion starts. - the other digits come from where the file is loaded into memory. When attached to a running process of d2 or d2se you'll see in the executable modules window the memory location in which a specific dll is loaded in virtual memory.
I've stayed quite a while and heard what you have to say. Now it is time for the real Kain to emerge.

Death Maestro
Posts: 5
Joined: Sat Apr 17, 2021 9:13 pm
United States of America

Re: Help understanding file offset conversion to memory address.

Post by Death Maestro » Sat Apr 17, 2021 11:20 pm

Thanks for the response!

I think I've come to understand that the 1000h is the header of the file. What confuses me is that 1000h + 72E74 = 73E74, not 6FDC3A74.

What information am I missing?

Death Maestro
Posts: 5
Joined: Sat Apr 17, 2021 9:13 pm
United States of America

Re: Help understanding file offset conversion to memory address.

Post by Death Maestro » Sat Apr 17, 2021 11:25 pm

Maybe its not a direct addition? I believe though, in following the tutorial, that in order to find the 6FDC3A74 memory address I need to add the header to the file location. I want to do this so that I can figure out the memory address of the file location for patch 1.13c since the tutorial is using a different patch and I can't just search, or use the goto fuction. I have an idea to search for the specific string in Olly, but that is all I have right now.

Death Maestro
Posts: 5
Joined: Sat Apr 17, 2021 9:13 pm
United States of America

Re: Help understanding file offset conversion to memory address.

Post by Death Maestro » Mon Apr 19, 2021 12:45 pm

I figured out my confusion in the tutorial, although I am uncertain of the why behind it.

7DE74 + 1000h ≠ 6FDC3A74

Instead:

7DE74 + 1000h - 0400h + 6FD50000 = 6FDC3A74

This might seem a minimal confusion, especially since I've learned more about Olly and how to navigate these files, but my brain was stuck pretty bad.

Thanks for the replies! :mrgreen:

User avatar
kain_abel_666
Posts: 68
Joined: Fri Apr 03, 2020 12:13 pm
Location: Canada
Canada

Re: Help understanding file offset conversion to memory address.

Post by kain_abel_666 » Mon Apr 19, 2021 11:20 pm

Please do not double or triple post, next time edit your previous post with updated information.
I've stayed quite a while and heard what you have to say. Now it is time for the real Kain to emerge.

Death Maestro
Posts: 5
Joined: Sat Apr 17, 2021 9:13 pm
United States of America

Re: Help understanding file offset conversion to memory address.

Post by Death Maestro » Sat Apr 24, 2021 10:16 pm

Thank you, my apologies :)

Post Reply

Return to “Code Editing”