-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathFunctionDump.lua
324 lines (245 loc) · 9.73 KB
/
FunctionDump.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
--[[
Report any bugs, issues and detections to me if you don't mind (NoTwistedHere#6703)
]]
if not FormatTable then
loadstring(game:HttpGet("https://raw.githubusercontent.com/NoTwistedHere/Roblox/" .. (Branch or "main") .. "/FormatTable.lua"))()
end
local Threading = loadstring(game:HttpGet("https://raw.githubusercontent.com/NoTwistedHere/Roblox/" .. (Branch or "main") .. "/Threading.lua"))()
local Place = game:GetService("MarketplaceService"):GetProductInfo(game.PlaceId)
local Global, Local = "Function Dumps/", ("%s [%d]/"):format(tostring(Place and Place.Name or "Unknown Game"):gsub("[^%w%s]", ""), game.PlaceId)
local Key = game:GetService("HttpService"):GenerateGUID(false)
getgenv().FunctionsPerThread = FunctionsPerThread or 200
getgenv().ScriptsPerThread = ScriptsPerThread or 5
local function ConvertCodepoints(OriginalString)
if OriginalString:match("[^%a%c%d%l%p%s%u%x]") or OriginalString:match("[\\/:*?\"<>|]") then
local String = ""
for i = 1, #OriginalString do
local Byte = string.byte(OriginalString, i, i)
local Char = string.char(Byte)
if Byte <= 126 and Byte >= 33 and not Char:match("[\\/:*?\"<>|]") then
String ..= string.char(Byte)
end
end
return String
end
return OriginalString
end
local function Stringify(String)
if type(String) ~= "string" then
return;
end
--return ConvertCodepoints(String:gsub("\\", ""):gsub("//", ""):gsub("\"", ""):gsub("\\(d+)", ""))
local NewString, C = String:gsub("[^%w%s%.%(%)=]", ""), -1
repeat
NewString, C = NewString:gsub("%.%.", ".")
until C == 0
if #NewString == 0 then
return "INVALID NAME"
end
return NewString
end
local function GiveColour(Current, Max, C)
return (Current < Max * 0.25 and (C and Color3.fromRGB(255, 0, 0) or "@@RED@@")) or (Current < Max * 0.5 and (C and Color3.fromRGB(255, 255, 0) or "@@YELLOW@@")) or (Current < Max * 0.75 and (C and Color3.fromRGB(0, 255, 255) or "@@CYAN@@")) or (C and Color3.fromRGB(0, 255, 0) or "@@GREEN@@")
end
local function GetLoading()
local SpinnerCount = 0
return function()
local Chars = { "|", "/", "—", "\\" }
SpinnerCount += 1
if SpinnerCount > #Chars then
SpinnerCount = 1
end
return " "..Chars[SpinnerCount]
end
end
local function ProgressBar(Header, Current, Max, Thread)
local Size, PreviousCur, PreviousMax, Complete = 80, Current, Max, Current == Max
local Loading = GetLoading()
local LoadingChar = Loading()
local function Update(Current, Max, Extra_After)
local Progress, Percentage = math.floor(Size * Current / Max), math.floor(100 * Current / Max)
if Complete then
return;
end
PreviousCur = Current
PreviousMax = Max
if not syn.oth then
rconsoleprint(GiveColour(Current, Max))
rconsoleprint(("\13%s%s %s%s"):format(("#"):rep(Progress), ("."):rep(Size - Progress), Percentage.."%", Percentage == 100 and "!\n" or Extra_After or LoadingChar))
rconsoleprint("@@WHITE@@")
else
rconsoleprint(("\13%s%s %s%s"):format(("#"):rep(Progress), ("."):rep(Size - Progress), Percentage.."%", Percentage == 100 and "!\n" or Extra_After or LoadingChar), GiveColour(Current, Max, true))
end
if Percentage == 100 then
Complete = true
end
end
rconsoleprint(Header.."\n")
task.spawn(function()
while not Complete and (not Thread and true or coroutine.status(Thread) ~= "dead") do
LoadingChar = Loading()
Update(PreviousCur, PreviousMax, LoadingChar)
task.wait(0.25)
end
end)
return function(...)
task.spawn(Update, ...)
end
end
local function CountTable(Table)
local Count = 0
for _ in next, Table do
Count += 1
end
return Count
end
if not isfolder(Global) then
makefolder(Global)
end
function Write(Function, Checked, OriginalFunction)
local Checked, Upvalues, Constants, Protos, Info = Checked or {}, getupvalues(Function), getconstants(Function), getprotos(Function), getinfo(Function)
local UserdataCount = 0
table.insert(Checked, Function)
for i, v in next, Protos do
if Checked[v] then
continue;
end
Protos[i] = Write(v, Checked, Function)
end
for i, v in next, Constants do
if typeof(v) == "userdata" and not getrawmetatable(v) then
local Proxy = newproxy(true)
UserdataCount += OriginalFunction and 0 or 1
setrawmetatable(Proxy, {
[Key] = OriginalFunction or (Protos[UserdataCount] and Protos[UserdataCount]["Info"]["func"]) or "[[LOCAL FUNCTION DEFINITIONS MAY BE INCORRECT]]";
})
Constants[i] = Proxy
end
end
if OriginalFunction then
return {Constants = Constants, Info = Info}
end
return {Upvalues = Upvalues, Constants = Constants, LocalFunctions = Protos, Info = Info}
end
function CheckFile(Directory, FileName)
local Name, New, Count = "", Directory..Stringify(FileName..".lua"), 0
if isfile(New) then
repeat
Count += 1
Name = FileName..(" (%d)"):format(Count)
New = Directory..Stringify(Name..".lua")
until not isfile(Directory..Stringify(Name..".lua"))
end
return New
end
local function Get(Table)
local Final = ""
for i, v in pairs(Table) do
Final ..= v[2]
end
return Final
end
getgenv().DumpScript = function(Source) --// Outdated, cba to update tbh
if not isfolder(Global..Local) then
makefolder(Global..Local)
elseif isfolder(Global..Local) then
delfolder(Global..Local)
end
local Functions, GC, Thread = {}, getgc(), coroutine.running()
local Final = CheckFile(Global..Local, Source)
rconsoleclear()
rconsolename("FunctionDumper")
local CPB = ProgressBar("\nCollecting Functions", 0, 1, Thread)
writefile(Final, "")
for i, v in next, getgc() do
local Info = type(v) == "function" and getinfo(v)
if Info and Info.source == Source then
table.insert(Functions, {v, Info})
CPB(i, #GC)
end
end
CPB(1, 1)
local CPB = ProgressBar(("\nDumping Functions [%d]"):format(#Functions), 0, 1, Thread)
table.sort(Functions, function(a, b) return a[2].currentline < b[2].currentline end)
for i, Data in next, Functions do
appendfile(Final, FormatTable(Write(Data[1]), {MetatableKey = Key}))
CPB(i, #Functions)
end
rconsoleprint("\nFinished")
end
getgenv().DumpFunctions = function()
if not isfolder(Global..Local) then
makefolder(Global..Local)
elseif isfolder(Global..Local) then
delfolder(Global..Local)
makefolder(Global..Local)
end
local Scripts, GC, TotalFunctions, Thread = {}, getgc(), 0, coroutine.running()
local Directory = Global..Local
rconsoleclear()
rconsolename("FunctionDumper")
local CPB = ProgressBar("\nCollecting Functions", 0, 1,Thread)
for i, v in next, GC do
local Info = type(v) == "function" and getinfo(v)
if Info and Info.source ~= "=[C]" and Info.source:sub(1, 1) == "=" then
if not Scripts[Info.source] then
Scripts[Info.source] = {}
end
TotalFunctions += 1
table.insert(Scripts[Info.source], {v, Info})
CPB(i, #GC)
end
end
CPB(1, 1)
local CPB = ProgressBar(("\nDumping Functions [%d]"):format(TotalFunctions), 0, 1, Thread)
local Count = 0
local Threads = Threading.new("Group")
for Source, Dump in next, Scripts do
if Threads.Active == ScriptsPerThread then
Threads.Available:Wait()
warn("NEXT")
end
task.wait()
Threads:Add(function()
local Final, FinalData, Thread = CheckFile(Directory, Source), {}, Threading.new("N/A", true)
table.sort(Dump, function(a, b) return a[2].currentline < b[2].currentline end)
writefile(Final, "")
local Max = math.ceil(#Dump / FunctionsPerThread) - 1
for ThreadNum = 0, Max do
Thread:Add(function()
for TIndex = 1, 201 do
local Data, FDCount, FDWrite = Dump[TIndex + (FunctionsPerThread * ThreadNum)], 0, {};
if not Data then
break;
end
FinalData[Data[2].currentline] = {Data[2].currentline, FormatTable(Write(Data[1]), {MetatableKey = Key}).."\n"}
for i, v in next, FinalData do
if FDCount == 0 then
FDCount = i
end
if i <= Data[2].currentline and FDCount == i then
table.insert(FDWrite, v)
FinalData[i] = nil
FDCount += 1
else
break;
end
end
appendfile(Final, Get(FDWrite))
Count += 1
CPB(Count, TotalFunctions)
end
CPB(Count, TotalFunctions)
if ThreadNum == Max then
Thread.Ended:Fire("done")
end
end)
end
Thread.Ended:Wait("f")
--table.sort(FinalData, function(a, b) return a[1] < b[1] end)
--writefile(Final, Get(FinalData))
end)
end
Threads.Ended:Wait()
rconsoleprint("Finished")
end