Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;/---------------------------------------------------------------------\
  2. ;|- Structures
  3. ;\---------------------------------------------------------------------/
  4. Structure Header
  5.   tmpByte.s[4]
  6.   tmpHex.s
  7.  
  8.   nameLength.b
  9.   nameString.s
  10.   productLength.b
  11.   productString.s
  12. EndStructure
  13.  
  14. Structure App
  15.   *tmpBuffer
  16.  
  17.   hFile.l
  18.   fOffset.i
  19.  
  20.   actualByte.b
  21.   lastByte.b
  22.   byteCount.i
  23.  
  24.   loopFinished.i
  25.  
  26.   Header.Header
  27. EndStructure
  28. Global App.App
  29.  
  30. ;/---------------------------------------------------------------------\
  31. ;|- Open file if possible
  32. ;\---------------------------------------------------------------------/
  33. App\hFile = OpenFile(#PB_Any, "mainData")
  34. If Not IsFile(App\hFile)
  35.   MessageRequester("Unity3D License Nullifier", "Can't open file 'mainData'", #MB_ICONERROR)
  36. EndIf
  37.  
  38. ;/---------------------------------------------------------------------\
  39. ;|- Get company name out of file header
  40. ;\---------------------------------------------------------------------/
  41.  
  42. ; Seek to right position
  43. App\fOffset = 36                          ; [OFFSET] 36 bytes
  44. FileSeek(App\hFile, App\fOffset)
  45.  
  46. ; Read 4 bytes
  47. App\Header\tmpByte[0] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  48. App\Header\tmpByte[1] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  49. App\Header\tmpByte[2] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  50. App\Header\tmpByte[3] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  51.  
  52. ; Generate hex string and detect company name length
  53. App\Header\tmpHex = "$"
  54. App\Header\tmpHex + App\Header\tmpByte[3]
  55. App\Header\tmpHex + App\Header\tmpByte[2]
  56. App\Header\tmpHex + App\Header\tmpByte[1]
  57. App\Header\tmpHex + App\Header\tmpByte[0]
  58. App\Header\nameLength = Val(App\Header\tmpHex)
  59.  
  60. ; Read out company name
  61. App\tmpBuffer = AllocateMemory(App\Header\nameLength)
  62. ReadData(App\hFile, App\tmpBuffer, App\Header\nameLength)
  63. App\Header\nameString = PeekS(App\tmpBuffer, App\Header\nameLength)
  64. FreeMemory(App\tmpBuffer)
  65.  
  66. ;/---------------------------------------------------------------------\
  67. ;|- Get product name out of file header
  68. ;\---------------------------------------------------------------------/
  69.  
  70. ; Seek to right position
  71. App\fOffset = 36                          ; [OFFSET] 36 bytes
  72. App\fOffset + 04                          ; [ADD] 4 bytes company name length
  73. App\fOffset + App\Header\nameLength       ; [ADD] ? bytes company name
  74. App\fOffset + 02                          ; [ADD] 2 empty bytes
  75.  
  76. FileSeek(App\hFile, App\fOffset)
  77.  
  78. ; Read 4 bytes
  79. App\Header\tmpByte[0] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  80. App\Header\tmpByte[1] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  81. App\Header\tmpByte[2] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  82. App\Header\tmpByte[3] = RSet(Str(ReadByte(App\hFile)), 2, "0")
  83.  
  84. ; Generate hex string and detect company name length
  85. App\Header\tmpHex = "$"
  86. App\Header\tmpHex + App\Header\tmpByte[3]
  87. App\Header\tmpHex + App\Header\tmpByte[2]
  88. App\Header\tmpHex + App\Header\tmpByte[1]
  89. App\Header\tmpHex + App\Header\tmpByte[0]
  90. App\Header\productLength = Val(App\Header\tmpHex)
  91.  
  92. ; Read out company name
  93. App\tmpBuffer = AllocateMemory(App\Header\productLength)
  94. ReadData(App\hFile, App\tmpBuffer, App\Header\productLength)
  95. App\Header\productString = PeekS(App\tmpBuffer, App\Header\productLength)
  96. FreeMemory(App\tmpBuffer)
  97.  
  98. ;/---------------------------------------------------------------------\
  99. ;|- Seek for scene header (128 times $FF)
  100. ;\---------------------------------------------------------------------/
  101.  
  102. App\loopFinished = #False
  103. Repeat
  104.   App\actualByte = ReadByte(App\hFile)
  105.   If App\actualByte = $FF
  106.     App\byteCount + 1
  107.     Debug App\byteCount
  108.   Else
  109.     App\byteCount = 0
  110.   EndIf
  111.   If App\byteCount = 128
  112.     Debug "Header found!"
  113.     App\loopFinished = #True
  114.   EndIf
  115. Until Eof(App\hFile) <> 0 Or App\loopFinished = #True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement