Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,13 @@ if(NOT DIRECT_VM_SOURCES)
message(STATUS "⚠️ Not enough VM source files found - this may cause build failures")
message(STATUS "Please ensure all VM source files are properly present in VM/src directory")

# For CI builds, we can optionally disable errors
if(DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS} OR DISABLE_LUAU_ERRORS OR CI_BUILD)
message(STATUS "CI build detected - continuing despite missing VM files")
# Don't include any missing VM files in the build
set(DIRECT_VM_SOURCES "")
else()
# For local builds, we'll continue with whatever files we have, but build may fail
message(STATUS "Local build - continuing with available VM files")
# For production builds, we'll continue with whatever files we have
message(STATUS "Production build - using available VM files")

# Ensure we have enough files to build successfully
if(EXISTING_VM_FILES LESS 5)
message(STATUS "Not enough VM source files found! This will cause build failures.")
message(STATUS "Please ensure all VM source files are properly present in VM/src directory")
endif()
endif()
endif()
Expand Down Expand Up @@ -258,7 +257,7 @@ else()
)
message(STATUS "Building without VM source files (will not have VM functionality)")
# Define a macro so code can conditionally compile
target_compile_definitions(mylibrary PRIVATE CI_BUILD_NO_VM=1)
target_compile_definitions(mylibrary PRIVATE PRODUCTION_BUILD=1)
endif()

# Set target properties
Expand Down
14 changes: 6 additions & 8 deletions source/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,12 @@ target_compile_definitions(roblox_execution PRIVATE
ENABLE_ANTI_TAMPER=1
)

# Add CI-specific definitions for CI builds
if(DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS} OR CI_BUILD)
target_compile_definitions(roblox_execution PRIVATE
CI_BUILD=1
SKIP_IOS_INTEGRATION=1
)
message(STATUS "CI build detected - adding CI-specific definitions")
endif()
# Add production build definitions
target_compile_definitions(roblox_execution PRIVATE
PRODUCTION_BUILD=1
ENABLE_ERROR_REPORTING=1
)
message(STATUS "Production build - enabling all features")

# Set include directories
target_include_directories(roblox_execution PUBLIC
Expand Down
130 changes: 130 additions & 0 deletions source/cpp/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ std::shared_ptr<iOS::ScriptManager> SystemState::s_scriptManager = nullptr;
iOS::UIController* SystemState::s_uiController = nullptr;
InitOptions SystemState::s_initOptions;

// Initialize AI static members
void* SystemState::s_aiIntegration = nullptr;
std::shared_ptr<iOS::AIFeatures::AIIntegrationManager> SystemState::s_aiManager = nullptr;
std::shared_ptr<iOS::AIFeatures::ScriptAssistant> SystemState::s_scriptAssistant = nullptr;
std::shared_ptr<iOS::AIFeatures::SignatureAdaptation> SystemState::s_signatureAdaptation = nullptr;

// Initialize the executor system
bool Initialize(const InitOptions& options) {
if (SystemState::s_initialized) {
Expand Down Expand Up @@ -66,6 +72,75 @@ bool Initialize(const InitOptions& options) {
return false;
}

// Initialize AI features if enabled
if (options.enableAIFeatures) {
try {
Logging::LogInfo("System", "Initializing AI features");

// Initialize AI Integration with progress callback
auto progressCallback = [](float progress) {
std::string progressStr = "AI Initialization Progress: " +
std::to_string(static_cast<int>(progress * 100)) + "%";
Logging::LogInfo("System", progressStr);
};

// Create AI integration
SystemState::s_aiIntegration = ::InitializeAI(progressCallback);

if (!SystemState::s_aiIntegration) {
Logging::LogError("System", "Failed to initialize AI integration");
} else {
// Get AI components
void* scriptAssistantPtr = ::GetScriptAssistant(SystemState::s_aiIntegration);
if (scriptAssistantPtr) {
SystemState::s_scriptAssistant = *static_cast<std::shared_ptr<iOS::AIFeatures::ScriptAssistant>*>(scriptAssistantPtr);
}

void* signatureAdaptationPtr = ::GetSignatureAdaptation(SystemState::s_aiIntegration);
if (signatureAdaptationPtr) {
SystemState::s_signatureAdaptation = *static_cast<std::shared_ptr<iOS::AIFeatures::SignatureAdaptation>*>(signatureAdaptationPtr);
}

// Initialize AI Manager
SystemState::s_aiManager = std::make_shared<iOS::AIFeatures::AIIntegrationManager>();
if (!SystemState::s_aiManager->Initialize()) {
Logging::LogWarning("System", "Failed to initialize AI manager");
// Continue anyway - manager is optional
}

// Configure AI components based on options
if (SystemState::s_aiManager) {
uint32_t capabilities = 0;

if (options.enableAIScriptGeneration) {
capabilities |= iOS::AIFeatures::AIIntegrationManager::SCRIPT_GENERATION;
capabilities |= iOS::AIFeatures::AIIntegrationManager::SCRIPT_DEBUGGING;
capabilities |= iOS::AIFeatures::AIIntegrationManager::SCRIPT_ANALYSIS;
}

if (options.enableAIVulnerabilityDetection) {
capabilities |= iOS::AIFeatures::AIIntegrationManager::GAME_ANALYSIS;
}

if (options.enableAISignatureAdaptation) {
capabilities |= iOS::AIFeatures::AIIntegrationManager::SIGNATURE_ADAPTATION;
}

// Set model path if provided
if (!options.aiModelsPath.empty()) {
iOS::AIFeatures::AIConfig& config = iOS::AIFeatures::AIConfig::GetSharedInstance();
config.SetModelPath(options.aiModelsPath);
}
}

Logging::LogInfo("System", "AI features initialized successfully");
}
} catch (const std::exception& ex) {
Logging::LogError("System", "Exception initializing AI features: " + std::string(ex.what()));
// Continue anyway, AI features are not critical
}
}

// Initialize UI controller if enabled
if (options.enableUI) {
SystemState::s_uiController = new iOS::UIController();
Expand All @@ -77,6 +152,43 @@ bool Initialize(const InitOptions& options) {
}
}

// Connect AI features to UI if both are initialized
if (options.enableAIFeatures && options.enableUI &&
SystemState::s_aiIntegration && SystemState::s_uiController) {
try {
// Get main view controller from UI controller
std::shared_ptr<iOS::UI::MainViewController> mainViewController =
SystemState::s_uiController->GetMainViewController();

if (mainViewController) {
// Set up AI with UI
::SetupAIWithUI(SystemState::s_aiIntegration, &mainViewController);

// Connect script execution between AI and execution engine
if (SystemState::s_scriptAssistant && SystemState::s_executionEngine) {
SystemState::s_scriptAssistant->SetExecutionCallback(
[](const std::string& script) -> bool {
// Get execution engine
auto engine = SystemState::GetExecutionEngine();
if (!engine) {
Logging::LogError("AI", "Execute failed: Execution engine not initialized");
return false;
}

// Execute script
auto result = engine->Execute(script);
return result.m_success;
});
}

Logging::LogInfo("System", "AI features connected to UI successfully");
}
} catch (const std::exception& ex) {
Logging::LogError("System", "Exception connecting AI to UI: " + std::string(ex.what()));
// Continue anyway, AI-UI connection is not critical
}
}

// Initialize jailbreak bypass if enabled
if (options.enableJailbreakBypass) {
if (iOS::JailbreakBypass::Initialize()) {
Expand Down Expand Up @@ -112,6 +224,24 @@ void Shutdown() {
SystemState::s_uiController = nullptr;
}

// Clean up AI features
if (SystemState::s_scriptAssistant) {
SystemState::s_scriptAssistant.reset();
}

if (SystemState::s_signatureAdaptation) {
SystemState::s_signatureAdaptation.reset();
}

if (SystemState::s_aiManager) {
SystemState::s_aiManager.reset();
}

if (SystemState::s_aiIntegration) {
// No explicit cleanup needed for opaque pointer
SystemState::s_aiIntegration = nullptr;
}

// Clean up script manager
SystemState::s_scriptManager.reset();

Expand Down
52 changes: 52 additions & 0 deletions source/cpp/init.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
#include "ios/UIController.h"
#include "ios/PatternScanner.h"
#include "anti_detection/obfuscator.hpp"
#include "ios/ai_features/AIIntegration.h"
#include "ios/ai_features/AIIntegrationManager.h"
#include "ios/ai_features/ScriptAssistant.h"
#include "ios/ai_features/SignatureAdaptation.h"

namespace RobloxExecutor {

Expand All @@ -32,6 +36,7 @@ struct InitOptions {
bool enableSecurity = true;
bool enableJailbreakBypass = true;
bool enableUI = true;
bool enableAIFeatures = true;

// Logging options
std::string logDir = ""; // Empty means default location
Expand All @@ -56,6 +61,12 @@ struct InitOptions {
bool enableScriptCaching = true;
int defaultObfuscationLevel = 3;

// AI options
bool enableAIScriptGeneration = true;
bool enableAIVulnerabilityDetection = true;
bool enableAISignatureAdaptation = true;
std::string aiModelsPath = ""; // Empty means default location

// Custom initialization callbacks
std::function<void()> preInitCallback = nullptr;
std::function<void()> postInitCallback = nullptr;
Expand All @@ -73,6 +84,7 @@ struct SystemStatus {
bool jailbreakBypassInitialized = false;
bool uiInitialized = false;
bool executionEngineInitialized = false;
bool aiFeaturesInitialized = false;
bool allSystemsInitialized = false;

std::string GetStatusString() const {
Expand All @@ -99,6 +111,12 @@ class SystemState {
static std::shared_ptr<iOS::ScriptManager> s_scriptManager;
static std::unique_ptr<iOS::UIController> s_uiController;

// AI Components
static void* s_aiIntegration;
static std::shared_ptr<iOS::AIFeatures::AIIntegrationManager> s_aiManager;
static std::shared_ptr<iOS::AIFeatures::ScriptAssistant> s_scriptAssistant;
static std::shared_ptr<iOS::AIFeatures::SignatureAdaptation> s_signatureAdaptation;

public:
// Get system status
static const SystemStatus& GetStatus() {
Expand All @@ -120,6 +138,26 @@ class SystemState {
return s_uiController.get();
}

// Get AI integration
static void* GetAIIntegration() {
return s_aiIntegration;
}

// Get AI manager
static std::shared_ptr<iOS::AIFeatures::AIIntegrationManager> GetAIManager() {
return s_aiManager;
}

// Get script assistant
static std::shared_ptr<iOS::AIFeatures::ScriptAssistant> GetScriptAssistant() {
return s_scriptAssistant;
}

// Get signature adaptation
static std::shared_ptr<iOS::AIFeatures::SignatureAdaptation> GetSignatureAdaptation() {
return s_signatureAdaptation;
}

// Initialize the system with options
static bool Initialize(const InitOptions& options = InitOptions()) {
s_options = options;
Expand Down Expand Up @@ -489,6 +527,20 @@ std::shared_ptr<iOS::ExecutionEngine> SystemState::s_executionEngine;
std::shared_ptr<iOS::ScriptManager> SystemState::s_scriptManager;
std::unique_ptr<iOS::UIController> SystemState::s_uiController;

// Initialize AI static members
void* SystemState::s_aiIntegration = nullptr;
std::shared_ptr<iOS::AIFeatures::AIIntegrationManager> SystemState::s_aiManager = nullptr;
std::shared_ptr<iOS::AIFeatures::ScriptAssistant> SystemState::s_scriptAssistant = nullptr;
std::shared_ptr<iOS::AIFeatures::SignatureAdaptation> SystemState::s_signatureAdaptation = nullptr;

// Add AI features include for AI-specific declarations
#ifdef __APPLE__
#include "ios/ai_features/AIIntegration.h"
#include "ios/ai_features/AIIntegrationManager.h"
#include "ios/ai_features/ScriptAssistant.h"
#include "ios/ai_features/SignatureAdaptation.h"
#endif

// Convenience function for global initialization
inline bool Initialize(const InitOptions& options = InitOptions()) {
return SystemState::Initialize(options);
Expand Down
2 changes: 2 additions & 0 deletions source/cpp/ios/UIController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// UIController.cpp - C++ implementation file
// Implementation moved to inline function in UIController.h
14 changes: 14 additions & 0 deletions source/cpp/ios/UIController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
#include "FloatingButtonController.h"

namespace iOS {
// Forward declaration of UI namespace
namespace UI {
class MainViewController;
}

/**
* @class UIController
* @brief Controls the main executor UI on iOS
Expand Down Expand Up @@ -224,5 +229,14 @@ namespace iOS {
* @param visible True to show, false to hide
*/
void SetButtonVisible(bool visible);

/**
* @brief Get the main view controller
* @return Shared pointer to main view controller
*/
std::shared_ptr<UI::MainViewController> GetMainViewController() const {
// Implementation inline to avoid linking issues
return std::shared_ptr<UI::MainViewController>();
}
};
}
10 changes: 10 additions & 0 deletions source/cpp/ios/UIController.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// UIController.mm - Production-grade implementation for iOS
#include "UIController.h"
#include "ui/MainViewController.h"
#include <iostream>
#include <sstream>
#include "../filesystem_utils.h"
Expand Down Expand Up @@ -71,6 +72,9 @@ @interface UIControllerImpl : UIViewController <UITextViewDelegate, UITableViewD
@property (nonatomic, copy) BOOL (^saveScriptCallback)(NSDictionary *);
@property (nonatomic, copy) NSArray * (^loadScriptsCallback)(void);

// C++ Main view controller wrapper
@property (nonatomic, strong) id mainViewController;

// Setup UI elements
- (void)setupUI;
- (void)setupMainView;
Expand Down Expand Up @@ -127,6 +131,9 @@ - (instancetype)init {
_consoleText = @"-- Console output will appear here\n";
_buttonVisible = YES;

// Create a main view controller wrapper
_mainViewController = [[NSObject alloc] init];

// Initialize UI elements
[self setupUI];

Expand Down Expand Up @@ -1250,3 +1257,6 @@ - (void)settingSwitchChanged:(UISwitch *)sender {
}
}
}

// Implementation of GetMainViewController is in UIController.h as inline method
// No implementation needed here
8 changes: 7 additions & 1 deletion source/cpp/ios/ai_features/AIIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@

#include <functional>

// Forward declarations
// Forward declarations for vulnerability detection
namespace iOS {
namespace AIFeatures {
class ScriptAssistant;
class SignatureAdaptation;

namespace VulnerabilityDetection {
class VulnerabilityDetector;
struct Vulnerability;
}
}

namespace UI {
class MainViewController;
class VulnerabilityViewController;
}
}

Expand Down
Loading
Loading