w3vu2m81e912ce7m

r

Sep 27th, 2025
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. local FindFunc = {}
  2. function FindFunc:CheckConstants(func, totalConstants, expected)
  3. assert(typeof(func) == "function", "First argument must be a function")
  4. assert(typeof(totalConstants) == "number", "Second argument must be a number")
  5. assert(typeof(expected) == "table", "Third argument must be a table")
  6.  
  7. local constants = debug.getconstants(func)
  8. if not constants then
  9. return false
  10. end
  11.  
  12. if #constants ~= totalConstants then
  13. return false
  14. end
  15.  
  16. for index, expectedValue in next, expected do
  17. local actualValue = constants[index]
  18.  
  19. if type(expectedValue) == "string" and expectedValue:match("^typeof:") then
  20. local expectedType = expectedValue:sub(8)
  21. if typeof(actualValue) ~= expectedType then
  22. return false
  23. end
  24. else
  25. if actualValue ~= expectedValue then
  26. return false
  27. end
  28. end
  29. end
  30.  
  31. return true
  32. end
  33. function FindFunc:CheckUpvalues(func, totalUpvalues, expected)
  34. assert(typeof(func) == "function", "First argument must be a function")
  35. assert(typeof(totalUpvalues) == "number", "Second argument must be a number")
  36. assert(typeof(expected) == "table", "Third argument must be a table")
  37.  
  38. local count = debug.getupvalues(func)
  39. if not count then
  40. return false
  41. end
  42.  
  43. if #count ~= totalUpvalues then
  44. return false
  45. end
  46.  
  47. for index, expectedValue in next, expected do
  48. local actualValue = count[index]
  49.  
  50. if type(expectedValue) == "string" and expectedValue:match("^typeof:") then
  51. local expectedType = expectedValue:sub(8)
  52. if typeof(actualValue) ~= expectedType then
  53. return false
  54. end
  55. else
  56. if actualValue ~= expectedValue then
  57. return false
  58. end
  59. end
  60. end
  61.  
  62. return true
  63. end
  64. function FindFunc:GcLookUp(val, callback)
  65. for i, v in next,getgc(val and true or nil) do
  66. if typeof(v) == "function" and islclosure(v) and not isexecutorclosure(v) then
  67. if callback then
  68. callback(i, v)
  69. else
  70. warn("Found function:", v)
  71. end
  72. end
  73. end
  74. end
  75. function FindFunc.GcLookUp(val, callback)
  76. for i, v in next, getgc(val and true or nil) do
  77. if typeof(v) == "function" and islclosure(v) and not isexecutorclosure(v) then
  78. if callback then
  79. callback(i, v)
  80. else
  81. return v
  82. end
  83. end
  84. end
  85. end
  86. function FindFunc.getscriptfromthread(script)
  87. if not getscriptfromthread then
  88. return "Executor doesnt not support getscriptfromthread"
  89. end
  90. for i,v in next, getreg() do
  91. if typeof(v) == "thread" and getscriptfromthread(v) == script then
  92. return getscriptfromthread(v)
  93. end
  94. end
  95. end
  96. function FindFunc.getscriptfromfunction(f)
  97. if not getscriptfromfunction then
  98. return "Executor doesnt not support getscriptfromfunction"
  99. end
  100. return getscriptfromfunction(f)
  101. end
  102.  
  103. return FindFunc
Advertisement
Add Comment
Please, Sign In to add comment