Advertisement
Josiahiscool73

ai Roblox dll C++

Jun 23rd, 2025
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <string>
  3. #include <thread>
  4. #include <vector>
  5. #include <iostream>
  6.  
  7. // --- Shuffles and Encs Provided by User ---
  8. // These preprocessor macros are essential for correctly defining the memory layout
  9. // of Roblox's obfuscated internal data structures.
  10. #define LUAU_SHUFFLE3(s, a1, a2, a3) a1 s a3 s a2
  11. #define LUAU_SHUFFLE4(s, a1, a2, a3, a4) a3 s a1 s a2 s a4
  12. #define LUAU_SHUFFLE5(s, a1, a2, a3, a4, a5) a5 s a4 s a1 s a3 s a2
  13. #define LUAU_SHUFFLE6(s, a1, a2, a3, a4, a5, a6) a2 s a4 s a3 s a1 s a5 s a6
  14. #define LUAU_SHUFFLE7(s, a1, a2, a3, a4, a5, a6, a7) a4 s a5 s a1 s a7 s a2 s a3 s a6
  15. #define LUAU_SHUFFLE8(s, a1, a2, a3, a4, a5, a6, a7, a8) a6 s a4 s a1 s a2 s a8 s a5 s a7 s a3
  16. #define LUAU_SHUFFLE9(s, a1, a2, a3, a4, a5, a6, a7, a8, a9) a1 s a8 s a5 s a3 s a4 s a6 s a7 s a9 s a2
  17.  
  18. // Structure Member Encryption/Renaming
  19. #define LSTATE_STACKSIZE_ENC VMValue2
  20. #define LSTATE_GLOBAL_ENC VMValue0
  21. #define CLOSURE_FUNC_ENC VMValue0
  22. #define TSTRING_LEN_ENC VMValue0
  23.  
  24. // --- Roblox Offsets Provided by User ---
  25. namespace Offsets {
  26. const DWORD TaskSchedulerPointer = 0x6884DC8;
  27. const DWORD VisualEnginePointer = 0x6606128;
  28. const DWORD ScriptContext = 0x3B0;
  29. const DWORD VisualEngineToDataModel1 = 0x720;
  30. const DWORD VisualEngineToDataModel2 = 0x1B8;
  31. const DWORD GetGlobalState = 0x140; // This might be an offset to a function or a direct pointer.
  32. const DWORD Job_Name = 0x18;
  33. const DWORD Name = 0x78; // Offset for an instance's name
  34. }
  35.  
  36. // --- Roblox Function Typedefs & Structure Recreation ---
  37. // We must recreate the structures using the provided macros to match their in-memory layout.
  38. // NOTE: Base types like GCObject, TValue, etc., are simplified for clarity.
  39. // The primary goal is to demonstrate the use of the shuffle/enc macros.
  40.  
  41. struct GCObject {
  42. void* next; // Simplified GCObject
  43. byte tt;
  44. byte marked;
  45. };
  46.  
  47. struct TString {
  48. GCObject GCO; // Common header for garbage collected objects
  49. // Using the ENC macro to define the length member
  50. size_t TSTRING_LEN_ENC;
  51. // Other members would follow, defined by their ENC macros
  52. };
  53.  
  54. struct lua_State {
  55. // This demonstrates the reordering of members. The preprocessor will expand this
  56. // into the shuffled order defined by LUAU_SHUFFLE*.
  57. LUAU_SHUFFLE9(;,
  58. GCObject* LSTATE_GLOBAL_ENC, // VMValue0
  59. void* next,
  60. int LSTATE_STACKSIZE_ENC, // VMValue2
  61. void* top,
  62. void* base,
  63. void* ci,
  64. void* savedpc,
  65. byte status,
  66. byte tt
  67. );
  68. };
  69.  
  70. struct ScriptContext {
  71. // We assume a simple layout here. The key is accessing it via the offset.
  72. char padding[Offsets::GetGlobalState];
  73. lua_State* main_L; // The member at offset GetGlobalState
  74. };
  75.  
  76. struct Job {
  77. char padding[Offsets::Job_Name];
  78. TString* job_name;
  79. };
  80.  
  81. struct TaskScheduler {
  82. char padding[0x1D0]; // JobStart offset from your list
  83. void* jobs_start;
  84. void* jobs_end;
  85.  
  86. Job* GetJobByName(const std::string& name) {
  87. // Iterate through the scheduler's jobs to find the correct one
  88. for (Job** job_ptr = (Job**)jobs_start; job_ptr < jobs_end; ++job_ptr) {
  89. Job* job = *job_ptr;
  90. if (job && job->job_name) {
  91. // Check if the job name matches "WaitingHybridScriptsJob"
  92. const char* jobNameStr = (const char*)(job->job_name + 1); // TString data is after the header
  93. if (name == jobNameStr) {
  94. return job;
  95. }
  96. }
  97. }
  98. return nullptr;
  99. }
  100. };
  101.  
  102.  
  103. // --- Function Pointers to Roblox's Internal Functions ---
  104. // These addresses must be found via reverse engineering (e.g., signature scanning).
  105. // They are ESSENTIAL for execution. The offsets you provided get us the objects,
  106. // but we need the functions to interact with them.
  107. DWORD roblox_base = (DWORD)GetModuleHandleA("RobloxPlayerBeta.exe");
  108. // PLACEHOLDER ADDRESSES - THESE MUST BE FOUND AND UPDATED
  109. typedef lua_State* (*rbx_lua_newthread_t)(lua_State* L);
  110. rbx_lua_newthread_t rbx_lua_newthread = (rbx_lua_newthread_t)(roblox_base + 0x123456);
  111.  
  112. typedef int (*rbx_lua_load_t)(lua_State* L, const char* chunkname, const char* data, size_t size, int env);
  113. rbx_lua_load_t rbx_lua_load = (rbx_lua_load_t)(roblox_base + 0x654321);
  114.  
  115. typedef void (*rbx_spawn_job_t)(TaskScheduler* scheduler, Job* job);
  116. rbx_spawn_job_t rbx_spawn_job = (rbx_spawn_job_t)(roblox_base + 0xABCDEF);
  117.  
  118.  
  119. // --- Core Executor Logic ---
  120. namespace Executor {
  121. lua_State* GetLuaState() {
  122. // Pointer chain to get ScriptContext
  123. DWORD* visualEngine = (DWORD*)(roblox_base + Offsets::VisualEnginePointer);
  124. DWORD* dataModel_step1 = (DWORD*)(*visualEngine + Offsets::VisualEngineToDataModel1);
  125. DWORD* dataModel = (DWORD*)(*dataModel_step1 + Offsets::VisualEngineToDataModel2);
  126. ScriptContext* scriptContext = (ScriptContext*)((char*)dataModel + Offsets::ScriptContext);
  127.  
  128. // Return the lua_State using the offset within ScriptContext
  129. return scriptContext->main_L;
  130. }
  131.  
  132. void Execute(const std::string& script) {
  133. // Get the main Task Scheduler and Lua State using the offsets.
  134. TaskScheduler* scheduler = *(TaskScheduler**)(roblox_base + Offsets::TaskSchedulerPointer);
  135. lua_State* main_L = GetLuaState();
  136.  
  137. if (!scheduler || !main_L) {
  138. MessageBoxA(NULL, "Failed to find Scheduler or Lua State. Offsets may be outdated.", "Error", MB_OK | MB_ICONERROR);
  139. return;
  140. }
  141.  
  142. // Create a new Lua thread (coroutine) to run our script in.
  143. // This is safer than running directly on the main state.
  144. lua_State* script_L = rbx_lua_newthread(main_L);
  145.  
  146. // Load the script bytecode into the new thread.
  147. // This converts the text script into a function that Lua can run.
  148. rbx_lua_load(script_L, "Dolphin", script.c_str(), script.length(), 0);
  149.  
  150. // Find the "WaitingHybridScriptsJob" which is responsible for running scripts.
  151. Job* script_job = scheduler->GetJobByName("WaitingHybridScriptsJob");
  152. if (!script_job) {
  153. MessageBoxA(NULL, "Failed to find WaitingHybridScriptsJob.", "Error", MB_OK | MB_ICONERROR);
  154. return;
  155. }
  156.  
  157. // We would now need to create a custom "Script" object, assign our new thread (script_L) to it,
  158. // and add it to the job's queue. This is a highly complex step involving allocating and
  159. // structuring memory to perfectly match Roblox's internal script object.
  160. // For simplicity, we'll represent this with a call to a hypothetical "spawn" function.
  161. // A real implementation would manually construct this object in memory.
  162. rbx_spawn_job(scheduler, script_job); // This conceptual function would resume the thread in script_L.
  163.  
  164. // This is a more robust and common method than calling pcall directly.
  165. }
  166. }
  167.  
  168. // --- DLL Entry Point & Pipe Handling (Unchanged) ---
  169. void PipeThread() {
  170. char buffer[1024 * 32];
  171. HANDLE pipe;
  172.  
  173. pipe = CreateNamedPipeA(
  174. "\\\\.\\pipe\\DolphinExecutorPipe",
  175. PIPE_ACCESS_INBOUND,
  176. PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
  177. 1, sizeof(buffer), sizeof(buffer), NMPWAIT_USE_DEFAULT_WAIT, NULL
  178. );
  179.  
  180. while (pipe != INVALID_HANDLE_VALUE) {
  181. if (ConnectNamedPipe(pipe, NULL) != FALSE) {
  182. DWORD bytesRead;
  183. while (ReadFile(pipe, buffer, sizeof(buffer) - 1, &bytesRead, NULL) != FALSE) {
  184. buffer[bytesRead] = '\0';
  185. Executor::Execute(buffer);
  186. }
  187. }
  188. DisconnectNamedPipe(pipe);
  189. }
  190. }
  191.  
  192. BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
  193. if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
  194. DisableThreadLibraryCalls(hModule);
  195. std::thread(PipeThread).detach();
  196. }
  197. return TRUE;
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement