Page 2 of 8

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Thu Dec 01, 2011 3:38 am
by Axsis
As I promised, the unpacked UI.sb, with bundles, that needs further reversing and unpacking (but format is not very complicated at first look):
http://www.multiupload.com/KU6463PF11
BMS script is still buggy (bundles unpacking part is ok, but chunks unpacking isn't), so I'm not going to post it now. Maybe, if I finish it, I'll post it. :bleh:
A small bonus: http://www.multiupload.com/CT1O4ALM35
Convert it to .avi with eaconv.exe :wink:

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Sat Dec 03, 2011 8:19 pm
by OrangeC
Nice, can't wait for the final bms script!

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Fri Dec 09, 2011 12:20 am
by xpertvision
cant wait to start making mods dor NFS THE RUN

i need the .sb unpacker/repacker please

many thanks ;)

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Fri Dec 09, 2011 7:34 pm
by sarzamin
unpacker please

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 14, 2011 9:01 am
by REDZOEU
Hhhhmmm... if the unpacker is done... Will it extract car model and texture data(s)?
If it is possible, good :D. If we can also extract some dummies like headlight dummies, or wheel dummies (for wheel position), it'll be a hella nice work :)

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Thu Dec 15, 2011 9:33 am
by SnarbleBarb
Axsis how far did you get?

I wrote a python script using the libfb2 to dump out all of the vehicles... but I'm not sure what to do with the resulting files. Looking at them in a hex editor, they have all sorts of _c4/*** directory listings with blobs of binary. It kinda sounds like they combine all of the meshes, textures, and other parameters into these files. Any idea how to extract/unpack these resultant files into workable images and mesh files? I'd love to get some of these cars into GTA4, etc.

Code: Select all

from libfb2.sb import Bundle
import os
import shutil

dst = r'C:\Temp\NFS'
idx = 0

BUNDLE_PATH = r'C:\Program Files (x86)\Need for Speed The Run\Need for Speed The Run\Data\Win32\ShippingVehicles'
"BUNDLE_PATH = r'C:\Program Files (x86)\Need for Speed The Run\Need for Speed The Run\Data\Win32\_c4\Blueprint\Metadata\AllVehicles_BlueprintMDB'"

bundle = Bundle(BUNDLE_PATH)
total = len(bundle.bundle_files)

idx = 0

for items in bundle.iter_files():
    vehicle = bundle.get_file(items.id)
    fn = os.path.join(dst, items.id)
    directory = os.path.dirname(fn)
    if not os.path.isdir(directory):
        os.makedirs(directory)
    with open(fn, 'wb') as out:
        print 'Extracting %s % 8d Bytes (%d/%d)' % \
            (vehicle.id, vehicle.size, idx, total)
        shutil.copyfileobj(vehicle.open(), out)
    idx = idx + 1

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Tue Dec 20, 2011 10:43 pm
by sarzamin
Axsis,ANY NEWS?

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 12:37 am
by xpertvision
any new on this?

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 4:29 am
by Axsis
Ok, here is the script for unpacking chunks and bundles from toc+sb files.
Audio and video are stored in chunks, while textures, levels and cars geometry and other data are in bundles. There is no chunk filenames stored in .toc, only hashes, so extracted filenames will be like "1DBEAD526CD3C6A1652994ACAF4D3C76" - that's normal.
Bundles are unpacked with normal names like "Win32\_c4\ui\flow\graph\frontend\ferootgraph_resourcebundle". Any help on further bundle unpacking is welcomed.
Repacking using quickbms -r should work, but not throughly tested. (with standart repacking limitations like <= size of repacking file)
Use this script on original .toc file (not decrypted with bf3decrypt or any other tool).
Usually script finishes with error "incomplete input file number -1, can't read 1 bytes." - this is normal.

Code: Select all

Open FDDE SB 1
Get DICE_HDR long
If DICE_HDR == 0x00CED100
 Get TOC_SIZE asize
 Math TOC_SIZE -= 0x22C
 CallFunction DecryptTOC
 #Log "_decrypted.toc" 0 TOC_SIZE MEMORY_FILE
 CallFunction TOCParser
EndIf

##############################
StartFunction DecryptTOC
 FileXOR 0x7B
 Log MEMORY_FILE2 0x128 0x101
 FileXOR ""
 Log MEMORY_FILE 0x22C TOC_SIZE
 For I = 0 < TOC_SIZE
  Math J = I
  Math J %= 0x101
  GetVarChr KEY MEMORY_FILE2 J byte
  GetVarChr B MEMORY_FILE I byte
  Math B ^= KEY
  PutVarChr MEMORY_FILE I B byte
 Next I
EndFunction
##############################
StartFunction GetVLISize
Set SHIFT byte 0
Set ENTRYSIZE long 0
Do
 Get B byte MEMORY_FILE
 Math MSB = B
 Math B & 0x7F
 Math B < SHIFT
 Math SHIFT + 7
 Math ENTRYSIZE | B
 Math MSB > 7
While MSB == 1
EndFunction
##############################
StartFunction TOCParser
Math FFLAG = 0
Do
 Get TYPECODE byte MEMORY_FILE
 Math FLAGS = TYPECODE
 Math TYPECODE & 0x1F
 Math FLAGS > 5
 #Print "T:%TYPECODE% \t F:%FLAGS%"

 If FLAGS >= 4
  Set KEY string ""
 ElseIf TYPECODE == 0
  Set KEY string ""
 Else
  Get KEY string MEMORY_FILE
 EndIf

 If TYPECODE == 0 # Terminator
  Print "End of current LIST or ENTRY"
 ElseIf TYPECODE == 1 # List
  CallFunction GetVLISize 1
  Print "Start of LIST '%KEY%' with size = %ENTRYSIZE%"
  CallFunction TOCParser
 ElseIf TYPECODE == 2 # Entry
  CallFunction GetVLISize 1
  Print "Start of ENTRY '%KEY%' with size = %ENTRYSIZE%"
  CallFunction TOCParser
 ElseIf TYPECODE == 6 # Bool
  Get VALUE byte MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 7 # String
  Get STRLEN byte MEMORY_FILE
  GetDString VALUE STRLEN MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 8 # Int32
  Get VALUE long MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 9 # Int64
  Get VALUE longlong MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 15 # UUID
  Endian BIG
  Get HASH1 long MEMORY_FILE
  Get HASH2 long MEMORY_FILE
  Get HASH3 long MEMORY_FILE
  Get HASH4 long MEMORY_FILE
  Endian LITTLE
  String VALUE p= "%08X%08X%08X%08X" HASH1 HASH2 HASH3 HASH4
  Print " %KEY% = %VALUE%"
 Else
  Print "Unknown TYPECODE = %TYPECODE%"
  CleanExit
 EndIf
 
 If KEY == "id"
  Set FNAME string VALUE
  Math FFLAG | 1
 ElseIf KEY == "offset"
  Math FOFFSET = VALUE
  Math FFLAG | 2
 ElseIf KEY == "size"
  Math FSIZE = VALUE
  Math FFLAG | 4
 EndIf
 If FFLAG == 7
  #Print "%FNAME% %FOFFSET% %FSIZE%"
  Log FNAME FOFFSET FSIZE 1
  Math FFLAG = 0
 EndIf

While TYPECODE != 0
EndFunction
##############################

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 9:25 am
by nosfornos
ohh.
For now, I wait for progress.
Once the BMS Script used, then I think the best feeling.
Sorry in such poor English.

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 6:39 pm
by OrangeC
Thanks it worked!!

I found the filenames for the audio chunks in the Level SB files but as to how to get that out and match them is way out of my league.

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 6:47 pm
by michalss
Axsis wrote:Ok, here is the script for unpacking chunks and bundles from toc+sb files.
Audio and video are stored in chunks, while textures, levels and cars geometry and other data are in bundles. There is no chunk filenames stored in .toc, only hashes, so extracted filenames will be like "1DBEAD526CD3C6A1652994ACAF4D3C76" - that's normal.
Bundles are unpacked with normal names like "Win32\_c4\ui\flow\graph\frontend\ferootgraph_resourcebundle". Any help on further bundle unpacking is welcomed.
Repacking using quickbms -r should work, but not throughly tested. (with standart repacking limitations like <= size of repacking file)
Use this script on original .toc file (not decrypted with bf3decrypt or any other tool).
Usually script finishes with error "incomplete input file number -1, can't read 1 bytes." - this is normal.

Code: Select all

Open FDDE SB 1
Get DICE_HDR long
If DICE_HDR == 0x00CED100
 Get TOC_SIZE asize
 Math TOC_SIZE -= 0x22C
 CallFunction DecryptTOC
 #Log "_decrypted.toc" 0 TOC_SIZE MEMORY_FILE
 CallFunction TOCParser
EndIf

##############################
StartFunction DecryptTOC
 FileXOR 0x7B
 Log MEMORY_FILE2 0x128 0x101
 FileXOR ""
 Log MEMORY_FILE 0x22C TOC_SIZE
 For I = 0 < TOC_SIZE
  Math J = I
  Math J %= 0x101
  GetVarChr KEY MEMORY_FILE2 J byte
  GetVarChr B MEMORY_FILE I byte
  Math B ^= KEY
  PutVarChr MEMORY_FILE I B byte
 Next I
EndFunction
##############################
StartFunction GetVLISize
Set SHIFT byte 0
Set ENTRYSIZE long 0
Do
 Get B byte MEMORY_FILE
 Math MSB = B
 Math B & 0x7F
 Math B < SHIFT
 Math SHIFT + 7
 Math ENTRYSIZE | B
 Math MSB > 7
While MSB == 1
EndFunction
##############################
StartFunction TOCParser
Math FFLAG = 0
Do
 Get TYPECODE byte MEMORY_FILE
 Math FLAGS = TYPECODE
 Math TYPECODE & 0x1F
 Math FLAGS > 5
 #Print "T:%TYPECODE% \t F:%FLAGS%"

 If FLAGS >= 4
  Set KEY string ""
 ElseIf TYPECODE == 0
  Set KEY string ""
 Else
  Get KEY string MEMORY_FILE
 EndIf

 If TYPECODE == 0 # Terminator
  Print "End of current LIST or ENTRY"
 ElseIf TYPECODE == 1 # List
  CallFunction GetVLISize 1
  Print "Start of LIST '%KEY%' with size = %ENTRYSIZE%"
  CallFunction TOCParser
 ElseIf TYPECODE == 2 # Entry
  CallFunction GetVLISize 1
  Print "Start of ENTRY '%KEY%' with size = %ENTRYSIZE%"
  CallFunction TOCParser
 ElseIf TYPECODE == 6 # Bool
  Get VALUE byte MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 7 # String
  Get STRLEN byte MEMORY_FILE
  GetDString VALUE STRLEN MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 8 # Int32
  Get VALUE long MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 9 # Int64
  Get VALUE longlong MEMORY_FILE
  Print " %KEY% = %VALUE%"
 ElseIf TYPECODE == 15 # UUID
  Endian BIG
  Get HASH1 long MEMORY_FILE
  Get HASH2 long MEMORY_FILE
  Get HASH3 long MEMORY_FILE
  Get HASH4 long MEMORY_FILE
  Endian LITTLE
  String VALUE p= "%08X%08X%08X%08X" HASH1 HASH2 HASH3 HASH4
  Print " %KEY% = %VALUE%"
 Else
  Print "Unknown TYPECODE = %TYPECODE%"
  CleanExit
 EndIf
 
 If KEY == "id"
  Set FNAME string VALUE
  Math FFLAG | 1
 ElseIf KEY == "offset"
  Math FOFFSET = VALUE
  Math FFLAG | 2
 ElseIf KEY == "size"
  Math FSIZE = VALUE
  Math FFLAG | 4
 EndIf
 If FFLAG == 7
  #Print "%FNAME% %FOFFSET% %FSIZE%"
  Log FNAME FOFFSET FSIZE 1
  Math FFLAG = 0
 EndIf

While TYPECODE != 0
EndFunction
##############################
Hi thx for script. Does it also work for X360 version please ?

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 6:56 pm
by OrangeC
It works on both pc and 360.

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Wed Dec 21, 2011 9:03 pm
by michalss
does work for loc files :) but extracted text files are mess :(

Re: Need For Speed: The Run [.SB & .TOC]

Posted: Thu Dec 22, 2011 7:58 am
by TomWin
I'm glad that somebody figured out how to extract data from .SB and .TOC files.