Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Need help with code

Featured Replies

  • Author
  • Localization

h3x3r, posted Fri Mar 18, 2022 5:56 pm (70584)


Hi there. I need your help guys. I mean you luigi.
I have this piece of code to parse file but i need to convert MATNAME long values to plain text and save as *.txt.
Output format should look like
Code:
0x13F610C6
0x0ABA20A8
and so on depends on MATCOUNT

and code
Code:
   if file_type == 25
      get SIZE long
      savepos OFFSET
      get MATCOUNT long
      math MATCOUNT - 2
      endian big
      get MDLHDRNAME long
         for i = 0 < MATCOUNT
            get MATNAME long
         next i
      endian little
      string NAME p "%s%s/%s/%d/0xx.mdlhdr_hdr" FNAME _unpacked Data file_type file_ID
      log NAME OFFSET SIZE

I tried slog but unsuccessfully. Maybe prinf function? Thanks in advance.
  • Author
  • Localization

spiritovod, posted Fri Mar 18, 2022 8:54 pm (70585)


I believe it's not an extremely casual task in quickbms, but you can use some workaround like the following one:
Code:
set TAB binary "\x0A"
set TMP string "0x"
log MEMORY_FILE2 0 0
math MEM = -2

for i = 0 < MATCOUNT
   getdstring MATNAME 4
   #string MATNAME r MATNAME # uncomment to swap endianness
   string MATNAME 0b MATNAME
   string BASE p "%s%s" TMP MATNAME
   putdstring BASE 10 MEM
   putct TAB string -1 MEM
next i

get SIZE asize MEM
log "output.txt" 0 SIZE MEM

You can set your own delimiter and prefix, and also change value endianness this way.
  • Author
  • Localization

h3x3r, posted Sat Mar 19, 2022 10:27 am (70601)


Thanks spirit it works like charm. But... it output only one file.
Here is whole code.
Code:
get FILES long
getdstring DUMMY 0x78

savepos TMP
math BASE_OFF = FILES
math BASE_OFF *= 10
math BASE_OFF = TMP
math BASE_OFF x= 8

for i = 0 < FILES

    get OFFSET long
   endian big
    get file_ID long
   endian little   
    get file_type byte
    get bComplex byte      
   string NAME p "%s%s/%s/%d/0xx.dat" FNAME _unpacked Data file_type file_ID
    math OFFSET *= 8
    math OFFSET = BASE_OFF
    savepos TMP
   goto OFFSET

   if file_type == 25
      get SIZE long
      savepos OFFSET
      get MATCOUNT long
      math MATCOUNT - 2
      set TAB binary "\x0A"
      set TMP string "0x"
      log MEMORY_FILE2 0 0
      math MEM = -2
      endian big
      get MDLHDRNAME long
         for i = 0 < MATCOUNT
            getdstring MATNAME 4
            #string MATNAME r MATNAME # uncomment to swap endianness
            string MATNAME 0b MATNAME
            string BASE p "%s%s" TMP MATNAME
            putdstring BASE 10 MEM
            putct TAB string -1 MEM
         next i
      endian little
      get SIZE asize MEM
      string NAME p "%s%s/%s/%d/0xx.txt" FNAME _unpacked Data file_type file_ID
      log NAME 0 SIZE MEM
   endif
    goto TMP
next i   


EDiT: Fixed. It was caused by set TMP string "0x" and string BASE p "%s%s" TMP MATNAME. Changed TMP to TMP0.
One more time thank you spirit.
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.