Skip to content

Commit

Permalink
Verify VDF
Browse files Browse the repository at this point in the history
  • Loading branch information
szapp committed Apr 6, 2021
1 parent 8c249a8 commit 6325417
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/data/io.asm
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ NINJA_PATH_IKARUSSRC db '\NINJA\_INTERN\IKARUS\IKARUS_G', g1g2('1','2'), '
NINJA_PATH_LEGOSRC db '\NINJA\_INTERN\LEGO\HEADER_G', g1g2('1','2'),'.SRC', 0
NINJA_MDS_PREFIX db 'ANIMS_', 0
NINJA_FILE db '\SYSTEM\NINJA.DLL', 0
NINJA_VDF_VERSION1 db 'PSVDSC_V2.00', 0xD, 0xA, 0xD, 0xA
NINJA_VDF_VERSION2 db 'PSVDSC_V2.00', 0xA, 0xD, 0xA, 0xD
NINJA_VDF_DIR_NAME db 'NINJA'
times 5 db ' '
26 changes: 26 additions & 0 deletions src/exec/createVdfArray.asm
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,30 @@ createVdfArray:
call _fread
add esp, 0x10

xor esi, esi
push 0x10 ; Verify VDF signature (G1)
lea eax, [esp+stackoffset+var_header+VDFheader.signature]
push eax
push NINJA_VDF_VERSION1
call _strncmp
add esp, 0xC
test eax, eax
jz .verifyEntrySize

push 0x10 ; Verify VDF signature (G2)
lea eax, [esp+stackoffset+var_header+VDFheader.signature]
push eax
push NINJA_VDF_VERSION2
call _strncmp
add esp, 0xC
test eax, eax
jnz .findClose

.verifyEntrySize:
mov eax, [esp+stackoffset+var_header+VDFheader.entrySize] ; Verify the VDF header entry size
cmp eax, 0x50
jnz .findClose

push SEEK_SET ; Start of in root directory of VDF map
push DWORD [esp+stackoffset+var_header+VDFheader.rootOffset]
push DWORD [esp+stackoffset+var_filehndl]
Expand Down Expand Up @@ -340,6 +364,8 @@ createVdfArray:
push DWORD [esp+stackoffset+var_root]
call operator_delete
add esp, 0x4

.findClose:
push DWORD [esp+stackoffset+var_filehndl]
call _fclose
add esp, 0x4
Expand Down

0 comments on commit 6325417

Please sign in to comment.