Log to specific offset of a MEMORY_FILE?

Programming related discussions related to game research
happydance
Posts: 81
Joined: Sun Jul 10, 2016 11:07 am

Log to specific offset of a MEMORY_FILE?

Post by happydance »

Code: Select all

get NAME_SIZE long
GetDString F_NAME NAME_SIZE

goto 0x58
get OFFSET long
get TEX_SIZE long
goto 0x92
get TEX_ARCHIVE_NAME line

string TEXTURE p= "%s.tex.DDS" F_NAME
string TEX_ARCHIVE p= "%s." TEX_ARCHIVE_NAME

log MEMORY_FILE1 0 0
log MEMORY_FILE2 0 0

open FDSE TEXTURE 1
open FDSE TEX_ARCHIVE 2

get TEX_ARCHIVE_SIZE ASIZE 2
log MEMORY_FILE1 0 TEX_ARCHIVE_SIZE 2
log MEMORY_FILE2 0x80 TEX_SIZE 1

append 1
log MEMORY_FILE1 OFFSET TEX_SIZE MEMORY_FILE2
append

get SIZE ASIZE MEMORY_FILE1
log test.dat 0 SIZE MEMORY_FILE1


I'm having a problem with log MEMORY_FILE1 OFFSET TEX_SIZE MEMORY_FILE2

the MEMORY_FILE2 should contain the DDS texture without the header and I'm trying to inject it to MEMORY_FILE1 on a specific offset from the data gathered from open FDSE TEX_ARCHIVE 2

I don't know if it's possible since if I change the OFFSET to 0 it can inject it at the beginning or end depending on the direction of the append but not on a specific offset.

I may be approaching it wrong. I'm still a noob at this and any assistance is appreaciated.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Log to specific offset of a MEMORY_FILE?

Post by aluigi »

From what I can see from the script:
- get OFFSET and TEX_SIZE from the file
- copy TEX_SIZE data from offset 0x80 from the other file to memory
- copy TEX_SIZE data from offset OFFSET from the memory

I guess there is something wrong because memory has a size of TEX_SIZE so the only valid OFFSET is zero, any other number means that the memory file has a size of OFFSET+TEX_SIZE which is impossible.

If you want to copy data to a specific offset using "append 1" you just need to use Goto, for example:

Code: Select all

log MEMORY_FILE 0 TEX_ARCHIVE_SIZE
goto OFFSET MEMORY_FILE
append 1
log MEMORY_FILE1 0 TEX_SIZE MEMORY_FILE2
append 1