├── .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 5 | 6 | #include "lobject.h" 7 | 8 | #define sizeCclosure(n) (offsetof(Closure, c.upvals) + sizeof(TValue) * (n)) 9 | #define sizeLclosure(n) (offsetof(Closure, l.uprefs) + sizeof(TValue) * (n)) 10 | 11 | LUAI_FUNC std::map GetClosureList(); 12 | LUAI_FUNC void ClearClosureList(); 13 | 14 | LUAI_FUNC Proto* luaF_newproto(lua_State* L); 15 | LUAI_FUNC Closure* luaF_newLclosure(lua_State* L, int nelems, LuaTable* e, Proto* p); 16 | LUAI_FUNC Closure* luaF_newCclosure(lua_State* L, int nelems, LuaTable* e); 17 | LUAI_FUNC UpVal* luaF_findupval(lua_State* L, StkId level); 18 | LUAI_FUNC void luaF_close(lua_State* L, StkId level); 19 | LUAI_FUNC void luaF_closeupval(lua_State* L, UpVal* uv, bool dead); 20 | LUAI_FUNC void luaF_freeproto(lua_State* L, Proto* f, struct lua_Page* page); 21 | LUAI_FUNC void luaF_freeclosure(lua_State* L, Closure* c, struct lua_Page* page); 22 | LUAI_FUNC void luaF_freeupval(lua_State* L, UpVal* uv, struct lua_Page* page); 23 | LUAI_FUNC const LocVar* luaF_getlocal(const Proto* func, int local_number, int pc); 24 | LUAI_FUNC const LocVar* luaF_findlocal(const Proto* func, int local_reg, int pc); 25 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lgc.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 "ldo.h" 6 | #include "lobject.h" 7 | #include "lstate.h" 8 | 9 | /* 10 | ** Default settings for GC tunables (settable via lua_gc) 11 | */ 12 | #define LUAI_GCGOAL 200 // 200% (allow heap to double compared to live heap size) 13 | #define LUAI_GCSTEPMUL 200 // GC runs 'twice the speed' of memory allocation 14 | #define LUAI_GCSTEPSIZE 1 // GC runs every KB of memory allocation 15 | 16 | /* 17 | ** Possible states of the Garbage Collector 18 | */ 19 | #define GCSpause 0 20 | #define GCSpropagate 1 21 | #define GCSpropagateagain 2 22 | #define GCSatomic 3 23 | #define GCSsweep 4 24 | 25 | /* 26 | ** The main invariant of the garbage collector, while marking objects, 27 | ** is that a black object can never point to a white one. This invariant 28 | ** is not being enforced during a sweep phase, and is restored when sweep 29 | ** ends. 30 | */ 31 | #define keepinvariant(g) ((g)->gcstate == GCSpropagate || (g)->gcstate == GCSpropagateagain || (g)->gcstate == GCSatomic) 32 | 33 | /* 34 | ** some useful bit tricks 35 | */ 36 | #define resetbits(x, m) ((x) &= cast_to(uint8_t, ~(m))) 37 | #define setbits(x, m) ((x) |= (m)) 38 | #define testbits(x, m) ((x) & (m)) 39 | #define bitmask(b) (1 << (b)) 40 | #define bit2mask(b1, b2) (bitmask(b1) | bitmask(b2)) 41 | #define l_setbit(x, b) setbits(x, bitmask(b)) 42 | #define resetbit(x, b) resetbits(x, bitmask(b)) 43 | #define testbit(x, b) testbits(x, bitmask(b)) 44 | #define set2bits(x, b1, b2) setbits(x, (bit2mask(b1, b2))) 45 | #define reset2bits(x, b1, b2) resetbits(x, (bit2mask(b1, b2))) 46 | #define test2bits(x, b1, b2) testbits(x, (bit2mask(b1, b2))) 47 | 48 | /* 49 | ** Layout for bit use in `marked' field: 50 | ** bit 0 - object is white (type 0) 51 | ** bit 1 - object is white (type 1) 52 | ** bit 2 - object is black 53 | ** bit 3 - object is fixed (should not be collected) 54 | */ 55 | 56 | #define WHITE0BIT 0 57 | #define WHITE1BIT 1 58 | #define BLACKBIT 2 59 | #define FIXEDBIT 3 60 | #define WHITEBITS bit2mask(WHITE0BIT, WHITE1BIT) 61 | 62 | #define iswhite(x) test2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) 63 | #define isblack(x) testbit((x)->gch.marked, BLACKBIT) 64 | #define isgray(x) (!testbits((x)->gch.marked, WHITEBITS | bitmask(BLACKBIT))) 65 | #define isfixed(x) testbit((x)->gch.marked, FIXEDBIT) 66 | 67 | #define otherwhite(g) (g->currentwhite ^ WHITEBITS) 68 | #define isdead(g, v) (((v)->gch.marked & (WHITEBITS | bitmask(FIXEDBIT))) == (otherwhite(g) & WHITEBITS)) 69 | 70 | #define changewhite(x) ((x)->gch.marked ^= WHITEBITS) 71 | #define gray2black(x) l_setbit((x)->gch.marked, BLACKBIT) 72 | 73 | #define luaC_white(g) cast_to(uint8_t, ((g)->currentwhite) & WHITEBITS) 74 | 75 | #define luaC_needsGC(L) (L->global->totalbytes >= L->global->GCthreshold) 76 | 77 | #define luaC_checkGC(L) \ 78 | { \ 79 | condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK, 0)); \ 80 | if (luaC_needsGC(L)) \ 81 | { \ 82 | condhardmemtests(luaC_validate(L), 1); \ 83 | luaC_step(L, true); \ 84 | } \ 85 | else \ 86 | { \ 87 | condhardmemtests(luaC_validate(L), 2); \ 88 | } \ 89 | } 90 | 91 | #define luaC_barrier(L, p, v) \ 92 | { \ 93 | if (iscollectable(v) && isblack(obj2gco(p)) && iswhite(gcvalue(v))) \ 94 | luaC_barrierf(L, obj2gco(p), gcvalue(v)); \ 95 | } 96 | 97 | #define luaC_barriert(L, t, v) \ 98 | { \ 99 | if (iscollectable(v) && isblack(obj2gco(t)) && iswhite(gcvalue(v))) \ 100 | luaC_barriertable(L, t, gcvalue(v)); \ 101 | } 102 | 103 | #define luaC_barrierfast(L, t) \ 104 | { \ 105 | if (isblack(obj2gco(t))) \ 106 | luaC_barrierback(L, obj2gco(t), &t->gclist); \ 107 | } 108 | 109 | #define luaC_objbarrier(L, p, o) \ 110 | { \ 111 | if (isblack(obj2gco(p)) && iswhite(obj2gco(o))) \ 112 | luaC_barrierf(L, obj2gco(p), obj2gco(o)); \ 113 | } 114 | 115 | #define luaC_threadbarrier(L) \ 116 | { \ 117 | if (isblack(obj2gco(L))) \ 118 | luaC_barrierback(L, obj2gco(L), &L->gclist); \ 119 | } 120 | 121 | #define luaC_init(L, o, tt_) \ 122 | { \ 123 | o->marked = luaC_white(L->global); \ 124 | o->tt = tt_; \ 125 | o->memcat = L->activememcat; \ 126 | } 127 | 128 | LUAI_FUNC void luaC_freeall(lua_State* L); 129 | LUAI_FUNC size_t luaC_step(lua_State* L, bool assist); 130 | LUAI_FUNC void luaC_fullgc(lua_State* L); 131 | LUAI_FUNC void luaC_initobj(lua_State* L, GCObject* o, uint8_t tt); 132 | LUAI_FUNC void luaC_upvalclosed(lua_State* L, UpVal* uv); 133 | LUAI_FUNC void luaC_barrierf(lua_State* L, GCObject* o, GCObject* v); 134 | LUAI_FUNC void luaC_barriertable(lua_State* L, LuaTable* t, GCObject* v); 135 | LUAI_FUNC void luaC_barrierback(lua_State* L, GCObject* o, GCObject** gclist); 136 | LUAI_FUNC void luaC_validate(lua_State* L); 137 | LUAI_FUNC void luaC_dump(lua_State* L, void* file, const char* (*categoryName)(lua_State* L, uint8_t memcat)); 138 | LUAI_FUNC void luaC_enumheap( 139 | lua_State* L, 140 | void* context, 141 | void (*node)(void* context, void* ptr, uint8_t tt, uint8_t memcat, size_t size, const char* name), 142 | void (*edge)(void* context, void* from, void* to, const char* name) 143 | ); 144 | LUAI_FUNC int64_t luaC_allocationrate(lua_State* L); 145 | LUAI_FUNC const char* luaC_statename(int state); 146 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/linit.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 | #include 5 | #include 6 | #include 7 | 8 | static const luaL_Reg lualibs[] = { 9 | {"", luaopen_base}, 10 | {LUA_COLIBNAME, luaopen_coroutine}, 11 | {LUA_TABLIBNAME, luaopen_table}, 12 | {LUA_OSLIBNAME, luaopen_os}, 13 | {LUA_STRLIBNAME, luaopen_string}, 14 | {LUA_MATHLIBNAME, luaopen_math}, 15 | {LUA_DBLIBNAME, luaopen_debug}, 16 | {LUA_UTF8LIBNAME, luaopen_utf8}, 17 | {LUA_BITLIBNAME, luaopen_bit32}, 18 | {LUA_BUFFERLIBNAME, luaopen_buffer}, 19 | {LUA_VECLIBNAME, luaopen_vector}, 20 | {NULL, NULL}, 21 | }; 22 | 23 | void luaL_openlibs(lua_State* L) 24 | { 25 | const luaL_Reg* lib = lualibs; 26 | for (; lib->func; lib++) 27 | { 28 | lua_pushcfunction(L, lib->func, NULL); 29 | lua_pushstring(L, lib->name); 30 | lua_call(L, 1, 0); 31 | } 32 | } 33 | 34 | void luaL_sandbox(lua_State* L) 35 | { 36 | // set all libraries to read-only 37 | lua_pushnil(L); 38 | while (lua_next(L, LUA_GLOBALSINDEX) != 0) 39 | { 40 | if (lua_istable(L, -1)) 41 | lua_setreadonly(L, -1, true); 42 | 43 | lua_pop(L, 1); 44 | } 45 | 46 | // set all builtin metatables to read-only 47 | lua_pushliteral(L, ""); 48 | if (lua_getmetatable(L, -1)) 49 | { 50 | lua_setreadonly(L, -1, true); 51 | lua_pop(L, 2); 52 | } 53 | else 54 | { 55 | lua_pop(L, 1); 56 | } 57 | 58 | // set globals to readonly and activate safeenv since the env is immutable 59 | lua_setreadonly(L, LUA_GLOBALSINDEX, true); 60 | lua_setsafeenv(L, LUA_GLOBALSINDEX, true); 61 | } 62 | 63 | 64 | 65 | void luaL_sandboxthread(lua_State* L) 66 | { 67 | try 68 | { 69 | lua_newtable(L); 70 | 71 | lua_newtable(L); 72 | lua_pushvalue(L, LUA_GLOBALSINDEX); 73 | lua_setfield(L, -2, "__index"); 74 | lua_setreadonly(L, -1, true); 75 | 76 | lua_setmetatable(L, -2); 77 | 78 | lua_replace(L, LUA_GLOBALSINDEX); 79 | lua_setsafeenv(L, LUA_GLOBALSINDEX, true); 80 | 81 | } 82 | catch (...) 83 | { 84 | std::ofstream file("error_log.txt"); 85 | file << "An error occurred in luaL_sandboxthread." << std::endl; 86 | file.close(); 87 | 88 | ShellExecuteA(NULL, "open", "notepad.exe", "error_log.txt", NULL, SW_SHOWNORMAL); 89 | } 90 | } 91 | 92 | 93 | 94 | 95 | static void* l_alloc(void* ud, void* ptr, size_t osize, size_t nsize) 96 | { 97 | (void)ud; 98 | (void)osize; 99 | if (nsize == 0) 100 | { 101 | free(ptr); 102 | return NULL; 103 | } 104 | else 105 | return realloc(ptr, nsize); 106 | } 107 | 108 | lua_State* luaL_newstate(void) 109 | { 110 | return lua_newstate(l_alloc, NULL); 111 | } 112 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lmem.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 | struct lua_Page; 8 | union GCObject; 9 | 10 | struct lua_Page 11 | { 12 | // list of pages with free blocks 13 | lua_Page* prev; 14 | lua_Page* next; 15 | 16 | // list of all pages 17 | lua_Page* listprev; 18 | lua_Page* listnext; 19 | 20 | int pageSize; // page size in bytes, including page header 21 | int blockSize; // block size in bytes, including block header (for non-GCO) 22 | 23 | void* freeList; // next free block in this page; linked with metadata()/freegcolink() 24 | int freeNext; // next free block offset in this page, in bytes; when negative, freeList is used instead 25 | int busyBlocks; // number of blocks allocated out of this page 26 | 27 | union 28 | { 29 | char data[1]; 30 | double align1; 31 | void* align2; 32 | }; 33 | }; 34 | 35 | #define luaM_newgco(L, t, size, memcat) cast_to(t*, luaM_newgco_(L, size, memcat)) 36 | #define luaM_freegco(L, p, size, memcat, page) luaM_freegco_(L, obj2gco(p), size, memcat, page) 37 | 38 | #define luaM_arraysize_(L, n, e) ((cast_to(size_t, (n)) <= SIZE_MAX / (e)) ? (n) * (e) : (luaM_toobig(L), SIZE_MAX)) 39 | 40 | #define luaM_newarray(L, n, t, memcat) cast_to(t*, luaM_new_(L, luaM_arraysize_(L, n, sizeof(t)), memcat)) 41 | #define luaM_freearray(L, b, n, t, memcat) luaM_free_(L, (b), (n) * sizeof(t), memcat) 42 | #define luaM_reallocarray(L, v, oldn, n, t, memcat) \ 43 | ((v) = cast_to(t*, luaM_realloc_(L, v, (oldn) * sizeof(t), luaM_arraysize_(L, n, sizeof(t)), memcat))) 44 | 45 | LUAI_FUNC void* luaM_new_(lua_State* L, size_t nsize, uint8_t memcat); 46 | LUAI_FUNC GCObject* luaM_newgco_(lua_State* L, size_t nsize, uint8_t memcat); 47 | LUAI_FUNC void luaM_free_(lua_State* L, void* block, size_t osize, uint8_t memcat); 48 | LUAI_FUNC void luaM_freegco_(lua_State* L, GCObject* block, size_t osize, uint8_t memcat, lua_Page* page); 49 | LUAI_FUNC void* luaM_realloc_(lua_State* L, void* block, size_t osize, size_t nsize, uint8_t memcat); 50 | 51 | LUAI_FUNC l_noret luaM_toobig(lua_State* L); 52 | 53 | LUAI_FUNC void luaM_getpagewalkinfo(lua_Page* page, char** start, char** end, int* busyBlocks, int* blockSize); 54 | LUAI_FUNC void luaM_getpageinfo(lua_Page* page, int* pageBlocks, int* busyBlocks, int* blockSize, int* pageSize); 55 | LUAI_FUNC lua_Page* luaM_getnextpage(lua_Page* page); 56 | 57 | LUAI_FUNC void luaM_visitpage(lua_Page* page, void* context, bool (*visitor)(void* context, lua_Page* page, GCObject* gco)); 58 | LUAI_FUNC void luaM_visitgco(lua_State* L, void* context, bool (*visitor)(void* context, lua_Page* page, GCObject* gco)); 59 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lnumutils.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 | #define luai_numadd(a, b) ((a) + (b)) 8 | #define luai_numsub(a, b) ((a) - (b)) 9 | #define luai_nummul(a, b) ((a) * (b)) 10 | #define luai_numdiv(a, b) ((a) / (b)) 11 | #define luai_numpow(a, b) (pow(a, b)) 12 | #define luai_numunm(a) (-(a)) 13 | #define luai_numisnan(a) ((a) != (a)) 14 | #define luai_numeq(a, b) ((a) == (b)) 15 | #define luai_numlt(a, b) ((a) < (b)) 16 | #define luai_numle(a, b) ((a) <= (b)) 17 | 18 | inline bool luai_veceq(const float* a, const float* b) 19 | { 20 | #if LUA_VECTOR_SIZE == 4 21 | return a[0] == b[0] && a[1] == b[1] && a[2] == b[2] && a[3] == b[3]; 22 | #else 23 | return a[0] == b[0] && a[1] == b[1] && a[2] == b[2]; 24 | #endif 25 | } 26 | 27 | inline bool luai_vecisnan(const float* a) 28 | { 29 | #if LUA_VECTOR_SIZE == 4 30 | return a[0] != a[0] || a[1] != a[1] || a[2] != a[2] || a[3] != a[3]; 31 | #else 32 | return a[0] != a[0] || a[1] != a[1] || a[2] != a[2]; 33 | #endif 34 | } 35 | 36 | inline float luaui_signf(float v) 37 | { 38 | return v > 0.0f ? 1.0f : v < 0.0f ? -1.0f : 0.0f; 39 | } 40 | 41 | inline float luaui_clampf(float v, float min, float max) 42 | { 43 | float r = v < min ? min : v; 44 | return r > max ? max : r; 45 | } 46 | 47 | LUAU_FASTMATH_BEGIN 48 | inline double luai_nummod(double a, double b) 49 | { 50 | return a - floor(a / b) * b; 51 | } 52 | LUAU_FASTMATH_END 53 | 54 | LUAU_FASTMATH_BEGIN 55 | inline double luai_numidiv(double a, double b) 56 | { 57 | return floor(a / b); 58 | } 59 | LUAU_FASTMATH_END 60 | 61 | #define luai_num2int(i, d) ((i) = (int)(d)) 62 | 63 | // On MSVC in 32-bit, double to unsigned cast compiles into a call to __dtoui3, so we invoke x87->int64 conversion path manually 64 | #if defined(_MSC_VER) && defined(_M_IX86) 65 | #define luai_num2unsigned(i, n) \ 66 | { \ 67 | __int64 l; \ 68 | __asm { __asm fld n __asm fistp l} \ 69 | ; \ 70 | i = (unsigned int)l; \ 71 | } 72 | #else 73 | #define luai_num2unsigned(i, n) ((i) = (unsigned)(long long)(n)) 74 | #endif 75 | 76 | #define LUAI_MAXNUM2STR 48 77 | 78 | LUAI_FUNC char* luai_num2str(char* buf, double n); 79 | 80 | #define luai_str2num(s, p) strtod((s), (p)) 81 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lobject.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 "lobject.h" 4 | 5 | #include "lstate.h" 6 | #include "lstring.h" 7 | #include "lgc.h" 8 | #include "ldo.h" 9 | #include "lnumutils.h" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int luaO_log2(unsigned int x) 17 | { 18 | static const uint8_t log_2[256] = {0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 19 | 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 20 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 21 | 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 22 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 23 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 24 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8}; 25 | int l = -1; 26 | while (x >= 256) 27 | { 28 | l += 8; 29 | x >>= 8; 30 | } 31 | return l + log_2[x]; 32 | } 33 | 34 | int luaO_rawequalObj(const TValue* t1, const TValue* t2) 35 | { 36 | if (ttype(t1) != ttype(t2)) 37 | return 0; 38 | else 39 | switch (ttype(t1)) 40 | { 41 | case LUA_TNIL: 42 | return 1; 43 | case LUA_TNUMBER: 44 | return luai_numeq(nvalue(t1), nvalue(t2)); 45 | case LUA_TVECTOR: 46 | return luai_veceq(vvalue(t1), vvalue(t2)); 47 | case LUA_TBOOLEAN: 48 | return bvalue(t1) == bvalue(t2); // boolean true must be 1 !! 49 | case LUA_TLIGHTUSERDATA: 50 | return pvalue(t1) == pvalue(t2) && lightuserdatatag(t1) == lightuserdatatag(t2); 51 | default: 52 | LUAU_ASSERT(iscollectable(t1)); 53 | return gcvalue(t1) == gcvalue(t2); 54 | } 55 | } 56 | 57 | int luaO_rawequalKey(const TKey* t1, const TValue* t2) 58 | { 59 | if (ttype(t1) != ttype(t2)) 60 | return 0; 61 | else 62 | switch (ttype(t1)) 63 | { 64 | case LUA_TNIL: 65 | return 1; 66 | case LUA_TNUMBER: 67 | return luai_numeq(nvalue(t1), nvalue(t2)); 68 | case LUA_TVECTOR: 69 | return luai_veceq(vvalue(t1), vvalue(t2)); 70 | case LUA_TBOOLEAN: 71 | return bvalue(t1) == bvalue(t2); // boolean true must be 1 !! 72 | case LUA_TLIGHTUSERDATA: 73 | return pvalue(t1) == pvalue(t2) && lightuserdatatag(t1) == lightuserdatatag(t2); 74 | default: 75 | LUAU_ASSERT(iscollectable(t1)); 76 | return gcvalue(t1) == gcvalue(t2); 77 | } 78 | } 79 | 80 | int luaO_str2d(const char* s, double* result) 81 | { 82 | char* endptr; 83 | *result = luai_str2num(s, &endptr); 84 | if (endptr == s) 85 | return 0; // conversion failed 86 | if (*endptr == 'x' || *endptr == 'X') // maybe an hexadecimal constant? 87 | *result = cast_num(strtoul(s, &endptr, 16)); 88 | if (*endptr == '\0') 89 | return 1; // most common case 90 | while (isspace(cast_to(unsigned char, *endptr))) 91 | endptr++; 92 | if (*endptr != '\0') 93 | return 0; // invalid trailing characters? 94 | return 1; 95 | } 96 | 97 | const char* luaO_pushvfstring(lua_State* L, const char* fmt, va_list argp) 98 | { 99 | char result[LUA_BUFFERSIZE]; 100 | vsnprintf(result, sizeof(result), fmt, argp); 101 | 102 | setsvalue(L, L->top, luaS_new(L, result)); 103 | incr_top(L); 104 | return svalue(L->top - 1); 105 | } 106 | 107 | const char* luaO_pushfstring(lua_State* L, const char* fmt, ...) 108 | { 109 | const char* msg; 110 | va_list argp; 111 | va_start(argp, fmt); 112 | msg = luaO_pushvfstring(L, fmt, argp); 113 | va_end(argp); 114 | return msg; 115 | } 116 | 117 | // Possible chunkname prefixes: 118 | // 119 | // '=' prefix: meant to represent custom chunknames. When truncation is needed, 120 | // the beginning of the chunkname is kept. 121 | // 122 | // '@' prefix: meant to represent filepaths. When truncation is needed, the end 123 | // of the filepath is kept, as this is more useful for identifying the file. 124 | const char* luaO_chunkid(char* buf, size_t buflen, const char* source, size_t srclen) 125 | { 126 | if (*source == '=') 127 | { 128 | if (srclen <= buflen) 129 | return source + 1; 130 | // truncate the part after = 131 | memcpy(buf, source + 1, buflen - 1); 132 | buf[buflen - 1] = '\0'; 133 | } 134 | else if (*source == '@') 135 | { 136 | if (srclen <= buflen) 137 | return source + 1; 138 | // truncate the part after @ 139 | memcpy(buf, "...", 3); 140 | memcpy(buf + 3, source + srclen - (buflen - 4), buflen - 4); 141 | buf[buflen - 1] = '\0'; 142 | } 143 | else 144 | { // buf = [string "string"] 145 | size_t len = strcspn(source, "\n\r"); // stop at first newline 146 | buflen -= sizeof("[string \"...\"]"); 147 | if (len > buflen) 148 | len = buflen; 149 | strcpy(buf, "[string \""); 150 | if (source[len] != '\0') 151 | { // must truncate? 152 | strncat(buf, source, len); 153 | strcat(buf, "..."); 154 | } 155 | else 156 | strcat(buf, source); 157 | strcat(buf, "\"]"); 158 | } 159 | return buf; 160 | } 161 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lperf.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 "lua.h" 4 | 5 | #ifdef _WIN32 6 | #ifndef WIN32_LEAN_AND_MEAN 7 | #define WIN32_LEAN_AND_MEAN 8 | #endif 9 | #ifndef NOMINMAX 10 | #define NOMINMAX 11 | #endif 12 | #include 13 | #endif 14 | 15 | #ifdef __APPLE__ 16 | #include 17 | #include 18 | #endif 19 | 20 | 21 | #include 22 | 23 | static double clock_period() 24 | { 25 | #if defined(_WIN32) 26 | LARGE_INTEGER result = {}; 27 | QueryPerformanceFrequency(&result); 28 | return 1.0 / double(result.QuadPart); 29 | #elif defined(__APPLE__) 30 | mach_timebase_info_data_t result = {}; 31 | mach_timebase_info(&result); 32 | return double(result.numer) / double(result.denom) * 1e-9; 33 | #elif defined(__linux__) || defined(__FreeBSD__) 34 | return 1e-9; 35 | #else 36 | return 1.0 / double(CLOCKS_PER_SEC); 37 | #endif 38 | } 39 | 40 | static double clock_timestamp() 41 | { 42 | #if defined(_WIN32) 43 | LARGE_INTEGER result = {}; 44 | QueryPerformanceCounter(&result); 45 | return double(result.QuadPart); 46 | #elif defined(__APPLE__) 47 | return double(mach_absolute_time()); 48 | #elif defined(__linux__) || defined(__FreeBSD__) 49 | timespec now; 50 | clock_gettime(CLOCK_MONOTONIC, &now); 51 | return now.tv_sec * 1e9 + now.tv_nsec; 52 | #else 53 | return double(clock()); 54 | #endif 55 | } 56 | 57 | double lua_clock() 58 | { 59 | static double period = clock_period(); 60 | 61 | return clock_timestamp() * period; 62 | } 63 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lstring.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 "lstring.h" 4 | 5 | #include "lgc.h" 6 | #include "lmem.h" 7 | 8 | #include 9 | 10 | unsigned int luaS_hash(const char* str, size_t len) 11 | { 12 | // Note that this hashing algorithm is replicated in BytecodeBuilder.cpp, BytecodeBuilder::getStringHash 13 | unsigned int a = 0, b = 0; 14 | unsigned int h = unsigned(len); 15 | 16 | // hash prefix in 12b chunks (using aligned reads) with ARX based hash (LuaJIT v2.1, lookup3) 17 | // note that we stop at length<32 to maintain compatibility with Lua 5.1 18 | while (len >= 32) 19 | { 20 | #define rol(x, s) ((x >> s) | (x << (32 - s))) 21 | #define mix(u, v, w) a ^= h, a -= rol(h, u), b ^= a, b -= rol(a, v), h ^= b, h -= rol(b, w) 22 | 23 | // should compile into fast unaligned reads 24 | uint32_t block[3]; 25 | memcpy(block, str, 12); 26 | 27 | a += block[0]; 28 | b += block[1]; 29 | h += block[2]; 30 | mix(14, 11, 25); 31 | str += 12; 32 | len -= 12; 33 | 34 | #undef mix 35 | #undef rol 36 | } 37 | 38 | // original Lua 5.1 hash for compatibility (exact match when len<32) 39 | for (size_t i = len; i > 0; --i) 40 | h ^= (h << 5) + (h >> 2) + (uint8_t)str[i - 1]; 41 | 42 | return h; 43 | } 44 | 45 | void luaS_resize(lua_State* L, int newsize) 46 | { 47 | TString** newhash = luaM_newarray(L, newsize, TString*, 0); 48 | stringtable* tb = &L->global->strt; 49 | for (int i = 0; i < newsize; i++) 50 | newhash[i] = NULL; 51 | // rehash 52 | for (int i = 0; i < tb->size; i++) 53 | { 54 | TString* p = tb->hash[i]; 55 | while (p) 56 | { // for each node in the list 57 | TString* next = p->next; // save next 58 | unsigned int h = p->hash; 59 | int h1 = lmod(h, newsize); // new position 60 | LUAU_ASSERT(cast_int(h % newsize) == lmod(h, newsize)); 61 | p->next = newhash[h1]; // chain it 62 | newhash[h1] = p; 63 | p = next; 64 | } 65 | } 66 | luaM_freearray(L, tb->hash, tb->size, TString*, 0); 67 | tb->size = newsize; 68 | tb->hash = newhash; 69 | } 70 | 71 | static TString* newlstr(lua_State* L, const char* str, size_t l, unsigned int h) 72 | { 73 | if (l > MAXSSIZE) 74 | luaM_toobig(L); 75 | 76 | TString* ts = luaM_newgco(L, TString, sizestring(l), L->activememcat); 77 | luaC_init(L, ts, LUA_TSTRING); 78 | ts->atom = ATOM_UNDEF; 79 | ts->hash = h; 80 | ts->len = unsigned(l); 81 | 82 | memcpy(ts->data, str, l); 83 | ts->data[l] = '\0'; // ending 0 84 | 85 | stringtable* tb = &L->global->strt; 86 | h = lmod(h, tb->size); 87 | ts->next = tb->hash[h]; // chain new entry 88 | tb->hash[h] = ts; 89 | 90 | tb->nuse++; 91 | if (tb->nuse > cast_to(uint32_t, tb->size) && tb->size <= INT_MAX / 2) 92 | luaS_resize(L, tb->size * 2); // too crowded 93 | 94 | return ts; 95 | } 96 | 97 | TString* luaS_bufstart(lua_State* L, size_t size) 98 | { 99 | if (size > MAXSSIZE) 100 | luaM_toobig(L); 101 | 102 | TString* ts = luaM_newgco(L, TString, sizestring(size), L->activememcat); 103 | luaC_init(L, ts, LUA_TSTRING); 104 | ts->atom = ATOM_UNDEF; 105 | ts->hash = 0; // computed in luaS_buffinish 106 | ts->len = unsigned(size); 107 | 108 | ts->next = NULL; 109 | 110 | return ts; 111 | } 112 | 113 | TString* luaS_buffinish(lua_State* L, TString* ts) 114 | { 115 | unsigned int h = luaS_hash(ts->data, ts->len); 116 | stringtable* tb = &L->global->strt; 117 | int bucket = lmod(h, tb->size); 118 | 119 | // search if we already have this string in the hash table 120 | for (TString* el = tb->hash[bucket]; el != NULL; el = el->next) 121 | { 122 | if (el->len == ts->len && memcmp(el->data, ts->data, ts->len) == 0) 123 | { 124 | // string may be dead 125 | if (isdead(L->global, obj2gco(el))) 126 | changewhite(obj2gco(el)); 127 | 128 | return el; 129 | } 130 | } 131 | 132 | LUAU_ASSERT(ts->next == NULL); 133 | 134 | ts->hash = h; 135 | ts->data[ts->len] = '\0'; // ending 0 136 | ts->atom = ATOM_UNDEF; 137 | ts->next = tb->hash[bucket]; // chain new entry 138 | tb->hash[bucket] = ts; 139 | 140 | tb->nuse++; 141 | if (tb->nuse > cast_to(uint32_t, tb->size) && tb->size <= INT_MAX / 2) 142 | luaS_resize(L, tb->size * 2); // too crowded 143 | 144 | return ts; 145 | } 146 | 147 | TString* luaS_newlstr(lua_State* L, const char* str, size_t l) 148 | { 149 | unsigned int h = luaS_hash(str, l); 150 | for (TString* el = L->global->strt.hash[lmod(h, L->global->strt.size)]; el != NULL; el = el->next) 151 | { 152 | if (el->len == l && (memcmp(str, getstr(el), l) == 0)) 153 | { 154 | // string may be dead 155 | if (isdead(L->global, obj2gco(el))) 156 | changewhite(obj2gco(el)); 157 | return el; 158 | } 159 | } 160 | return newlstr(L, str, l, h); // not found 161 | } 162 | 163 | static bool unlinkstr(lua_State* L, TString* ts) 164 | { 165 | global_State* g = L->global; 166 | 167 | TString** p = &g->strt.hash[lmod(ts->hash, g->strt.size)]; 168 | 169 | while (TString* curr = *p) 170 | { 171 | if (curr == ts) 172 | { 173 | *p = curr->next; 174 | return true; 175 | } 176 | else 177 | { 178 | p = &curr->next; 179 | } 180 | } 181 | 182 | return false; 183 | } 184 | 185 | void luaS_free(lua_State* L, TString* ts, lua_Page* page) 186 | { 187 | if (unlinkstr(L, ts)) 188 | L->global->strt.nuse--; 189 | else 190 | LUAU_ASSERT(ts->next == NULL); // orphaned string buffer 191 | 192 | luaM_freegco(L, ts, sizestring(ts->len), ts->memcat, page); 193 | } 194 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lstring.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 | 8 | // string size limit 9 | #define MAXSSIZE (1 << 30) 10 | 11 | // string atoms are not defined by default; the storage is 16-bit integer 12 | #define ATOM_UNDEF -32768 13 | 14 | #define sizestring(len) (offsetof(TString, data) + len + 1) 15 | 16 | #define luaS_new(L, s) (luaS_newlstr(L, s, strlen(s))) 17 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, (sizeof(s) / sizeof(char)) - 1)) 18 | 19 | #define luaS_fix(s) l_setbit((s)->marked, FIXEDBIT) 20 | 21 | LUAI_FUNC unsigned int luaS_hash(const char* str, size_t len); 22 | 23 | LUAI_FUNC void luaS_resize(lua_State* L, int newsize); 24 | 25 | LUAI_FUNC TString* luaS_newlstr(lua_State* L, const char* str, size_t l); 26 | LUAI_FUNC void luaS_free(lua_State* L, TString* ts, struct lua_Page* page); 27 | 28 | LUAI_FUNC TString* luaS_bufstart(lua_State* L, size_t size); 29 | LUAI_FUNC TString* luaS_buffinish(lua_State* L, TString* ts); 30 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/ltable.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 | #include 8 | #include 9 | 10 | 11 | #define gnode(t, i) (&(t)->node[i]) 12 | #define gkey(n) (&(n)->key) 13 | #define gval(n) (&(n)->val) 14 | #define gnext(n) ((n)->key.next) 15 | 16 | #define gval2slot(t, v) int(cast_to(LuaNode*, static_cast(v)) - t->node) 17 | 18 | // reset cache of absent metamethods, cache is updated in luaT_gettm 19 | #define invalidateTMcache(t) t->tmcache = 0 20 | 21 | LUAI_FUNC const TValue* luaH_getnum(LuaTable* t, int key); 22 | LUAI_FUNC TValue* luaH_setnum(lua_State* L, LuaTable* t, int key); 23 | LUAI_FUNC const TValue* luaH_getstr(LuaTable* t, TString* key); 24 | LUAI_FUNC TValue* luaH_setstr(lua_State* L, LuaTable* t, TString* key); 25 | LUAI_FUNC const TValue* luaH_get(LuaTable* t, const TValue* key); 26 | LUAI_FUNC TValue* luaH_set(lua_State* L, LuaTable* t, const TValue* key); 27 | LUAI_FUNC TValue* luaH_newkey(lua_State* L, LuaTable* t, const TValue* key); 28 | LUAI_FUNC LuaTable* luaH_new(lua_State* L, int narray, int lnhash); 29 | LUAI_FUNC void luaH_resizearray(lua_State* L, LuaTable* t, int nasize); 30 | LUAI_FUNC void luaH_resizehash(lua_State* L, LuaTable* t, int nhsize); 31 | LUAI_FUNC void luaH_free(lua_State* L, LuaTable* t, struct lua_Page* page); 32 | LUAI_FUNC int luaH_next(lua_State* L, LuaTable* t, StkId key); 33 | LUAI_FUNC int luaH_getn(LuaTable* t); 34 | LUAI_FUNC LuaTable* luaH_clone(lua_State* L, LuaTable* tt); 35 | LUAI_FUNC void luaH_clear(LuaTable* tt); 36 | 37 | #define luaH_setslot(L, t, slot, key) (invalidateTMcache(t), (slot == luaO_nilobject ? luaH_newkey(L, t, key) : cast_to(TValue*, slot))) 38 | 39 | #define dummynode (LuaNode*)Offsets::LuaH_DummyNode -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/ltm.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 "ltm.h" 4 | 5 | #include "lstate.h" 6 | #include "lstring.h" 7 | #include "ludata.h" 8 | #include "ltable.h" 9 | #include "lgc.h" 10 | 11 | #include 12 | 13 | // clang-format off 14 | const char* const luaT_typenames[] = { 15 | // ORDER TYPE 16 | "nil", 17 | "boolean", 18 | 19 | "userdata", 20 | "number", 21 | "vector", 22 | 23 | "string", 24 | 25 | "table", 26 | "function", 27 | "userdata", 28 | "thread", 29 | "buffer", 30 | }; 31 | 32 | const char* const luaT_eventname[] = { 33 | // ORDER TM 34 | 35 | LUAU_SHUFFLE7(LUAU_COMMA_SEP, 36 | "__index", 37 | "__newindex", 38 | "__mode", 39 | "__namecall", 40 | "__call", 41 | "__iter", 42 | "__len"), 43 | 44 | "__eq", 45 | 46 | LUAU_SHUFFLE8(LUAU_COMMA_SEP, 47 | "__add", 48 | "__sub", 49 | "__mul", 50 | "__div", 51 | "__idiv", 52 | "__mod", 53 | "__pow", 54 | "__unm"), 55 | 56 | LUAU_SHUFFLE5(LUAU_COMMA_SEP, 57 | "__lt", 58 | "__le", 59 | "__concat", 60 | "__type", 61 | "__metatable"), 62 | }; 63 | // clang-format on 64 | 65 | static_assert(sizeof(luaT_typenames) / sizeof(luaT_typenames[0]) == LUA_T_COUNT, "luaT_typenames size mismatch"); 66 | static_assert(sizeof(luaT_eventname) / sizeof(luaT_eventname[0]) == TM_N, "luaT_eventname size mismatch"); 67 | static_assert(TM_EQ < 8, "fasttm optimization stores a bitfield with metamethods in a byte"); 68 | 69 | void luaT_init(lua_State* L) 70 | { 71 | int i; 72 | for (i = 0; i < LUA_T_COUNT; i++) 73 | { 74 | L->global->ttname[i] = luaS_new(L, luaT_typenames[i]); 75 | luaS_fix(L->global->ttname[i]); // never collect these names 76 | } 77 | for (i = 0; i < TM_N; i++) 78 | { 79 | L->global->tmname[i] = luaS_new(L, luaT_eventname[i]); 80 | luaS_fix(L->global->tmname[i]); // never collect these names 81 | } 82 | } 83 | 84 | /* 85 | ** function to be used with macro "fasttm": optimized for absence of 86 | ** tag methods. 87 | */ 88 | const TValue* luaT_gettm(LuaTable* events, TMS event, TString* ename) 89 | { 90 | const TValue* tm = luaH_getstr(events, ename); 91 | LUAU_ASSERT(event <= TM_EQ); 92 | if (ttisnil(tm)) 93 | { // no tag method? 94 | events->tmcache |= cast_byte(1u << event); // cache this fact 95 | return NULL; 96 | } 97 | else 98 | return tm; 99 | } 100 | 101 | const TValue* luaT_gettmbyobj(lua_State* L, const TValue* o, TMS event) 102 | { 103 | /* 104 | NB: Tag-methods were replaced by meta-methods in Lua 5.0, but the 105 | old names are still around (this function, for example). 106 | */ 107 | LuaTable* mt; 108 | switch (ttype(o)) 109 | { 110 | case LUA_TTABLE: 111 | mt = hvalue(o)->metatable; 112 | break; 113 | case LUA_TUSERDATA: 114 | mt = uvalue(o)->metatable; 115 | break; 116 | default: 117 | mt = L->global->mt[ttype(o)]; 118 | } 119 | return (mt ? luaH_getstr(mt, L->global->tmname[event]) : luaO_nilobject); 120 | } 121 | 122 | const TString* luaT_objtypenamestr(lua_State* L, const TValue* o) 123 | { 124 | // Userdata created by the environment can have a custom type name set in the individual metatable 125 | // If there is no custom name, 'userdata' is returned 126 | if (ttisuserdata(o) && uvalue(o)->tag != UTAG_PROXY && uvalue(o)->metatable) 127 | { 128 | const TValue* type = luaH_getstr(uvalue(o)->metatable, L->global->tmname[TM_TYPE]); 129 | 130 | if (ttisstring(type)) 131 | return tsvalue(type); 132 | 133 | return L->global->ttname[ttype(o)]; 134 | } 135 | 136 | // Tagged lightuserdata can be named using lua_setlightuserdataname 137 | if (ttislightuserdata(o)) 138 | { 139 | int tag = lightuserdatatag(o); 140 | 141 | if (unsigned(tag) < LUA_LUTAG_LIMIT) 142 | { 143 | if (const TString* name = L->global->lightuserdataname[tag]) 144 | return name; 145 | } 146 | } 147 | 148 | // For all types except userdata and table, a global metatable can be set with a global name override 149 | if (LuaTable* mt = L->global->mt[ttype(o)]) 150 | { 151 | const TValue* type = luaH_getstr(mt, L->global->tmname[TM_TYPE]); 152 | 153 | if (ttisstring(type)) 154 | return tsvalue(type); 155 | } 156 | 157 | return L->global->ttname[ttype(o)]; 158 | } 159 | 160 | const char* luaT_objtypename(lua_State* L, const TValue* o) 161 | { 162 | return getstr(luaT_objtypenamestr(L, o)); 163 | } 164 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/ltm.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 | /* 8 | * WARNING: if you change the order of this enumeration, 9 | * grep "ORDER TM" 10 | */ 11 | // clang-format off 12 | typedef enum 13 | { 14 | 15 | LUAU_SHUFFLE7(LUAU_COMMA_SEP, 16 | TM_INDEX, 17 | TM_NEWINDEX, 18 | TM_MODE, 19 | TM_NAMECALL, 20 | TM_CALL, 21 | TM_ITER, 22 | TM_LEN), 23 | 24 | 25 | TM_EQ, // last tag method with `fast' access 26 | 27 | LUAU_SHUFFLE8(LUAU_COMMA_SEP, 28 | TM_ADD, 29 | TM_SUB, 30 | TM_MUL, 31 | TM_DIV, 32 | TM_IDIV, 33 | TM_MOD, 34 | TM_POW, 35 | TM_UNM), 36 | 37 | LUAU_SHUFFLE5(LUAU_COMMA_SEP, 38 | TM_LT, 39 | TM_LE, 40 | TM_CONCAT, 41 | TM_TYPE, 42 | TM_METATABLE), 43 | 44 | TM_N // number of elements in the enum 45 | } TMS; 46 | // clang-format on 47 | 48 | #define gfasttm(g, et, e) ((et) == NULL ? NULL : ((et)->tmcache & (1u << (e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 49 | 50 | #define fasttm(l, et, e) gfasttm(l->global, et, e) 51 | #define fastnotm(et, e) ((et) == NULL || ((et)->tmcache & (1u << (e)))) 52 | 53 | LUAI_DATA const char* const luaT_typenames[]; 54 | LUAI_DATA const char* const luaT_eventname[]; 55 | 56 | LUAI_FUNC const TValue* luaT_gettm(LuaTable* events, TMS event, TString* ename); 57 | LUAI_FUNC const TValue* luaT_gettmbyobj(lua_State* L, const TValue* o, TMS event); 58 | 59 | LUAI_FUNC const TString* luaT_objtypenamestr(lua_State* L, const TValue* o); 60 | LUAI_FUNC const char* luaT_objtypename(lua_State* L, const TValue* o); 61 | 62 | LUAI_FUNC void luaT_init(lua_State* L); 63 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/ludata.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 "ludata.h" 4 | 5 | #include "lgc.h" 6 | #include "lmem.h" 7 | 8 | #include 9 | 10 | Udata* luaU_newudata(lua_State* L, size_t s, int tag) 11 | { 12 | if (s > INT_MAX - sizeof(Udata)) 13 | luaM_toobig(L); 14 | Udata* u = luaM_newgco(L, Udata, sizeudata(s), L->activememcat); 15 | luaC_init(L, u, LUA_TUSERDATA); 16 | u->len = int(s); 17 | u->metatable = NULL; 18 | LUAU_ASSERT(tag >= 0 && tag <= 255); 19 | u->tag = uint8_t(tag); 20 | return u; 21 | } 22 | 23 | void luaU_freeudata(lua_State* L, Udata* u, lua_Page* page) 24 | { 25 | if (u->tag < LUA_UTAG_LIMIT) 26 | { 27 | lua_Destructor dtor = L->global->udatagc[u->tag]; 28 | // TODO: access to L here is highly unsafe since this is called during internal GC traversal 29 | // certain operations such as lua_getthreaddata are okay, but by and large this risks crashes on improper use 30 | if (dtor) 31 | dtor(L, u->data); 32 | } 33 | else if (u->tag == UTAG_IDTOR) 34 | { 35 | void (*dtor)(void*) = nullptr; 36 | memcpy(&dtor, &u->data + u->len - sizeof(dtor), sizeof(dtor)); 37 | if (dtor) 38 | dtor(u->data); 39 | } 40 | 41 | 42 | luaM_freegco(L, u, sizeudata(u->len), u->memcat, page); 43 | } 44 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/ludata.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 | // special tag value is used for user data with inline dtors 8 | #define UTAG_IDTOR LUA_UTAG_LIMIT 9 | 10 | // special tag value is used for newproxy-created user data (all other user data objects are host-exposed) 11 | #define UTAG_PROXY (LUA_UTAG_LIMIT + 1) 12 | 13 | #define sizeudata(len) (offsetof(Udata, data) + len) 14 | 15 | LUAI_FUNC Udata* luaU_newudata(lua_State* L, size_t s, int tag); 16 | LUAI_FUNC void luaU_freeudata(lua_State* L, Udata* u, struct lua_Page* page); 17 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/Luau/VM/src/lvm.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 "ltm.h" 7 | 8 | #define tostring(L, o) ((ttype(o) == LUA_TSTRING) || (luaV_tostring(L, o))) 9 | 10 | #define tonumber(o, n) (ttype(o) == LUA_TNUMBER || (((o) = luaV_tonumber(o, n)) != NULL)) 11 | 12 | #define equalobj(L, o1, o2) (ttype(o1) == ttype(o2) && luaV_equalval(L, o1, o2)) 13 | 14 | LUAI_FUNC int luaV_strcmp(const TString* ls, const TString* rs); 15 | LUAI_FUNC int luaV_lessthan(lua_State* L, const TValue* l, const TValue* r); 16 | LUAI_FUNC int luaV_lessequal(lua_State* L, const TValue* l, const TValue* r); 17 | LUAI_FUNC int luaV_equalval(lua_State* L, const TValue* t1, const TValue* t2); 18 | 19 | template 20 | void luaV_doarithimpl(lua_State* L, StkId ra, const TValue* rb, const TValue* rc); 21 | 22 | LUAI_FUNC void luaV_dolen(lua_State* L, StkId ra, const TValue* rb); 23 | LUAI_FUNC const TValue* luaV_tonumber(const TValue* obj, TValue* n); 24 | LUAI_FUNC const float* luaV_tovector(const TValue* obj); 25 | LUAI_FUNC int luaV_tostring(lua_State* L, StkId obj); 26 | LUAI_FUNC void luaV_gettable(lua_State* L, const TValue* t, TValue* key, StkId val); 27 | LUAI_FUNC void luaV_settable(lua_State* L, const TValue* t, TValue* key, StkId val); 28 | LUAI_FUNC void luaV_concat(lua_State* L, int total, int last); 29 | LUAI_FUNC void luaV_getimport(lua_State* L, LuaTable* env, TValue* k, StkId res, uint32_t id, bool propagatenil); 30 | LUAI_FUNC void luaV_prepareFORN(lua_State* L, StkId plimit, StkId pstep, StkId pinit); 31 | LUAI_FUNC void luaV_callTM(lua_State* L, int nparams, int res); 32 | LUAI_FUNC void luaV_tryfuncTM(lua_State* L, StkId func); 33 | 34 | LUAI_FUNC void luau_execute(lua_State* L); 35 | LUAI_FUNC int luau_precall(lua_State* L, struct lua_TValue* func, int nresults); 36 | LUAI_FUNC void luau_poscall(lua_State* L, StkId first); 37 | LUAI_FUNC void luau_callhook(lua_State* L, lua_Hook hook, void* userdata); 38 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/lz4/include/lz4file.h: -------------------------------------------------------------------------------- 1 | /* 2 | LZ4 file library 3 | Header File 4 | Copyright (C) 2022, Xiaomi Inc. 5 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are 9 | met: 10 | 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following disclaimer 15 | in the documentation and/or other materials provided with the 16 | distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | You can contact the author at : 31 | - LZ4 source repository : https://github.com/lz4/lz4 32 | - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c 33 | */ 34 | #if defined (__cplusplus) 35 | extern "C" { 36 | #endif 37 | 38 | #ifndef LZ4FILE_H 39 | #define LZ4FILE_H 40 | 41 | #include 42 | #include "lz4frame_static.h" 43 | 44 | typedef struct LZ4_readFile_s LZ4_readFile_t; 45 | typedef struct LZ4_writeFile_s LZ4_writeFile_t; 46 | 47 | /*! LZ4F_readOpen() : 48 | * Set read lz4file handle. 49 | * `lz4f` will set a lz4file handle. 50 | * `fp` must be the return value of the lz4 file opened by fopen. 51 | */ 52 | LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readOpen(LZ4_readFile_t** lz4fRead, FILE* fp); 53 | 54 | /*! LZ4F_read() : 55 | * Read lz4file content to buffer. 56 | * `lz4f` must use LZ4_readOpen to set first. 57 | * `buf` read data buffer. 58 | * `size` read data buffer size. 59 | */ 60 | LZ4FLIB_STATIC_API size_t LZ4F_read(LZ4_readFile_t* lz4fRead, void* buf, size_t size); 61 | 62 | /*! LZ4F_readClose() : 63 | * Close lz4file handle. 64 | * `lz4f` must use LZ4_readOpen to set first. 65 | */ 66 | LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_readClose(LZ4_readFile_t* lz4fRead); 67 | 68 | /*! LZ4F_writeOpen() : 69 | * Set write lz4file handle. 70 | * `lz4f` will set a lz4file handle. 71 | * `fp` must be the return value of the lz4 file opened by fopen. 72 | */ 73 | LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeOpen(LZ4_writeFile_t** lz4fWrite, FILE* fp, const LZ4F_preferences_t* prefsPtr); 74 | 75 | /*! LZ4F_write() : 76 | * Write buffer to lz4file. 77 | * `lz4f` must use LZ4F_writeOpen to set first. 78 | * `buf` write data buffer. 79 | * `size` write data buffer size. 80 | */ 81 | LZ4FLIB_STATIC_API size_t LZ4F_write(LZ4_writeFile_t* lz4fWrite, void* buf, size_t size); 82 | 83 | /*! LZ4F_writeClose() : 84 | * Close lz4file handle. 85 | * `lz4f` must use LZ4F_writeOpen to set first. 86 | */ 87 | LZ4FLIB_STATIC_API LZ4F_errorCode_t LZ4F_writeClose(LZ4_writeFile_t* lz4fWrite); 88 | 89 | #endif /* LZ4FILE_H */ 90 | 91 | #if defined (__cplusplus) 92 | } 93 | #endif 94 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/lz4/include/lz4frame_static.h: -------------------------------------------------------------------------------- 1 | /* 2 | LZ4 auto-framing library 3 | Header File for static linking only 4 | Copyright (C) 2011-2020, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - LZ4 source repository : https://github.com/lz4/lz4 33 | - LZ4 public forum : https://groups.google.com/forum/#!forum/lz4c 34 | */ 35 | 36 | #ifndef LZ4FRAME_STATIC_H_0398209384 37 | #define LZ4FRAME_STATIC_H_0398209384 38 | 39 | /* The declarations that formerly were made here have been merged into 40 | * lz4frame.h, protected by the LZ4F_STATIC_LINKING_ONLY macro. Going forward, 41 | * it is recommended to simply include that header directly. 42 | */ 43 | 44 | #define LZ4F_STATIC_LINKING_ONLY 45 | #include "lz4frame.h" 46 | 47 | #endif /* LZ4FRAME_STATIC_H_0398209384 */ 48 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/lz4/lib/lz4.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/ModuleBase/Dependencies/lz4/lib/lz4.lib -------------------------------------------------------------------------------- /ModuleBase/Dependencies/zstd/include/desktop.ini: -------------------------------------------------------------------------------- 1 | [LocalizedFileNames] 2 | xxhash.c=@xxhash.c,0 3 | threading.h=@threading.h,0 4 | threading.c=@threading.c,0 5 | portability_macros.h=@portability_macros.h,0 6 | pool.h=@pool.h,0 7 | pool.c=@pool.c,0 8 | mem.h=@mem.h,0 9 | huf.h=@huf.h,0 10 | fse_decompress.c=@fse_decompress.c,0 11 | fse.h=@fse.h,0 12 | error_private.h=@error_private.h,0 13 | error_private.c=@error_private.c,0 14 | entropy_common.c=@entropy_common.c,0 15 | debug.h=@debug.h,0 16 | debug.c=@debug.c,0 17 | cpu.h=@cpu.h,0 18 | compiler.h=@compiler.h,0 19 | bitstream.h=@bitstream.h,0 20 | bits.h=@bits.h,0 21 | allocations.h=@allocations.h,0 22 | zstd_errors.h=@zstd_errors.h,0 23 | zdict.h=@zdict.h,0 24 | libzstd.mk=@libzstd.mk,0 25 | streaming_memory_usage.c=@streaming_memory_usage.c,0 26 | streaming_decompression.c=@streaming_decompression.c,0 27 | streaming_compression_thread_pool.c=@streaming_compression_thread_pool.c,0 28 | streaming_compression.c=@streaming_compression.c,0 29 | simple_decompression.c=@simple_decompression.c,0 30 | simple_compression.c=@simple_compression.c,0 31 | multiple_streaming_compression.c=@multiple_streaming_compression.c,0 32 | multiple_simple_compression.c=@multiple_simple_compression.c,0 33 | dictionary_decompression.c=@dictionary_decompression.c,0 34 | dictionary_compression.c=@dictionary_compression.c,0 35 | common.h=@common.h,0 36 | zstd_decompress.h=@zstd_decompress.h,0 37 | zstd_decompress.c=@zstd_decompress.c,0 38 | harness.c=@harness.c,0 39 | zstd_manual.html=@zstd_manual.html,0 40 | seqBench.c=@seqBench.c,0 41 | seekable_tests.c=@seekable_tests.c,0 42 | seekable_decompression_mem.c=@seekable_decompression_mem.c,0 43 | seekable_decompression.c=@seekable_decompression.c,0 44 | seekable_compression.c=@seekable_compression.c,0 45 | parallel_processing.c=@parallel_processing.c,0 46 | parallel_compression.c=@parallel_compression.c,0 47 | zstdseek_decompress.c=@zstdseek_decompress.c,0 48 | zstdseek_compress.c=@zstdseek_compress.c,0 49 | zstd_seekable.h=@zstd_seekable.h,0 50 | recover_directory.c=@recover_directory.c,0 51 | WorkQueueTest.cpp=@WorkQueueTest.cpp,0 52 | ThreadPoolTest.cpp=@ThreadPoolTest.cpp,0 53 | ScopeGuardTest.cpp=@ScopeGuardTest.cpp,0 54 | ResourcePoolTest.cpp=@ResourcePoolTest.cpp,0 55 | RangeTest.cpp=@RangeTest.cpp,0 56 | BufferTest.cpp=@BufferTest.cpp,0 57 | WorkQueue.h=@WorkQueue.h,0 58 | ThreadPool.h=@ThreadPool.h,0 59 | ScopeGuard.h=@ScopeGuard.h,0 60 | ResourcePool.h=@ResourcePool.h,0 61 | Range.h=@Range.h,0 62 | Portability.h=@Portability.h,0 63 | Likely.h=@Likely.h,0 64 | FileSystem.h=@FileSystem.h,0 65 | Buffer.h=@Buffer.h,0 66 | RoundTripTest.cpp=@RoundTripTest.cpp,0 67 | RoundTrip.h=@RoundTrip.h,0 68 | PzstdTest.cpp=@PzstdTest.cpp,0 69 | OptionsTest.cpp=@OptionsTest.cpp,0 70 | main.cpp=@main.cpp,0 71 | SkippableFrame.h=@SkippableFrame.h,0 72 | zstd.h=@zstd.h,0 73 | xxhash.h=@xxhash.h,0 74 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/zstd/include/zstd/desktop.ini: -------------------------------------------------------------------------------- 1 | [LocalizedFileNames] 2 | zstd.h=@zstd.h,0 3 | xxhash.h=@xxhash.h,0 4 | -------------------------------------------------------------------------------- /ModuleBase/Dependencies/zstd/lib/zstd_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/ModuleBase/Dependencies/zstd/lib/zstd_static.lib -------------------------------------------------------------------------------- /ModuleBase/Environment/Environment.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Libs/FileSystem/FileSystem.hpp" 4 | #include 5 | 6 | 7 | #define REGISTERFUNCTION(name, func) {name, func} 8 | #define END_REGISTRATION {NULL, NULL} 9 | 10 | 11 | // THIS ENVIRONMENT IS FROM BYTECODE'S MODULE! 12 | 13 | namespace Environment { 14 | 15 | static const struct luaL_Reg Lib[] = { 16 | REGISTERFUNCTION("readfile", Filesystem::readfile), 17 | REGISTERFUNCTION("listfiles", Filesystem::listfiles), 18 | REGISTERFUNCTION("writefile", Filesystem::writefile), 19 | REGISTERFUNCTION("makefolder", Filesystem::makefolder), 20 | REGISTERFUNCTION("appendfile", Filesystem::appendfile), 21 | REGISTERFUNCTION("isfile", Filesystem::isfile), 22 | REGISTERFUNCTION("isfolder", Filesystem::isfolder), 23 | REGISTERFUNCTION("delfolder", Filesystem::delfolder), 24 | REGISTERFUNCTION("delfile", Filesystem::delfile), 25 | REGISTERFUNCTION("loadfile", Filesystem::loadfile), 26 | REGISTERFUNCTION("dofile", Filesystem::dofile), 27 | REGISTERFUNCTION("getcustomasset", Filesystem::getcustomasset), 28 | 29 | 30 | END_REGISTRATION, 31 | }; 32 | 33 | 34 | 35 | struct Init { 36 | 37 | void Env(lua_State* l) { 38 | lua_newtable(l); 39 | lua_setglobal(l, "_G"); 40 | 41 | lua_newtable(l); 42 | lua_setglobal(l, "shared"); 43 | 44 | 45 | lua_pushvalue(l, LUA_GLOBALSINDEX); 46 | 47 | const luaL_Reg* i = Lib; 48 | for (; i->name; i++) { 49 | lua_pushcfunction(l, i->func, i->name); 50 | lua_setfield(l, -2, i->name); 51 | } 52 | 53 | lua_pop(l, 1); 54 | } 55 | 56 | }; 57 | inline Init* Initializes = new Init(); 58 | 59 | } -------------------------------------------------------------------------------- /ModuleBase/Execution/Execution.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | 5 | #define xorstr_(x) x 6 | namespace Execution { 7 | static struct CBase { 8 | class CBytecodeEncoder : public Luau::BytecodeEncoder { 9 | inline void encode(uint32_t* ptr, size_t len) override { 10 | size_t idx = 0; 11 | while (idx < len) { 12 | auto& inst = *(uint8_t*)(ptr + idx); 13 | auto step = Luau::getOpLength(LuauOpcode(inst)); 14 | inst *= 227; 15 | idx += step; 16 | } 17 | } 18 | }; 19 | 20 | CBytecodeEncoder encoder{}; 21 | 22 | std::string CompileSrc(const std::string code) { 23 | auto compiled = Luau::compile(code, { 1, 1, 2 }, { true, true }, &encoder); 24 | 25 | auto rawSize = compiled.size(); 26 | auto compBound = ZSTD_compressBound(rawSize); 27 | std::vector output(compBound + 8); 28 | 29 | memcpy(output.data(), xorstr_("RSB1"), 4); 30 | memcpy(output.data() + 4, &rawSize, sizeof(rawSize)); 31 | 32 | auto compSize = ZSTD_compress(output.data() + 8, compBound, compiled.data(), rawSize, ZSTD_maxCLevel()); 33 | auto total = compSize + 8; 34 | 35 | auto hash = XXH32(output.data(), total, 42); 36 | auto* keys = reinterpret_cast(&hash); 37 | 38 | for (size_t i = 0; i < total; ++i) { 39 | output[i] ^= keys[i % 4] + i * 41; 40 | } 41 | 42 | return std::string(output.data(), total); 43 | } 44 | 45 | void Execute(lua_State* L, std::string src) { 46 | if (!L || src.empty()) return; 47 | auto data = CompileSrc(src); 48 | if (data.empty() || data[0] == '\0') { 49 | return; 50 | } 51 | 52 | lua_settop(L, 0); 53 | lua_gc(L, LUA_GCSTOP, 0); 54 | 55 | auto thread = lua_newthread(L); 56 | luaL_sandboxthread(thread); 57 | if (!thread) { 58 | lua_gc(L, LUA_GCRESTART, 0); 59 | return; 60 | } 61 | 62 | lua_settop(thread, 0); 63 | lua_getglobal(thread, xorstr_("task")); 64 | 65 | if (lua_isnil(thread, -1)) { 66 | lua_gc(L, LUA_GCRESTART, 0); 67 | return; 68 | } 69 | 70 | lua_getfield(thread, -1, xorstr_("defer")); 71 | 72 | auto user = reinterpret_cast(thread->userdata); 73 | if (!user) { 74 | lua_gc(L, LUA_GCRESTART, 0); 75 | return; 76 | } 77 | 78 | auto ident = user + Offsets::Identity; 79 | auto caps = user + Offsets::Capabilities; 80 | 81 | if (ident && caps) { 82 | *reinterpret_cast(ident) = 8; 83 | *reinterpret_cast(caps) = ~0ULL; 84 | } 85 | else { 86 | lua_gc(L, LUA_GCRESTART, 0); 87 | return; 88 | } 89 | 90 | auto res = RBX::LuaVM__Load(thread, &data, "[BASE]", 0); 91 | if (res != LUA_OK) { 92 | std::string err = luaL_checklstring(thread, -1, nullptr); 93 | lua_pop(thread, 1); 94 | lua_gc(L, LUA_GCRESTART, 0); 95 | return; 96 | } 97 | 98 | auto* func = clvalue(luaA_toobject(thread, -1)); 99 | if (!func) { 100 | lua_gc(L, LUA_GCRESTART, 0); 101 | return; 102 | } 103 | 104 | Base::Roblox->SetProtoCapabilities(func->l.p); 105 | 106 | if (lua_pcall(thread, 1, 0, 0) != LUA_OK) { 107 | std::string err = luaL_checklstring(thread, -1, nullptr); 108 | lua_pop(thread, 1); 109 | lua_gc(L, LUA_GCRESTART, 0); 110 | return; 111 | } 112 | 113 | lua_pop(thread, 1); 114 | lua_gc(L, LUA_GCRESTART, 0); 115 | } 116 | 117 | 118 | 119 | 120 | }; 121 | inline CBase* cBase = new CBase(); 122 | } -------------------------------------------------------------------------------- /ModuleBase/NamedPipe.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | class LuaScriptServer { 9 | private: 10 | static constexpr const char* PIPE_NAME = "\\\\.\\pipe\\CLDYexecution"; 11 | static constexpr DWORD BUFFER_SIZE = 65536; // 64KB buffer 12 | HANDLE hPipe; 13 | bool running; 14 | std::thread exploitThread; 15 | 16 | public: 17 | LuaScriptServer() : hPipe(INVALID_HANDLE_VALUE), running(false) {} 18 | 19 | ~LuaScriptServer() { 20 | Stop(); 21 | } 22 | 23 | bool Start() { 24 | running = true; 25 | 26 | while (running) { 27 | hPipe = CreateNamedPipeA( 28 | PIPE_NAME, 29 | PIPE_ACCESS_DUPLEX, 30 | PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT, 31 | PIPE_UNLIMITED_INSTANCES, 32 | BUFFER_SIZE, 33 | BUFFER_SIZE, 34 | 0, 35 | nullptr 36 | ); 37 | 38 | if (hPipe == INVALID_HANDLE_VALUE) { 39 | return false; 40 | } 41 | BOOL connected = ConnectNamedPipe(hPipe, nullptr) ? 42 | TRUE : (GetLastError() == ERROR_PIPE_CONNECTED); 43 | 44 | if (connected) { 45 | HandleClient(); 46 | } 47 | else { 48 | } 49 | 50 | CloseHandle(hPipe); 51 | hPipe = INVALID_HANDLE_VALUE; 52 | } 53 | 54 | return true; 55 | } 56 | 57 | void Stop() { 58 | running = false; 59 | if (hPipe != INVALID_HANDLE_VALUE) { 60 | CloseHandle(hPipe); 61 | hPipe = INVALID_HANDLE_VALUE; 62 | } 63 | if (exploitThread.joinable()) { 64 | exploitThread.join(); 65 | } 66 | } 67 | 68 | private: 69 | void HandleClient() { 70 | char buffer[BUFFER_SIZE]; 71 | DWORD bytesRead; 72 | DWORD bytesWritten; 73 | 74 | while (running) { 75 | BOOL success = ReadFile( 76 | hPipe, 77 | buffer, 78 | BUFFER_SIZE - 1, 79 | &bytesRead, 80 | nullptr 81 | ); 82 | 83 | if (!success || bytesRead == 0) { 84 | if (GetLastError() == ERROR_BROKEN_PIPE) { 85 | } 86 | else { 87 | } 88 | break; 89 | } 90 | 91 | buffer[bytesRead] = '\0'; 92 | std::string luaScript(buffer, bytesRead); 93 | 94 | try { 95 | Execution::cBase->Execute(Globals::exploitThread, luaScript); 96 | const char* response = "Script executed successfully"; 97 | WriteFile( 98 | hPipe, 99 | response, 100 | strlen(response), 101 | &bytesWritten, 102 | nullptr 103 | ); 104 | } 105 | catch (const std::exception& e) { 106 | std::string errorMsg = "Execution error: " + std::string(e.what()); 107 | WriteFile( 108 | hPipe, 109 | errorMsg.c_str(), 110 | errorMsg.length(), 111 | &bytesWritten, 112 | nullptr 113 | ); 114 | } 115 | 116 | FlushFileBuffers(hPipe); 117 | } 118 | } 119 | }; 120 | 121 | inline int startpipe() { 122 | 123 | LuaScriptServer server; 124 | 125 | std::thread serverThread([&server]() { 126 | server.Start(); 127 | }); 128 | 129 | 130 | if (serverThread.joinable()) { 131 | serverThread.join(); 132 | } 133 | return 0; 134 | } -------------------------------------------------------------------------------- /ModuleBase/Tasks/TaskScheduler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | inline uintptr_t bitmap = *reinterpret_cast(Offsets::BitMap); 18 | namespace Base { 19 | static struct SRoblox { 20 | 21 | uintptr_t capabilities = ~0ULL; 22 | void SetProtoCapabilities(Proto* proto) { 23 | proto->userdata = &capabilities; 24 | for (int i = 0; i < proto->sizep; i++) 25 | { 26 | SetProtoCapabilities(proto->p[i]); 27 | } 28 | } 29 | 30 | void SetThreadCap(lua_State* l, int lvl, uintptr_t c) { 31 | auto extraSpace = (uintptr_t)(l->userdata); 32 | *reinterpret_cast(extraSpace + 0x48) = c; 33 | *reinterpret_cast(extraSpace + 0x30) = lvl; 34 | } 35 | 36 | __forceinline void PatchCFG(uintptr_t address) { 37 | uintptr_t byteOffset = (address >> 0x13); 38 | uintptr_t bitOffset = (address >> 0x10) & 7; 39 | 40 | uint8_t* Cache = (uint8_t*)(bitmap + byteOffset); 41 | 42 | DWORD oldProtect; 43 | VirtualProtect(Cache, 1, PAGE_READWRITE, &oldProtect); 44 | 45 | *Cache |= (1 << bitOffset); 46 | 47 | VirtualProtect(Cache, 1, oldProtect, &oldProtect); 48 | } 49 | 50 | 51 | }; 52 | 53 | 54 | 55 | inline SRoblox* Roblox = new SRoblox(); 56 | 57 | 58 | 59 | } -------------------------------------------------------------------------------- /ModuleBase/Tasks/Utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Utils { 5 | 6 | struct STask { 7 | inline uintptr_t GetDataModel() { 8 | uintptr_t fakeDm = *(uintptr_t*)Offsets::FakeDataModel; 9 | uintptr_t Dm = *(uintptr_t*)(fakeDm + Offsets::FakeDataModelToDataModel); 10 | 11 | uintptr_t nameptr = *(uintptr_t*)(Dm + Offsets::Name); 12 | 13 | std::string dataModelName = *(std::string*)nameptr; 14 | if (dataModelName == "LuaApp") { 15 | return 0x0; 16 | } 17 | std::ostringstream ss; 18 | ss << "DataModel: " << Dm; 19 | RBX::Print(1, ss.str().c_str()); 20 | return Dm; 21 | } 22 | 23 | inline uintptr_t GetScriptContext(uintptr_t Dm) { 24 | uintptr_t childrenC = *(uintptr_t*)(Dm + Offsets::Children); 25 | uintptr_t children = *(uintptr_t*)childrenC; 26 | uintptr_t ScriptContext = *(uintptr_t*)(children + Offsets::ScriptContext); 27 | 28 | std::ostringstream ss; 29 | ss << "ScriptContext: " << ScriptContext; 30 | RBX::Print(1, ss.str().c_str()); 31 | return ScriptContext; 32 | } 33 | 34 | inline uintptr_t GetGlobalState(uintptr_t ScriptContext) { 35 | int32_t i = 0; 36 | uintptr_t a = {}; 37 | return RBX::GetGlobalState(ScriptContext, &i, &a); 38 | } 39 | 40 | inline uintptr_t DecryptLuaState(uintptr_t encryptedState) { 41 | return RBX::DecryptLuaState(encryptedState); 42 | } 43 | 44 | inline uintptr_t GetLuaState(uintptr_t DataModel) { 45 | uintptr_t luaState; 46 | 47 | uintptr_t ScriptContext = GetScriptContext(DataModel); 48 | if (!ScriptContext) 49 | return 0x0; 50 | *reinterpret_cast(ScriptContext + Offsets::Require_bypass) = 1; 51 | uintptr_t GlobalState = GetGlobalState(ScriptContext + Offsets::GlobalState); 52 | luaState = DecryptLuaState(GlobalState + Offsets::EncryptedState); 53 | 54 | return luaState; 55 | } 56 | 57 | inline bool CreateThread() { 58 | 59 | 60 | lua_gc((lua_State*)Globals::LuaState, LUA_GCSTOP, 0); 61 | Globals::exploitThread = lua_newthread((lua_State*)Globals::LuaState); 62 | lua_ref((lua_State*)Globals::LuaState, -1); 63 | luaL_sandboxthread(Globals::exploitThread); 64 | lua_pop((lua_State*)Globals::LuaState, 1); 65 | lua_gc((lua_State*)Globals::LuaState, LUA_GCRESTART, 0); 66 | Base::Roblox->SetThreadCap(Globals::exploitThread, 8, ~0ULL); 67 | 68 | return true; 69 | 70 | } 71 | 72 | bool isGameLoaded(uintptr_t dm) { 73 | uint64_t value = *reinterpret_cast(dm + Offsets::GameLoaded); 74 | if (value != 31) { 75 | return false; 76 | } 77 | int val = value; 78 | std::ostringstream ss; 79 | ss << "GameLoaded: " << val; 80 | RBX::Print(1, ss.str().c_str()); 81 | 82 | return true; 83 | } 84 | 85 | 86 | 87 | }; 88 | inline STask* Task = new STask(); 89 | } -------------------------------------------------------------------------------- /ModuleBase/Update/Offsets.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | struct lua_State; 8 | 9 | #define REBASE(x) x + (uintptr_t)GetModuleHandle(nullptr) 10 | #define REBASEHYPERION(x) x + (uintptr_t)GetModuleHandle("RobloxPlayerBeta.dll") 11 | 12 | 13 | namespace Offsets { 14 | inline const uintptr_t LuaO_NilObject = REBASE(0x468DCA8); 15 | inline const uintptr_t LuaH_DummyNode = REBASE(0x468D6C8); 16 | inline const uintptr_t Luau_Execute = REBASE(0x275D280); 17 | inline const uintptr_t LockViolationInstanceCrash = REBASE(0x5F4A5A8); 18 | inline const uintptr_t Print = REBASE(0x15469F0); 19 | inline const uintptr_t GetProperty = REBASE(0xA3DDB0); 20 | inline const uintptr_t GetGlobalState = REBASE(0xDA0660); 21 | inline const uintptr_t DecryptLuaState = REBASE(0xB25660); 22 | inline const uintptr_t PushInstance = REBASE(0xE7CBC0); 23 | inline const uintptr_t LuaVM__Load = REBASE(0xB28790); 24 | inline const uintptr_t Task__Defer = REBASE(0xFC9CA0);// 25 | inline const uintptr_t FireTouchInterest = REBASE(0x141B380); 26 | inline const uintptr_t FireProximityPrompt = REBASE(0x1D236A0); 27 | inline const uintptr_t RequestCode = REBASE(0x8EBD60); 28 | inline const uintptr_t GetCurrentThreadId = REBASE(0x37F55A0); 29 | inline const uintptr_t IdentityPtr = REBASE(0x6304418); 30 | inline const uintptr_t LuaD_throw = REBASE(0x272A4B0); 31 | inline const uintptr_t RawScheduler = REBASE(0x67AB9E8); 32 | inline const uintptr_t KTable = REBASE(0x62D04B0); 33 | 34 | 35 | inline const uintptr_t Luau_CompileSrc = REBASE(0x15C7AA0); 36 | 37 | 38 | // FIRECLICKDETECTOR 39 | inline const uintptr_t FireMouseClick = REBASE(0x1C4E4E0);/// 40 | inline const uintptr_t FireRightMouseClick = REBASE(0x1C4E680);/// 41 | inline const uintptr_t FireMouseHoverEnter = REBASE(0x1C4FA80);/// 42 | inline const uintptr_t FireMouseHoverLeave = REBASE(0x1C4FC20);/// 43 | 44 | inline const uintptr_t BitMap = REBASEHYPERION(0x2855A8); 45 | 46 | inline const uintptr_t GlobalState = 0x140;/// 47 | inline const uintptr_t EncryptedState = 0x88;/// 48 | inline const uintptr_t ScriptContextStart = 0x1F8; /// 49 | 50 | inline const uintptr_t FakeDataModel = REBASE(0x66EA5E8);/// 51 | inline const uintptr_t FakeDataModelToDataModel = 0x1B8;/// 52 | 53 | inline const uintptr_t ScriptContext = 944;/// 3b0 54 | inline const uintptr_t ClassDescriptor = 0x18;/// 55 | inline const uintptr_t PropertyDescriptor = 0x3B8; // --> GetProtperty -> OFF_ 56 | inline const uintptr_t ClassName = 0x8;/// 57 | inline const uintptr_t Name = 0x78;/// 58 | inline const uintptr_t Children = 0x80;/// 59 | inline const uintptr_t LocalScriptEmbedded = 0x1B0; 60 | inline const uintptr_t LocalScriptHash = 0x1C0; 61 | inline const uintptr_t ModuleScriptEmbedded = 0x158; 62 | inline const uintptr_t ModuleScriptHash = 0x180; 63 | 64 | inline const uintptr_t RunContext = 0x150;/// 65 | inline const uintptr_t GameLoaded = 0x650; // 66 | inline const uintptr_t weak_thread_node = 0x188;/// 67 | inline const uintptr_t weak_thread_ref = 0x8;/// 68 | inline const uintptr_t weak_thread_ref_live = 0x20;/// 69 | inline const uintptr_t weak_thread_ref_live_thread = 0x8;/// 70 | 71 | 72 | 73 | inline const uintptr_t Identity = 0x30;/// 74 | inline const uintptr_t Capabilities = 0x48;/// 75 | 76 | 77 | inline const uintptr_t FpsCap = 0x1B0;/// 78 | inline const uintptr_t JobStart = 0x1D0;/// 79 | inline const uintptr_t JobName = 0x18;/// 80 | inline const uintptr_t Require_bypass = 0x6E0; 81 | 82 | } 83 | namespace Globals { 84 | inline uintptr_t LuaState; 85 | inline uintptr_t DataModel; 86 | inline lua_State* exploitThread; 87 | } 88 | namespace RBX { 89 | using TPrint = void(__fastcall*)(int, const char*); 90 | inline auto Print = reinterpret_cast(Offsets::Print); 91 | 92 | using TLuaVM__Load = int(__fastcall*)(lua_State*, void*, const char*, int); 93 | inline auto LuaVM__Load = reinterpret_cast(Offsets::LuaVM__Load); 94 | 95 | using TLuau_CompileSrc = int(__fastcall*)(int64_t, int64_t); 96 | inline auto Luau_CompileSrc = reinterpret_cast(Offsets::Luau_CompileSrc); 97 | 98 | using TTask__Defer = int(__fastcall*)(lua_State*); 99 | inline auto Task__Defer = reinterpret_cast(Offsets::Task__Defer); 100 | 101 | using TGetGlobalState = uintptr_t(__fastcall*)(uintptr_t, int32_t*, uintptr_t*); 102 | inline auto GetGlobalState = reinterpret_cast(Offsets::GetGlobalState); 103 | 104 | using TDecryptLuaState = uintptr_t(__fastcall*)(uintptr_t); 105 | inline auto DecryptLuaState = reinterpret_cast(Offsets::DecryptLuaState); 106 | 107 | using TPushInstance = void(__fastcall*)(lua_State* state, void* instance); 108 | inline auto PushInstance = reinterpret_cast(Offsets::PushInstance); 109 | 110 | using TLuaD_throw = void(__fastcall*)(lua_State*, int); 111 | inline auto LuaD_throw = reinterpret_cast(Offsets::LuaD_throw); 112 | 113 | using TGetProperty = uintptr_t * (__thiscall*)(uintptr_t, uintptr_t*); 114 | inline auto GetProperty = reinterpret_cast(Offsets::GetProperty); 115 | 116 | using TFireTouchInterest = void(__fastcall*)(uintptr_t, uintptr_t, uintptr_t, bool, bool); 117 | inline auto FireTouchInterest = reinterpret_cast(Offsets::FireTouchInterest); 118 | 119 | using TFireProxmityPrompt = std::uintptr_t(__fastcall*)(std::uintptr_t prompt); 120 | inline auto FireProximityPrompt = reinterpret_cast(Offsets::FireProximityPrompt); 121 | 122 | using TRequestCode = uintptr_t(__fastcall*)(uintptr_t protected_string_ref, uintptr_t script); 123 | inline auto RequestCode = reinterpret_cast(Offsets::RequestCode); 124 | 125 | using TFireMouseClick = void(__fastcall*)(__int64 a1, float a2, __int64 a3); 126 | inline auto FireMouseClick = reinterpret_cast(Offsets::FireMouseClick); 127 | 128 | using TFireRightMouseClick = void(__fastcall*)(__int64 a1, float a2, __int64 a3); 129 | inline auto FireRightMouseClick = reinterpret_cast(Offsets::FireRightMouseClick); 130 | 131 | using TFireMouseHoverEnter = void(__fastcall*)(__int64 a1, __int64 a2); 132 | inline auto FireMouseHoverEnter = reinterpret_cast(Offsets::FireMouseHoverEnter); 133 | 134 | using TFireMouseHoverLeave = void(__fastcall*)(__int64 a1, __int64 a2); 135 | inline auto FireMouseHoverLeave = reinterpret_cast(Offsets::FireMouseHoverLeave); 136 | 137 | 138 | } -------------------------------------------------------------------------------- /ModuleBase/Update/Protection.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ProtectionStructure.hpp" 4 | 5 | #define LUAU_COMMA_SEP , 6 | #define LUAU_SEMICOLON_SEP ; 7 | 8 | #define LUAU_SHUFFLE3(s, a1, a2, a3) a1 s a3 s a2 9 | #define LUAU_SHUFFLE4(s, a1, a2, a3, a4) a4 s a3 s a1 s a2 10 | #define LUAU_SHUFFLE5(s, a1, a2, a3, a4, a5) a5 s a3 s a2 s a1 s a4 11 | #define LUAU_SHUFFLE6(s, a1, a2, a3, a4, a5, a6) a1 s a3 s a2 s a6 s a5 s a4 12 | #define LUAU_SHUFFLE7(s, a1, a2, a3, a4, a5, a6, a7) a6 s a2 s a7 s a3 s a1 s a4 s a5 13 | #define LUAU_SHUFFLE8(s, a1, a2, a3, a4, a5, a6, a7, a8) a1 s a8 s a4 s a6 s a2 s a7 s a5 s a3 14 | #define LUAU_SHUFFLE9(s, a1, a2, a3, a4, a5, a6, a7, a8, a9) a9 s a7 s a3 s a5 s a1 s a6 s a2 s a8 s a4 15 | 16 | 17 | #define PROTO_MEMBER1_ENC VMValue0 18 | #define PROTO_MEMBER2_ENC VMValue2 19 | #define PROTO_DEBUGISN_ENC VMValue4 20 | #define PROTO_TYPEINFO_ENC VMValue1 21 | #define PROTO_DEBUGNAME_ENC VMValue3 22 | 23 | 24 | #define LSTATE_STACKSIZE_ENC VMValue1 25 | #define LSTATE_GLOBAL_ENC VMValue0 26 | 27 | #define CLOSURE_FUNC_ENC VMValue0 28 | #define CLOSURE_CONT_ENC VMValue4 29 | #define CLOSURE_DEBUGNAME_ENC VMValue2 30 | 31 | #define TABLE_MEMBER_ENC VMValue0 32 | #define TABLE_META_ENC VMValue0 33 | 34 | #define UDATA_META_ENC VMValue4 35 | 36 | #define TSTRING_HASH_ENC VMValue3 37 | #define TSTRING_LEN_ENC VMValue0 38 | 39 | #define GSTATE_TTNAME_ENC VMValue0 40 | #define GSTATE_TMNAME_ENC VMValue0 41 | -------------------------------------------------------------------------------- /ModuleBase/Update/ProtectionStructure.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | template 8 | struct VMValue0 9 | { 10 | private: 11 | T storage; 12 | 13 | public: 14 | operator const T() const 15 | { 16 | return storage; 17 | } 18 | 19 | void operator=(const T& value) 20 | { 21 | storage = value; 22 | } 23 | 24 | const T operator->() const 25 | { 26 | return operator const T(); 27 | } 28 | 29 | T get() 30 | { 31 | return operator const T(); 32 | } 33 | 34 | void set(const T& value) 35 | { 36 | operator=(value); 37 | } 38 | }; 39 | 40 | template struct VMValue1 { 41 | private: 42 | T Storage; 43 | public: 44 | operator const T() const { 45 | return (T)((uintptr_t)this->Storage - (uintptr_t)this); 46 | } 47 | 48 | void operator=(const T& Value) { 49 | this->Storage = (T)((uintptr_t)Value + (uintptr_t)this); 50 | } 51 | 52 | const T operator->() const { 53 | return operator const T(); 54 | } 55 | 56 | T Get() { 57 | return operator const T(); 58 | } 59 | 60 | void Set(const T& Value) { 61 | operator=(Value); 62 | } 63 | }; 64 | 65 | template struct VMValue2 { 66 | private: 67 | T Storage; 68 | public: 69 | operator const T() const { 70 | return (T)((uintptr_t)this - (uintptr_t)this->Storage); 71 | } 72 | 73 | void operator=(const T& Value) { 74 | this->Storage = (T)((uintptr_t)this - (uintptr_t)Value); 75 | } 76 | 77 | const T operator->() const { 78 | return operator const T(); 79 | } 80 | 81 | T Get() { 82 | return operator const T(); 83 | } 84 | 85 | void Set(const T& Value) { 86 | operator=(Value); 87 | } 88 | }; 89 | 90 | template struct VMValue3 { 91 | private: 92 | T Storage; 93 | public: 94 | operator const T() const { 95 | return (T)((uintptr_t)this ^ (uintptr_t)this->Storage); 96 | } 97 | 98 | void operator=(const T& Value) { 99 | this->Storage = (T)((uintptr_t)Value ^ (uintptr_t)this); 100 | } 101 | 102 | const T operator->() const { 103 | return operator const T(); 104 | } 105 | 106 | T Get() { 107 | return operator const T(); 108 | } 109 | 110 | void Set(const T& Value) { 111 | operator=(Value); 112 | } 113 | }; 114 | 115 | template struct VMValue4 { 116 | private: 117 | T Storage; 118 | public: 119 | operator const T() const { 120 | return (T)((uintptr_t)this + (uintptr_t)this->Storage); 121 | } 122 | 123 | void operator=(const T& Value) { 124 | this->Storage = (T)((uintptr_t)Value - (uintptr_t)this); 125 | } 126 | 127 | const T operator->() const { 128 | return operator const T(); 129 | } 130 | 131 | T Get() { 132 | return operator const T(); 133 | } 134 | 135 | void Set(const T& Value) { 136 | operator=(Value); 137 | } 138 | }; -------------------------------------------------------------------------------- /ModuleBase/dllmain.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | void threadA() { 6 | RBX::Print(1, "injecting..."); 7 | Sleep(4000); 8 | Globals::DataModel = Utils::Task->GetDataModel(); 9 | if (!Utils::Task->isGameLoaded(Globals::DataModel)) { // make sure injected ingame (ingame = 31, home = 15) 10 | std::this_thread::sleep_for(std::chrono::milliseconds(400)); 11 | return threadA(); 12 | } 13 | 14 | Globals::LuaState = Utils::Task->GetLuaState(Globals::DataModel); 15 | if (!Utils::Task->CreateThread()) 16 | return threadA(); 17 | std::this_thread::sleep_for(std::chrono::seconds(2)); 18 | Environment::Initializes->Env(Globals::exploitThread); // --> To get the file system work, Create a folder called "Base" in your LocalAppdata folder, then create the Workspace folder inside of it. (automise it youself) 19 | // Execution::cBase->Execute(Globals::exploitThread, "print('Injected')"); 20 | while (true) { 21 | 22 | } 23 | } 24 | 25 | 26 | 27 | BOOL APIENTRY DllMain( HMODULE hModule, 28 | DWORD ul_reason_for_call, 29 | LPVOID lpReserved 30 | ) 31 | { 32 | switch (ul_reason_for_call) 33 | { 34 | case DLL_PROCESS_ATTACH: 35 | std::thread(threadA).detach(); 36 | startpipe(); 37 | break; 38 | case DLL_THREAD_ATTACH: 39 | case DLL_THREAD_DETACH: 40 | case DLL_PROCESS_DETACH: 41 | break; 42 | } 43 | return TRUE; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Internal-Base 2 | A full roblox internal base -- Everything you need for your own internal 3 | 4 | ## This includes: 5 | -> Injector (A fork of https://github.com/Deni210/Roblox-MMap-Injector) 6 | -> Module (15% Unc --> Filesystem Environment taken from @goodbytecode) 7 | -> Executor Ui (example) 8 | 9 | 10 | 11 | ## How to Update? 12 | Update files are located in `Update\Offsets.hpp` and `Update\Protection.hpp`. 13 | Get Latest offsets, Shuffles and Encryptions at discord.gg/getcloudy 14 | 15 | ### ON 40 STARS ILL ADD A DUMPER SRC TO IT ASWELL 16 | 17 | ## Is that cloudy's source? 18 | Nope! This Module and Injector is **DETECTED** By Yara-Ruleset and Roblox detections and wont be used by Cloudy. 19 | 20 | # IF YOU USE THIS MODULE... 21 | **please credit @goodbytecode(1303083805447426080). He originally made the Injector and the Environment (UNC).** 22 | -------------------------------------------------------------------------------- /build/Injector.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/build/Injector.exe -------------------------------------------------------------------------------- /build/fmt.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/volxp/InternalBase/78b4883b26c8f66b0768849204df7d216dbaa86b/build/fmt.dll --------------------------------------------------------------------------------