├── .gitattributes
├── .gitignore
├── Executor
├── App.config
├── Executor.csproj
├── FastColoredTextBox.dll
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Injector
├── Dependencies
│ ├── ICHooker.asm
│ ├── ICHooker.obj
│ ├── ThreadPool.h
│ ├── Tools_.obj
│ ├── WorkerFactory.h
│ ├── ntdlldefs.cpp
│ ├── ntdlldefs.h
│ └── syscallcaller.obj
├── ICHook
│ ├── ICHooker.asm
│ └── ICHooker.h
├── Idk
│ ├── Roblox.h
│ ├── SyscalCaller.h
│ └── Utils
│ │ ├── TPInjection.cpp
│ │ ├── TPInjection.h
│ │ ├── Tools.cpp
│ │ ├── Tools.h
│ │ └── WorkerFactory.h
├── Injection
│ ├── Injection.cpp
│ └── Injection.h
├── Injector.cpp
├── Injector.vcxproj
├── Injector.vcxproj.filters
├── Update
│ └── Offsets.hpp
└── main.h
├── ModuleBase.sln
├── ModuleBase
├── Dependencies
│ ├── Luau
│ │ ├── Ast
│ │ │ ├── include
│ │ │ │ └── Luau
│ │ │ │ │ ├── Allocator.h
│ │ │ │ │ ├── Ast.h
│ │ │ │ │ ├── Confusables.h
│ │ │ │ │ ├── Cst.h
│ │ │ │ │ ├── Lexer.h
│ │ │ │ │ ├── Location.h
│ │ │ │ │ ├── ParseOptions.h
│ │ │ │ │ ├── ParseResult.h
│ │ │ │ │ ├── Parser.h
│ │ │ │ │ ├── StringUtils.h
│ │ │ │ │ └── TimeTrace.h
│ │ │ └── src
│ │ │ │ ├── Allocator.cpp
│ │ │ │ ├── Ast.cpp
│ │ │ │ ├── Confusables.cpp
│ │ │ │ ├── Cst.cpp
│ │ │ │ ├── Lexer.cpp
│ │ │ │ ├── Location.cpp
│ │ │ │ ├── Parser.cpp
│ │ │ │ ├── StringUtils.cpp
│ │ │ │ └── TimeTrace.cpp
│ │ ├── Common
│ │ │ └── include
│ │ │ │ └── Luau
│ │ │ │ ├── Bytecode.h
│ │ │ │ ├── BytecodeUtils.h
│ │ │ │ ├── Common.h
│ │ │ │ ├── DenseHash.h
│ │ │ │ ├── ExperimentalFlags.h
│ │ │ │ ├── Variant.h
│ │ │ │ └── VecDeque.h
│ │ ├── Compiler
│ │ │ ├── include
│ │ │ │ ├── Luau
│ │ │ │ │ ├── BytecodeBuilder.h
│ │ │ │ │ └── Compiler.h
│ │ │ │ └── luacode.h
│ │ │ └── src
│ │ │ │ ├── BuiltinFolding.cpp
│ │ │ │ ├── BuiltinFolding.h
│ │ │ │ ├── Builtins.cpp
│ │ │ │ ├── Builtins.h
│ │ │ │ ├── BytecodeBuilder.cpp
│ │ │ │ ├── Compiler.cpp
│ │ │ │ ├── ConstantFolding.cpp
│ │ │ │ ├── ConstantFolding.h
│ │ │ │ ├── CostModel.cpp
│ │ │ │ ├── CostModel.h
│ │ │ │ ├── TableShape.cpp
│ │ │ │ ├── TableShape.h
│ │ │ │ ├── Types.cpp
│ │ │ │ ├── Types.h
│ │ │ │ ├── ValueTracking.cpp
│ │ │ │ ├── ValueTracking.h
│ │ │ │ └── lcode.cpp
│ │ └── VM
│ │ │ ├── include
│ │ │ ├── lua.h
│ │ │ ├── luaconf.h
│ │ │ └── lualib.h
│ │ │ └── src
│ │ │ ├── lapi.cpp
│ │ │ ├── lapi.h
│ │ │ ├── laux.cpp
│ │ │ ├── lbaselib.cpp
│ │ │ ├── lbitlib.cpp
│ │ │ ├── lbuffer.cpp
│ │ │ ├── lbuffer.h
│ │ │ ├── lbuflib.cpp
│ │ │ ├── lbuiltins.cpp
│ │ │ ├── lbuiltins.h
│ │ │ ├── lbytecode.h
│ │ │ ├── lcommon.h
│ │ │ ├── lcorolib.cpp
│ │ │ ├── ldblib.cpp
│ │ │ ├── ldebug.cpp
│ │ │ ├── ldebug.h
│ │ │ ├── ldo.cpp
│ │ │ ├── ldo.h
│ │ │ ├── lfunc.cpp
│ │ │ ├── lfunc.h
│ │ │ ├── lgc.cpp
│ │ │ ├── lgc.h
│ │ │ ├── lgcdebug.cpp
│ │ │ ├── linit.cpp
│ │ │ ├── lmathlib.cpp
│ │ │ ├── lmem.cpp
│ │ │ ├── lmem.h
│ │ │ ├── lnumprint.cpp
│ │ │ ├── lnumutils.h
│ │ │ ├── lobject.cpp
│ │ │ ├── lobject.h
│ │ │ ├── loslib.cpp
│ │ │ ├── lperf.cpp
│ │ │ ├── lstate.cpp
│ │ │ ├── lstate.h
│ │ │ ├── lstring.cpp
│ │ │ ├── lstring.h
│ │ │ ├── lstrlib.cpp
│ │ │ ├── ltable.cpp
│ │ │ ├── ltable.h
│ │ │ ├── ltablib.cpp
│ │ │ ├── ltm.cpp
│ │ │ ├── ltm.h
│ │ │ ├── ludata.cpp
│ │ │ ├── ludata.h
│ │ │ ├── lutf8lib.cpp
│ │ │ ├── lveclib.cpp
│ │ │ ├── lvm.h
│ │ │ ├── lvmexecute.cpp
│ │ │ ├── lvmload.cpp
│ │ │ └── lvmutils.cpp
│ ├── lz4
│ │ ├── include
│ │ │ ├── lz4.h
│ │ │ ├── lz4file.h
│ │ │ ├── lz4frame.h
│ │ │ ├── lz4frame_static.h
│ │ │ ├── lz4hc.h
│ │ │ └── xxhash.h
│ │ └── lib
│ │ │ └── lz4.lib
│ └── zstd
│ │ ├── include
│ │ ├── desktop.ini
│ │ └── zstd
│ │ │ ├── desktop.ini
│ │ │ ├── xxhash.h
│ │ │ └── zstd.h
│ │ └── lib
│ │ └── zstd_static.lib
├── Environment
│ ├── Environment.hpp
│ └── Libs
│ │ └── FileSystem
│ │ └── FileSystem.hpp
├── Execution
│ └── Execution.hpp
├── ModuleBase.vcxproj
├── ModuleBase.vcxproj.filters
├── NamedPipe.hpp
├── Tasks
│ ├── TaskScheduler.hpp
│ └── Utils.hpp
├── Update
│ ├── Offsets.hpp
│ ├── Protection.hpp
│ └── ProtectionStructure.hpp
└── dllmain.cpp
├── README.md
└── build
├── Injector.exe
└── fmt.dll
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Executor/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Executor/Executor.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}
8 | WinExe
9 | Executor
10 | Executor
11 | v4.7.2
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | ..\x64\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 | .\FastColoredTextBox.dll
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | Form
54 |
55 |
56 | Form1.cs
57 |
58 |
59 |
60 |
61 | Form1.cs
62 |
63 |
64 | ResXFileCodeGenerator
65 | Resources.Designer.cs
66 | Designer
67 |
68 |
69 | True
70 | Resources.resx
71 |
72 |
73 | SettingsSingleFileGenerator
74 | Settings.Designer.cs
75 |
76 |
77 | True
78 | Settings.settings
79 | True
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Executor/FastColoredTextBox.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/Executor/FastColoredTextBox.dll
--------------------------------------------------------------------------------
/Executor/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace Executor
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
33 | this.button1 = new System.Windows.Forms.Button();
34 | this.fastColoredTextBox1 = new FastColoredTextBoxNS.FastColoredTextBox();
35 | this.button2 = new System.Windows.Forms.Button();
36 | ((System.ComponentModel.ISupportInitialize)(this.fastColoredTextBox1)).BeginInit();
37 | this.SuspendLayout();
38 | //
39 | // button1
40 | //
41 | this.button1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
42 | this.button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
43 | this.button1.ForeColor = System.Drawing.SystemColors.ControlText;
44 | this.button1.Location = new System.Drawing.Point(658, 364);
45 | this.button1.Name = "button1";
46 | this.button1.Size = new System.Drawing.Size(120, 74);
47 | this.button1.TabIndex = 0;
48 | this.button1.Text = "Execute";
49 | this.button1.UseVisualStyleBackColor = false;
50 | this.button1.Click += new System.EventHandler(this.button1_Click);
51 | //
52 | // fastColoredTextBox1
53 | //
54 | this.fastColoredTextBox1.AutoCompleteBracketsList = new char[] {
55 | '(',
56 | ')',
57 | '{',
58 | '}',
59 | '[',
60 | ']',
61 | '\"',
62 | '\"',
63 | '\'',
64 | '\''};
65 | this.fastColoredTextBox1.AutoIndentCharsPatterns = "^\\s*[\\w\\.]+(\\s\\w+)?\\s*(?=)\\s*(?[^;=]+);\r\n^\\s*(case|default)\\s*[^:]*" +
66 | "(?:)\\s*(?[^;]+);";
67 | this.fastColoredTextBox1.AutoScrollMinSize = new System.Drawing.Size(179, 14);
68 | this.fastColoredTextBox1.BackBrush = null;
69 | this.fastColoredTextBox1.BackColor = System.Drawing.Color.Transparent;
70 | this.fastColoredTextBox1.CharHeight = 14;
71 | this.fastColoredTextBox1.CharWidth = 8;
72 | this.fastColoredTextBox1.Cursor = System.Windows.Forms.Cursors.IBeam;
73 | this.fastColoredTextBox1.DefaultMarkerSize = 8;
74 | this.fastColoredTextBox1.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))));
75 | this.fastColoredTextBox1.Font = new System.Drawing.Font("Courier New", 9.75F);
76 | this.fastColoredTextBox1.ForeColor = System.Drawing.SystemColors.Highlight;
77 | this.fastColoredTextBox1.IsReplaceMode = false;
78 | this.fastColoredTextBox1.Location = new System.Drawing.Point(12, 12);
79 | this.fastColoredTextBox1.Name = "fastColoredTextBox1";
80 | this.fastColoredTextBox1.Paddings = new System.Windows.Forms.Padding(0);
81 | this.fastColoredTextBox1.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255)))));
82 | this.fastColoredTextBox1.ServiceColors = ((FastColoredTextBoxNS.ServiceColors)(resources.GetObject("fastColoredTextBox1.ServiceColors")));
83 | this.fastColoredTextBox1.Size = new System.Drawing.Size(776, 346);
84 | this.fastColoredTextBox1.TabIndex = 2;
85 | this.fastColoredTextBox1.Text = "fastColoredTextBox1";
86 | this.fastColoredTextBox1.Zoom = 100;
87 | //
88 | // button2
89 | //
90 | this.button2.BackColor = System.Drawing.Color.LightGray;
91 | this.button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
92 | this.button2.ForeColor = System.Drawing.SystemColors.ControlText;
93 | this.button2.Location = new System.Drawing.Point(12, 364);
94 | this.button2.Name = "button2";
95 | this.button2.Size = new System.Drawing.Size(120, 74);
96 | this.button2.TabIndex = 3;
97 | this.button2.Text = "Inject";
98 | this.button2.UseVisualStyleBackColor = false;
99 | this.button2.Click += new System.EventHandler(this.button2_Click);
100 | //
101 | // Form1
102 | //
103 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
104 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
105 | this.BackColor = System.Drawing.Color.White;
106 | this.ClientSize = new System.Drawing.Size(800, 450);
107 | this.Controls.Add(this.button2);
108 | this.Controls.Add(this.fastColoredTextBox1);
109 | this.Controls.Add(this.button1);
110 | this.ForeColor = System.Drawing.Color.White;
111 | this.Name = "Form1";
112 | this.Text = "Form1";
113 | ((System.ComponentModel.ISupportInitialize)(this.fastColoredTextBox1)).EndInit();
114 | this.ResumeLayout(false);
115 |
116 | }
117 |
118 | #endregion
119 |
120 | private System.Windows.Forms.Button button1;
121 | private FastColoredTextBoxNS.FastColoredTextBox fastColoredTextBox1;
122 | private System.Windows.Forms.Button button2;
123 | }
124 | }
125 |
126 |
--------------------------------------------------------------------------------
/Executor/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using System.Diagnostics;
11 | using System.IO.Pipes;
12 | using System.IO;
13 |
14 | namespace Executor
15 | {
16 | public partial class Form1: Form
17 | {
18 | public Form1()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void button1_Click(object sender, EventArgs e)
24 | {
25 | using (NamedPipeClientStream namedPipeClientStream = new NamedPipeClientStream(".", "CLDYexecution", PipeDirection.InOut))
26 | {
27 | try
28 | {
29 | namedPipeClientStream.Connect(5000);
30 | byte[] bytes = Encoding.UTF8.GetBytes(fastColoredTextBox1.Text);
31 | namedPipeClientStream.Write(bytes, 0, bytes.Length);
32 | namedPipeClientStream.Flush();
33 | byte[] array = new byte[1024];
34 | int count = namedPipeClientStream.Read(array, 0, array.Length);
35 | string result = Encoding.UTF8.GetString(array, 0, count);
36 | }
37 | catch (TimeoutException)
38 | {
39 | throw new Exception("Connection timeout");
40 | }
41 | catch (Exception ex2)
42 | {
43 | throw new Exception("Failed to execute Lua script: " + ex2.Message);
44 | }
45 | }
46 | }
47 |
48 | private void button2_Click(object sender, EventArgs e)
49 | {
50 | try
51 | {
52 | Process process = new Process
53 | {
54 | StartInfo =
55 | {
56 | FileName = "Injector.exe",
57 | UseShellExecute = false,
58 | CreateNoWindow = true
59 | }
60 | };
61 | process.Start();
62 | }
63 | catch (Exception ex)
64 | {
65 | MessageBox.Show("Error starting injector: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/Executor/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace Executor
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Executor/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Executor")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Executor")]
13 | [assembly: AssemblyCopyright("Copyright © 2025")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("fc42a5a5-d037-42d4-bd99-c6570efeb837")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
--------------------------------------------------------------------------------
/Executor/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Executor.Properties
12 | {
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// Returns the cached ResourceManager instance used by this class.
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Executor.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// Overrides the current thread's CurrentUICulture property for all
56 | /// resource lookups using this strongly typed resource class.
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/Executor/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Executor/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Executor.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/Executor/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Injector/Dependencies/ICHooker.asm:
--------------------------------------------------------------------------------
1 | .data
2 | Hooker QWORD 0
3 | .const
4 |
5 |
6 | .code
7 | ICHookerLowLevelPartSetHooker PROC
8 | mov Hooker,rcx
9 | ret
10 | ICHookerLowLevelPartSetHooker ENDP
11 |
12 | ICHookerLowLevelPart PROC
13 |
14 |
15 | push rax ;anti-recursion
16 | mov rax,gs:[030h]
17 | test byte ptr [rax+02ECh],01
18 | je notrecursion
19 | pop rax
20 | jmp r10
21 | notrecursion:
22 | pop rax
23 |
24 | ;pushing old rsp
25 | push rsp
26 | ;return addr space
27 | sub rsp,08h
28 | ;pushing regs
29 | push rax
30 | push rcx
31 | push rdx
32 | push rbx
33 | push rbp
34 | push rsi
35 | push rdi
36 | push r8
37 | push r9
38 | push r10
39 | push r11
40 | push r12
41 | push r13
42 | push r14
43 | push r15
44 | sub rsp,010h
45 | movdqu [rsp],xmm0
46 | sub rsp,010h
47 | movdqu [rsp],xmm1
48 | sub rsp,010h
49 | movdqu [rsp],xmm2
50 | sub rsp,010h
51 | movdqu [rsp],xmm3
52 | sub rsp,010h
53 | movdqu [rsp],xmm4
54 | sub rsp,010h
55 | movdqu [rsp],xmm5
56 | sub rsp,010h
57 | movdqu [rsp],xmm6
58 | sub rsp,010h
59 | movdqu [rsp],xmm7
60 |
61 | push gs:[2e0h]
62 | push gs:[2d8h]
63 | mov gs:[2e0h], rsp
64 | mov gs:[2d8h], r10
65 |
66 | mov rax,gs:[030h] ;disabling IC
67 | mov byte ptr [rax+02ech],1
68 |
69 | mov rcx,rsp
70 | add rcx,10h
71 | sub rsp,30h
72 | and rsp,0fffffffffffffff0h
73 |
74 | call Hooker
75 |
76 | mov rax,gs:[030h] ;enabling IC
77 | mov byte ptr [rax+02ech],0
78 |
79 | mov rsp, gs:[2e0h]
80 | mov r10, gs:[2d8h]
81 | pop gs:[2e0h]
82 | pop gs:[2d8h]
83 |
84 | movdqu [rsp],xmm7
85 | add rsp,010h
86 | movdqu [rsp],xmm6
87 | add rsp,010h
88 | movdqu [rsp],xmm5
89 | add rsp,010h
90 | movdqu [rsp],xmm4
91 | add rsp,010h
92 | movdqu [rsp],xmm3
93 | add rsp,010h
94 | movdqu [rsp],xmm2
95 | add rsp,010h
96 | movdqu [rsp],xmm1
97 | add rsp,010h
98 | movdqu [rsp],xmm0
99 | add rsp,010h
100 | pop r15
101 | pop r14
102 | pop r13
103 | pop r12
104 | pop r11
105 | pop r10
106 | pop r9
107 | pop r8
108 | pop rdi
109 | pop rsi
110 | pop rbp
111 | pop rbx
112 | pop rdx
113 | pop rcx
114 | pop rax
115 | ;mov rsp,[rsp] ;real bad idea
116 | add rsp,10h
117 | recursion:
118 | jmp QWORD PTR [rsp-010h]
119 | ICHookerLowLevelPart ENDP
120 |
121 |
122 |
123 | END
--------------------------------------------------------------------------------
/Injector/Dependencies/ICHooker.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/Injector/Dependencies/ICHooker.obj
--------------------------------------------------------------------------------
/Injector/Dependencies/Tools_.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/Injector/Dependencies/Tools_.obj
--------------------------------------------------------------------------------
/Injector/Dependencies/WorkerFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #define WORKER_FACTORY_RELEASE_WORKER 0x0001
4 | #define WORKER_FACTORY_WAIT 0x0002
5 | #define WORKER_FACTORY_SET_INFORMATION 0x0004
6 | #define WORKER_FACTORY_QUERY_INFORMATION 0x0008
7 | #define WORKER_FACTORY_READY_WORKER 0x0010
8 | #define WORKER_FACTORY_SHUTDOWN 0x0020
9 |
10 | #define WORKER_FACTORY_ALL_ACCESS ( \
11 | STANDARD_RIGHTS_REQUIRED | \
12 | WORKER_FACTORY_RELEASE_WORKER | \
13 | WORKER_FACTORY_WAIT | \
14 | WORKER_FACTORY_SET_INFORMATION | \
15 | WORKER_FACTORY_QUERY_INFORMATION | \
16 | WORKER_FACTORY_READY_WORKER | \
17 | WORKER_FACTORY_SHUTDOWN \
18 | )
19 |
20 | typedef struct _WORKER_FACTORY_BASIC_INFORMATION
21 | {
22 | LARGE_INTEGER Timeout;
23 | LARGE_INTEGER RetryTimeout;
24 | LARGE_INTEGER IdleTimeout;
25 | BOOLEAN Paused;
26 | BOOLEAN TimerSet;
27 | BOOLEAN QueuedToExWorker;
28 | BOOLEAN MayCreate;
29 | BOOLEAN CreateInProgress;
30 | BOOLEAN InsertedIntoQueue;
31 | BOOLEAN Shutdown;
32 | ULONG BindingCount;
33 | ULONG ThreadMinimum;
34 | ULONG ThreadMaximum;
35 | ULONG PendingWorkerCount;
36 | ULONG WaitingWorkerCount;
37 | ULONG TotalWorkerCount;
38 | ULONG ReleaseCount;
39 | LONGLONG InfiniteWaitGoal;
40 | PVOID StartRoutine;
41 | PVOID StartParameter;
42 | HANDLE ProcessId;
43 | SIZE_T StackReserve;
44 | SIZE_T StackCommit;
45 | NTSTATUS LastThreadCreationStatus;
46 | } WORKER_FACTORY_BASIC_INFORMATION, * PWORKER_FACTORY_BASIC_INFORMATION;
47 |
48 | typedef enum _SET_WORKERFACTORYINFOCLASS
49 | {
50 | WorkerFactoryTimeout = 0,
51 | WorkerFactoryRetryTimeout = 1,
52 | WorkerFactoryIdleTimeout = 2,
53 | WorkerFactoryBindingCount = 3,
54 | WorkerFactoryThreadMinimum = 4,
55 | WorkerFactoryThreadMaximum = 5,
56 | WorkerFactoryPaused = 6,
57 | WorkerFactoryAdjustThreadGoal = 8,
58 | WorkerFactoryCallbackType = 9,
59 | WorkerFactoryStackInformation = 10,
60 | WorkerFactoryThreadBasePriority = 11,
61 | WorkerFactoryTimeoutWaiters = 12,
62 | WorkerFactoryFlags = 13,
63 | WorkerFactoryThreadSoftMaximum = 14,
64 | WorkerFactoryMaxInfoClass = 15 /* Not implemented */
65 | } SET_WORKERFACTORYINFOCLASS, * PSET_WORKERFACTORYINFOCLASS;
66 |
67 | typedef enum _QUERY_WORKERFACTORYINFOCLASS
68 | {
69 | WorkerFactoryBasicInformation = 7,
70 | } QUERY_WORKERFACTORYINFOCLASS, * PQUERY_WORKERFACTORYINFOCLASS;
71 |
--------------------------------------------------------------------------------
/Injector/Dependencies/ntdlldefs.cpp:
--------------------------------------------------------------------------------
1 | #include "ntdlldefs.h"
2 | HMODULE NTDLL = NULL;
--------------------------------------------------------------------------------
/Injector/Dependencies/syscallcaller.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/Injector/Dependencies/syscallcaller.obj
--------------------------------------------------------------------------------
/Injector/ICHook/ICHooker.asm:
--------------------------------------------------------------------------------
1 | .data
2 | Hooker QWORD 0
3 | .const
4 |
5 |
6 | .code
7 | ICHookerLowLevelPartSetHooker PROC
8 | mov Hooker,rcx
9 | ret
10 | ICHookerLowLevelPartSetHooker ENDP
11 |
12 | ICHookerLowLevelPart PROC
13 |
14 |
15 | push rax ;anti-recursion
16 | mov rax,gs:[030h]
17 | test byte ptr [rax+02ECh],01
18 | je notrecursion
19 | pop rax
20 | jmp r10
21 | notrecursion:
22 | pop rax
23 |
24 | ;pushing old rsp
25 | push rsp
26 | ;return addr space
27 | sub rsp,08h
28 | ;pushing regs
29 | push rax
30 | push rcx
31 | push rdx
32 | push rbx
33 | push rbp
34 | push rsi
35 | push rdi
36 | push r8
37 | push r9
38 | push r10
39 | push r11
40 | push r12
41 | push r13
42 | push r14
43 | push r15
44 | sub rsp,010h
45 | movdqu [rsp],xmm0
46 | sub rsp,010h
47 | movdqu [rsp],xmm1
48 | sub rsp,010h
49 | movdqu [rsp],xmm2
50 | sub rsp,010h
51 | movdqu [rsp],xmm3
52 | sub rsp,010h
53 | movdqu [rsp],xmm4
54 | sub rsp,010h
55 | movdqu [rsp],xmm5
56 | sub rsp,010h
57 | movdqu [rsp],xmm6
58 | sub rsp,010h
59 | movdqu [rsp],xmm7
60 |
61 | push gs:[2e0h]
62 | push gs:[2d8h]
63 | mov gs:[2e0h], rsp
64 | mov gs:[2d8h], r10
65 |
66 | mov rax,gs:[030h] ;disabling IC
67 | mov byte ptr [rax+02ech],1
68 |
69 | mov rcx,rsp
70 | add rcx,10h
71 | sub rsp,30h
72 | and rsp,0fffffffffffffff0h
73 |
74 | call Hooker
75 |
76 | mov rax,gs:[030h] ;enabling IC
77 | mov byte ptr [rax+02ech],0
78 |
79 | mov rsp, gs:[2e0h]
80 | mov r10, gs:[2d8h]
81 | pop gs:[2e0h]
82 | pop gs:[2d8h]
83 |
84 | movdqu [rsp],xmm7
85 | add rsp,010h
86 | movdqu [rsp],xmm6
87 | add rsp,010h
88 | movdqu [rsp],xmm5
89 | add rsp,010h
90 | movdqu [rsp],xmm4
91 | add rsp,010h
92 | movdqu [rsp],xmm3
93 | add rsp,010h
94 | movdqu [rsp],xmm2
95 | add rsp,010h
96 | movdqu [rsp],xmm1
97 | add rsp,010h
98 | movdqu [rsp],xmm0
99 | add rsp,010h
100 | pop r15
101 | pop r14
102 | pop r13
103 | pop r12
104 | pop r11
105 | pop r10
106 | pop r9
107 | pop r8
108 | pop rdi
109 | pop rsi
110 | pop rbp
111 | pop rbx
112 | pop rdx
113 | pop rcx
114 | pop rax
115 | ;mov rsp,[rsp] ;real bad idea
116 | add rsp,10h
117 | recursion:
118 | jmp QWORD PTR [rsp-010h]
119 | ICHookerLowLevelPart ENDP
120 |
121 |
122 |
123 | END
--------------------------------------------------------------------------------
/Injector/ICHook/ICHooker.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include "ntdlldefs.h"
4 |
5 | extern "C" void ICHookerLowLevelPart();
6 | extern "C" void ICHookerLowLevelPartSetHooker(void*);
7 |
8 |
9 | struct ICStack {
10 |
11 | M128A xmm7;
12 | M128A xmm6;
13 | M128A xmm5;
14 | M128A xmm4;
15 | M128A xmm3;
16 | M128A xmm2;
17 | M128A xmm1;
18 | M128A xmm0;
19 |
20 | DWORD64 r15;
21 | DWORD64 r14;
22 | DWORD64 r13;
23 | DWORD64 r12;
24 | DWORD64 r11;
25 | DWORD64 r10;
26 | DWORD64 r9;
27 | DWORD64 r8;
28 |
29 | DWORD64 rdi;
30 | DWORD64 rsi;
31 | DWORD64 rbp;
32 | DWORD64 rbx;
33 | DWORD64 rdx;
34 | DWORD64 rcx;
35 | DWORD64 rax;
36 |
37 | DWORD64 returnaddr;
38 |
39 | DWORD64 rsp;
40 |
41 | };
--------------------------------------------------------------------------------
/Injector/Idk/Roblox.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | class instance_t final
4 | {
5 |
6 |
7 | public:
8 |
9 | uint64_t self;
10 |
11 | std::string name();
12 |
13 | };
--------------------------------------------------------------------------------
/Injector/Idk/SyscalCaller.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | extern "C" DWORD64 CallSyscall(WORD syscall,...);
--------------------------------------------------------------------------------
/Injector/Idk/Utils/TPInjection.cpp:
--------------------------------------------------------------------------------
1 | #include "TPInjection.h"
2 | bool CreateTPDirectThread(HANDLE process, void* addr) {
3 | PROCESS_HANDLE_SNAPSHOT_INFORMATION* handles = (PROCESS_HANDLE_SNAPSHOT_INFORMATION*)(new BYTE[100000]);
4 | goto sk;
5 | err:
6 | delete handles;
7 | return 0;
8 | sk:
9 | NTSTATUS stat = (DWORD)NtF("NtQuerySystemInformation")(ProcessHandleInformation, handles, 100000, NULL);
10 | if (stat != 0) { goto err; }
11 | DWORD handlen = 0;
12 | void (*fcn0)(...) = (void (*)(...))NtF("NtQueryObject");
13 | OBJECT_TYPE_INFORMATION* hndtype = (OBJECT_TYPE_INFORMATION*)(new BYTE[10000]);
14 | HANDLE iocomp = NULL;
15 | while (handlen < handles->NumberOfHandles) {
16 | if (DuplicateHandle(process, (HANDLE)handlen, GetCurrentProcess(), &iocomp, 0, 0, DUPLICATE_SAME_ACCESS) != 0) {
17 | fcn0(iocomp, 2, hndtype, 10000, NULL);
18 | //std::wcerr << hndtype->TypeName.Buffer << "\n";
19 | if (wcscmp(L"IoCompletion", hndtype->TypeName.Buffer) == 0) {
20 | goto iocompfound;
21 | }
22 | CloseHandle(iocomp);
23 | }
24 | handlen+=1;
25 | }
26 | goto err;
27 | iocompfound:
28 | TP_DIRECT Direct{ 0 };
29 | Direct.Callback = (TP_DIRECT*)(addr);
30 | PTP_DIRECT RemoteDirectAddress = (PTP_DIRECT)(VirtualAllocEx(process, NULL, sizeof(TP_DIRECT), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE));
31 | if (RemoteDirectAddress == NULL) { goto err; }
32 | if (WriteProcessMemory(process, RemoteDirectAddress, &Direct, sizeof(TP_DIRECT), NULL) == 0) { goto err; };
33 | if ((DWORD)NtF("ZwSetIoCompletion")(iocomp, RemoteDirectAddress, 0, 0, 0) != 0) { goto err; };
34 |
35 | delete handles;
36 | return 1;
37 | }
--------------------------------------------------------------------------------
/Injector/Idk/Utils/TPInjection.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "ntdlldefs.h"
9 | #include "ThreadPool.h"
10 | #include "WorkerFactory.h"
11 |
12 | bool CreateTPDirectThread(HANDLE process, void* addr);
--------------------------------------------------------------------------------
/Injector/Idk/Utils/Tools.cpp:
--------------------------------------------------------------------------------
1 | #include "Tools.h"
2 | #include
3 |
4 | SYSTEM_PROCESS_INFORMATION* FindProcessByModuleName(const wchar_t* modname) {
5 | SYSTEM_PROCESS_INFORMATION* Processes = (SYSTEM_PROCESS_INFORMATION*)malloc(0x400000);
6 | SYSTEM_PROCESS_INFORMATION* ret = NULL;
7 | SYSTEM_PROCESS_INFORMATION* ProcessCur;
8 | goto s;
9 | end:
10 | return ret;
11 | s:
12 |
13 | if ((DWORD)NtF("NtQuerySystemInformation")(SystemProcessInformation, Processes, 0x400000, NULL) != 0) { goto end; };
14 |
15 | ProcessCur = Processes;
16 | while (ProcessCur->NextOffset) {
17 | if (ProcessCur->ImageName.Buffer != 0) {
18 | if (wcscmp(ProcessCur->ImageName.Buffer, modname) == 0) {
19 | ret = ProcessCur;
20 | goto end;
21 | }
22 | }
23 | ProcessCur = (SYSTEM_PROCESS_INFORMATION*)((BYTE*)ProcessCur + ProcessCur->NextOffset);
24 | }
25 | goto end;
26 | }
27 |
28 | MODULEINFO FindModuleByNameInProcess(HANDLE process, const wchar_t* modname) {
29 | MODULEINFO info = { 0 };
30 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE | TH32CS_SNAPMODULE32, GetProcessId(process));
31 |
32 | if (hSnapshot != INVALID_HANDLE_VALUE) {
33 | MODULEENTRY32W me;
34 | me.dwSize = sizeof(me);
35 |
36 | if (Module32FirstW(hSnapshot, &me)) {
37 | do {
38 | if (_wcsicmp(me.szModule, modname) == 0) {
39 | info.lpBaseOfDll = me.modBaseAddr;
40 | info.SizeOfImage = me.modBaseSize;
41 | info.EntryPoint = me.hModule;
42 | break;
43 | }
44 | } while (Module32NextW(hSnapshot, &me));
45 | }
46 | CloseHandle(hSnapshot);
47 | }
48 | return info;
49 | }
50 |
51 | ULONG_PTR boffset(SIZE_T size, ULONG_PTR start, ULONG_PTR cur) {
52 | return (cur - start) % size;
53 | }
54 |
55 | ULONG_PTR PFindData(const BYTE* data, ULONG_PTR dsize, ULONG_PTR startpos, SIZE_T fsize, HANDLE hProcess, SIZE_T bufsize) {
56 | BYTE* buf = (BYTE*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE);
57 | BYTE* subbuf = (BYTE*)VirtualAlloc(NULL, dsize, MEM_COMMIT, PAGE_READWRITE);
58 | ULONG_PTR cur = startpos;
59 | while (cur - startpos < fsize) {
60 | if (boffset(bufsize, startpos, cur) == 0) {
61 | ReadProcessMemory(hProcess, (LPVOID)cur, buf, bufsize, NULL);
62 | }
63 | if (buf[boffset(bufsize, startpos, cur)] == data[0]) {
64 | ReadProcessMemory(hProcess, (LPVOID)cur, subbuf, dsize, NULL);
65 | ULONG_PTR subcur = 1;
66 | while (subcur < dsize & cur + subcur - startpos < fsize) {
67 | if (subbuf[subcur] != data[subcur]) {
68 | break;
69 | }
70 | subcur++;
71 | }
72 |
73 | if (subcur == dsize) {
74 | VirtualFree(buf, 0, MEM_RELEASE);
75 | VirtualFree(subbuf, 0, MEM_RELEASE);
76 | return cur;
77 | }
78 | }
79 | cur++;
80 | }
81 | VirtualFree(buf, 0, MEM_RELEASE);
82 | VirtualFree(subbuf, 0, MEM_RELEASE);
83 | return -1;
84 | }
--------------------------------------------------------------------------------
/Injector/Idk/Utils/Tools.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "ntdlldefs.h"
9 |
10 | static const char* basic_chars = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM<>,./?:;'\"|\\{}-_=+!@#$%^&*()[]~ \n";
11 |
12 | SYSTEM_PROCESS_INFORMATION * FindProcessByModuleName(const wchar_t * modname);
13 | MODULEINFO FindModuleByNameInProcess(HANDLE process,const wchar_t * modname);
14 | ULONG_PTR PFindData(const BYTE* data, ULONG_PTR dsize, ULONG_PTR startpos, SIZE_T fsize, HANDLE hProcess, SIZE_T bufsize);
15 |
16 | extern "C" DWORD GetCurrentTID();
17 | extern "C" void Capture(...);
18 |
19 | extern "C" NTSTATUS NtQueryVirtualMemoryInline(_In_ HANDLE ProcessHandle, _In_opt_ PVOID BaseAddress, _In_ MEMORY_INFORMATION_CLASS MemoryInformationClass, _Out_writes_bytes_(MemoryInformationLength) PVOID MemoryInformation, _In_ SIZE_T MemoryInformationLength, _Out_opt_ PSIZE_T ReturnLength);
20 | extern "C" NTSTATUS NtContuneInline(PCONTEXT context,BOOL a);
21 | extern "C" NTSTATUS NtProtectVirtualMemoryInline( _In_ HANDLE ProcessHandle, _Inout_ PVOID* BaseAddress, _Inout_ PSIZE_T RegionSize, _In_ ULONG NewProtect, _Out_ PULONG OldProtect);
--------------------------------------------------------------------------------
/Injector/Idk/Utils/WorkerFactory.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #define WORKER_FACTORY_RELEASE_WORKER 0x0001
4 | #define WORKER_FACTORY_WAIT 0x0002
5 | #define WORKER_FACTORY_SET_INFORMATION 0x0004
6 | #define WORKER_FACTORY_QUERY_INFORMATION 0x0008
7 | #define WORKER_FACTORY_READY_WORKER 0x0010
8 | #define WORKER_FACTORY_SHUTDOWN 0x0020
9 |
10 | #define WORKER_FACTORY_ALL_ACCESS ( \
11 | STANDARD_RIGHTS_REQUIRED | \
12 | WORKER_FACTORY_RELEASE_WORKER | \
13 | WORKER_FACTORY_WAIT | \
14 | WORKER_FACTORY_SET_INFORMATION | \
15 | WORKER_FACTORY_QUERY_INFORMATION | \
16 | WORKER_FACTORY_READY_WORKER | \
17 | WORKER_FACTORY_SHUTDOWN \
18 | )
19 |
20 | typedef struct _WORKER_FACTORY_BASIC_INFORMATION
21 | {
22 | LARGE_INTEGER Timeout;
23 | LARGE_INTEGER RetryTimeout;
24 | LARGE_INTEGER IdleTimeout;
25 | BOOLEAN Paused;
26 | BOOLEAN TimerSet;
27 | BOOLEAN QueuedToExWorker;
28 | BOOLEAN MayCreate;
29 | BOOLEAN CreateInProgress;
30 | BOOLEAN InsertedIntoQueue;
31 | BOOLEAN Shutdown;
32 | ULONG BindingCount;
33 | ULONG ThreadMinimum;
34 | ULONG ThreadMaximum;
35 | ULONG PendingWorkerCount;
36 | ULONG WaitingWorkerCount;
37 | ULONG TotalWorkerCount;
38 | ULONG ReleaseCount;
39 | LONGLONG InfiniteWaitGoal;
40 | PVOID StartRoutine;
41 | PVOID StartParameter;
42 | HANDLE ProcessId;
43 | SIZE_T StackReserve;
44 | SIZE_T StackCommit;
45 | NTSTATUS LastThreadCreationStatus;
46 | } WORKER_FACTORY_BASIC_INFORMATION, * PWORKER_FACTORY_BASIC_INFORMATION;
47 |
48 | typedef enum _SET_WORKERFACTORYINFOCLASS
49 | {
50 | WorkerFactoryTimeout = 0,
51 | WorkerFactoryRetryTimeout = 1,
52 | WorkerFactoryIdleTimeout = 2,
53 | WorkerFactoryBindingCount = 3,
54 | WorkerFactoryThreadMinimum = 4,
55 | WorkerFactoryThreadMaximum = 5,
56 | WorkerFactoryPaused = 6,
57 | WorkerFactoryAdjustThreadGoal = 8,
58 | WorkerFactoryCallbackType = 9,
59 | WorkerFactoryStackInformation = 10,
60 | WorkerFactoryThreadBasePriority = 11,
61 | WorkerFactoryTimeoutWaiters = 12,
62 | WorkerFactoryFlags = 13,
63 | WorkerFactoryThreadSoftMaximum = 14,
64 | WorkerFactoryMaxInfoClass = 15 /* Not implemented */
65 | } SET_WORKERFACTORYINFOCLASS, * PSET_WORKERFACTORYINFOCLASS;
66 |
67 | typedef enum _QUERY_WORKERFACTORYINFOCLASS
68 | {
69 | WorkerFactoryBasicInformation = 7,
70 | } QUERY_WORKERFACTORYINFOCLASS, * PQUERY_WORKERFACTORYINFOCLASS;
71 |
--------------------------------------------------------------------------------
/Injector/Injection/Injection.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "ntdlldefs.h"
10 | #include "ThreadPool.h"
11 | #include "WorkerFactory.h"
12 | #include "Tools.h"
13 | #include "TPInjection.h"
14 | #include "SyscalCaller.h"
15 | #include "ICHooker.h"
16 |
17 |
18 | struct INJECTION_DLL_PARAMS {
19 | ULONG_PTR EntryPointOffset;
20 | void* BaseAddr;
21 | };
22 |
23 | typedef struct InternalVars {
24 | MODULEINFO byfron;
25 | void* ICAddr;
26 | void* Injector;
27 | INJECTION_DLL_PARAMS dllparams;
28 | MEMORY_BASIC_INFORMATION InjectionHiddenMemory[256] = {};
29 | DWORD InjectionHiddenMemoryC = 0;
30 | SYSTEM_PROCESS_INFORMATION* RobloxProcessInfo;
31 | }*PInternalVars;
32 |
33 | extern InternalVars injection_vars;
34 | extern MODULEINFO thismoduleinfo;
35 |
36 | const BYTE ByfronICPattern[8] = { 0x41,0x52,0x50,0x9c,0x53,0x48,0x89,0xe3 }; //Byfron's IC pattern
37 |
38 | typedef BOOL(*DLLMAIN)(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved);
39 |
40 | bool GetThisModuleInfo();
41 |
42 | //Internal part
43 | void InjectionICHook(ICStack* stack);
44 | int InjectionDllCaller();
45 |
46 | //External part
47 | bool InjectionFindByfron(HANDLE process, PInternalVars s);
48 | bool InjectionAllocSelf(HANDLE process, PInternalVars s, MODULEINFO thismodinfo);
49 | bool InjectionSetupInternalPart(HANDLE process, PInternalVars s);
50 |
51 | //tools
52 | ULONG_PTR ConvertAddrByBase(ULONG_PTR Addr, ULONG_PTR OldBase, ULONG_PTR NewBase);
53 | void* ConvertAddrByBase(const void* Addr, const void* OldBase, const void* NewBase);
--------------------------------------------------------------------------------
/Injector/Injector.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 | Source Files
35 |
36 |
37 | Source Files
38 |
39 |
40 |
41 |
42 |
43 | Source Files
44 |
45 |
46 |
47 |
48 | Header Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 | Header Files
58 |
59 |
60 | Header Files
61 |
62 |
63 | Header Files
64 |
65 |
66 | Header Files
67 |
68 |
69 | Header Files
70 |
71 |
72 | Header Files
73 |
74 |
75 |
--------------------------------------------------------------------------------
/Injector/Update/Offsets.hpp:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | #define Hyperion "RobloxPlayerBeta.dll"
6 | inline std::wstring Hyp(Hyperion, Hyperion + strlen(Hyperion));
7 |
8 |
9 |
10 | #define Dll1 "msvcp140.dll"
11 | #define Dll2 "vcruntime140.dll"
12 | #define Dll3 "vcruntime140_1.dll"
13 |
14 |
15 |
16 | // updated for: version-ad3ee47cdc5e44f6
17 | #define REBASE(x) x + (uintptr_t)GetModuleHandle("RobloxPlayerBeta.exe")
18 | namespace Offsets {
19 | inline uintptr_t O_SetInsert = 0xD77510;
20 | inline uintptr_t O_WhitelistedPages = 0x2A3820;
21 | inline uintptr_t O_PageHash = 0xAA9F8E1B;
22 |
23 | namespace virtuals {
24 | inline uintptr_t PageShift = 0xc;
25 | inline uintptr_t kbyeshift = 0x2C;
26 |
27 | }
28 | namespace BitMap {
29 | inline uintptr_t Bitmap = 0x2855A8;
30 | inline uintptr_t BitmapShift = 0x13;
31 | inline uintptr_t BitmapFieldShift = 0x10;
32 | inline uintptr_t BitmapHash = 0x27;
33 | }
34 | namespace Extraspace {
35 | inline uintptr_t MaxCap = 0xfffffffffffff000;
36 | inline uint32_t IDE = 7;
37 |
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Injector/main.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "Injection.h"
9 | #include "ICHooker.h"
10 | #include "ntdlldefs.h"
11 | #include "ThreadPool.h"
12 | #include "WorkerFactory.h"
13 | #include "Tools.h"
14 | #include "SyscalCaller.h"
15 | #include
16 |
17 | #include
18 | int wmain(int argc, wchar_t* argv[]);
19 | int WINAPI WinMain(
20 | HINSTANCE hInstance,
21 | HINSTANCE hPrevInstance,
22 | LPSTR lpCmdLine,
23 | int nCmdShow)
24 | {
25 | AllocConsole();
26 | FILE* pCout;
27 | freopen_s(&pCout, "CONOUT$", "w", stdout);
28 | FILE* pCin;
29 | freopen_s(&pCin, "CONIN$", "r", stdin);
30 | FILE* pCerr;
31 | freopen_s(&pCerr, "CONOUT$", "w", stderr);
32 | int argc;
33 | LPWSTR* wargv = CommandLineToArgvW(GetCommandLineW(), &argc);
34 | int result = wmain(argc, wargv);
35 | LocalFree(wargv);
36 | std::cin.get();
37 |
38 | return result;
39 | }
--------------------------------------------------------------------------------
/ModuleBase.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.13.35806.99
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ModuleBase", "ModuleBase\ModuleBase.vcxproj", "{F500F81E-C90D-4E84-AAB5-49BDC1D503D8}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Executor", "Executor\Executor.csproj", "{FC42A5A5-D037-42D4-BD99-C6570EFEB837}"
9 | EndProject
10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Injector", "Injector\Injector.vcxproj", "{44BCAE83-EE1A-4E26-898F-2B0265992774}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Debug|x64 = Debug|x64
16 | Debug|x86 = Debug|x86
17 | Release|Any CPU = Release|Any CPU
18 | Release|x64 = Release|x64
19 | Release|x86 = Release|x86
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|Any CPU.ActiveCfg = Debug|x64
23 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|Any CPU.Build.0 = Debug|x64
24 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|x64.ActiveCfg = Debug|x64
25 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|x64.Build.0 = Debug|x64
26 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|x86.ActiveCfg = Debug|Win32
27 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Debug|x86.Build.0 = Debug|Win32
28 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|Any CPU.ActiveCfg = Release|x64
29 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|Any CPU.Build.0 = Release|x64
30 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|x64.ActiveCfg = Release|x64
31 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|x64.Build.0 = Release|x64
32 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|x86.ActiveCfg = Release|Win32
33 | {F500F81E-C90D-4E84-AAB5-49BDC1D503D8}.Release|x86.Build.0 = Release|Win32
34 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|x64.ActiveCfg = Debug|Any CPU
37 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|x64.Build.0 = Debug|Any CPU
38 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|x86.ActiveCfg = Debug|Any CPU
39 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Debug|x86.Build.0 = Debug|Any CPU
40 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|Any CPU.Build.0 = Release|Any CPU
42 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|x64.ActiveCfg = Release|Any CPU
43 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|x64.Build.0 = Release|Any CPU
44 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|x86.ActiveCfg = Release|Any CPU
45 | {FC42A5A5-D037-42D4-BD99-C6570EFEB837}.Release|x86.Build.0 = Release|Any CPU
46 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|Any CPU.ActiveCfg = Debug|x64
47 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|Any CPU.Build.0 = Debug|x64
48 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|x64.ActiveCfg = Debug|x64
49 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|x64.Build.0 = Debug|x64
50 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|x86.ActiveCfg = Debug|Win32
51 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Debug|x86.Build.0 = Debug|Win32
52 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|Any CPU.ActiveCfg = Release|x64
53 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|Any CPU.Build.0 = Release|x64
54 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|x64.ActiveCfg = Release|x64
55 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|x64.Build.0 = Release|x64
56 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|x86.ActiveCfg = Release|Win32
57 | {44BCAE83-EE1A-4E26-898F-2B0265992774}.Release|x86.Build.0 = Release|Win32
58 | EndGlobalSection
59 | GlobalSection(SolutionProperties) = preSolution
60 | HideSolutionNode = FALSE
61 | EndGlobalSection
62 | GlobalSection(ExtensibilityGlobals) = postSolution
63 | SolutionGuid = {6A79191E-5C89-4024-B076-D642ED8B2E12}
64 | EndGlobalSection
65 | EndGlobal
66 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/Allocator.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/Location.h"
6 | #include "Luau/DenseHash.h"
7 | #include "Luau/Common.h"
8 |
9 | #include
10 |
11 | namespace Luau
12 | {
13 |
14 | class Allocator
15 | {
16 | public:
17 | Allocator();
18 | Allocator(Allocator&&);
19 |
20 | Allocator& operator=(Allocator&&) = delete;
21 |
22 | ~Allocator();
23 |
24 | void* allocate(size_t size);
25 |
26 | template
27 | T* alloc(Args&&... args)
28 | {
29 | static_assert(std::is_trivially_destructible::value, "Objects allocated with this allocator will never have their destructors run!");
30 |
31 | T* t = static_cast(allocate(sizeof(T)));
32 | new (t) T(std::forward(args)...);
33 | return t;
34 | }
35 |
36 | private:
37 | struct Page
38 | {
39 | Page* next;
40 |
41 | alignas(8) char data[8192];
42 | };
43 |
44 | Page* root;
45 | size_t offset;
46 | };
47 |
48 | } // namespace Luau
49 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/Confusables.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include
5 |
6 | namespace Luau
7 | {
8 | const char* findConfusable(uint32_t codepoint);
9 | }
10 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/Location.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | namespace Luau
5 | {
6 |
7 | struct Position
8 | {
9 | unsigned int line, column;
10 |
11 | Position(unsigned int line, unsigned int column)
12 | : line(line)
13 | , column(column)
14 | {
15 | }
16 |
17 | bool operator==(const Position& rhs) const
18 | {
19 | return this->column == rhs.column && this->line == rhs.line;
20 | }
21 |
22 | bool operator!=(const Position& rhs) const
23 | {
24 | return !(*this == rhs);
25 | }
26 | bool operator<(const Position& rhs) const
27 | {
28 | if (line == rhs.line)
29 | return column < rhs.column;
30 | else
31 | return line < rhs.line;
32 | }
33 | bool operator>(const Position& rhs) const
34 | {
35 | if (line == rhs.line)
36 | return column > rhs.column;
37 | else
38 | return line > rhs.line;
39 | }
40 | bool operator<=(const Position& rhs) const
41 | {
42 | return *this == rhs || *this < rhs;
43 | }
44 | bool operator>=(const Position& rhs) const
45 | {
46 | return *this == rhs || *this > rhs;
47 | }
48 |
49 | void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
50 | };
51 |
52 | struct Location
53 | {
54 | Position begin, end;
55 |
56 | Location()
57 | : begin(0, 0)
58 | , end(0, 0)
59 | {
60 | }
61 |
62 | Location(const Position& begin, const Position& end)
63 | : begin(begin)
64 | , end(end)
65 | {
66 | }
67 |
68 | Location(const Position& begin, unsigned int length)
69 | : begin(begin)
70 | , end(begin.line, begin.column + length)
71 | {
72 | }
73 |
74 | Location(const Location& begin, const Location& end)
75 | : begin(begin.begin)
76 | , end(end.end)
77 | {
78 | }
79 |
80 | bool operator==(const Location& rhs) const
81 | {
82 | return this->begin == rhs.begin && this->end == rhs.end;
83 | }
84 | bool operator!=(const Location& rhs) const
85 | {
86 | return !(*this == rhs);
87 | }
88 |
89 | bool encloses(const Location& l) const;
90 | bool overlaps(const Location& l) const;
91 | bool contains(const Position& p) const;
92 | bool containsClosed(const Position& p) const;
93 | void extend(const Location& other);
94 | void shift(const Position& start, const Position& oldEnd, const Position& newEnd);
95 | };
96 |
97 | } // namespace Luau
98 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/ParseOptions.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/DenseHash.h"
6 |
7 | #include
8 |
9 | namespace Luau
10 | {
11 |
12 | enum class Mode
13 | {
14 | NoCheck, // Do not perform any inference
15 | Nonstrict, // Unannotated symbols are any
16 | Strict, // Unannotated symbols are inferred
17 | Definition, // Type definition module, has special parsing rules
18 | };
19 |
20 | struct FragmentParseResumeSettings
21 | {
22 | DenseHashMap localMap{AstName()};
23 | std::vector localStack;
24 | Position resumePosition;
25 | };
26 |
27 | struct ParseOptions
28 | {
29 | bool allowDeclarationSyntax = false;
30 | bool captureComments = false;
31 | std::optional parseFragment = std::nullopt;
32 | bool storeCstData = false;
33 | bool noErrorLimit = false;
34 | };
35 |
36 | } // namespace Luau
37 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/ParseResult.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Common.h"
5 | #include "Luau/Location.h"
6 | #include "Luau/Lexer.h"
7 | #include "Luau/StringUtils.h"
8 |
9 | namespace Luau
10 | {
11 |
12 | class AstStatBlock;
13 | class CstNode;
14 |
15 | class ParseError : public std::exception
16 | {
17 | public:
18 | ParseError(const Location& location, const std::string& message);
19 |
20 | virtual const char* what() const throw();
21 |
22 | const Location& getLocation() const;
23 | const std::string& getMessage() const;
24 |
25 | static LUAU_NORETURN void raise(const Location& location, const char* format, ...) LUAU_PRINTF_ATTR(2, 3);
26 |
27 | private:
28 | Location location;
29 | std::string message;
30 | };
31 |
32 | class ParseErrors : public std::exception
33 | {
34 | public:
35 | ParseErrors(std::vector errors);
36 |
37 | virtual const char* what() const throw();
38 |
39 | const std::vector& getErrors() const;
40 |
41 | private:
42 | std::vector errors;
43 | std::string message;
44 | };
45 |
46 | struct HotComment
47 | {
48 | bool header;
49 | Location location;
50 | std::string content;
51 | };
52 |
53 | struct Comment
54 | {
55 | Lexeme::Type type; // Comment, BlockComment, or BrokenComment
56 | Location location;
57 | };
58 |
59 | using CstNodeMap = DenseHashMap;
60 |
61 | struct ParseResult
62 | {
63 | AstStatBlock* root;
64 | size_t lines = 0;
65 |
66 | std::vector hotcomments;
67 | std::vector errors;
68 |
69 | std::vector commentLocations;
70 |
71 | CstNodeMap cstNodeMap{nullptr};
72 | };
73 |
74 | struct ParseExprResult
75 | {
76 | AstExpr* expr;
77 | size_t lines = 0;
78 |
79 | std::vector hotcomments;
80 | std::vector errors;
81 |
82 | std::vector commentLocations;
83 |
84 | CstNodeMap cstNodeMap{nullptr};
85 | };
86 |
87 | static constexpr const char* kParseNameError = "%error-id%";
88 |
89 | } // namespace Luau
90 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/include/Luau/StringUtils.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Common.h"
5 |
6 | #include
7 | #include
8 |
9 | #include
10 |
11 | namespace Luau
12 | {
13 |
14 | std::string format(const char* fmt, ...) LUAU_PRINTF_ATTR(1, 2);
15 | std::string vformat(const char* fmt, va_list args);
16 |
17 | void formatAppend(std::string& str, const char* fmt, ...) LUAU_PRINTF_ATTR(2, 3);
18 | void vformatAppend(std::string& ret, const char* fmt, va_list args);
19 |
20 | std::string join(const std::vector& segments, std::string_view delimiter);
21 | std::string join(const std::vector& segments, std::string_view delimiter);
22 |
23 | std::vector split(std::string_view s, char delimiter);
24 |
25 | // Computes the Damerau-Levenshtein distance of A and B.
26 | // https://en.wikipedia.org/wiki/Damerau-Levenshtein_distance#Distance_with_adjacent_transpositions
27 | size_t editDistance(std::string_view a, std::string_view b);
28 |
29 | bool startsWith(std::string_view lhs, std::string_view rhs);
30 | bool equalsLower(std::string_view lhs, std::string_view rhs);
31 |
32 | size_t hashRange(const char* data, size_t size);
33 |
34 | std::string escape(std::string_view s, bool escapeForInterpString = false);
35 | bool isIdentifier(std::string_view s);
36 | } // namespace Luau
37 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/src/Allocator.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 |
3 | #include "Luau/Allocator.h"
4 |
5 | namespace Luau
6 | {
7 |
8 | Allocator::Allocator()
9 | : root(static_cast(operator new(sizeof(Page))))
10 | , offset(0)
11 | {
12 | root->next = nullptr;
13 | }
14 |
15 | Allocator::Allocator(Allocator&& rhs)
16 | : root(rhs.root)
17 | , offset(rhs.offset)
18 | {
19 | rhs.root = nullptr;
20 | rhs.offset = 0;
21 | }
22 |
23 | Allocator::~Allocator()
24 | {
25 | Page* page = root;
26 |
27 | while (page)
28 | {
29 | Page* next = page->next;
30 |
31 | operator delete(page);
32 |
33 | page = next;
34 | }
35 | }
36 |
37 | void* Allocator::allocate(size_t size)
38 | {
39 | constexpr size_t align = alignof(void*) > alignof(double) ? alignof(void*) : alignof(double);
40 |
41 | if (root)
42 | {
43 | uintptr_t data = reinterpret_cast(root->data);
44 | uintptr_t result = (data + offset + align - 1) & ~(align - 1);
45 | if (result + size <= data + sizeof(root->data))
46 | {
47 | offset = result - data + size;
48 | return reinterpret_cast(result);
49 | }
50 | }
51 |
52 | // allocate new page
53 | size_t pageSize = size > sizeof(root->data) ? size : sizeof(root->data);
54 | void* pageData = operator new(offsetof(Page, data) + pageSize);
55 |
56 | Page* page = static_cast(pageData);
57 |
58 | page->next = root;
59 |
60 | root = page;
61 | offset = size;
62 |
63 | return page->data;
64 | }
65 |
66 | } // namespace Luau
67 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Ast/src/Location.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #include "Luau/Location.h"
3 |
4 | namespace Luau
5 | {
6 |
7 | void Position::shift(const Position& start, const Position& oldEnd, const Position& newEnd)
8 | {
9 | if (*this >= start)
10 | {
11 | if (this->line > oldEnd.line)
12 | this->line += (newEnd.line - oldEnd.line);
13 | else
14 | {
15 | this->line = newEnd.line;
16 | this->column += (newEnd.column - oldEnd.column);
17 | }
18 | }
19 | }
20 |
21 | bool Location::encloses(const Location& l) const
22 | {
23 | return begin <= l.begin && end >= l.end;
24 | }
25 |
26 | bool Location::overlaps(const Location& l) const
27 | {
28 | return (begin <= l.begin && end >= l.begin) || (begin <= l.end && end >= l.end) || (begin >= l.begin && end <= l.end);
29 | }
30 |
31 | bool Location::contains(const Position& p) const
32 | {
33 | return begin <= p && p < end;
34 | }
35 |
36 | bool Location::containsClosed(const Position& p) const
37 | {
38 | return begin <= p && p <= end;
39 | }
40 |
41 | void Location::extend(const Location& other)
42 | {
43 | if (other.begin < begin)
44 | begin = other.begin;
45 | if (other.end > end)
46 | end = other.end;
47 | }
48 |
49 | void Location::shift(const Position& start, const Position& oldEnd, const Position& newEnd)
50 | {
51 | begin.shift(start, oldEnd, newEnd);
52 | end.shift(start, oldEnd, newEnd);
53 | }
54 |
55 | } // namespace Luau
56 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Common/include/Luau/BytecodeUtils.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Bytecode.h"
5 |
6 | namespace Luau
7 | {
8 |
9 | inline int getOpLength(LuauOpcode op)
10 | {
11 | switch (op)
12 | {
13 | case LOP_GETGLOBAL:
14 | case LOP_SETGLOBAL:
15 | case LOP_GETIMPORT:
16 | case LOP_GETTABLEKS:
17 | case LOP_SETTABLEKS:
18 | case LOP_NAMECALL:
19 | case LOP_JUMPIFEQ:
20 | case LOP_JUMPIFLE:
21 | case LOP_JUMPIFLT:
22 | case LOP_JUMPIFNOTEQ:
23 | case LOP_JUMPIFNOTLE:
24 | case LOP_JUMPIFNOTLT:
25 | case LOP_NEWTABLE:
26 | case LOP_SETLIST:
27 | case LOP_FORGLOOP:
28 | case LOP_LOADKX:
29 | case LOP_FASTCALL2:
30 | case LOP_FASTCALL2K:
31 | case LOP_FASTCALL3:
32 | case LOP_JUMPXEQKNIL:
33 | case LOP_JUMPXEQKB:
34 | case LOP_JUMPXEQKN:
35 | case LOP_JUMPXEQKS:
36 | return 2;
37 |
38 | default:
39 | return 1;
40 | }
41 | }
42 |
43 | } // namespace Luau
44 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Common/include/Luau/Common.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | // Compiler codegen control macros
5 | #ifdef _MSC_VER
6 | #define LUAU_NORETURN __declspec(noreturn)
7 | #define LUAU_NOINLINE __declspec(noinline)
8 | #define LUAU_FORCEINLINE __forceinline
9 | #define LUAU_LIKELY(x) x
10 | #define LUAU_UNLIKELY(x) x
11 | #define LUAU_UNREACHABLE() __assume(false)
12 | #define LUAU_DEBUGBREAK() __debugbreak()
13 | #else
14 | #define LUAU_NORETURN __attribute__((__noreturn__))
15 | #define LUAU_NOINLINE __attribute__((noinline))
16 | #define LUAU_FORCEINLINE inline __attribute__((always_inline))
17 | #define LUAU_LIKELY(x) __builtin_expect(x, 1)
18 | #define LUAU_UNLIKELY(x) __builtin_expect(x, 0)
19 | #define LUAU_UNREACHABLE() __builtin_unreachable()
20 | #define LUAU_DEBUGBREAK() __builtin_trap()
21 | #endif
22 |
23 | // LUAU_FALLTHROUGH is a C++11-compatible alternative to [[fallthrough]] for use in the VM library
24 | #if defined(__clang__) && defined(__has_warning)
25 | #if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
26 | #define LUAU_FALLTHROUGH [[clang::fallthrough]]
27 | #else
28 | #define LUAU_FALLTHROUGH
29 | #endif
30 | #elif defined(__GNUC__) && __GNUC__ >= 7
31 | #define LUAU_FALLTHROUGH [[gnu::fallthrough]]
32 | #else
33 | #define LUAU_FALLTHROUGH
34 | #endif
35 |
36 | #if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
37 | #define LUAU_BIG_ENDIAN
38 | #endif
39 |
40 | namespace Luau
41 | {
42 |
43 | using AssertHandler = int (*)(const char* expression, const char* file, int line, const char* function);
44 |
45 | inline AssertHandler& assertHandler()
46 | {
47 | static AssertHandler handler = nullptr;
48 | return handler;
49 | }
50 |
51 | // We want 'inline' to correctly link this function declared in the header
52 | // But we also want to prevent compiler from inlining this function when optimization and assertions are enabled together
53 | // Reason for that is that compilation times can increase significantly in such a configuration
54 | LUAU_NOINLINE inline int assertCallHandler(const char* expression, const char* file, int line, const char* function)
55 | {
56 | if (AssertHandler handler = assertHandler())
57 | return handler(expression, file, line, function);
58 |
59 | return 1;
60 | }
61 |
62 | } // namespace Luau
63 |
64 | #if !defined(NDEBUG) || defined(LUAU_ENABLE_ASSERT)
65 | #define LUAU_ASSERT(expr) ((void)(!!(expr) || (Luau::assertCallHandler(#expr, __FILE__, __LINE__, __FUNCTION__) && (LUAU_DEBUGBREAK(), 0))))
66 | #define LUAU_ASSERTENABLED
67 | #else
68 | #define LUAU_ASSERT(expr) (void)sizeof(!!(expr))
69 | #endif
70 |
71 | namespace Luau
72 | {
73 |
74 | template
75 | struct FValue
76 | {
77 | static FValue* list;
78 |
79 | T value;
80 | bool dynamic;
81 | const char* name;
82 | FValue* next;
83 |
84 | FValue(const char* name, T def, bool dynamic)
85 | : value(def)
86 | , dynamic(dynamic)
87 | , name(name)
88 | , next(list)
89 | {
90 | list = this;
91 | }
92 |
93 | LUAU_FORCEINLINE operator T() const
94 | {
95 | return value;
96 | }
97 | };
98 |
99 | template
100 | FValue* FValue::list = nullptr;
101 |
102 | } // namespace Luau
103 |
104 | #define LUAU_FASTFLAG(flag) \
105 | namespace FFlag \
106 | { \
107 | extern Luau::FValue flag; \
108 | }
109 | #define LUAU_FASTFLAGVARIABLE(flag) \
110 | namespace FFlag \
111 | { \
112 | Luau::FValue flag(#flag, false, false); \
113 | }
114 | #define LUAU_FASTINT(flag) \
115 | namespace FInt \
116 | { \
117 | extern Luau::FValue flag; \
118 | }
119 | #define LUAU_FASTINTVARIABLE(flag, def) \
120 | namespace FInt \
121 | { \
122 | Luau::FValue flag(#flag, def, false); \
123 | }
124 |
125 | #define LUAU_DYNAMIC_FASTFLAG(flag) \
126 | namespace DFFlag \
127 | { \
128 | extern Luau::FValue flag; \
129 | }
130 | #define LUAU_DYNAMIC_FASTFLAGVARIABLE(flag, def) \
131 | namespace DFFlag \
132 | { \
133 | Luau::FValue flag(#flag, def, true); \
134 | }
135 | #define LUAU_DYNAMIC_FASTINT(flag) \
136 | namespace DFInt \
137 | { \
138 | extern Luau::FValue flag; \
139 | }
140 | #define LUAU_DYNAMIC_FASTINTVARIABLE(flag, def) \
141 | namespace DFInt \
142 | { \
143 | Luau::FValue flag(#flag, def, true); \
144 | }
145 |
146 | #if defined(__GNUC__)
147 | #define LUAU_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))
148 | #else
149 | #define LUAU_PRINTF_ATTR(fmt, arg)
150 | #endif
151 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Common/include/Luau/ExperimentalFlags.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include
5 |
6 | namespace Luau
7 | {
8 |
9 | inline bool isAnalysisFlagExperimental(const char* flag)
10 | {
11 | // Flags in this list are disabled by default in various command-line tools. They may have behavior that is not fully final,
12 | // or critical bugs that are found after the code has been submitted. This list is intended _only_ for flags that affect
13 | // Luau's type checking. Flags that may change runtime behavior (e.g.: parser or VM flags) are not appropriate for this list.
14 | static const char* const kList[] = {
15 | "LuauInstantiateInSubtyping", // requires some fixes to lua-apps code
16 | "LuauFixIndexerSubtypingOrdering", // requires some small fixes to lua-apps code since this fixes a false negative
17 | "StudioReportLuauAny2", // takes telemetry data for usage of any types
18 | "LuauTableCloneClonesType3", // requires fixes in lua-apps code, terrifyingly
19 | "LuauSolverV2",
20 | // makes sure we always have at least one entry
21 | nullptr,
22 | };
23 |
24 | for (const char* item : kList)
25 | if (item && strcmp(item, flag) == 0)
26 | return true;
27 |
28 | return false;
29 | }
30 |
31 | } // namespace Luau
32 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/include/Luau/Compiler.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/ParseOptions.h"
5 | #include "Luau/Location.h"
6 | #include "Luau/StringUtils.h"
7 | #include "Luau/Common.h"
8 |
9 | namespace Luau
10 | {
11 | class AstNameTable;
12 | struct ParseResult;
13 | class BytecodeBuilder;
14 | class BytecodeEncoder;
15 |
16 | using CompileConstant = void*;
17 |
18 | // return a type identifier for a global library member
19 | // values are defined by 'enum LuauBytecodeType' in Bytecode.h
20 | using LibraryMemberTypeCallback = int (*)(const char* library, const char* member);
21 |
22 | // setup a value of a constant for a global library member
23 | // use setCompileConstant*** set of functions for values
24 | using LibraryMemberConstantCallback = void (*)(const char* library, const char* member, CompileConstant* constant);
25 |
26 | // Note: this structure is duplicated in luacode.h, don't forget to change these in sync!
27 | struct CompileOptions
28 | {
29 | // 0 - no optimization
30 | // 1 - baseline optimization level that doesn't prevent debuggability
31 | // 2 - includes optimizations that harm debuggability such as inlining
32 | int optimizationLevel = 1;
33 |
34 | // 0 - no debugging support
35 | // 1 - line info & function names only; sufficient for backtraces
36 | // 2 - full debug info with local & upvalue names; necessary for debugger
37 | int debugLevel = 1;
38 |
39 | // type information is used to guide native code generation decisions
40 | // information includes testable types for function arguments, locals, upvalues and some temporaries
41 | // 0 - generate for native modules
42 | // 1 - generate for all modules
43 | int typeInfoLevel = 0;
44 |
45 | // 0 - no code coverage support
46 | // 1 - statement coverage
47 | // 2 - statement and expression coverage (verbose)
48 | int coverageLevel = 0;
49 |
50 | // alternative global builtin to construct vectors, in addition to default builtin 'vector.create'
51 | const char* vectorLib = nullptr;
52 | const char* vectorCtor = nullptr;
53 |
54 | // alternative vector type name for type tables, in addition to default type 'vector'
55 | const char* vectorType = nullptr;
56 |
57 | // null-terminated array of globals that are mutable; disables the import optimization for fields accessed through these
58 | const char* const* mutableGlobals = nullptr;
59 |
60 | // null-terminated array of userdata types that will be included in the type information
61 | const char* const* userdataTypes = nullptr;
62 |
63 | // null-terminated array of globals which act as libraries and have members with known type and/or constant value
64 | // when an import of one of these libraries is accessed, callbacks below will be called to receive that information
65 | const char* const* librariesWithKnownMembers = nullptr;
66 | LibraryMemberTypeCallback libraryMemberTypeCb = nullptr;
67 | LibraryMemberConstantCallback libraryMemberConstantCb = nullptr;
68 |
69 | // null-terminated array of library functions that should not be compiled into a built-in fastcall ("name" "lib.name")
70 | const char* const* disabledBuiltins = nullptr;
71 | };
72 |
73 | class CompileError : public std::exception
74 | {
75 | public:
76 | CompileError(const Location& location, const std::string& message);
77 |
78 | virtual ~CompileError() throw();
79 |
80 | virtual const char* what() const throw();
81 |
82 | const Location& getLocation() const;
83 |
84 | static LUAU_NORETURN void raise(const Location& location, const char* format, ...) LUAU_PRINTF_ATTR(2, 3);
85 |
86 | private:
87 | Location location;
88 | std::string message;
89 | };
90 |
91 | // compiles bytecode into bytecode builder using either a pre-parsed AST or parsing it from source; throws on errors
92 | void compileOrThrow(BytecodeBuilder& bytecode, const ParseResult& parseResult, const AstNameTable& names, const CompileOptions& options = {});
93 | void compileOrThrow(BytecodeBuilder& bytecode, const std::string& source, const CompileOptions& options = {}, const ParseOptions& parseOptions = {});
94 |
95 | // compiles bytecode into a bytecode blob, that either contains the valid bytecode or an encoded error that luau_load can decode
96 | std::string compile(
97 | const std::string& source,
98 | const CompileOptions& options = {},
99 | const ParseOptions& parseOptions = {},
100 | BytecodeEncoder* encoder = nullptr
101 | );
102 |
103 | void setCompileConstantNil(CompileConstant* constant);
104 | void setCompileConstantBoolean(CompileConstant* constant, bool b);
105 | void setCompileConstantNumber(CompileConstant* constant, double n);
106 | void setCompileConstantVector(CompileConstant* constant, float x, float y, float z, float w);
107 | void setCompileConstantString(CompileConstant* constant, const char* s, size_t l);
108 |
109 | } // namespace Luau
110 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/include/luacode.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include
5 |
6 | // can be used to reconfigure visibility/exports for public APIs
7 | #ifndef LUACODE_API
8 | #define LUACODE_API extern
9 | #endif
10 |
11 | typedef struct lua_CompileOptions lua_CompileOptions;
12 | typedef void* lua_CompileConstant;
13 |
14 | // return a type identifier for a global library member
15 | // values are defined by 'enum LuauBytecodeType' in Bytecode.h
16 | typedef int (*lua_LibraryMemberTypeCallback)(const char* library, const char* member);
17 |
18 | // setup a value of a constant for a global library member
19 | // use luau_set_compile_constant_*** set of functions for values
20 | typedef void (*lua_LibraryMemberConstantCallback)(const char* library, const char* member, lua_CompileConstant* constant);
21 |
22 | struct lua_CompileOptions
23 | {
24 | // 0 - no optimization
25 | // 1 - baseline optimization level that doesn't prevent debuggability
26 | // 2 - includes optimizations that harm debuggability such as inlining
27 | int optimizationLevel; // default=1
28 |
29 | // 0 - no debugging support
30 | // 1 - line info & function names only; sufficient for backtraces
31 | // 2 - full debug info with local & upvalue names; necessary for debugger
32 | int debugLevel; // default=1
33 |
34 | // type information is used to guide native code generation decisions
35 | // information includes testable types for function arguments, locals, upvalues and some temporaries
36 | // 0 - generate for native modules
37 | // 1 - generate for all modules
38 | int typeInfoLevel; // default=0
39 |
40 | // 0 - no code coverage support
41 | // 1 - statement coverage
42 | // 2 - statement and expression coverage (verbose)
43 | int coverageLevel; // default=0
44 |
45 | // alternative global builtin to construct vectors, in addition to default builtin 'vector.create'
46 | const char* vectorLib;
47 | const char* vectorCtor;
48 |
49 | // alternative vector type name for type tables, in addition to default type 'vector'
50 | const char* vectorType;
51 |
52 | // null-terminated array of globals that are mutable; disables the import optimization for fields accessed through these
53 | const char* const* mutableGlobals;
54 |
55 | // null-terminated array of userdata types that will be included in the type information
56 | const char* const* userdataTypes;
57 |
58 | // null-terminated array of globals which act as libraries and have members with known type and/or constant value
59 | // when an import of one of these libraries is accessed, callbacks below will be called to receive that information
60 | const char* const* librariesWithKnownMembers;
61 | lua_LibraryMemberTypeCallback libraryMemberTypeCb;
62 | lua_LibraryMemberConstantCallback libraryMemberConstantCb;
63 |
64 | // null-terminated array of library functions that should not be compiled into a built-in fastcall ("name" "lib.name")
65 | const char* const* disabledBuiltins;
66 | };
67 |
68 | // compile source to bytecode; when source compilation fails, the resulting bytecode contains the encoded error. use free() to destroy
69 | LUACODE_API char* luau_compile(const char* source, size_t size, lua_CompileOptions* options, size_t* outsize);
70 |
71 | // when libraryMemberConstantCb is called, these methods can be used to set a value of the opaque lua_CompileConstant struct
72 | // vector component 'w' is not visible to VM runtime configured with LUA_VECTOR_SIZE == 3, but can affect constant folding during compilation
73 | // string storage must outlive the invocation of 'luau_compile' which used the callback
74 | LUACODE_API void luau_set_compile_constant_nil(lua_CompileConstant* constant);
75 | LUACODE_API void luau_set_compile_constant_boolean(lua_CompileConstant* constant, int b);
76 | LUACODE_API void luau_set_compile_constant_number(lua_CompileConstant* constant, double n);
77 | LUACODE_API void luau_set_compile_constant_vector(lua_CompileConstant* constant, float x, float y, float z, float w);
78 | LUACODE_API void luau_set_compile_constant_string(lua_CompileConstant* constant, const char* s, size_t l);
79 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/BuiltinFolding.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "ConstantFolding.h"
5 |
6 | namespace Luau
7 | {
8 | namespace Compile
9 | {
10 |
11 | Constant foldBuiltin(int bfid, const Constant* args, size_t count);
12 | Constant foldBuiltinMath(AstName index);
13 |
14 | } // namespace Compile
15 | } // namespace Luau
16 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/Builtins.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "ValueTracking.h"
5 |
6 | namespace Luau
7 | {
8 | struct CompileOptions;
9 | }
10 |
11 | namespace Luau
12 | {
13 | namespace Compile
14 | {
15 |
16 | struct Builtin
17 | {
18 | AstName object;
19 | AstName method;
20 |
21 | bool empty() const
22 | {
23 | return object == AstName() && method == AstName();
24 | }
25 |
26 | bool isGlobal(const char* name) const
27 | {
28 | return object == AstName() && method == name;
29 | }
30 |
31 | bool isMethod(const char* table, const char* name) const
32 | {
33 | return object == table && method == name;
34 | }
35 | };
36 |
37 | Builtin getBuiltin(AstExpr* node, const DenseHashMap& globals, const DenseHashMap& variables);
38 |
39 | void analyzeBuiltins(
40 | DenseHashMap& result,
41 | const DenseHashMap& globals,
42 | const DenseHashMap& variables,
43 | const CompileOptions& options,
44 | AstNode* root,
45 | const AstNameTable& names
46 | );
47 |
48 | struct BuiltinInfo
49 | {
50 | enum Flags
51 | {
52 | // none-safe builtins are builtins that have the same behavior for arguments that are nil or none
53 | // this allows the compiler to compile calls to builtins more efficiently in certain cases
54 | // for example, math.abs(x()) may compile x() as if it returns one value; if it returns no values, abs() will get nil instead of none
55 | Flag_NoneSafe = 1 << 0,
56 | };
57 |
58 | int params;
59 | int results;
60 | unsigned int flags;
61 | };
62 |
63 | BuiltinInfo getBuiltinInfo(int bfid);
64 |
65 | } // namespace Compile
66 | } // namespace Luau
67 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/ConstantFolding.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Compiler.h"
5 |
6 | #include "ValueTracking.h"
7 |
8 | namespace Luau
9 | {
10 | namespace Compile
11 | {
12 |
13 | struct Constant
14 | {
15 | enum Type
16 | {
17 | Type_Unknown,
18 | Type_Nil,
19 | Type_Boolean,
20 | Type_Number,
21 | Type_Vector,
22 | Type_String,
23 | };
24 |
25 | Type type = Type_Unknown;
26 | unsigned int stringLength = 0;
27 |
28 | union
29 | {
30 | bool valueBoolean;
31 | double valueNumber;
32 | float valueVector[4];
33 | const char* valueString = nullptr; // length stored in stringLength
34 | };
35 |
36 | bool isTruthful() const
37 | {
38 | LUAU_ASSERT(type != Type_Unknown);
39 | return type != Type_Nil && !(type == Type_Boolean && valueBoolean == false);
40 | }
41 |
42 | AstArray getString() const
43 | {
44 | LUAU_ASSERT(type == Type_String);
45 | return {valueString, stringLength};
46 | }
47 | };
48 |
49 | void foldConstants(
50 | DenseHashMap& constants,
51 | DenseHashMap& variables,
52 | DenseHashMap& locals,
53 | const DenseHashMap* builtins,
54 | bool foldLibraryK,
55 | LibraryMemberConstantCallback libraryMemberConstantCb,
56 | AstNode* root
57 | );
58 |
59 | } // namespace Compile
60 | } // namespace Luau
61 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/CostModel.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/DenseHash.h"
6 |
7 | namespace Luau
8 | {
9 | namespace Compile
10 | {
11 |
12 | // cost model: 8 bytes, where first byte is the baseline cost, and the next 7 bytes are discounts for when variable #i is constant
13 | uint64_t modelCost(AstNode* root, AstLocal* const* vars, size_t varCount, const DenseHashMap& builtins);
14 |
15 | // cost is computed as B - sum(Di * Ci), where B is baseline cost, Di is the discount for each variable and Ci is 1 when variable #i is constant
16 | int computeCost(uint64_t model, const bool* varsConst, size_t varCount);
17 |
18 | // get loop trip count or -1 if we can't compute it precisely
19 | int getTripCount(double from, double to, double step);
20 |
21 | } // namespace Compile
22 | } // namespace Luau
23 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/TableShape.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #include "TableShape.h"
3 |
4 | namespace Luau
5 | {
6 | namespace Compile
7 | {
8 |
9 | // conservative limit for the loop bound that establishes table array size
10 | static const int kMaxLoopBound = 16;
11 |
12 | static AstExprTable* getTableHint(AstExpr* expr)
13 | {
14 | // unadorned table literal
15 | if (AstExprTable* table = expr->as())
16 | return table;
17 |
18 | // setmetatable(table literal, ...)
19 | if (AstExprCall* call = expr->as(); call && !call->self && call->args.size == 2)
20 | if (AstExprGlobal* func = call->func->as(); func && func->name == "setmetatable")
21 | if (AstExprTable* table = call->args.data[0]->as())
22 | return table;
23 |
24 | return nullptr;
25 | }
26 |
27 | struct ShapeVisitor : AstVisitor
28 | {
29 | struct Hasher
30 | {
31 | size_t operator()(const std::pair& p) const
32 | {
33 | return DenseHashPointer()(p.first) ^ std::hash()(p.second);
34 | }
35 | };
36 |
37 | DenseHashMap& shapes;
38 |
39 | DenseHashMap tables;
40 | DenseHashSet, Hasher> fields;
41 |
42 | DenseHashMap loops; // iterator => upper bound for 1..k
43 |
44 | ShapeVisitor(DenseHashMap& shapes)
45 | : shapes(shapes)
46 | , tables(nullptr)
47 | , fields(std::pair())
48 | , loops(nullptr)
49 | {
50 | }
51 |
52 | void assignField(AstExpr* expr, AstName index)
53 | {
54 | if (AstExprLocal* lv = expr->as())
55 | {
56 | if (AstExprTable** table = tables.find(lv->local))
57 | {
58 | std::pair field = {*table, index};
59 |
60 | if (!fields.contains(field))
61 | {
62 | fields.insert(field);
63 | shapes[*table].hashSize += 1;
64 | }
65 | }
66 | }
67 | }
68 |
69 | void assignField(AstExpr* expr, AstExpr* index)
70 | {
71 | AstExprLocal* lv = expr->as();
72 | if (!lv)
73 | return;
74 |
75 | AstExprTable** table = tables.find(lv->local);
76 | if (!table)
77 | return;
78 |
79 | if (AstExprConstantNumber* number = index->as())
80 | {
81 | TableShape& shape = shapes[*table];
82 |
83 | if (number->value == double(shape.arraySize + 1))
84 | shape.arraySize += 1;
85 | }
86 | else if (AstExprLocal* iter = index->as())
87 | {
88 | if (const unsigned int* bound = loops.find(iter->local))
89 | {
90 | TableShape& shape = shapes[*table];
91 |
92 | if (shape.arraySize == 0)
93 | shape.arraySize = *bound;
94 | }
95 | }
96 | }
97 |
98 | void assign(AstExpr* var)
99 | {
100 | if (AstExprIndexName* index = var->as())
101 | {
102 | assignField(index->expr, index->index);
103 | }
104 | else if (AstExprIndexExpr* index = var->as())
105 | {
106 | assignField(index->expr, index->index);
107 | }
108 | }
109 |
110 | bool visit(AstStatLocal* node) override
111 | {
112 | // track local -> table association so that we can update table size prediction in assignField
113 | if (node->vars.size == 1 && node->values.size == 1)
114 | if (AstExprTable* table = getTableHint(node->values.data[0]); table && table->items.size == 0)
115 | tables[node->vars.data[0]] = table;
116 |
117 | return true;
118 | }
119 |
120 | bool visit(AstStatAssign* node) override
121 | {
122 | for (size_t i = 0; i < node->vars.size; ++i)
123 | assign(node->vars.data[i]);
124 |
125 | for (size_t i = 0; i < node->values.size; ++i)
126 | node->values.data[i]->visit(this);
127 |
128 | return false;
129 | }
130 |
131 | bool visit(AstStatFunction* node) override
132 | {
133 | assign(node->name);
134 | node->func->visit(this);
135 |
136 | return false;
137 | }
138 |
139 | bool visit(AstStatFor* node) override
140 | {
141 | AstExprConstantNumber* from = node->from->as();
142 | AstExprConstantNumber* to = node->to->as();
143 |
144 | if (from && to && from->value == 1.0 && to->value >= 1.0 && to->value <= double(kMaxLoopBound) && !node->step)
145 | loops[node->var] = unsigned(to->value);
146 |
147 | return true;
148 | }
149 | };
150 |
151 | void predictTableShapes(DenseHashMap& shapes, AstNode* root)
152 | {
153 | ShapeVisitor visitor{shapes};
154 | root->visit(&visitor);
155 | }
156 |
157 | } // namespace Compile
158 | } // namespace Luau
159 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/TableShape.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/DenseHash.h"
6 |
7 | namespace Luau
8 | {
9 | namespace Compile
10 | {
11 |
12 | struct TableShape
13 | {
14 | unsigned int arraySize = 0;
15 | unsigned int hashSize = 0;
16 | };
17 |
18 | void predictTableShapes(DenseHashMap& shapes, AstNode* root);
19 |
20 | } // namespace Compile
21 | } // namespace Luau
22 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/Types.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/Bytecode.h"
6 | #include "Luau/Compiler.h"
7 | #include "Luau/DenseHash.h"
8 | #include "ValueTracking.h"
9 |
10 | #include
11 |
12 | namespace Luau
13 | {
14 | class BytecodeBuilder;
15 |
16 | struct BuiltinAstTypes
17 | {
18 | BuiltinAstTypes(const char* hostVectorType)
19 | : hostVectorType{{}, std::nullopt, AstName{hostVectorType}, std::nullopt, {}}
20 | {
21 | }
22 |
23 | // AstName use here will not match the AstNameTable, but the way we use them here always forces a full string compare
24 | AstTypeReference booleanType{{}, std::nullopt, AstName{"boolean"}, std::nullopt, {}};
25 | AstTypeReference numberType{{}, std::nullopt, AstName{"number"}, std::nullopt, {}};
26 | AstTypeReference stringType{{}, std::nullopt, AstName{"string"}, std::nullopt, {}};
27 | AstTypeReference vectorType{{}, std::nullopt, AstName{"vector"}, std::nullopt, {}};
28 |
29 | AstTypeReference hostVectorType;
30 | };
31 |
32 | void buildTypeMap(
33 | DenseHashMap& functionTypes,
34 | DenseHashMap& localTypes,
35 | DenseHashMap& exprTypes,
36 | AstNode* root,
37 | const char* hostVectorType,
38 | const DenseHashMap& userdataTypes,
39 | const BuiltinAstTypes& builtinTypes,
40 | const DenseHashMap& builtinCalls,
41 | const DenseHashMap& globals,
42 | LibraryMemberTypeCallback libraryMemberTypeCb,
43 | BytecodeBuilder& bytecode
44 | );
45 |
46 | } // namespace Luau
47 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/ValueTracking.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #include "ValueTracking.h"
3 |
4 | #include "Luau/Lexer.h"
5 |
6 | namespace Luau
7 | {
8 | namespace Compile
9 | {
10 |
11 | struct ValueVisitor : AstVisitor
12 | {
13 | DenseHashMap& globals;
14 | DenseHashMap& variables;
15 |
16 | ValueVisitor(DenseHashMap& globals, DenseHashMap& variables)
17 | : globals(globals)
18 | , variables(variables)
19 | {
20 | }
21 |
22 | void assign(AstExpr* var)
23 | {
24 | if (AstExprLocal* lv = var->as())
25 | {
26 | variables[lv->local].written = true;
27 | }
28 | else if (AstExprGlobal* gv = var->as())
29 | {
30 | globals[gv->name] = Global::Written;
31 | }
32 | else
33 | {
34 | // we need to be able to track assignments in all expressions, including crazy ones like t[function() t = nil end] = 5
35 | var->visit(this);
36 | }
37 | }
38 |
39 | bool visit(AstStatLocal* node) override
40 | {
41 | for (size_t i = 0; i < node->vars.size && i < node->values.size; ++i)
42 | variables[node->vars.data[i]].init = node->values.data[i];
43 |
44 | for (size_t i = node->values.size; i < node->vars.size; ++i)
45 | variables[node->vars.data[i]].init = nullptr;
46 |
47 | return true;
48 | }
49 |
50 | bool visit(AstStatAssign* node) override
51 | {
52 | for (size_t i = 0; i < node->vars.size; ++i)
53 | assign(node->vars.data[i]);
54 |
55 | for (size_t i = 0; i < node->values.size; ++i)
56 | node->values.data[i]->visit(this);
57 |
58 | return false;
59 | }
60 |
61 | bool visit(AstStatCompoundAssign* node) override
62 | {
63 | assign(node->var);
64 | node->value->visit(this);
65 |
66 | return false;
67 | }
68 |
69 | bool visit(AstStatLocalFunction* node) override
70 | {
71 | variables[node->name].init = node->func;
72 |
73 | return true;
74 | }
75 |
76 | bool visit(AstStatFunction* node) override
77 | {
78 | assign(node->name);
79 | node->func->visit(this);
80 |
81 | return false;
82 | }
83 | };
84 |
85 | void assignMutable(DenseHashMap& globals, const AstNameTable& names, const char* const* mutableGlobals)
86 | {
87 | if (AstName name = names.get("_G"); name.value)
88 | globals[name] = Global::Mutable;
89 |
90 | if (mutableGlobals)
91 | for (const char* const* ptr = mutableGlobals; *ptr; ++ptr)
92 | if (AstName name = names.get(*ptr); name.value)
93 | globals[name] = Global::Mutable;
94 | }
95 |
96 | void trackValues(DenseHashMap& globals, DenseHashMap& variables, AstNode* root)
97 | {
98 | ValueVisitor visitor{globals, variables};
99 | root->visit(&visitor);
100 | }
101 |
102 | } // namespace Compile
103 | } // namespace Luau
104 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/ValueTracking.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "Luau/Ast.h"
5 | #include "Luau/DenseHash.h"
6 |
7 | namespace Luau
8 | {
9 | class AstNameTable;
10 | }
11 |
12 | namespace Luau
13 | {
14 | namespace Compile
15 | {
16 |
17 | enum class Global
18 | {
19 | Default = 0,
20 | Mutable, // builtin that has contents unknown at compile time, blocks GETIMPORT for chains
21 | Written, // written in the code which means we can't reason about the value
22 | };
23 |
24 | struct Variable
25 | {
26 | AstExpr* init = nullptr; // initial value of the variable; filled by trackValues
27 | bool written = false; // is the variable ever assigned to? filled by trackValues
28 | bool constant = false; // is the variable's value a compile-time constant? filled by constantFold
29 | };
30 |
31 | void assignMutable(DenseHashMap& globals, const AstNameTable& names, const char* const* mutableGlobals);
32 | void trackValues(DenseHashMap& globals, DenseHashMap& variables, AstNode* root);
33 |
34 | inline Global getGlobalState(const DenseHashMap& globals, AstName name)
35 | {
36 | const Global* it = globals.find(name);
37 |
38 | return it ? *it : Global::Default;
39 | }
40 |
41 | } // namespace Compile
42 | } // namespace Luau
43 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/Compiler/src/lcode.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #include "luacode.h"
3 |
4 | #include "Luau/Compiler.h"
5 |
6 | #include
7 |
8 | char* luau_compile(const char* source, size_t size, lua_CompileOptions* options, size_t* outsize)
9 | {
10 | LUAU_ASSERT(outsize);
11 |
12 | Luau::CompileOptions opts;
13 |
14 | if (options)
15 | {
16 | static_assert(sizeof(lua_CompileOptions) == sizeof(Luau::CompileOptions), "C and C++ interface must match");
17 | memcpy(static_cast(&opts), options, sizeof(opts));
18 | }
19 |
20 | std::string result = compile(std::string(source, size), opts);
21 |
22 | char* copy = static_cast(malloc(result.size()));
23 | if (!copy)
24 | return nullptr;
25 |
26 | memcpy(copy, result.data(), result.size());
27 | *outsize = result.size();
28 | return copy;
29 | }
30 |
31 | void luau_set_compile_constant_nil(lua_CompileConstant* constant)
32 | {
33 | Luau::setCompileConstantNil(constant);
34 | }
35 |
36 | void luau_set_compile_constant_boolean(lua_CompileConstant* constant, int b)
37 | {
38 | Luau::setCompileConstantBoolean(constant, b != 0);
39 | }
40 |
41 | void luau_set_compile_constant_number(lua_CompileConstant* constant, double n)
42 | {
43 | Luau::setCompileConstantNumber(constant, n);
44 | }
45 |
46 | void luau_set_compile_constant_vector(lua_CompileConstant* constant, float x, float y, float z, float w)
47 | {
48 | Luau::setCompileConstantVector(constant, x, y, z, w);
49 | }
50 |
51 | void luau_set_compile_constant_string(lua_CompileConstant* constant, const char* s, size_t l)
52 | {
53 | Luau::setCompileConstantString(constant, s, l);
54 | }
55 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/include/luaconf.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include
6 |
7 | // When debugging complex issues, consider enabling one of these:
8 | // This will reallocate the stack very aggressively at every opportunity; use this with asan to catch stale stack pointers
9 | // #define HARDSTACKTESTS 1
10 | // This will call GC validation very aggressively at every incremental GC step; use this with caution as it's SLOW
11 | // #define HARDMEMTESTS 1
12 | // This will call GC validation very aggressively at every GC opportunity; use this with caution as it's VERY SLOW
13 | // #define HARDMEMTESTS 2
14 |
15 | // To force MSVC2017+ to generate SSE2 code for some stdlib functions we need to locally enable /fp:fast
16 | // Note that /fp:fast changes the semantics of floating point comparisons so this is only safe to do for functions without ones
17 | #if defined(_MSC_VER) && !defined(__clang__)
18 | #define LUAU_FASTMATH_BEGIN __pragma(float_control(precise, off, push))
19 | #define LUAU_FASTMATH_END __pragma(float_control(pop))
20 | #else
21 | #define LUAU_FASTMATH_BEGIN
22 | #define LUAU_FASTMATH_END
23 | #endif
24 |
25 | // Some functions like floor/ceil have SSE4.1 equivalents but we currently support systems without SSE4.1
26 | // Note that we only need to do this when SSE4.1 support is not guaranteed by compiler settings, as otherwise compiler will optimize these for us.
27 | #if (defined(__x86_64__) || defined(_M_X64)) && !defined(__SSE4_1__) && !defined(__AVX__)
28 | #if defined(_MSC_VER) && !defined(__clang__)
29 | #define LUAU_TARGET_SSE41
30 | #elif defined(__GNUC__) && defined(__has_attribute)
31 | #if __has_attribute(target)
32 | #define LUAU_TARGET_SSE41 __attribute__((target("sse4.1")))
33 | #endif
34 | #endif
35 | #endif
36 |
37 | // Used on functions that have a printf-like interface to validate them statically
38 | #if defined(__GNUC__)
39 | #define LUA_PRINTF_ATTR(fmt, arg) __attribute__((format(printf, fmt, arg)))
40 | #else
41 | #define LUA_PRINTF_ATTR(fmt, arg)
42 | #endif
43 |
44 | #ifdef _MSC_VER
45 | #define LUA_NORETURN __declspec(noreturn)
46 | #else
47 | #define LUA_NORETURN __attribute__((__noreturn__))
48 | #endif
49 |
50 | // Can be used to reconfigure visibility/exports for public APIs
51 | #ifndef LUA_API
52 | #define LUA_API extern
53 | #endif
54 |
55 | #define LUALIB_API LUA_API
56 |
57 | // Can be used to reconfigure visibility for internal APIs
58 | #if defined(__GNUC__)
59 | #define LUAI_FUNC __attribute__((visibility("hidden"))) extern
60 | #define LUAI_DATA LUAI_FUNC
61 | #else
62 | #define LUAI_FUNC extern
63 | #define LUAI_DATA extern
64 | #endif
65 |
66 | // Can be used to reconfigure internal error handling to use longjmp instead of C++ EH
67 | #ifndef LUA_USE_LONGJMP
68 | #define LUA_USE_LONGJMP 0
69 | #endif
70 |
71 | // LUA_IDSIZE gives the maximum size for the description of the source
72 | #ifndef LUA_IDSIZE
73 | #define LUA_IDSIZE 256
74 | #endif
75 |
76 | // LUA_MINSTACK is the guaranteed number of Lua stack slots available to a C function
77 | #ifndef LUA_MINSTACK
78 | #define LUA_MINSTACK 20
79 | #endif
80 |
81 | // LUAI_MAXCSTACK limits the number of Lua stack slots that a C function can use
82 | #ifndef LUAI_MAXCSTACK
83 | #define LUAI_MAXCSTACK 8000
84 | #endif
85 |
86 | // LUAI_MAXCALLS limits the number of nested calls
87 | #ifndef LUAI_MAXCALLS
88 | #define LUAI_MAXCALLS 20000
89 | #endif
90 |
91 | // LUAI_MAXCCALLS is the maximum depth for nested C calls; this limit depends on native stack size
92 | #ifndef LUAI_MAXCCALLS
93 | #define LUAI_MAXCCALLS 200
94 | #endif
95 |
96 | // buffer size used for on-stack string operations; this limit depends on native stack size
97 | #ifndef LUA_BUFFERSIZE
98 | #define LUA_BUFFERSIZE 512
99 | #endif
100 |
101 | // number of valid Lua userdata tags
102 | #ifndef LUA_UTAG_LIMIT
103 | #define LUA_UTAG_LIMIT 128
104 | #endif
105 |
106 | // number of valid Lua lightuserdata tags
107 | #ifndef LUA_LUTAG_LIMIT
108 | #define LUA_LUTAG_LIMIT 128
109 | #endif
110 |
111 | // upper bound for number of size classes used by page allocator
112 | #ifndef LUA_SIZECLASSES
113 | #define LUA_SIZECLASSES 40
114 | #endif
115 |
116 | // available number of separate memory categories
117 | #ifndef LUA_MEMORY_CATEGORIES
118 | #define LUA_MEMORY_CATEGORIES 256
119 | #endif
120 |
121 | // minimum size for the string table (must be power of 2)
122 | #ifndef LUA_MINSTRTABSIZE
123 | #define LUA_MINSTRTABSIZE 32
124 | #endif
125 |
126 | // maximum number of captures supported by pattern matching
127 | #ifndef LUA_MAXCAPTURES
128 | #define LUA_MAXCAPTURES 32
129 | #endif
130 |
131 | // }==================================================================
132 |
133 | /*
134 | @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
135 | ** CHANGE it if your system requires alignments larger than double. (For
136 | ** instance, if your system supports long doubles and they must be
137 | ** aligned in 16-byte boundaries, then you should add long double in the
138 | ** union.) Probably you do not need to change this.
139 | */
140 | #define LUAI_USER_ALIGNMENT_T \
141 | union \
142 | { \
143 | double u; \
144 | void* s; \
145 | long l; \
146 | }
147 |
148 | #ifndef LUA_VECTOR_SIZE
149 | #define LUA_VECTOR_SIZE 3 // must be 3 or 4
150 | #endif
151 |
152 | #define LUA_EXTRA_SIZE (LUA_VECTOR_SIZE - 2)
153 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/include/lualib.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include "lua.h"
6 |
7 | #define luaL_error(L, fmt, ...) luaL_errorL(L, fmt, ##__VA_ARGS__)
8 | #define luaL_typeerror(L, narg, tname) luaL_typeerrorL(L, narg, tname)
9 | #define luaL_argerror(L, narg, extramsg) luaL_argerrorL(L, narg, extramsg)
10 |
11 | struct luaL_Reg
12 | {
13 | const char* name;
14 | lua_CFunction func;
15 | };
16 | typedef struct luaL_Reg luaL_Reg;
17 |
18 | LUALIB_API void luaL_register(lua_State* L, const char* libname, const luaL_Reg* l);
19 | LUALIB_API int luaL_getmetafield(lua_State* L, int obj, const char* e);
20 | LUALIB_API int luaL_callmeta(lua_State* L, int obj, const char* e);
21 | LUALIB_API l_noret luaL_typeerrorL(lua_State* L, int narg, const char* tname);
22 | LUALIB_API l_noret luaL_argerrorL(lua_State* L, int narg, const char* extramsg);
23 | LUALIB_API const char* luaL_checklstring(lua_State* L, int numArg, size_t* l);
24 | LUALIB_API const char* luaL_optlstring(lua_State* L, int numArg, const char* def, size_t* l);
25 | LUALIB_API double luaL_checknumber(lua_State* L, int numArg);
26 | LUALIB_API double luaL_optnumber(lua_State* L, int nArg, double def);
27 |
28 | LUALIB_API int luaL_checkboolean(lua_State* L, int narg);
29 | LUALIB_API int luaL_optboolean(lua_State* L, int narg, int def);
30 |
31 | LUALIB_API int luaL_checkinteger(lua_State* L, int numArg);
32 | LUALIB_API int luaL_optinteger(lua_State* L, int nArg, int def);
33 | LUALIB_API unsigned luaL_checkunsigned(lua_State* L, int numArg);
34 | LUALIB_API unsigned luaL_optunsigned(lua_State* L, int numArg, unsigned def);
35 |
36 | LUALIB_API const float* luaL_checkvector(lua_State* L, int narg);
37 | LUALIB_API const float* luaL_optvector(lua_State* L, int narg, const float* def);
38 |
39 | LUALIB_API void luaL_checkstack(lua_State* L, int sz, const char* msg);
40 | LUALIB_API void luaL_checktype(lua_State* L, int narg, int t);
41 | LUALIB_API void luaL_checkany(lua_State* L, int narg);
42 |
43 | LUALIB_API int luaL_newmetatable(lua_State* L, const char* tname);
44 | LUALIB_API void* luaL_checkudata(lua_State* L, int ud, const char* tname);
45 |
46 | LUALIB_API void* luaL_checkbuffer(lua_State* L, int narg, size_t* len);
47 |
48 | LUALIB_API void luaL_where(lua_State* L, int lvl);
49 | LUALIB_API LUA_PRINTF_ATTR(2, 3) l_noret luaL_errorL(lua_State* L, const char* fmt, ...);
50 |
51 | LUALIB_API int luaL_checkoption(lua_State* L, int narg, const char* def, const char* const lst[]);
52 |
53 | LUALIB_API const char* luaL_tolstring(lua_State* L, int idx, size_t* len);
54 |
55 | LUALIB_API lua_State* luaL_newstate(void);
56 |
57 | LUALIB_API const char* luaL_findtable(lua_State* L, int idx, const char* fname, int szhint);
58 |
59 | LUALIB_API const char* luaL_typename(lua_State* L, int idx);
60 |
61 | /*
62 | ** ===============================================================
63 | ** some useful macros
64 | ** ===============================================================
65 | */
66 |
67 | #define luaL_argcheck(L, cond, arg, extramsg) ((void)((cond) ? (void)0 : luaL_argerror(L, arg, extramsg)))
68 | #define luaL_argexpected(L, cond, arg, tname) ((void)((cond) ? (void)0 : luaL_typeerror(L, arg, tname)))
69 |
70 | #define luaL_checkstring(L, n) (luaL_checklstring(L, (n), NULL))
71 | #define luaL_optstring(L, n, d) (luaL_optlstring(L, (n), (d), NULL))
72 |
73 | #define luaL_getmetatable(L, n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
74 |
75 | #define luaL_opt(L, f, n, d) (lua_isnoneornil(L, (n)) ? (d) : f(L, (n)))
76 |
77 | // generic buffer manipulation
78 |
79 | struct luaL_Strbuf
80 | {
81 | char* p; // current position in buffer
82 | char* end; // end of the current buffer
83 | lua_State* L;
84 | struct TString* storage;
85 | char buffer[LUA_BUFFERSIZE];
86 | };
87 | typedef struct luaL_Strbuf luaL_Strbuf;
88 |
89 | // compatibility typedef: this type is called luaL_Buffer in Lua headers
90 | // renamed to luaL_Strbuf to reduce confusion with internal VM buffer type
91 | typedef struct luaL_Strbuf luaL_Buffer;
92 |
93 | // when internal buffer storage is exhausted, a mutable string value 'storage' will be placed on the stack
94 | // in general, functions expect the mutable string buffer to be placed on top of the stack (top-1)
95 | // with the exception of luaL_addvalue that expects the value at the top and string buffer further away (top-2)
96 |
97 | #define luaL_addchar(B, c) ((void)((B)->p < (B)->end || luaL_prepbuffsize(B, 1)), (*(B)->p++ = (char)(c)))
98 | #define luaL_addstring(B, s) luaL_addlstring(B, s, strlen(s))
99 |
100 | LUALIB_API void luaL_buffinit(lua_State* L, luaL_Strbuf* B);
101 | LUALIB_API char* luaL_buffinitsize(lua_State* L, luaL_Strbuf* B, size_t size);
102 | LUALIB_API char* luaL_prepbuffsize(luaL_Buffer* B, size_t size);
103 | LUALIB_API void luaL_addlstring(luaL_Strbuf* B, const char* s, size_t l);
104 | LUALIB_API void luaL_addvalue(luaL_Strbuf* B);
105 | LUALIB_API void luaL_addvalueany(luaL_Strbuf* B, int idx);
106 | LUALIB_API void luaL_pushresult(luaL_Strbuf* B);
107 | LUALIB_API void luaL_pushresultsize(luaL_Strbuf* B, size_t size);
108 |
109 | // builtin libraries
110 | LUALIB_API int luaopen_base(lua_State* L);
111 |
112 | #define LUA_COLIBNAME "coroutine"
113 | LUALIB_API int luaopen_coroutine(lua_State* L);
114 |
115 | #define LUA_TABLIBNAME "table"
116 | LUALIB_API int luaopen_table(lua_State* L);
117 |
118 | #define LUA_OSLIBNAME "os"
119 | LUALIB_API int luaopen_os(lua_State* L);
120 |
121 | #define LUA_STRLIBNAME "string"
122 | LUALIB_API int luaopen_string(lua_State* L);
123 |
124 | #define LUA_BITLIBNAME "bit32"
125 | LUALIB_API int luaopen_bit32(lua_State* L);
126 |
127 | #define LUA_BUFFERLIBNAME "buffer"
128 | LUALIB_API int luaopen_buffer(lua_State* L);
129 |
130 | #define LUA_UTF8LIBNAME "utf8"
131 | LUALIB_API int luaopen_utf8(lua_State* L);
132 |
133 | #define LUA_MATHLIBNAME "math"
134 | LUALIB_API int luaopen_math(lua_State* L);
135 |
136 | #define LUA_DBLIBNAME "debug"
137 | LUALIB_API int luaopen_debug(lua_State* L);
138 |
139 | #define LUA_VECLIBNAME "vector"
140 | LUALIB_API int luaopen_vector(lua_State* L);
141 |
142 | // open all builtin libraries
143 | LUALIB_API void luaL_openlibs(lua_State* L);
144 |
145 | // sandbox libraries and globals
146 | LUALIB_API void luaL_sandbox(lua_State* L);
147 | LUALIB_API void luaL_sandboxthread(lua_State* L);
148 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lapi.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include "lobject.h"
6 |
7 | LUAI_FUNC const TValue* luaA_toobject(lua_State* L, int idx);
8 | LUAI_FUNC void luaA_pushobject(lua_State* L, const TValue* o);
9 | TValue* index2addr(lua_State* L, int idx);
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lbitlib.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #include "lualib.h"
4 |
5 | #include "lcommon.h"
6 | #include "lnumutils.h"
7 |
8 | #define ALLONES ~0u
9 | #define NBITS int(8 * sizeof(unsigned))
10 |
11 | // macro to trim extra bits
12 | #define trim(x) ((x) & ALLONES)
13 |
14 | // builds a number with 'n' ones (1 <= n <= NBITS)
15 | #define mask(n) (~((ALLONES << 1) << ((n)-1)))
16 |
17 | typedef unsigned b_uint;
18 |
19 | static b_uint andaux(lua_State* L)
20 | {
21 | int i, n = lua_gettop(L);
22 | b_uint r = ~(b_uint)0;
23 | for (i = 1; i <= n; i++)
24 | r &= luaL_checkunsigned(L, i);
25 | return trim(r);
26 | }
27 |
28 | static int b_and(lua_State* L)
29 | {
30 | b_uint r = andaux(L);
31 | lua_pushunsigned(L, r);
32 | return 1;
33 | }
34 |
35 | static int b_test(lua_State* L)
36 | {
37 | b_uint r = andaux(L);
38 | lua_pushboolean(L, r != 0);
39 | return 1;
40 | }
41 |
42 | static int b_or(lua_State* L)
43 | {
44 | int i, n = lua_gettop(L);
45 | b_uint r = 0;
46 | for (i = 1; i <= n; i++)
47 | r |= luaL_checkunsigned(L, i);
48 | lua_pushunsigned(L, trim(r));
49 | return 1;
50 | }
51 |
52 | static int b_xor(lua_State* L)
53 | {
54 | int i, n = lua_gettop(L);
55 | b_uint r = 0;
56 | for (i = 1; i <= n; i++)
57 | r ^= luaL_checkunsigned(L, i);
58 | lua_pushunsigned(L, trim(r));
59 | return 1;
60 | }
61 |
62 | static int b_not(lua_State* L)
63 | {
64 | b_uint r = ~luaL_checkunsigned(L, 1);
65 | lua_pushunsigned(L, trim(r));
66 | return 1;
67 | }
68 |
69 | static int b_shift(lua_State* L, b_uint r, int i)
70 | {
71 | if (i < 0)
72 | { // shift right?
73 | i = -i;
74 | r = trim(r);
75 | if (i >= NBITS)
76 | r = 0;
77 | else
78 | r >>= i;
79 | }
80 | else
81 | { // shift left
82 | if (i >= NBITS)
83 | r = 0;
84 | else
85 | r <<= i;
86 | r = trim(r);
87 | }
88 | lua_pushunsigned(L, r);
89 | return 1;
90 | }
91 |
92 | static int b_lshift(lua_State* L)
93 | {
94 | return b_shift(L, luaL_checkunsigned(L, 1), luaL_checkinteger(L, 2));
95 | }
96 |
97 | static int b_rshift(lua_State* L)
98 | {
99 | return b_shift(L, luaL_checkunsigned(L, 1), -luaL_checkinteger(L, 2));
100 | }
101 |
102 | static int b_arshift(lua_State* L)
103 | {
104 | b_uint r = luaL_checkunsigned(L, 1);
105 | int i = luaL_checkinteger(L, 2);
106 | if (i < 0 || !(r & ((b_uint)1 << (NBITS - 1))))
107 | return b_shift(L, r, -i);
108 | else
109 | { // arithmetic shift for 'negative' number
110 | if (i >= NBITS)
111 | r = ALLONES;
112 | else
113 | r = trim((r >> i) | ~(~(b_uint)0 >> i)); // add signal bit
114 | lua_pushunsigned(L, r);
115 | return 1;
116 | }
117 | }
118 |
119 | static int b_rot(lua_State* L, int i)
120 | {
121 | b_uint r = luaL_checkunsigned(L, 1);
122 | i &= (NBITS - 1); // i = i % NBITS
123 | r = trim(r);
124 | if (i != 0) // avoid undefined shift of NBITS when i == 0
125 | r = (r << i) | (r >> (NBITS - i));
126 | lua_pushunsigned(L, trim(r));
127 | return 1;
128 | }
129 |
130 | static int b_lrot(lua_State* L)
131 | {
132 | return b_rot(L, luaL_checkinteger(L, 2));
133 | }
134 |
135 | static int b_rrot(lua_State* L)
136 | {
137 | return b_rot(L, -luaL_checkinteger(L, 2));
138 | }
139 |
140 | /*
141 | ** get field and width arguments for field-manipulation functions,
142 | ** checking whether they are valid.
143 | ** ('luaL_error' called without 'return' to avoid later warnings about
144 | ** 'width' being used uninitialized.)
145 | */
146 | static int fieldargs(lua_State* L, int farg, int* width)
147 | {
148 | int f = luaL_checkinteger(L, farg);
149 | int w = luaL_optinteger(L, farg + 1, 1);
150 | luaL_argcheck(L, 0 <= f, farg, "field cannot be negative");
151 | luaL_argcheck(L, 0 < w, farg + 1, "width must be positive");
152 | if (f + w > NBITS)
153 | luaL_error(L, "trying to access non-existent bits");
154 | *width = w;
155 | return f;
156 | }
157 |
158 | static int b_extract(lua_State* L)
159 | {
160 | int w;
161 | b_uint r = luaL_checkunsigned(L, 1);
162 | int f = fieldargs(L, 2, &w);
163 | r = (r >> f) & mask(w);
164 | lua_pushunsigned(L, r);
165 | return 1;
166 | }
167 |
168 | static int b_replace(lua_State* L)
169 | {
170 | int w;
171 | b_uint r = luaL_checkunsigned(L, 1);
172 | b_uint v = luaL_checkunsigned(L, 2);
173 | int f = fieldargs(L, 3, &w);
174 | int m = mask(w);
175 | v &= m; // erase bits outside given width
176 | r = (r & ~(m << f)) | (v << f);
177 | lua_pushunsigned(L, r);
178 | return 1;
179 | }
180 |
181 | static int b_countlz(lua_State* L)
182 | {
183 | b_uint v = luaL_checkunsigned(L, 1);
184 |
185 | b_uint r = NBITS;
186 | for (int i = 0; i < NBITS; ++i)
187 | if (v & (1u << (NBITS - 1 - i)))
188 | {
189 | r = i;
190 | break;
191 | }
192 |
193 | lua_pushunsigned(L, r);
194 | return 1;
195 | }
196 |
197 | static int b_countrz(lua_State* L)
198 | {
199 | b_uint v = luaL_checkunsigned(L, 1);
200 |
201 | b_uint r = NBITS;
202 | for (int i = 0; i < NBITS; ++i)
203 | if (v & (1u << i))
204 | {
205 | r = i;
206 | break;
207 | }
208 |
209 | lua_pushunsigned(L, r);
210 | return 1;
211 | }
212 |
213 | static int b_swap(lua_State* L)
214 | {
215 | b_uint n = luaL_checkunsigned(L, 1);
216 | n = (n << 24) | ((n << 8) & 0xff0000) | ((n >> 8) & 0xff00) | (n >> 24);
217 |
218 | lua_pushunsigned(L, n);
219 | return 1;
220 | }
221 |
222 | static const luaL_Reg bitlib[] = {
223 | {"arshift", b_arshift},
224 | {"band", b_and},
225 | {"bnot", b_not},
226 | {"bor", b_or},
227 | {"bxor", b_xor},
228 | {"btest", b_test},
229 | {"extract", b_extract},
230 | {"lrotate", b_lrot},
231 | {"lshift", b_lshift},
232 | {"replace", b_replace},
233 | {"rrotate", b_rrot},
234 | {"rshift", b_rshift},
235 | {"countlz", b_countlz},
236 | {"countrz", b_countrz},
237 | {"byteswap", b_swap},
238 | {NULL, NULL},
239 | };
240 |
241 | int luaopen_bit32(lua_State* L)
242 | {
243 | luaL_register(L, LUA_BITLIBNAME, bitlib);
244 |
245 | return 1;
246 | }
247 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lbuffer.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #include "lbuffer.h"
3 |
4 | #include "lgc.h"
5 | #include "lmem.h"
6 |
7 | #include
8 |
9 | Buffer* luaB_newbuffer(lua_State* L, size_t s)
10 | {
11 | if (s > MAX_BUFFER_SIZE)
12 | luaM_toobig(L);
13 |
14 | Buffer* b = luaM_newgco(L, Buffer, sizebuffer(s), L->activememcat);
15 | luaC_init(L, b, LUA_TBUFFER);
16 | b->len = unsigned(s);
17 | memset(b->data, 0, b->len);
18 | return b;
19 | }
20 |
21 | void luaB_freebuffer(lua_State* L, Buffer* b, lua_Page* page)
22 | {
23 | luaM_freegco(L, b, sizebuffer(b->len), b->memcat, page);
24 | }
25 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lbuffer.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | #pragma once
3 |
4 | #include "lobject.h"
5 |
6 | // buffer size limit
7 | #define MAX_BUFFER_SIZE (1 << 30)
8 |
9 | // GCObject size has to be at least 16 bytes, so a minimum of 8 bytes is always reserved
10 | #define sizebuffer(len) (offsetof(Buffer, data) + ((len) < 8 ? 8 : (len)))
11 |
12 | LUAI_FUNC Buffer* luaB_newbuffer(lua_State* L, size_t s);
13 | LUAI_FUNC void luaB_freebuffer(lua_State* L, Buffer* u, struct lua_Page* page);
14 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lbuiltins.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include "lobject.h"
6 |
7 | typedef int (*luau_FastFunction)(lua_State* L, StkId res, TValue* arg0, int nresults, StkId args, int nparams);
8 |
9 | extern const luau_FastFunction luauF_table[256];
10 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lbytecode.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | // This is a forwarding header for Luau bytecode definition
6 | #include "Luau/Bytecode.h"
7 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lcommon.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include
6 | #include
7 |
8 | #include "luaconf.h"
9 |
10 | #include "Luau/Common.h"
11 |
12 | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
13 |
14 | // internal assertions for in-house debugging
15 | #define check_exp(c, e) (LUAU_ASSERT(c), (e))
16 | #define api_check(l, e) LUAU_ASSERT(e)
17 |
18 | #ifndef cast_to
19 | #define cast_to(t, exp) ((t)(exp))
20 | #endif
21 |
22 | #define cast_byte(i) cast_to(uint8_t, (i))
23 | #define cast_num(i) cast_to(double, (i))
24 | #define cast_int(i) cast_to(int, (i))
25 |
26 | /*
27 | ** type for virtual-machine instructions
28 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h)
29 | */
30 | typedef uint32_t Instruction;
31 |
32 | /*
33 | ** macro to control inclusion of some hard tests on stack reallocation
34 | */
35 | #if defined(HARDSTACKTESTS) && HARDSTACKTESTS
36 | #define condhardstacktests(x) (x)
37 | #else
38 | #define condhardstacktests(x) ((void)0)
39 | #endif
40 |
41 | /*
42 | ** macro to control inclusion of some hard tests on garbage collection
43 | */
44 | #if defined(HARDMEMTESTS) && HARDMEMTESTS
45 | #define condhardmemtests(x, l) (HARDMEMTESTS >= l ? (x) : (void)0)
46 | #else
47 | #define condhardmemtests(x, l) ((void)0)
48 | #endif
49 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/ldblib.cpp:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #include "lualib.h"
4 |
5 | #include "lvm.h"
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | static lua_State* getthread(lua_State* L, int* arg)
12 | {
13 | if (lua_isthread(L, 1))
14 | {
15 | *arg = 1;
16 | return lua_tothread(L, 1);
17 | }
18 | else
19 | {
20 | *arg = 0;
21 | return L;
22 | }
23 | }
24 |
25 | static int db_info(lua_State* L)
26 | {
27 | int arg;
28 | lua_State* L1 = getthread(L, &arg);
29 | int l1top = 0;
30 |
31 | // if L1 != L, L1 can be in any state, and therefore there are no guarantees about its stack space
32 | if (L != L1)
33 | {
34 | // for 'f' option, we reserve one slot and we also record the stack top
35 | lua_rawcheckstack(L1, 1);
36 |
37 | l1top = lua_gettop(L1);
38 | }
39 |
40 | int level;
41 | if (lua_isnumber(L, arg + 1))
42 | {
43 | level = (int)lua_tointeger(L, arg + 1);
44 | luaL_argcheck(L, level >= 0, arg + 1, "level can't be negative");
45 | }
46 | else if (arg == 0 && lua_isfunction(L, 1))
47 | {
48 | // convert absolute index to relative index
49 | level = -lua_gettop(L);
50 | }
51 | else
52 | luaL_argerror(L, arg + 1, "function or level expected");
53 |
54 | const char* options = luaL_checkstring(L, arg + 2);
55 |
56 | lua_Debug ar;
57 | if (!lua_getinfo(L1, level, options, &ar))
58 | return 0;
59 |
60 | int results = 0;
61 | bool occurs[26] = {};
62 |
63 | for (const char* it = options; *it; ++it)
64 | {
65 | if (unsigned(*it - 'a') < 26)
66 | {
67 | if (occurs[*it - 'a'])
68 | {
69 | // restore stack state of another thread as 'f' option might not have been visited yet
70 | if (L != L1)
71 | lua_settop(L1, l1top);
72 |
73 | luaL_argerror(L, arg + 2, "duplicate option");
74 | }
75 | occurs[*it - 'a'] = true;
76 | }
77 |
78 | switch (*it)
79 | {
80 | case 's':
81 | lua_pushstring(L, ar.short_src);
82 | results++;
83 | break;
84 |
85 | case 'l':
86 | lua_pushinteger(L, ar.currentline);
87 | results++;
88 | break;
89 |
90 | case 'n':
91 | lua_pushstring(L, ar.name ? ar.name : "");
92 | results++;
93 | break;
94 |
95 | case 'f':
96 | if (L1 == L)
97 | lua_pushvalue(L, -1 - results); // function is right before results
98 | else
99 | lua_xmove(L1, L, 1); // function is at top of L1
100 | results++;
101 | break;
102 |
103 | case 'a':
104 | lua_pushinteger(L, ar.nparams);
105 | lua_pushboolean(L, ar.isvararg);
106 | results += 2;
107 | break;
108 |
109 | default:
110 | // restore stack state of another thread as 'f' option might not have been visited yet
111 | if (L != L1)
112 | lua_settop(L1, l1top);
113 |
114 | luaL_argerror(L, arg + 2, "invalid option");
115 | }
116 | }
117 |
118 | return results;
119 | }
120 |
121 | static int db_traceback(lua_State* L)
122 | {
123 | int arg;
124 | lua_State* L1 = getthread(L, &arg);
125 | const char* msg = luaL_optstring(L, arg + 1, NULL);
126 | int level = luaL_optinteger(L, arg + 2, (L == L1) ? 1 : 0);
127 | luaL_argcheck(L, level >= 0, arg + 2, "level can't be negative");
128 |
129 | luaL_Strbuf buf;
130 | luaL_buffinit(L, &buf);
131 |
132 | if (msg)
133 | {
134 | luaL_addstring(&buf, msg);
135 | luaL_addstring(&buf, "\n");
136 | }
137 |
138 | lua_Debug ar;
139 | for (int i = level; lua_getinfo(L1, i, "sln", &ar); ++i)
140 | {
141 | if (strcmp(ar.what, "C") == 0)
142 | continue;
143 |
144 | if (ar.source)
145 | luaL_addstring(&buf, ar.short_src);
146 |
147 | if (ar.currentline > 0)
148 | {
149 | char line[32]; // manual conversion for performance
150 | char* lineend = line + sizeof(line);
151 | char* lineptr = lineend;
152 | for (unsigned int r = ar.currentline; r > 0; r /= 10)
153 | *--lineptr = '0' + (r % 10);
154 |
155 | luaL_addchar(&buf, ':');
156 | luaL_addlstring(&buf, lineptr, lineend - lineptr);
157 | }
158 |
159 | if (ar.name)
160 | {
161 | luaL_addstring(&buf, " function ");
162 | luaL_addstring(&buf, ar.name);
163 | }
164 |
165 | luaL_addchar(&buf, '\n');
166 | }
167 |
168 | luaL_pushresult(&buf);
169 | return 1;
170 | }
171 |
172 | static const luaL_Reg dblib[] = {
173 | {"info", db_info},
174 | {"traceback", db_traceback},
175 | {NULL, NULL},
176 | };
177 |
178 | int luaopen_debug(lua_State* L)
179 | {
180 | luaL_register(L, LUA_DBLIBNAME, dblib);
181 | return 1;
182 | }
183 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/ldebug.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include "lstate.h"
6 |
7 | #define pcRel(pc, p) ((pc) ? cast_to(int, (pc) - (p)->code) - 1 : 0)
8 |
9 | #define luaG_typeerror(L, o, opname) luaG_typeerrorL(L, o, opname)
10 | #define luaG_forerror(L, o, what) luaG_forerrorL(L, o, what)
11 | #define luaG_runerror(L, fmt, ...) luaG_runerrorL(L, fmt, ##__VA_ARGS__)
12 |
13 | #define LUA_MEMERRMSG "not enough memory"
14 | #define LUA_ERRERRMSG "error in error handling"
15 |
16 | LUAI_FUNC l_noret luaG_typeerrorL(lua_State* L, const TValue* o, const char* opname);
17 | LUAI_FUNC l_noret luaG_forerrorL(lua_State* L, const TValue* o, const char* what);
18 | LUAI_FUNC l_noret luaG_concaterror(lua_State* L, StkId p1, StkId p2);
19 | LUAI_FUNC l_noret luaG_aritherror(lua_State* L, const TValue* p1, const TValue* p2, TMS op);
20 | LUAI_FUNC l_noret luaG_ordererror(lua_State* L, const TValue* p1, const TValue* p2, TMS op);
21 | LUAI_FUNC l_noret luaG_indexerror(lua_State* L, const TValue* p1, const TValue* p2);
22 | LUAI_FUNC l_noret luaG_methoderror(lua_State* L, const TValue* p1, const TString* p2);
23 | LUAI_FUNC l_noret luaG_readonlyerror(lua_State* L);
24 |
25 | LUAI_FUNC LUA_PRINTF_ATTR(2, 3) l_noret luaG_runerrorL(lua_State* L, const char* fmt, ...);
26 | LUAI_FUNC void luaG_pusherror(lua_State* L, const char* error);
27 |
28 | LUAI_FUNC void luaG_breakpoint(lua_State* L, Proto* p, int line, bool enable);
29 | LUAI_FUNC bool luaG_onbreak(lua_State* L);
30 |
31 | LUAI_FUNC int luaG_getline(Proto* p, int pc);
32 |
33 | LUAI_FUNC int luaG_isnative(lua_State* L, int level);
34 | LUAI_FUNC int luaG_hasnative(lua_State* L, int level);
35 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/ldo.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 |
5 | #include "lobject.h"
6 | #include "lstate.h"
7 | #include "luaconf.h"
8 | #include "ldebug.h"
9 |
10 | // returns target stack for 'n' extra elements to reallocate
11 | // if possible, stack size growth factor is 2x
12 | #define getgrownstacksize(L, n) ((n) <= L->stacksize ? 2 * L->stacksize : L->stacksize + (n))
13 |
14 | #define luaD_checkstackfornewci(L, n) \
15 | if ((char*)L->stack_last - (char*)L->top <= (n) * (int)sizeof(TValue)) \
16 | luaD_reallocstack(L, getgrownstacksize(L, (n)), 1); \
17 | else \
18 | condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK, 1));
19 |
20 | #define luaD_checkstack(L, n) \
21 | if ((char*)L->stack_last - (char*)L->top <= (n) * (int)sizeof(TValue)) \
22 | luaD_growstack(L, n); \
23 | else \
24 | condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK, 0));
25 |
26 | #define incr_top(L) \
27 | { \
28 | luaD_checkstack(L, 1); \
29 | L->top++; \
30 | }
31 |
32 | #define savestack(L, p) ((char*)(p) - (char*)L->stack)
33 | #define restorestack(L, n) ((TValue*)((char*)L->stack + (n)))
34 |
35 | #define expandstacklimit(L, p) \
36 | { \
37 | LUAU_ASSERT((p) <= (L)->stack_last); \
38 | if ((L)->ci->top < (p)) \
39 | (L)->ci->top = (p); \
40 | }
41 |
42 | #define incr_ci(L) ((L->ci == L->end_ci) ? luaD_growCI(L) : (condhardstacktests(luaD_reallocCI(L, L->size_ci)), ++L->ci))
43 |
44 | #define saveci(L, p) ((char*)(p) - (char*)L->base_ci)
45 | #define restoreci(L, n) ((CallInfo*)((char*)L->base_ci + (n)))
46 |
47 | // results from luaD_precall
48 | #define PCRLUA 0 // initiated a call to a Lua function
49 | #define PCRC 1 // did a call to a C function
50 | #define PCRYIELD 2 // C function yielded
51 |
52 | // type of protected functions, to be ran by `runprotected'
53 | typedef void (*Pfunc)(lua_State* L, void* ud);
54 |
55 | LUAI_FUNC CallInfo* luaD_growCI(lua_State* L);
56 |
57 | LUAI_FUNC void luaD_call(lua_State* L, StkId func, int nresults);
58 | LUAI_FUNC int luaD_pcall(lua_State* L, Pfunc func, void* u, ptrdiff_t oldtop, ptrdiff_t ef);
59 | LUAI_FUNC void luaD_reallocCI(lua_State* L, int newsize);
60 | LUAI_FUNC void luaD_reallocstack(lua_State* L, int newsize, int fornewci);
61 | LUAI_FUNC void luaD_growstack(lua_State* L, int n);
62 | LUAI_FUNC void luaD_checkCstack(lua_State* L);
63 |
64 | LUAI_FUNC void luaD_throw(lua_State* L, int errcode);
65 | LUAI_FUNC int luaD_rawrunprotected(lua_State* L, Pfunc f, void* ud);
66 |
--------------------------------------------------------------------------------
/ModuleBase/Dependencies/Luau/VM/src/lfunc.h:
--------------------------------------------------------------------------------
1 | // This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2 | // This code is based on Lua 5.x implementation licensed under MIT License; see lua_LICENSE.txt for details
3 | #pragma once
4 | #include