.xni decompiler [Star Wars TFU, "aCmp"]

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
cornel
Posts: 30
Joined: Sun Feb 25, 2018 4:27 pm

.xni decompiler [Star Wars TFU, "aCmp"]

Post by cornel »

Is there a tool that can decompile (Star Wars: The Force Unleashed) game .xni files?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: .xni decompiler [Star Wars TFU, "aCmp"]

Post by aluigi »

Info for other users, the file starts with "aCmp" and seems to contain a sort of uncompressed size 32bit field but the data in it is not really compressed due to the many duplicate and whole strings, probably it's an inefficient algorithm or the files are "compiled" from text to binary form.
I attached one of the samples.
cornel
Posts: 30
Joined: Sun Feb 25, 2018 4:27 pm

Re: .xni decompiler [Star Wars TFU, "aCmp"]

Post by cornel »

Also, in case it matters: the file was extracted (but not correctly or completely?) from an .lp game file with this script:

Code: Select all

# Star Wars The Force Unleashed PC / .lp extractor
# script for QuickBMS http://aluigi.org/papers.htm#quickbms

# OFFSET TABLE LAYOUT - SIZE=0x10
#
#   0x00 - FILE INDEX - 4
#    0x04 - FILE DATA OFFSET - 4
#   0x08 - ALWAYS 0 - 4
#   0x0C - ALWAYS 0 - 4

# INFO TABLE LAYOUT - SIZE=0x40
#
#   0x00 - UNKNOWN - 4
#   0x04 - UNKNOWN - 4
#   0x08 - ALWAYS 0 - 4
#   0x0C - UNKNOWN - 4
#   0x10 - UNKNOWN - 4
#   0x14 - NAME OFFSET - 4
#   0x18 - UNKNOWN - 4
#   0x1C - ALWAYS 0 - 4
#   0x20 - ALWAYS 0 - 4
#   0x24 - ALWAYS 0 - 4
#   0x28 - FILE SIZE - 4
#   0x2C - FILE SIZE CHECK? - 4
#   0x30 - ALWAYS 0 - 4
#   0x34 - UNKNOWN - 4
#   0x38 - ALWAYS 0 - 4
#   0x3C - ALWAYS 0 - 4

getdstring   IDSTRING      4
get      FILE_VERSION      long
get      NUM_FILES      long

get      UNKNOWN1      long # Seems to be always 0x00000000
get      UNKNOWN2      long # Seems to be always 0xFFFFFFFF
get      UNKNOWN3      long # Seems to be always 0x00000000


# The header seems to change depending of this value
# It seems to be the extra header size
# Default header size is 0x50, to get the correct offset for the name table, you have to do
# 0x50 + EXTRA_HEADER_SIZE

get      EXTRA_HEADER_SIZE   long
get      NAME_TABLE_SIZE      long
get      OFFSET_TABLE_OFF   long
get      DATA_OFF      long
get      UNKNOWN4      long
get      UNKNOWN5      long
get      DATA_OFF_2      long # Seems to be always the same value as DATA_OFF
get      WHOLE_FILE_SIZE      long # Seems to be the size of the whole file
get      UNKNOWN6      long # Seems to be always 0x00000000
get      UNKNOWN7      long # Seems to be always 0x00000000
get      UNKNOWN8      long # Seems to be always 0x00000000
get      DATA_OFF_3      long # Seems to be always the same value as DATA_OFF
get      WHOLE_FILE_SIZE_2   long # Seems to be always the same value as WHOLE_FILE_SIZE
get      UNKNOWN9      long # Seems to be always 0x00000000

set      NAME_TABLE_OFF      EXTRA_HEADER_SIZE
math      NAME_TABLE_OFF      += 0x50

set      INFO_TABLE_OFF      NAME_TABLE_OFF
math      INFO_TABLE_OFF      += NAME_TABLE_SIZE

########### FILE CHECKS ##############

if   IDSTRING != "kaPA"
      print "File type check error\nThis is not a SWTFU .lp file\n"
      cleanExit
endif

if   FILE_VERSION != 0x00000005
      print "File version is not supported!\nExpected version: 5\nThis version: %FILE_VERSION%\n"
      cleanExit
endif

if   WHOLE_FILE_SIZE != WHOLE_FILE_SIZE_2
      print "File size check error: %WHOLE_FILE_SIZE% - %WHOLE_FILE_SIZE_2%\n"
      cleanExit
endif

if   DATA_OFF != DATA_OFF_2
      print "Data offset check error: %DATA_OFF% - %DATA_OFF_2% - %DATA_OFF_3%\n"
      cleanExit
elseif   DATA_OFF != DATA_OFF_3
      print "Data offset check error: %DATA_OFF% - %DATA_OFF_2% - %DATA_OFF_3%\n"
      cleanExit
endif

########### EXTRACTION ###############

for   i = 0 < NUM_FILES
   
      set   FILE_INFO_POS      i
      math   FILE_INFO_POS      *= 0x40 # Size of INFO_TABLE struct for each file
      math   FILE_INFO_POS      += INFO_TABLE_OFF

      set   FILE_OFFSET_POS      i
      math   FILE_OFFSET_POS      *= 0x10 # Size of FILE_OFFSET struct for each file
      math   FILE_OFFSET_POS      += OFFSET_TABLE_OFF

      # GET FILE NAME

      set   TEMP_POS      FILE_INFO_POS
      math   TEMP_POS      += 0x14
     
      goto   TEMP_POS
      get   FILE_NAME_OFFSET   long
      math   FILE_NAME_OFFSET   += NAME_TABLE_OFF
     
      goto   FILE_NAME_OFFSET
      get   FILE_NAME      string

      # GET FILE SIZE
     
      set   TEMP_POS      FILE_INFO_POS
      math   TEMP_POS      += 0x28
   
      goto   TEMP_POS
      get   FILE_SIZE      long
     
      # GET FILE DATA

      set   TEMP_POS      FILE_OFFSET_POS
      math   TEMP_POS      += 0x04
     
      goto   TEMP_POS
      get   FILE_DATA_OFFSET   long
      math   FILE_DATA_OFFSET   += DATA_OFF

      # WRITE FILE

      log   FILE_NAME FILE_DATA_OFFSET FILE_SIZE

next i

######################################
(http://forum.xentax.com/viewtopic.php?p=33723#p33723 *edit by aluigi*)
cornel
Posts: 30
Joined: Sun Feb 25, 2018 4:27 pm

Re: .xni decompiler [Star Wars TFU, "aCmp"]

Post by cornel »

And this is the original lp file (with the xni file inside)...
cornel
Posts: 30
Joined: Sun Feb 25, 2018 4:27 pm

Re: .xni decompiler [Star Wars TFU, "aCmp"]

Post by cornel »

To clarify: the xni file is only partially decompiled and readable...