diff --git a/source/cpp/ios/FloatingButtonController.mm b/source/cpp/ios/FloatingButtonController.mm index 4a179fe2..e5bf1158 100644 --- a/source/cpp/ios/FloatingButtonController.mm +++ b/source/cpp/ios/FloatingButtonController.mm @@ -203,10 +203,9 @@ - (void)snapToNearestEdge { UITapGestureRecognizer* tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:button action:@selector(handleTap:)]; [button addGestureRecognizer:tapGesture]; - // Store the button and apply initial position - // Manual retain in non-ARC mode + // Store the button and apply initial position (manual memory management) m_buttonView = (void*)button; - [button retain]; + [button retain]; // Explicitly retain the button since we're not using ARC UpdateButtonPosition(); // Initially hidden @@ -219,8 +218,7 @@ - (void)snapToNearestEdge { if (m_buttonView) { FloatingButton* button = (FloatingButton*)m_buttonView; [button removeFromSuperview]; - // Manual release in non-ARC mode - [button release]; + [button release]; // Explicitly release since we're manually retaining m_buttonView = nullptr; } } diff --git a/source/cpp/ios/JailbreakBypass.mm b/source/cpp/ios/JailbreakBypass.mm index 69866a31..14a13ffe 100644 --- a/source/cpp/ios/JailbreakBypass.mm +++ b/source/cpp/ios/JailbreakBypass.mm @@ -22,9 +22,9 @@ std::unordered_set JailbreakBypass::m_jailbreakProcesses; std::unordered_map JailbreakBypass::m_fileRedirects; - // Original function pointers and their stub implementations + // Define function pointers for non-iOS platforms #if !defined(IOS_TARGET) && !defined(__APPLE__) - // These function pointers are only populated on non-iOS platforms + // These function pointers are populated with MSHookFunction static int (*original_stat)(const char* path, struct stat* buf); static int (*original_access)(const char* path, int mode); static FILE* (*original_fopen)(const char* path, const char* mode); @@ -33,39 +33,38 @@ static int (*original_fork)(void); static int (*original_execve)(const char* path, char* const argv[], char* const envp[]); #else - // On iOS, we create stub functions instead of function pointers - // We'll redefine the "original_*" names to be actual functions - // This avoids undefined identifiers in the other methods - static int original_stat(const char* path, struct stat* buf) { - return ::stat(path, (struct ::stat*)buf); // Direct call, no hook on iOS - explicitly cast to global stat struct + // For iOS, define function implementations that call the system functions directly + // This avoids using function pointers which are populated via MSHookFunction + static int original_stat(const char* path, struct stat* buf) { + return ::stat(path, buf); } static int original_access(const char* path, int mode) { - return access(path, mode); // Direct call, no hook on iOS + return ::access(path, mode); } static FILE* original_fopen(const char* path, const char* mode) { - return fopen(path, mode); // Direct call, no hook on iOS + return ::fopen(path, mode); } static char* original_getenv(const char* name) { - return getenv(name); // Direct call, no hook on iOS + return ::getenv(name); } static int original_system(const char* command) { - // system() is not available on iOS, so just log and return success + // system() is often unavailable on iOS, just log and return success std::cout << "iOS: system() call would execute: " << (command ? command : "null") << std::endl; - return 0; // Pretend it succeeded + return 0; } static int original_fork(void) { - // fork() usually won't work on iOS, so return error + // fork() usually fails on iOS, return error errno = EPERM; return -1; } static int original_execve(const char* path, char* const argv[], char* const envp[]) { - // execve() often won't work on iOS apps, so log and return error + // execve() might not work as expected on iOS, log and return error std::cout << "iOS: execve() call would execute: " << (path ? path : "null") << std::endl; errno = EPERM; return -1; diff --git a/source/cpp/ios/MemoryAccess.h b/source/cpp/ios/MemoryAccess.h index 4f4b0023..1193f75b 100644 --- a/source/cpp/ios/MemoryAccess.h +++ b/source/cpp/ios/MemoryAccess.h @@ -1,59 +1,17 @@ #pragma once #include - -// Define platform-specific includes +// mach_vm.h is not supported on iOS, use alternative headers #if !defined(IOS_TARGET) && !defined(__APPLE__) -// Non-iOS includes #include #else -// iOS-specific includes - more comprehensive set +// Add additional headers needed for iOS compatibility #include #include #include #include -#include -#include -#include - -// Define compatibility typedefs for iOS only if not already defined -#if !defined(mach_vm_address_t) && !__has_include() -typedef vm_address_t mach_vm_address_t; -#endif - -#if !defined(mach_vm_size_t) && !__has_include() -typedef vm_size_t mach_vm_size_t; #endif -#if !defined(mach_vm_info_t) && !__has_include() -typedef vm_region_info_t mach_vm_info_t; -#endif - -// Define compatibility wrappers for missing functions -#ifndef mach_vm_region_defined -#define mach_vm_region_defined -static inline kern_return_t mach_vm_region( - vm_map_t target_task, - mach_vm_address_t *address, - mach_vm_size_t *size, - vm_region_flavor_t flavor, - vm_region_info_t info, - mach_msg_type_number_t *infoCnt, - mach_port_t *object_name) -{ - // Forward to vm_region_64 on iOS - return vm_region_64( - target_task, - (vm_address_t*)address, - (vm_size_t*)size, - flavor, - info, - infoCnt, - object_name); -} -#endif // mach_vm_region_defined -#endif // iOS block - #include #include #include diff --git a/source/cpp/ios/MemoryAccess.mm b/source/cpp/ios/MemoryAccess.mm index 5dfed26d..a8383b52 100644 --- a/source/cpp/ios/MemoryAccess.mm +++ b/source/cpp/ios/MemoryAccess.mm @@ -85,33 +85,23 @@ regions.clear(); // Variables for memory region iteration - mach_vm_address_t address = 0; - mach_vm_size_t size = 0; + vm_address_t vm_address = 0; // Use vm_address_t for compatibility with vm_region_64 + vm_size_t vm_size = 0; // Use vm_size_t for compatibility with vm_region_64 vm_region_basic_info_data_64_t info; mach_msg_type_number_t infoCount = VM_REGION_BASIC_INFO_COUNT_64; mach_port_t objectName = MACH_PORT_NULL; kern_return_t kr = KERN_SUCCESS; while (true) { - mach_vm_size_t regionSize; // Store size for later use - - #if defined(IOS_TARGET) || defined(__APPLE__) - // On iOS we use vm_region_64 instead of mach_vm_region which is unavailable + // Use variables with correct types for vm_region_64 kr = vm_region_64( m_targetTask, - (vm_address_t*)&address, // Cast to match vm_region_64 signature - (vm_size_t*)®ionSize, // Cast to match vm_region_64 signature and capture size + &vm_address, + &vm_size, VM_REGION_BASIC_INFO_64, (vm_region_info_t)&info, &infoCount, &objectName); - #else - kr = mach_vm_region(m_targetTask, &address, ®ionSize, - VM_REGION_BASIC_INFO_64, - (vm_region_info_t)&info, - &infoCount, - &objectName); - #endif if (kr != KERN_SUCCESS) { if (kr != KERN_INVALID_ADDRESS) { @@ -120,11 +110,11 @@ break; } - // Store the size with the region for later use - info.protection |= (regionSize & 0xFFFFFFFF) << 32; // Store size in unused upper bits of protection + // Store region size in the upper bits of the protection field so we can access it later + info.protection |= ((uint64_t)vm_size & 0xFFFFFFFF) << 32; regions.push_back(info); - address += regionSize; + vm_address += vm_size; } return !regions.empty(); @@ -247,22 +237,26 @@ continue; } - // Scan this region - mach_vm_size_t regionSize; - #if defined(IOS_TARGET) || defined(__APPLE__) - // For iOS, use a reasonable default size for scanning - // This is safer than trying to extract size from protection bits - regionSize = 4 * 1024 * 1024; // 4MB default scan size - #else - regionSize = region.virtual_size; - #endif - + // Extract region size from the upper bits of protection where we stored it + mach_vm_size_t regionSize = (region.protection >> 32) & 0xFFFFFFFF; + + // Use a reasonable default if size wasn't properly stored + if (regionSize == 0) { + #if defined(IOS_TARGET) || defined(__APPLE__) + // For iOS, use a reasonable default scan size + regionSize = 4 * 1024 * 1024; // 4MB default scan size + #else + regionSize = region.virtual_size; + #endif + } + + // Scan this region with the correct size mach_vm_address_t result = FindPattern(address, regionSize, pattern, mask); if (result != 0) { return result; } - // Move to next region - use the regionSize we already calculated above + // Move to next region using the extracted size address += regionSize; } diff --git a/source/cpp/ios/ai_features/OfflineAISystem.mm b/source/cpp/ios/ai_features/OfflineAISystem.mm index 5a4cd2fe..f43e6e9f 100644 --- a/source/cpp/ios/ai_features/OfflineAISystem.mm +++ b/source/cpp/ios/ai_features/OfflineAISystem.mm @@ -607,20 +607,6 @@ return true; } -// Get script templates - implementation for declaration in header -std::unordered_map OfflineAISystem::GetScriptTemplates() const { - return m_scriptTemplates; -} - -// Load script templates - implementation for declaration in header -void OfflineAISystem::LoadScriptTemplates() { - // This would load templates from files - // For now, just populate with some built-in templates - m_scriptTemplates["esp"] = "-- Basic ESP Script\nlocal esp = {}\n\n-- Implementation goes here\n\nreturn esp"; - m_scriptTemplates["aimbot"] = "-- Basic Aimbot\nlocal aimbot = {}\n\n-- Implementation goes here\n\nreturn aimbot"; - m_scriptTemplates["speed"] = "-- Speed Hack\nlocal speed = {}\n\n-- Implementation goes here\n\nreturn speed"; -} - // Unload model void OfflineAISystem::UnloadModel(const std::string& modelName) { auto it = m_modelCache.find(modelName); @@ -678,7 +664,7 @@ void* OfflineAISystem::GetModel(const std::string& modelName) const { auto it = m_modelCache.find(modelName); if (it != m_modelCache.end()) { - // Direct access to pointer instead of using get() + // Direct access to pointer instead of using get() since we're storing raw pointers now return it->second; } return nullptr; @@ -887,7 +873,21 @@ local function getClosestPlayer() )"; } -// Get cached templates +// Get script templates +std::unordered_map OfflineAISystem::GetScriptTemplates() const { + return m_scriptTemplates; +} + +// Load script templates +void OfflineAISystem::LoadScriptTemplates() { + // This would load templates from files + // For now, just populate with some built-in templates + m_scriptTemplates["esp"] = "-- Basic ESP Script\nlocal esp = {}\n\n-- Implementation goes here\n\nreturn esp"; + m_scriptTemplates["aimbot"] = "-- Basic Aimbot\nlocal aimbot = {}\n\n-- Implementation goes here\n\nreturn aimbot"; + m_scriptTemplates["speed"] = "-- Speed Hack\nlocal speed = {}\n\n-- Implementation goes here\n\nreturn speed"; +} + +// Get template cache std::unordered_map OfflineAISystem::GetTemplateCache() const { return m_templateCache; }