Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;/---------------------------------------------------------------------\
- ;|- Structures
- ;\---------------------------------------------------------------------/
- Structure Header
- tmpByte.s[4]
- tmpHex.s
- nameLength.b
- nameString.s
- productLength.b
- productString.s
- EndStructure
- Structure App
- *tmpBuffer
- hFile.l
- fOffset.i
- actualByte.b
- lastByte.b
- byteCount.i
- loopFinished.i
- Header.Header
- EndStructure
- Global App.App
- ;/---------------------------------------------------------------------\
- ;|- Open file if possible
- ;\---------------------------------------------------------------------/
- App\hFile = OpenFile(#PB_Any, "mainData")
- If Not IsFile(App\hFile)
- MessageRequester("Unity3D License Nullifier", "Can't open file 'mainData'", #MB_ICONERROR)
- EndIf
- ;/---------------------------------------------------------------------\
- ;|- Get company name out of file header
- ;\---------------------------------------------------------------------/
- ; Seek to right position
- App\fOffset = 36 ; [OFFSET] 36 bytes
- FileSeek(App\hFile, App\fOffset)
- ; Read 4 bytes
- App\Header\tmpByte[0] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[1] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[2] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[3] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- ; Generate hex string and detect company name length
- App\Header\tmpHex = "$"
- App\Header\tmpHex + App\Header\tmpByte[3]
- App\Header\tmpHex + App\Header\tmpByte[2]
- App\Header\tmpHex + App\Header\tmpByte[1]
- App\Header\tmpHex + App\Header\tmpByte[0]
- App\Header\nameLength = Val(App\Header\tmpHex)
- ; Read out company name
- App\tmpBuffer = AllocateMemory(App\Header\nameLength)
- ReadData(App\hFile, App\tmpBuffer, App\Header\nameLength)
- App\Header\nameString = PeekS(App\tmpBuffer, App\Header\nameLength)
- FreeMemory(App\tmpBuffer)
- ;/---------------------------------------------------------------------\
- ;|- Get product name out of file header
- ;\---------------------------------------------------------------------/
- ; Seek to right position
- App\fOffset = 36 ; [OFFSET] 36 bytes
- App\fOffset + 04 ; [ADD] 4 bytes company name length
- App\fOffset + App\Header\nameLength ; [ADD] ? bytes company name
- App\fOffset + 02 ; [ADD] 2 empty bytes
- FileSeek(App\hFile, App\fOffset)
- ; Read 4 bytes
- App\Header\tmpByte[0] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[1] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[2] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- App\Header\tmpByte[3] = RSet(Str(ReadByte(App\hFile)), 2, "0")
- ; Generate hex string and detect company name length
- App\Header\tmpHex = "$"
- App\Header\tmpHex + App\Header\tmpByte[3]
- App\Header\tmpHex + App\Header\tmpByte[2]
- App\Header\tmpHex + App\Header\tmpByte[1]
- App\Header\tmpHex + App\Header\tmpByte[0]
- App\Header\productLength = Val(App\Header\tmpHex)
- ; Read out company name
- App\tmpBuffer = AllocateMemory(App\Header\productLength)
- ReadData(App\hFile, App\tmpBuffer, App\Header\productLength)
- App\Header\productString = PeekS(App\tmpBuffer, App\Header\productLength)
- FreeMemory(App\tmpBuffer)
- ;/---------------------------------------------------------------------\
- ;|- Seek for scene header (128 times $FF)
- ;\---------------------------------------------------------------------/
- App\loopFinished = #False
- Repeat
- App\actualByte = ReadByte(App\hFile)
- If App\actualByte = $FF
- App\byteCount + 1
- Debug App\byteCount
- Else
- App\byteCount = 0
- EndIf
- If App\byteCount = 128
- Debug "Header found!"
- App\loopFinished = #True
- EndIf
- Until Eof(App\hFile) <> 0 Or App\loopFinished = #True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement