Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.98 KB | None | 0 0
  1. local byte = string.byte
  2. local sub = string.sub
  3. local fmt = string.format
  4. local chrr = string.char
  5. local fun = string.dump
  6. local cnc = table.concat
  7.  
  8. local ran = math.random
  9. local flo = math.floor
  10. local fxp = math.frexp
  11.  
  12. local env = getfenv
  13. local req = require
  14. local unp = unpack
  15. local pca = pcall
  16. local ass = assert
  17. local err = error
  18. local sele = select
  19. local pai = pairs
  20. local typ = type
  21.  
  22. local gmt = getmetatable
  23. local smt = setmetatable
  24.  
  25. local serialize
  26. local deserialize
  27. do
  28. if not fxp then
  29. local i, j, flo = math.log, math.abs, math.floor;
  30. local k = i(2)
  31. fxp = function(l)
  32. if l == 0 then
  33. return 0, 0
  34. end;
  35. local m = flo(i(j(l)) / k + 1)
  36. return l / 2 ^ m, m
  37. end
  38. end;
  39. local function n(...)
  40. return {
  41. ...
  42. }, sele("#", ...)
  43. end;
  44. local function o(l, p)
  45. return typ(l) ~= "number" or l < 1 or l > p or l ~= flo(l)
  46. end;
  47. local function q(l, r, s)
  48. ass(typ(l) == r, fmt(s, r))
  49. end;
  50. local t = false;
  51. local u;
  52. if math.typ then
  53. local v = math.typ;
  54. t = (function()
  55. local chrr = string.char;
  56. return function(w)
  57. local x = w < 0 and -(w + 1) or w;
  58. local y = x / 0x100000000000000;
  59. local z = x / 0x1000000000000 % 0x100;
  60. local A = x / 0x10000000000 % 0x100;
  61. local B = x / 0x100000000 % 0x100;
  62. local C = x / 0x1000000 % 0x100;
  63. local D = x / 0x10000 % 0x100;
  64. local E = x / 0x100 % 0x100;
  65. local F = x % 0x100;
  66. if w < 0 then
  67. y, z, A, B = 0xFF - y, 0xFF - z, 0xFF - A, 0xFF - B;
  68. C, D, E, F = 0xFF - C, 0xFF - D, 0xFF - E, 0xFF - F
  69. end;
  70. return chrr(212, y, z, A, B, C, D, E, F)
  71. end
  72. end)()
  73. u = function(l)
  74. return v(l) == 'integer'
  75. end
  76. else
  77. u = function(l)
  78. return flo(l) == l
  79. end
  80. end;
  81. local function G(w)
  82. if u(w) then
  83. if w <= 100 and w >= -27 then
  84. return chrr(w + 27)
  85. elseif w <= 8191 and w >= -8192 then
  86. w = w + 8192;
  87. return chrr(128 + flo(w / 0x100) % 0x100, w % 0x100)
  88. elseif t then
  89. return t(w)
  90. end
  91. end;
  92. local H = 0;
  93. if w < 0.0 then
  94. H = 0x80;
  95. w = -w
  96. end;
  97. local I, m = fxp(w)
  98. if I ~= I then
  99. return chrr(203, 0xFF, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  100. elseif I == 1 / 0 then
  101. if H == 0 then
  102. return chrr(203, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  103. else
  104. return chrr(203, 0xFF, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
  105. end
  106. end;
  107. m = m + 0x3FE;
  108. if m < 1 then
  109. I = I * 2 ^ (52 + m)
  110. m = 0
  111. else
  112. I = (I * 2 - 1) * 2 ^ 52
  113. end;
  114. return chrr(203, H + flo(m / 0x10), m % 0x10 * 0x10 + flo(I / 0x1000000000000), flo(I / 0x10000000000) % 0x100, flo(I / 0x100000000) % 0x100, flo(I / 0x1000000) % 0x100, flo(I / 0x10000) % 0x100, flo(I / 0x100) % 0x100, I % 0x100)
  115. end;
  116. local function J(K, L)
  117. local M = byte(K, L)
  118. if not M then
  119. err()
  120. end;
  121. if M < 128 then
  122. return M - 27, L + 1
  123. elseif M < 192 then
  124. local z = byte(K, L + 1)
  125. if not z then
  126. err()
  127. end;
  128. return z + 0x100 * (M - 128) - 8192, L + 2
  129. end;
  130. local y, z, A, B, C, D, E, F = byte(K, L + 1, L + 8)
  131. if not y or not z or not A or not B or not C or not D or not E or not F then
  132. err()
  133. end;
  134. if M == 212 then
  135. local N = y >= 128;
  136. if N then
  137. y, z, A, B = 0xFF - y, 0xFF - z, 0xFF - A, 0xFF - B;
  138. C, D, E, F = 0xFF - C, 0xFF - D, 0xFF - E, 0xFF - F
  139. end;
  140. local w = ((((((y * 0x100 + z) * 0x100 + A) * 0x100 + B) * 0x100 + C) * 0x100 + D) * 0x100 + E) * 0x100 + F;
  141. if N then
  142. return -w - 1, L + 9
  143. else
  144. return w, L + 9
  145. end
  146. end;
  147. if M ~= 203 then
  148. err()
  149. end;
  150. local H = y > 0x7F and -1 or 1;
  151. local m = y % 0x80 * 0x10 + flo(z / 0x10)
  152. local I = (((((z % 0x10 * 0x100 + A) * 0x100 + B) * 0x100 + C) * 0x100 + D) * 0x100 + E) * 0x100 + F;
  153. local w;
  154. if m == 0 then
  155. if I == 0 then
  156. w = H * 0.0
  157. else
  158. w = H * I / 2 ^ 52 * 2 ^ -1022
  159. end
  160. elseif m == 0x7FF then
  161. if I == 0 then
  162. w = H * 1 / 0
  163. else
  164. w = 0.0 / 0.0
  165. end
  166. else
  167. w = H * (1.0 + I / 2 ^ 52) * 2 ^ (m - 0x3FF)
  168. end;
  169. return w, L + 9
  170. end;
  171. do
  172. local P = {}
  173. local Q = {}
  174. local R = {}
  175. local S = {}
  176. local T = {}
  177. local U = {}
  178. local V = {}
  179. local W = {}
  180. local X = {}
  181. X["nil"] = function(l, Y, Z)
  182. Z[#Z + 1] = "\202"
  183. end;
  184. function X.number(l, Y, Z)
  185. Z[#Z + 1] = G(l)
  186. end;
  187. function X.boolean(l, Y, Z)
  188. Z[#Z + 1] = l and "\204" or "\205"
  189. end;
  190. function X.string(l, Y, Z)
  191. local _ = #Z;
  192. if Y[l] then
  193. Z[_ + 1] = "\208"
  194. Z[_ + 2] = G(Y[l])
  195. else
  196. Y[l] = Y[P]
  197. Y[P] = Y[P] + 1;
  198. Z[_ + 1] = "\206"
  199. Z[_ + 2] = G(#l)
  200. Z[_ + 3] = l
  201. end
  202. end;
  203. local function a0(l, Y, Z)
  204. local a1 = V[l]
  205. if a1 then
  206. Z[#Z + 1] = "\211"
  207. X[typ(a1)](a1, Y, Z)
  208. return true
  209. end;
  210. local a2 = gmt(l)
  211. local a3 = a2 and S[a2]
  212. if a3 then
  213. local a4 = Y[Q]
  214. if a4[l] then
  215. err()
  216. end;
  217. a4[l] = true;
  218. Z[#Z + 1] = "\209"
  219. X[typ(a3)](a3, Y, Z)
  220. local a5, p = n(T[a3](l))
  221. Z[#Z + 1] = G(p)
  222. for a6 = 1, p do
  223. local a7 = a5[a6]
  224. X[typ(a7)](a7, Y, Z)
  225. end;
  226. Y[l] = Y[P]
  227. Y[P] = Y[P] + 1;
  228. a4[l] = nil;
  229. return true
  230. end
  231. end;
  232. function X.userdata(l, Y, Z)
  233. if Y[l] then
  234. Z[#Z + 1] = "\208"
  235. Z[#Z + 1] = G(Y[l])
  236. else
  237. if a0(l, Y, Z) then
  238. return
  239. end;
  240. err()
  241. end
  242. end;
  243. function X.table(l, Y, Z)
  244. if Y[l] then
  245. Z[#Z + 1] = "\208"
  246. Z[#Z + 1] = G(Y[l])
  247. else
  248. if a0(l, Y, Z) then
  249. return
  250. end;
  251. Y[l] = Y[P]
  252. Y[P] = Y[P] + 1;
  253. local a8 = #l;
  254. local a2 = gmt(l)
  255. if a2 then
  256. Z[#Z + 1] = "\213"
  257. X.table(a2, Y, Z)
  258. else
  259. Z[#Z + 1] = "\207"
  260. end;
  261. Z[#Z + 1] = G(a8)
  262. for a6 = 1, a8 do
  263. local a9 = l[a6]
  264. X[typ(a9)](a9, Y, Z)
  265. end;
  266. local aa = 0;
  267. for ab in pai(l) do
  268. if o(ab, a8) then
  269. aa = aa + 1
  270. end
  271. end;
  272. Z[#Z + 1] = G(aa)
  273. for ab, a9 in pai(l) do
  274. if o(ab, a8) then
  275. X[typ(ab)](ab, Y, Z)
  276. X[typ(a9)](a9, Y, Z)
  277. end
  278. end
  279. end
  280. end;
  281. X["function"] = function(l, Y, Z)
  282. if Y[l] then
  283. Z[#Z + 1] = "\208"
  284. Z[#Z + 1] = G(Y[l])
  285. else
  286. if a0(l, Y, Z) then
  287. return
  288. end;
  289. Y[l] = Y[P]
  290. Y[P] = Y[P] + 1;
  291. local K = fun(l)
  292. Z[#Z + 1] = "\210"
  293. Z[#Z + 1] = G(#K)
  294. Z[#Z + 1] = K
  295. end
  296. end;
  297. X.cdata = function(l, Y, Z)
  298. if Y[l] then
  299. Z[#Z + 1] = "\208"
  300. Z[#Z + 1] = G(Y[l])
  301. else
  302. if a0(l, Y, #Z) then
  303. return
  304. end;
  305. err()
  306. end
  307. end;
  308. X.thread = function()
  309. err()
  310. end;
  311. local function ac(K, L, Y)
  312. local ad = byte(K, L)
  313. if not ad then
  314. return nil, L
  315. end;
  316. if ad < 128 then
  317. return ad - 27, L + 1
  318. elseif ad < 192 then
  319. local z = byte(K, L + 1)
  320. if not z then
  321. err()
  322. end;
  323. return z + 0x100 * (ad - 128) - 8192, L + 2
  324. elseif ad == 202 then
  325. return nil, L + 1
  326. elseif ad == 203 or ad == 212 then
  327. return J(K, L)
  328. elseif ad == 204 then
  329. return true, L + 1
  330. elseif ad == 205 then
  331. return false, L + 1
  332. elseif ad == 206 then
  333. local ae, af = J(K, L + 1)
  334. local ag = af + ae;
  335. if not(ae >= 0) then
  336. err()
  337. end;
  338. if #K < ag - 1 then
  339. err()
  340. end;
  341. local ah = sub(K, af, ag - 1)
  342. Y[#Y + 1] = ah;
  343. return ah, ag
  344. elseif ad == 207 or ad == 213 then
  345. local a2, ai, ag;
  346. local aj = {}
  347. Y[#Y + 1] = aj;
  348. ag = L + 1;
  349. if ad == 213 then
  350. a2, ag = ac(K, ag, Y)
  351. if typ(a2) ~= "table" then
  352. err()
  353. end
  354. end;
  355. ai, ag = J(K, ag)
  356. for a6 = 1, ai do
  357. local ak = ag;
  358. aj[a6], ag = ac(K, ag, Y)
  359. if ag == ak then
  360. err()
  361. end
  362. end;
  363. ai, ag = J(K, ag)
  364. for a6 = 1, ai do
  365. local ab, a9;
  366. local ak = ag;
  367. ab, ag = ac(K, ag, Y)
  368. if ag == ak then
  369. err()
  370. end;
  371. ak = ag;
  372. a9, ag = ac(K, ag, Y)
  373. if ag == ak then
  374. err()
  375. end;
  376. if ab == nil then
  377. err()
  378. end;
  379. aj[ab] = a9
  380. end;
  381. if a2 then
  382. smt(aj, a2)
  383. end;
  384. return aj, ag
  385. elseif ad == 208 then
  386. local al, ag = J(K, L + 1)
  387. return Y[al], ag
  388. elseif ad == 209 then
  389. local ai;
  390. local s, ag = ac(K, L + 1, Y)
  391. ai, ag = J(K, ag)
  392. local a5 = {}
  393. for a6 = 1, ai do
  394. local ak = ag;
  395. a5[a6], ag = ac(K, ag, Y)
  396. if ag == ak then
  397. err()
  398. end
  399. end;
  400. if not s or not U[s] then
  401. err()
  402. end;
  403. local aj = U[s](unp(a5))
  404. Y[#Y + 1] = aj;
  405. return aj, ag
  406. elseif ad == 211 then
  407. local am, ag = ac(K, L + 1, Y)
  408. if am == nil then
  409. err()
  410. end;
  411. local a1 = W[am]
  412. if a1 == nil then
  413. err()
  414. end;
  415. return a1, ag
  416. else
  417. err()
  418. end
  419. end;
  420. function serialize(...)
  421. local Y = {
  422. [P] = 1,
  423. [Q] = {}
  424. }
  425. local Z = {}
  426. for a6 = 1, sele("#", ...) do
  427. local l = sele(a6, ...)
  428. X[typ(l)](l, Y, Z)
  429. end;
  430. return cnc(Z)
  431. end;
  432. local function ao(ap)
  433. return smt({}, {
  434. __newindex = function(aq, aq, a9)
  435. ap:write(a9)
  436. end
  437. })
  438. end;
  439. local function ar(as, at, ...)
  440. local ap, au = io.open(as, at)
  441. ass(ap, au)
  442. local Y = {
  443. [P] = 1,
  444. [Q] = {}
  445. }
  446. local Z = ao(ap)
  447. for a6 = 1, sele("#", ...) do
  448. local l = sele(a6, ...)
  449. X[typ(l)](l, Y, Z)
  450. end;
  451. ap:flush()
  452. ap:close()
  453. end;
  454. local function av(as, ...)
  455. return ar(as, "wb", ...)
  456. end;
  457. local function aw(as, ...)
  458. return ar(as, "ab", ...)
  459. end;
  460. function deserialize(K, L)
  461. ass(typ(K) == "string")
  462. local ay = {}
  463. L = L or 1;
  464. local Y = {}
  465. local p = 0;
  466. local az;
  467. while true do
  468. local ag;
  469. az, ag = ac(K, L, Y)
  470. if ag > L then
  471. p = p + 1;
  472. ay[p] = az;
  473. L = ag
  474. else
  475. break
  476. end
  477. end;
  478. return ay, p
  479. end;
  480. local function aA(K, w, L)
  481. ass(typ(K) == "string")
  482. w = w or 1;
  483. ass(typ(w) == "number")
  484. ass(w > 0 and flo(w) == w)
  485. local ay = {}
  486. L = L or 1;
  487. local Y = {}
  488. local p = 0;
  489. local az;
  490. while p < w do
  491. local ag;
  492. az, ag = ac(K, L, Y)
  493. if ag > L then
  494. p = p + 1;
  495. ay[p] = az;
  496. L = ag
  497. else
  498. break
  499. end
  500. end;
  501. ay[p + 1] = L;
  502. return unp(ay, 1, w + 1)
  503. end;
  504. local function aB(as)
  505. local ap, au = io.open(as, "rb")
  506. ass(ap, au)
  507. local K = ap:read("*all")
  508. ap:close()
  509. return deserialize(K)
  510. end;
  511. local function aC(aD, s)
  512. q(s, "string", "name")
  513. ass(not V[aD])
  514. ass(not W[s], fmt(s))
  515. W[s] = aD;
  516. V[aD] = s;
  517. return aD
  518. end;
  519. local function aE(s)
  520. q(s, "string", "name")
  521. ass(W[s], fmt("Resource %q does not exist.", s))
  522. local aD = W[s]
  523. W[s] = nil;
  524. V[aD] = nil;
  525. return aD
  526. end;
  527. local function aF(aG)
  528. local aj = {}
  529. for a6 = 1, #aG do
  530. aj[a6] = aG[a6]
  531. end;
  532. local aH = {}
  533. for ab in pai(aG) do
  534. if o(ab, #aG) then
  535. aH[#aH + 1] = ab
  536. end
  537. end;
  538. table.sort(aH)
  539. for a6 = 1, #aH do
  540. local s = aH[a6]
  541. aj[#aj + 1] = {
  542. s,
  543. aF(aG[s])
  544. }
  545. end;
  546. return aj
  547. end;
  548. local function aI(aJ, aK, l, p)
  549. local aL = {}
  550. local aM = 0;
  551. for ab, a9 in pai(l) do
  552. aL[ab] = a9;
  553. aM = aM + 1
  554. end;
  555. for a6 = 1, #aJ do
  556. local s;
  557. if typ(aJ[a6]) == "table" then
  558. s = aJ[a6][1]
  559. p = aI(aJ[a6][2], aK, l[s], p)
  560. else
  561. s = aJ[a6]
  562. p = p + 1;
  563. aK[p] = l[aJ[a6]]
  564. end;
  565. if aL[s] ~= nil then
  566. aM = aM - 1;
  567. aL[s] = nil
  568. end
  569. end;
  570. if aM > 0 then
  571. aK[p + 1] = aL
  572. else
  573. aK[p + 1] = nil
  574. end;
  575. return p + 1
  576. end;
  577. local function aN(aj, aJ, aO, aP)
  578. for a6 = 1, #aJ do
  579. local s = aJ[a6]
  580. if typ(s) == "table" then
  581. local aQ = {}
  582. aj[s[1]] = aQ;
  583. aP = aN(aQ, s[2], aO, aP)
  584. else
  585. aj[s] = aO[aP]
  586. aP = aP + 1
  587. end
  588. end;
  589. local aL = aO[aP]
  590. if aL then
  591. for ab, a9 in pai(aL) do
  592. aj[ab] = a9
  593. end
  594. end;
  595. return aP + 1
  596. end;
  597. local function aR(aS, aG)
  598. return function(l)
  599. local aK = {}
  600. local p = aI(aG, aK, l, 0)
  601. return unp(aK, 1, p)
  602. end, function(...)
  603. local aj = {}
  604. local a5 = {
  605. ...
  606. }
  607. aN(aj, aG, a5, 1)
  608. return smt(aj, aS)
  609. end
  610. end;
  611. local function aT(aS, s, serialize, deserialize)
  612. if typ(aS) == "table" then
  613. s = s or aS.name;
  614. serialize = serialize or aS._serialize;
  615. deserialize = deserialize or aS._deserialize;
  616. if not serialize or not deserialize then
  617. if aS._template then
  618. local ad = aF(aS._template)
  619. serialize, deserialize = aR(aS, ad)
  620. else
  621. aC(aS, s)
  622. return
  623. end
  624. end
  625. elseif typ(aS) == "string" then
  626. s = s or aS
  627. end;
  628. q(s, "string", "name")
  629. q(serialize, "function")
  630. q(deserialize, "function")
  631. ass(not S[aS] and not V[aS])
  632. ass(not R[s] and not W[s])
  633. R[s] = aS;
  634. S[aS] = s;
  635. T[s] = serialize;
  636. U[s] = deserialize;
  637. return aS
  638. end;
  639. local function aU(aV)
  640. local s, aS;
  641. if typ(aV) == "string" then
  642. s, aS = aV, R[aV]
  643. else
  644. s, aS = S[aV], aV
  645. end;
  646. q(s, "string", "name")
  647. R[s] = nil;
  648. if aS then
  649. V[aS] = nil;
  650. S[aS] = nil
  651. end;
  652. T[s] = nil;
  653. U[s] = nil;
  654. W[s] = nil;
  655. return aS
  656. end;
  657. local function aW(aX, s)
  658. s = s or aX.name;
  659. if aX.__instanceDict then
  660. aT(aX.__instanceDict, s)
  661. else
  662. aT(aX, s)
  663. end;
  664. return aX
  665. end;
  666. end
  667. end
  668.  
  669. local bit = bit or bit32 or req('bit')
  670. local rshift = bit.rshift
  671. local lshift = bit.lshift
  672. local band = bit.band
  673.  
  674. local function run(bytecode)
  675. local stm_lua_bytecode
  676. local wrap_lua_func
  677. local decode
  678. env = env()
  679.  
  680. local function rd_int_basic(src, s, e, d)
  681. local num = 0x0
  682. for i = s, e, d do
  683. num = num + byte(src, i, i) * (0xFF + 0x1) ^ (i - s)
  684. end
  685. return num
  686. end
  687.  
  688. local function rd_flt_basic(f1, f2, f3, f4)
  689. local sign = rshift(f4, 0x7)
  690. local exp = rshift(f3, 0x7) + lshift(band(f4, 0x7F), 0x1)
  691. local frac = f1 + lshift(f2, 0x8) + lshift(band(f3, 0x7F), 16)
  692. local normal = 0x1
  693. if exp == 0x0 then
  694. if frac == 0x0 then
  695. return 0x0
  696. else
  697. normal = 0x0
  698. exp = 0x1
  699. end
  700. elseif exp == 0x7F then
  701. if frac == 0x0 then
  702. return sign * (0x1 / 0x0)
  703. else
  704. return sign * (0x0 / 0x0)
  705. end
  706. end
  707. return -0x1 ^ sign * 0x2 ^ (exp - 127) * (0x1 + normal / 0x2 ^ 23)
  708. end
  709.  
  710. local function rd_dbl_basic(f1, f2, f3, f4, f5, f6, f7, f8)
  711. local sign = rshift(f8, 0x7)
  712. local exp = lshift(band(f8, 0x7F), 0x4) + rshift(f7, 0x4)
  713. local frac = band(f7, 0x0F) * 0x2 ^ 48
  714. local normal = 0x1
  715. frac = frac + (f6 * 0x2 ^ 40) + (f5 * 0x2 ^ 32) + (f4 * 0x2 ^ 24) + (f3 * 0x2 ^ 16) + (f2 * 0x2 ^ 0x8) + f1
  716. if exp == 0x0 then
  717. if frac == 0x0 then
  718. return 0x0
  719. else
  720. normal = 0x0
  721. exp = 0x1
  722. end
  723. elseif exp == 0x7FF then
  724. if frac == 0x0 then
  725. return sign * (0x1 / 0x0)
  726. else
  727. return sign * (0x0 / 0x0)
  728. end
  729. end
  730. return -0x1 ^ sign * 0x2 ^ (exp - 1023) * (normal + frac / 0x2 ^ 52)
  731. end
  732.  
  733. local function rd_int_le(src, s, e)
  734. return rd_int_basic(src, s, e - 0x1, 0x1)
  735. end
  736.  
  737. local function rd_int_be(src, s, e)
  738. return rd_int_basic(src, e - 0x1, s, -0x1)
  739. end
  740.  
  741. local function rd_flt_le(src, s)
  742. return rd_flt_basic(byte(src, s, s + 0x3))
  743. end
  744.  
  745. local function rd_flt_be(src, s)
  746. local f1, f2, f3, f4 = byte(src, s, s + 0x3)
  747. return rd_flt_basic(f4, f3, f2, f1)
  748. end
  749.  
  750. local function rd_dbl_le(src, s)
  751. return rd_dbl_basic(byte(src, s, s + 0x7))
  752. end
  753.  
  754. local function rd_dbl_be(src, s)
  755. local f1, f2, f3, f4, f5, f6, f7, f8 = byte(src, s, s + 0x7)
  756. return rd_dbl_basic(f8, f7, f6, f5, f4, f3, f2, f1)
  757. end
  758.  
  759. local float_types = {
  760. [0x4] = {
  761. little = rd_flt_le,
  762. big = rd_flt_be
  763. },
  764. [0x8] = {
  765. little = rd_dbl_le,
  766. big = rd_dbl_be
  767. }
  768. }
  769.  
  770. local function stm_byte(S)
  771. local idx = S.b
  772. local bt = byte(S.a, idx, idx)
  773.  
  774. S.b = idx + 0x1
  775. return bt
  776. end
  777.  
  778. local function stm_string(S, len)
  779. local pos = S.b + len
  780. local str = sub(S.a, S.b, pos - 0x1)
  781.  
  782. S.b = pos
  783. return str
  784. end
  785.  
  786. local function stm_lstring(S)
  787. local len = S:s_szt()
  788. local str
  789.  
  790. if len ~= 0x0 then
  791. str = sub(stm_string(S, len), 0x1, -0x2)
  792. end
  793.  
  794. return str
  795. end
  796.  
  797. local function cst_int_rdr(len, func)
  798. return function(S)
  799. local pos = S.b + len
  800. local int = func(S.a, S.b, pos)
  801. S.b = pos
  802.  
  803. return int
  804. end
  805. end
  806.  
  807. local function cst_flt_rdr(len, func)
  808. return function(S)
  809. local flt = func(S.a, S.b)
  810. S.b = S.b + len
  811.  
  812. return flt
  813. end
  814. end
  815.  
  816. local function stm_instructions(S)
  817. local size = S:s_int()
  818. local code = {}
  819. local types = {}
  820. local modes = {}
  821. do
  822. for i = 0x1, 37 do
  823. types[i] = 0x1
  824. end
  825. for i = 0x1, 37 do
  826. modes[i] = {0x5}
  827. end
  828. for i = 12, 17 do
  829. modes[i] = {0x4}
  830. end
  831. types[0x1] = 0x3
  832. types[0x5] = 0x3
  833. types[0x7] = 0x3
  834. types[36] = 0x3
  835. types[22] = 0x1
  836. types[31] = 0x1
  837. types[32] = 0x1
  838. modes[0x1] = {0x4}
  839. modes[0x5] = {0x4}
  840. modes[0x6] = {0x5, 0x4}
  841. modes[0x7] = {0x4}
  842. modes[0x9] = {0x4}
  843. modes[11] = {0x5, 0x4}
  844. modes[23] = {0x4}
  845. modes[24] = {0x4}
  846. modes[25] = {0x4}
  847. end
  848. for i = 0x1, size do
  849. local ins = S:s_ins()
  850. local lIiliiI = band(ins, 0x3F)
  851. local args = types[lIiliiI]
  852. local mode = modes[lIiliiI]
  853. local data = {
  854. iIIiiilliIliiI = ins,
  855. lIiliiI = lIiliiI,
  856. illliiliiI = band(rshift(ins, 0x6), 0xFF)
  857. }
  858. if args == 0x1 then
  859. data.B = band(rshift(ins, 23), 0x1FF)
  860. data.C = band(rshift(ins, 14), 0x1FF)
  861. data.lIIIIlIIiIllii = mode[0x1] == 0x4 and data.B > 0xFF
  862. data.IliiIll = mode[0x2] == 0x4 and data.C > 0xFF
  863. elseif args == 0x3 then
  864. data.Bx = band(rshift(ins, 14), 0x3FFFF)
  865. data.liliIlIliI = mode[0x1] == 0x4
  866. elseif args == 0x1 then
  867. data.sBx = band(rshift(ins, 14), 0x3FFFF) - 131071
  868. end
  869.  
  870. code[i] = data
  871. end
  872.  
  873. return code
  874. end
  875.  
  876. local function stm_constants(S)
  877. local size = S:s_int()
  878. local consts = {}
  879.  
  880. for i = 0x1, size do
  881. local tt = stm_byte(S)
  882. local k
  883.  
  884. if tt == 0x1 then
  885. k = stm_byte(S) ~= 0x0
  886. elseif tt == 0x3 then
  887. k = S:s_num()
  888. elseif tt == 0x4 then
  889. k = stm_lstring(S)
  890. end
  891.  
  892. consts[i] = k
  893. end
  894.  
  895. return consts
  896. end
  897.  
  898. local function stm_subfuncs(S, src)
  899. local size = S:s_int()
  900. local sub = {}
  901.  
  902. for i = 0x1, size do
  903. sub[i] = deserialize(decode(S, src)[0x1])
  904. end
  905.  
  906. return sub
  907. end
  908.  
  909. local function stm_lineinfo(S)
  910. local size = S:s_int()
  911. local c = {}
  912.  
  913. for i = 0x1, size do
  914. c[i] = S:s_int()
  915. end
  916.  
  917. return c
  918. end
  919.  
  920. local function stm_locvars(S)
  921. local size = S:s_int()
  922. local locvars = {}
  923.  
  924. for i = 0x1, size do
  925. locvars[i] = {
  926. varname = stm_lstring(S),
  927. startpc = S:s_int(),
  928. endpc = S:s_int()
  929. }
  930. end
  931.  
  932. return locvars
  933. end
  934.  
  935. local function stm_upvals(S)
  936. local size = S:s_int()
  937. local h = {}
  938.  
  939. for i = 0x1, size do
  940. h[i] = stm_lstring(S)
  941. end
  942.  
  943. return h
  944. end
  945.  
  946. function decode(S, psrc)
  947. local proto = {}
  948. local src = stm_lstring(S) or psrc
  949. proto.iiiIlII = src
  950. S:s_int()
  951. S:s_int()
  952. proto.iIlllIIIiII = stm_byte(S)
  953. proto.iIlllIIIiII = stm_byte(S)
  954. stm_byte(S)
  955. stm_byte(S)
  956. proto.f = stm_instructions(S)
  957. proto.IilIllliiII = stm_constants(S)
  958. proto.d = stm_subfuncs(S, src)
  959. proto.c = stm_lineinfo(S)
  960.  
  961. stm_locvars(S)
  962. stm_upvals(S)
  963.  
  964. for _, v in ipairs(proto.f) do
  965. if v.liliIlIliI then
  966. v.IilIllliiII = proto.IilIllliiII[v.Bx + 0x1]
  967. else
  968. if v.lIIIIlIIiIllii then
  969. v.const_B = proto.IilIllliiII[v.B - 0xFF]
  970. end
  971.  
  972. if v.IliiIll then
  973. v.const_C = proto.IilIllliiII[v.C - 0xFF]
  974. end
  975. end
  976. end
  977.  
  978. return serialize(proto)
  979. end
  980.  
  981. function stm_lua_bytecode(src)
  982. local rdr_func
  983.  
  984. local little
  985. local size_int
  986. local size_szt
  987. local size_ins
  988. local size_num
  989. local flag_int
  990.  
  991. local stream = {
  992. b = 0x1,
  993. a = src
  994. }
  995.  
  996. ass(stm_string(stream, 0x4) == '\27Lua', 'Lua bytecode expected')
  997. ass(stm_byte(stream) == 0x51, 'Only Lua 5.1 supported')
  998. ass(stm_byte(stream) == 0x0, 'Invalid Lua format')
  999.  
  1000. little = stm_byte(stream) ~= 0x0
  1001. size_int = stm_byte(stream)
  1002. size_szt = stm_byte(stream)
  1003. size_ins = stm_byte(stream)
  1004. size_num = stm_byte(stream)
  1005. flag_int = stm_byte(stream) ~= 0x0
  1006.  
  1007. rdr_func = little and rd_int_le or rd_int_be
  1008. stream.s_int = cst_int_rdr(size_int, rdr_func)
  1009. stream.s_szt = cst_int_rdr(size_szt, rdr_func)
  1010. stream.s_ins = cst_int_rdr(size_ins, rdr_func)
  1011.  
  1012. if flag_int then
  1013. stream.s_num = cst_int_rdr(size_num, rdr_func)
  1014. elseif float_types[size_num] then
  1015. stream.s_num = cst_flt_rdr(size_num, float_types[size_num][little and 'little' or 'big'])
  1016. else
  1017. err()
  1018. end
  1019.  
  1020. return decode(stream, 0x1)
  1021. end
  1022.  
  1023. local function close_lua_upiIIiiilliIliiIs(list, b)
  1024. for i, uv in pai(list) do
  1025. if i <= b then
  1026. uv.iIIiiilliIliiI = uv.store[uv.b]
  1027. uv.store = uv
  1028. list[i] = nil
  1029. end
  1030. end
  1031. end
  1032.  
  1033. local function lIiliiIen_lua_upiIIiiilliIliiI(list, b, x)
  1034. local prev = list[b]
  1035.  
  1036. if not prev then
  1037. prev = {
  1038. b = b,
  1039. store = x
  1040. }
  1041. list[b] = prev
  1042. end
  1043.  
  1044. return prev
  1045. end
  1046.  
  1047. local function wrap_lua_variadic(...)
  1048. return select('#', ...), {
  1049. ...
  1050. }
  1051. end
  1052.  
  1053. local function on_lua_error(exst, erro)
  1054. local src = ran(0x1, 25)
  1055. local line = exst.c[exst.pc - 0x1]
  1056. local psrc, pline, pmsg = erro:match('^(.-):(%d+):%s+(.+)')
  1057. local gmtt = '%s:%i: [%s:%i] %s'
  1058.  
  1059. line = line or '0'
  1060. psrc = psrc or '?'
  1061. pline = pline or '0'
  1062. pmsg = pmsg or erro
  1063. err(fmt(gmtt, src, line, psrc, pline, pmsg), 0x0)
  1064. end
  1065.  
  1066. local function exec_lua_func(exst)
  1067. local code = exst.f
  1068. local d = exst.d
  1069. local env = exst.g
  1070. local upvs = exst.h
  1071. local vargs = exst.s
  1072.  
  1073. local stktlIiliiI = -0x1
  1074. local lIiliiIenupvs = {}
  1075. local x = exst.x
  1076. local pc = exst.pc
  1077.  
  1078. while true do
  1079. local inst = code[pc]
  1080. local lIiliiI = inst.lIiliiI
  1081. pc = pc + 0x1
  1082.  
  1083. if lIiliiI < 19 then
  1084. if lIiliiI < 0x9 then
  1085. if lIiliiI < 0x4 then
  1086. if lIiliiI < 0x2 then
  1087. if lIiliiI < 0x1 then
  1088.  
  1089. x[inst.illliiliiI] = x[inst.B]
  1090. else
  1091. x[inst.illliiliiI] = inst.IilIllliiII
  1092. end
  1093. elseif lIiliiI > 0x2 then
  1094.  
  1095. for i = inst.illliiliiI, inst.B do
  1096. x[i] = nil
  1097. end
  1098. else
  1099.  
  1100. x[inst.illliiliiI] = inst.B ~= 0x0
  1101.  
  1102. if inst.C ~= 0x0 then
  1103. pc = pc + 0x1
  1104. end
  1105. end
  1106. elseif lIiliiI > 0x4 then
  1107. if lIiliiI < 0x7 then
  1108. if lIiliiI < 0x6 then
  1109.  
  1110. x[inst.illliiliiI] = env[inst.IilIllliiII]
  1111. else
  1112.  
  1113. local b
  1114.  
  1115. if inst.IliiIll then
  1116. b = inst.const_C
  1117. else
  1118. b = x[inst.C]
  1119. end
  1120.  
  1121. x[inst.illliiliiI] = x[inst.B][b]
  1122. end
  1123. elseif lIiliiI > 0x7 then
  1124.  
  1125. local uv = upvs[inst.B]
  1126.  
  1127. uv.store[uv.b] = x[inst.illliiliiI]
  1128. else
  1129.  
  1130. env[inst.IilIllliiII] = x[inst.illliiliiI]
  1131. end
  1132. else
  1133.  
  1134. local uv = upvs[inst.B]
  1135.  
  1136. x[inst.illliiliiI] = uv.store[uv.b]
  1137. end
  1138. elseif lIiliiI > 0x9 then
  1139. if lIiliiI < 14 then
  1140. if lIiliiI < 12 then
  1141. if lIiliiI < 11 then
  1142.  
  1143. x[inst.illliiliiI] = {}
  1144. else
  1145.  
  1146. local illliiliiI = inst.illliiliiI
  1147. local B = inst.B
  1148. local b
  1149.  
  1150. if inst.IliiIll then
  1151. b = inst.const_C
  1152. else
  1153. b = x[inst.C]
  1154. end
  1155.  
  1156. x[illliiliiI + 0x1] = x[B]
  1157. x[illliiliiI] = x[B][b]
  1158. end
  1159. elseif lIiliiI > 12 then
  1160.  
  1161. local lhs, rhs
  1162.  
  1163. if inst.lIIIIlIIiIllii then
  1164. lhs = inst.const_B
  1165. else
  1166. lhs = x[inst.B]
  1167. end
  1168.  
  1169. if inst.IliiIll then
  1170. rhs = inst.const_C
  1171. else
  1172. rhs = x[inst.C]
  1173. end
  1174.  
  1175. x[inst.illliiliiI] = lhs - rhs
  1176. else
  1177.  
  1178. local lhs, rhs
  1179.  
  1180. if inst.lIIIIlIIiIllii then
  1181. lhs = inst.const_B
  1182. else
  1183. lhs = x[inst.B]
  1184. end
  1185.  
  1186. if inst.IliiIll then
  1187. rhs = inst.const_C
  1188. else
  1189. rhs = x[inst.C]
  1190. end
  1191.  
  1192. x[inst.illliiliiI] = lhs + rhs
  1193. end
  1194. elseif lIiliiI > 14 then
  1195. if lIiliiI < 17 then
  1196. if lIiliiI < 16 then
  1197.  
  1198. local lhs, rhs
  1199.  
  1200. if inst.lIIIIlIIiIllii then
  1201. lhs = inst.const_B
  1202. else
  1203. lhs = x[inst.B]
  1204. end
  1205.  
  1206. if inst.IliiIll then
  1207. rhs = inst.const_C
  1208. else
  1209. rhs = x[inst.C]
  1210. end
  1211.  
  1212. x[inst.illliiliiI] = lhs / rhs
  1213. else
  1214.  
  1215. local lhs, rhs
  1216.  
  1217. if inst.lIIIIlIIiIllii then
  1218. lhs = inst.const_B
  1219. else
  1220. lhs = x[inst.B]
  1221. end
  1222.  
  1223. if inst.IliiIll then
  1224. rhs = inst.const_C
  1225. else
  1226. rhs = x[inst.C]
  1227. end
  1228.  
  1229. x[inst.illliiliiI] = lhs % rhs
  1230. end
  1231. elseif lIiliiI > 17 then
  1232.  
  1233. x[inst.illliiliiI] = -x[inst.B]
  1234. else
  1235.  
  1236. local lhs, rhs
  1237.  
  1238. if inst.lIIIIlIIiIllii then
  1239. lhs = inst.const_B
  1240. else
  1241. lhs = x[inst.B]
  1242. end
  1243.  
  1244. if inst.IliiIll then
  1245. rhs = inst.const_C
  1246. else
  1247. rhs = x[inst.C]
  1248. end
  1249.  
  1250. x[inst.illliiliiI] = lhs ^ rhs
  1251. end
  1252. else
  1253.  
  1254. local lhs, rhs
  1255.  
  1256. if inst.lIIIIlIIiIllii then
  1257. lhs = inst.const_B
  1258. else
  1259. lhs = x[inst.B]
  1260. end
  1261.  
  1262. if inst.IliiIll then
  1263. rhs = inst.const_C
  1264. else
  1265. rhs = x[inst.C]
  1266. end
  1267.  
  1268. x[inst.illliiliiI] = lhs * rhs
  1269. end
  1270. else
  1271.  
  1272. local b, iIIiiilliIliiI
  1273.  
  1274. if inst.lIIIIlIIiIllii then
  1275. b = inst.const_B
  1276. else
  1277. b = x[inst.B]
  1278. end
  1279.  
  1280. if inst.IliiIll then
  1281. iIIiiilliIliiI = inst.const_C
  1282. else
  1283. iIIiiilliIliiI = x[inst.C]
  1284. end
  1285.  
  1286. x[inst.illliiliiI][b] = iIIiiilliIliiI
  1287. end
  1288. elseif lIiliiI > 19 then
  1289. if lIiliiI < 29 then
  1290. if lIiliiI < 24 then
  1291. if lIiliiI < 22 then
  1292. if lIiliiI < 21 then
  1293.  
  1294. x[inst.illliiliiI] = #x[inst.B]
  1295. else
  1296.  
  1297. local str = x[inst.B]
  1298.  
  1299. for i = inst.B + 0x1, inst.C do
  1300. str = str .. x[i]
  1301. end
  1302.  
  1303. x[inst.illliiliiI] = str
  1304. end
  1305. elseif lIiliiI > 22 then
  1306.  
  1307. local lhs, rhs
  1308.  
  1309. if inst.lIIIIlIIiIllii then
  1310. lhs = inst.const_B
  1311. else
  1312. lhs = x[inst.B]
  1313. end
  1314.  
  1315. if inst.IliiIll then
  1316. rhs = inst.const_C
  1317. else
  1318. rhs = x[inst.C]
  1319. end
  1320.  
  1321. if (lhs == rhs) ~= (inst.illliiliiI ~= 0x0) then
  1322. pc = pc + 0x1
  1323. end
  1324. else
  1325.  
  1326. pc = pc + inst.sBx
  1327. end
  1328. elseif lIiliiI > 24 then
  1329. if lIiliiI < 27 then
  1330. if lIiliiI < 26 then
  1331.  
  1332. local lhs, rhs
  1333.  
  1334. if inst.lIIIIlIIiIllii then
  1335. lhs = inst.const_B
  1336. else
  1337. lhs = x[inst.B]
  1338. end
  1339.  
  1340. if inst.IliiIll then
  1341. rhs = inst.const_C
  1342. else
  1343. rhs = x[inst.C]
  1344. end
  1345.  
  1346. if (lhs <= rhs) ~= (inst.illliiliiI ~= 0x0) then
  1347. pc = pc + 0x1
  1348. end
  1349. else
  1350.  
  1351. if (not x[inst.illliiliiI]) == (inst.C ~= 0x0) then
  1352. pc = pc + 0x1
  1353. end
  1354. end
  1355. elseif lIiliiI > 27 then
  1356.  
  1357. local illliiliiI = inst.illliiliiI
  1358. local B = inst.B
  1359. local C = inst.C
  1360. local params
  1361. local sz_vals, l_vals
  1362.  
  1363. if B == 0x0 then
  1364. params = stktlIiliiI - illliiliiI
  1365. else
  1366. params = B - 0x1
  1367. end
  1368.  
  1369. sz_vals, l_vals = wrap_lua_variadic(x[illliiliiI](unp(x, illliiliiI + 0x1, illliiliiI + params)))
  1370.  
  1371. if C == 0x0 then
  1372. stktlIiliiI = illliiliiI + sz_vals - 0x1
  1373. else
  1374. sz_vals = C - 0x1
  1375. end
  1376.  
  1377. for i = 0x1, sz_vals do
  1378. x[illliiliiI + i - 0x1] = l_vals[i]
  1379. end
  1380. else
  1381.  
  1382. local illliiliiI = inst.illliiliiI
  1383. local B = inst.B
  1384.  
  1385. if (not x[B]) == (inst.C ~= 0x0) then
  1386. pc = pc + 0x1
  1387. else
  1388. x[illliiliiI] = x[B]
  1389. end
  1390. end
  1391. else
  1392.  
  1393. local lhs, rhs
  1394.  
  1395. if inst.lIIIIlIIiIllii then
  1396. lhs = inst.const_B
  1397. else
  1398. lhs = x[inst.B]
  1399. end
  1400.  
  1401. if inst.IliiIll then
  1402. rhs = inst.const_C
  1403. else
  1404. rhs = x[inst.C]
  1405. end
  1406.  
  1407. if (lhs < rhs) ~= (inst.illliiliiI ~= 0x0) then
  1408. pc = pc + 0x1
  1409. end
  1410. end
  1411. elseif lIiliiI > 29 then
  1412. if lIiliiI < 34 then
  1413. if lIiliiI < 32 then
  1414. if lIiliiI < 31 then
  1415.  
  1416. local illliiliiI = inst.illliiliiI
  1417. local B = inst.B
  1418. local vals = {}
  1419. local size
  1420.  
  1421. if B == 0x0 then
  1422. size = stktlIiliiI - illliiliiI + 0x1
  1423. else
  1424. size = B - 0x1
  1425. end
  1426.  
  1427. for i = 0x1, size do
  1428. vals[i] = x[illliiliiI + i - 0x1]
  1429. end
  1430.  
  1431. close_lua_upiIIiiilliIliiIs(lIiliiIenupvs, math.huge)
  1432. return size, vals
  1433. else
  1434.  
  1435. local illliiliiI = inst.illliiliiI
  1436. local step = x[illliiliiI + 0x2]
  1437. local b = x[illliiliiI] + step
  1438. local limit = x[illliiliiI + 0x1]
  1439. local lolIiliiIs
  1440.  
  1441. if step == math.abs(step) then
  1442. lolIiliiIs = b <= limit
  1443. else
  1444. lolIiliiIs = b >= limit
  1445. end
  1446.  
  1447. if lolIiliiIs then
  1448. x[inst.illliiliiI] = b
  1449. x[inst.illliiliiI + 0x3] = b
  1450. pc = pc + inst.sBx
  1451. end
  1452. end
  1453. elseif lIiliiI > 32 then
  1454.  
  1455. local illliiliiI = inst.illliiliiI
  1456. local func = x[illliiliiI]
  1457. local state = x[illliiliiI + 0x1]
  1458. local b = x[illliiliiI + 0x2]
  1459. local base = illliiliiI + 0x3
  1460. local vals
  1461.  
  1462. x[base + 0x2] = b
  1463. x[base + 0x1] = state
  1464. x[base] = func
  1465.  
  1466. vals = {
  1467. func(state, b)
  1468. }
  1469.  
  1470. for i = 0x1, inst.C do
  1471. x[base + i - 0x1] = vals[i]
  1472. end
  1473.  
  1474. if x[base] ~= nil then
  1475. x[illliiliiI + 0x2] = x[base]
  1476. else
  1477. pc = pc + 0x1
  1478. end
  1479. else
  1480.  
  1481. local illliiliiI = inst.illliiliiI
  1482. local init, limit, step
  1483.  
  1484. init = ass(tonumber(x[illliiliiI]), on_lua_error)
  1485. limit = ass(tonumber(x[illliiliiI + 0x1]), on_lua_error)
  1486. step = ass(tonumber(x[illliiliiI + 0x2]), on_lua_error)
  1487.  
  1488. x[illliiliiI] = init - step
  1489. x[illliiliiI + 0x1] = limit
  1490. x[illliiliiI + 0x2] = step
  1491.  
  1492. pc = pc + inst.sBx
  1493. end
  1494. elseif lIiliiI > 34 then
  1495. if lIiliiI < 36 then
  1496.  
  1497. close_lua_upiIIiiilliIliiIs(lIiliiIenupvs, inst.illliiliiI)
  1498. elseif lIiliiI > 36 then
  1499.  
  1500. local illliiliiI = inst.illliiliiI
  1501. local size = inst.B
  1502.  
  1503. if size == 0x0 then
  1504. size = vargs.size
  1505. stktlIiliiI = illliiliiI + size - 0x1
  1506. end
  1507.  
  1508. for i = 0x1, size do
  1509. x[illliiliiI + i - 0x1] = vargs.list[i]
  1510. end
  1511. else
  1512.  
  1513. local sub = d[inst.Bx + 0x1]
  1514. local nups = sub.iIlllIIIiII
  1515. local uvlist
  1516.  
  1517. if nups ~= 0x0 then
  1518. uvlist = {}
  1519.  
  1520. for i = 0x1, nups do
  1521. local pseudo = code[pc + i - 0x1]
  1522.  
  1523. if pseudo.lIiliiI == 0x0 then
  1524. uvlist[i - 0x1] = lIiliiIen_lua_upiIIiiilliIliiI(lIiliiIenupvs, pseudo.B, x)
  1525. elseif pseudo.lIiliiI == 0x4 then
  1526. uvlist[i - 0x1] = upvs[pseudo.B]
  1527. end
  1528. end
  1529.  
  1530. pc = pc + nups
  1531. end
  1532.  
  1533. x[inst.illliiliiI] = wrap_lua_func(sub, env, uvlist)
  1534. end
  1535. else
  1536.  
  1537. local illliiliiI = inst.illliiliiI
  1538. local C = inst.C
  1539. local size = inst.B
  1540. local tab = x[illliiliiI]
  1541. local offset
  1542.  
  1543. if size == 0x0 then
  1544. size = stktlIiliiI - illliiliiI
  1545. end
  1546.  
  1547. if C == 0x0 then
  1548. C = inst[pc].iIIiiilliIliiI
  1549. pc = pc + 0x1
  1550. end
  1551.  
  1552. offset = (C - 0x1) * 50
  1553.  
  1554. for i = 0x1, size do
  1555. tab[i + offset] = x[illliiliiI + i]
  1556. end
  1557. end
  1558. else
  1559.  
  1560. local illliiliiI = inst.illliiliiI
  1561. local B = inst.B
  1562. local params
  1563.  
  1564. if B == 0x0 then
  1565. params = stktlIiliiI - illliiliiI
  1566. else
  1567. params = B - 0x1
  1568. end
  1569.  
  1570. close_lua_upiIIiiilliIliiIs(lIiliiIenupvs, math.huge)
  1571. return wrap_lua_variadic(x[illliiliiI](unp(x, illliiliiI + 0x1, illliiliiI + params)))
  1572. end
  1573. else
  1574.  
  1575. x[inst.illliiliiI] = not x[inst.B]
  1576. end
  1577.  
  1578. exst.pc = pc
  1579. end
  1580. end
  1581.  
  1582. function wrap_lua_func(state, env, h)
  1583.  
  1584. if typ(state) == 'string' then
  1585. state = deserialize(state)[0x1]
  1586. end
  1587.  
  1588. local st_code = state.f
  1589. local st_d = state.d
  1590. local st_c = state.c
  1591. local st_a = state.iiiIlII
  1592. local st_numparams = state.iIlllIIIiII
  1593.  
  1594. local function exec_wrap(...)
  1595. local x = {}
  1596. local s = {}
  1597. local sizevarg = 0x0
  1598. local sz_args, l_args = wrap_lua_variadic(...)
  1599.  
  1600. local exst
  1601. local ok, err, vals
  1602.  
  1603. for i = 0x1, st_numparams do
  1604. x[i - 0x1] = l_args[i]
  1605. end
  1606.  
  1607. if st_numparams < sz_args then
  1608. sizevarg = sz_args - st_numparams
  1609. for i = 0x1, sizevarg do
  1610. s[i] = l_args[st_numparams + i]
  1611. end
  1612. end
  1613.  
  1614. exst = {
  1615. s = {
  1616. list = s,
  1617. size = sizevarg
  1618. },
  1619. f = st_code,
  1620. d = st_d,
  1621. c = st_c,
  1622. a = st_a,
  1623. g = env,
  1624. h = h,
  1625. x = x,
  1626. pc = 0x1
  1627. }
  1628.  
  1629. ok, err, vals = pca(exec_lua_func, exst, ...)
  1630.  
  1631. if ok then
  1632. return unp(vals, 0x1, err)
  1633. else
  1634. on_lua_error(exst, err)
  1635. end
  1636.  
  1637. return
  1638. end
  1639.  
  1640. return exec_wrap
  1641. end
  1642. local bytecode = stm_lua_bytecode(bytecode)
  1643. return wrap_lua_func(bytecode, env)()
  1644. end
  1645.  
  1646. run('')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement