From 231b7e19cd5267e13dcdedbed7923822359c4a3e Mon Sep 17 00:00:00 2001 From: Avery Black Date: Sat, 7 Jan 2023 11:36:44 -0800 Subject: [PATCH] Start trying to add 32bit support This doesn't actually build a 32bit binary yet --- VoodooInput.xcodeproj/project.pbxproj | 33 +++++++-- .../VoodooInputWellspringUserClient.cpp | 69 ++++++++++++------- .../VoodooInputWellspringUserClient.hpp | 8 ++- 3 files changed, 77 insertions(+), 33 deletions(-) diff --git a/VoodooInput.xcodeproj/project.pbxproj b/VoodooInput.xcodeproj/project.pbxproj index 9b89d3a..e94d86e 100644 --- a/VoodooInput.xcodeproj/project.pbxproj +++ b/VoodooInput.xcodeproj/project.pbxproj @@ -284,6 +284,8 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = x86_64; + CC = "$(inherited)"; + "CC[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -313,7 +315,10 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; + "COMPILER_INDEX_STORE_ENABLE[arch=ACID32]" = NO; COPY_PHASE_STRIP = NO; + CXX = "$(inherited)"; + "CXX[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -333,11 +338,14 @@ GCC_WARN_UNUSED_VARIABLE = YES; KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; + LDPLUSPLUS = "$(inherited)"; + "LDPLUSPLUS[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; + ONLY_ACTIVE_ARCH = NO; SDKROOT = macosx; + VALID_ARCHS = x86_64; }; name = Debug; }; @@ -346,6 +354,8 @@ buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; ARCHS = x86_64; + CC = "$(inherited)"; + "CC[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; @@ -375,7 +385,11 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = "-"; + COMPILER_INDEX_STORE_ENABLE = YES; + "COMPILER_INDEX_STORE_ENABLE[arch=ACID32]" = NO; COPY_PHASE_STRIP = NO; + CXX = "$(inherited)"; + "CXX[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -389,10 +403,13 @@ GCC_WARN_UNUSED_VARIABLE = YES; KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; + LDPLUSPLUS = "$(inherited)"; + "LDPLUSPLUS[arch=ACID32]" = "$(PROJECT_DIR)/clang32/clang-12"; MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; + VALID_ARCHS = x86_64; }; name = Release; }; @@ -408,14 +425,17 @@ INFOPLIST_FILE = VoodooInput/Info.plist; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", + "$(PROJECT_DIR)/MacKernelSDK/Library/universal", ); - MACOSX_DEPLOYMENT_TARGET = 10.7; + MACOSX_DEPLOYMENT_TARGET = 10.6; + "MACOSX_DEPLOYMENT_TARGET[arch=ACID32]" = 10.5; MODULE_NAME = me.kishorprins.VoodooInput; MODULE_VERSION = 1.1.3; + OTHER_CFLAGS = "-Wno-stdlibcxx-not-found"; PRODUCT_BUNDLE_IDENTIFIER = me.kishorprins.VoodooInput; PRODUCT_NAME = "$(TARGET_NAME)"; RUN_CLANG_STATIC_ANALYZER = YES; + VALID_ARCHS = "x86_64 ACID32"; WRAPPER_EXTENSION = kext; }; name = Debug; @@ -429,13 +449,16 @@ INFOPLIST_FILE = VoodooInput/Info.plist; LIBRARY_SEARCH_PATHS = ( "$(inherited)", - "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", + "$(PROJECT_DIR)/MacKernelSDK/Library/universal", ); - MACOSX_DEPLOYMENT_TARGET = 10.7; + MACOSX_DEPLOYMENT_TARGET = 10.6; + "MACOSX_DEPLOYMENT_TARGET[arch=ACID32]" = 10.5; MODULE_NAME = me.kishorprins.VoodooInput; MODULE_VERSION = 1.1.3; + OTHER_CFLAGS = "-Wno-stdlibcxx-not-found"; PRODUCT_BUNDLE_IDENTIFIER = me.kishorprins.VoodooInput; PRODUCT_NAME = "$(TARGET_NAME)"; + VALID_ARCHS = "x86_64 ACID32"; WRAPPER_EXTENSION = kext; }; name = Release; diff --git a/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.cpp b/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.cpp index 58b4928..8975637 100644 --- a/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.cpp +++ b/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.cpp @@ -13,29 +13,48 @@ OSDefineMetaClassAndStructors(VoodooInputWellspringUserClient, IOUserClient); #if defined(__x86_64__) -// { Object, Func pointer, Flags, Inputs, Outputs } -static const IOExternalMethod sMethods[VoodooInputMT1UserClientMethodsNumMethods] = { +// { Object, Func pointer, Padding, Flags, Inputs, Outputs } +IOExternalMethodACID VoodooInputWellspringUserClient::sMethods[VoodooInputMT1UserClientMethodsNumMethods] = { // VoodooInputMT1UserClientMethodsSetSendsFrames - {0, reinterpret_cast(&VoodooInputWellspringUserClient::sSetSendFrames), kIOUCScalarIScalarO, 1, 0}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sSetSendFrames, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 1, 0}, // VoodooInputMT1UserClientMethodsGetReport - {0, reinterpret_cast(&VoodooInputWellspringUserClient::sGetReport), kIOUCStructIStructO, sizeof(MTDeviceReportStruct), sizeof(MTDeviceReportStruct)}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sGetReport, kIOExternalMethodACIDPadding, kIOUCStructIStructO, sizeof(MTDeviceReportStruct), sizeof(MTDeviceReportStruct)}, // VoodooInputMT1UserClientMethodsSetReport - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCStructIStructO, 0x208, 0x208}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCStructIStructO, 0x208, 0x208}, // VoodooInputMT1UserClientMethodsSetSendLogs - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 1, 0}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 1, 0}, // VoodooInputMT1UserClientMethodsIssueDriverRequest - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCStructIStructO, 0x204, 0x204}, - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 3, 0}, // Relative Mouse Movement - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 3, 0}, // Scroll Wheel - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 2, 0}, // Keyboard - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 1, 0}, // Map Clicks + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCStructIStructO, 0x204, 0x204}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 3, 0}, // Relative Mouse Movement + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 3, 0}, // Scroll Wheel + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 2, 0}, // Keyboard + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 1, 0}, // Map Clicks // VoodooInputMT1UserClientMethodsRecacheProperties - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 0, 0}, - {0, static_cast(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 3, 0}, // Momentum Scroll + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 0, 0}, + {0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 3, 0}, // Momentum Scroll }; - -#else // __defined(__x86_64__) -// TODO: Switch where padding is in struct +#elif defined(__i386__) +// { Object, Padding, Func pointer, Flags, Inputs, Outputs } +IOExternalMethodACID VoodooInputWellspringUserClient::sMethods[VoodooInputMT1UserClientMethodsNumMethods] = { + // VoodooInputMT1UserClientMethodsSetSendsFrames + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sSetSendFrames, kIOUCScalarIScalarO, 1, 0}, + // VoodooInputMT1UserClientMethodsGetReport + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sGetReport, kIOUCStructIStructO, sizeof(MTDeviceReportStruct), sizeof(MTDeviceReportStruct)}, + // VoodooInputMT1UserClientMethodsSetReport + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCStructIStructO, 0x208, 0x208}, + // VoodooInputMT1UserClientMethodsSetSendLogs + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 1, 0}, + // VoodooInputMT1UserClientMethodsIssueDriverRequest + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCStructIStructO, 0x204, 0x204}, + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 3, 0}, // Relative Mouse Movement + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 3, 0}, // Scroll Wheel + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 2, 0}, // Keyboard + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 1, 0}, // Map Clicks + // VoodooInputMT1UserClientMethodsRecacheProperties + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 0, 0}, + {0, kIOExternalMethodACIDPadding, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOUCScalarIScalarO, 3, 0}, // Momentum Scroll +}; +#else #error "Invalid architecture" #endif // __defined(__x86_64__) @@ -99,31 +118,31 @@ IOExternalMethod *VoodooInputWellspringUserClient::getTargetAndMethodForIndex(IO } *targetP = this; - return const_cast(&sMethods[index]); + return reinterpret_cast(&sMethods[index]); } -IOReturn VoodooInputWellspringUserClient::sSetSendFrames(bool enableReports) { +IOReturn VoodooInputWellspringUserClient::sSetSendFrames(VoodooInputWellspringUserClient *that, bool enableReports) { bool success = true; - IOLog("%s Set Send Frames: %d\n", getName(), enableReports); + IOLog("%s Set Send Frames: %d\n", that->getName(), enableReports); if (enableReports) { - success = simulator->registerUserClient(this); + success = that->simulator->registerUserClient(that); } else { - simulator->unregisterUserClient(this); + that->simulator->unregisterUserClient(that); } return success ? kIOReturnSuccess : kIOReturnError; } // I'm not really sure why they use two different structs here??? -IOReturn VoodooInputWellspringUserClient::sGetReport(MTDeviceReportStruct *input, MTDeviceReportStruct *output) { +IOReturn VoodooInputWellspringUserClient::sGetReport(VoodooInputWellspringUserClient *that, MTDeviceReportStruct *input, MTDeviceReportStruct *output) { if (input == nullptr || output == nullptr) { return kIOReturnBadArgument; } - IOLog("%s Get Report: %d\n", getName(), input->reportId); + IOLog("%s Get Report: %d\n", that->getName(), input->reportId); - IOReturn ret = simulator->getReport(input); + IOReturn ret = that->simulator->getReport(input); if (ret == kIOReturnSuccess) { memmove(output->data, input->data, input->dataSize); output->dataSize = input->dataSize; @@ -137,6 +156,6 @@ void VoodooInputWellspringUserClient::enqueueData(void *data, size_t size) { dataQueue->enqueue(data, (UInt32) size); } -IOReturn VoodooInputWellspringUserClient::sNoop(void *p1, void *p2, void *p3, void *p4, void *p5, void *p6) { +IOReturn VoodooInputWellspringUserClient::sNoop(VoodooInputWellspringUserClient *that, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6) { return kIOReturnSuccess; // noop } diff --git a/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.hpp b/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.hpp index bd6031e..f96426f 100644 --- a/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.hpp +++ b/VoodooInput/VoodooInputWellspringSimulator/VoodooInputWellspringUserClient.hpp @@ -49,9 +49,9 @@ class EXPORT VoodooInputWellspringUserClient : public IOUserClient { virtual IOReturn clientMemoryForType(UInt32 type, IOOptionBits *options, IOMemoryDescriptor **memory) override; virtual IOExternalMethod *getTargetAndMethodForIndex(IOService **targetP, UInt32 index) override; - IOReturn sSetSendFrames(bool enableFrames); - IOReturn sGetReport(MTDeviceReportStruct *input, MTDeviceReportStruct *output); - IOReturn sNoop(void *p1, void *p2, void *p3, void *p4, void *p5, void *p6); + static IOReturn sSetSendFrames(VoodooInputWellspringUserClient *that, bool enableFrames); + static IOReturn sGetReport(VoodooInputWellspringUserClient *that, MTDeviceReportStruct *input, MTDeviceReportStruct *output); + static IOReturn sNoop(VoodooInputWellspringUserClient *that, void *p1, void *p2, void *p3, void *p4, void *p5, void *p6); void enqueueData(void *data, size_t size); private: @@ -61,6 +61,8 @@ class EXPORT VoodooInputWellspringUserClient : public IOUserClient { IOSharedDataQueue *logQueue {nullptr}; IOMemoryDescriptor *dataQueueDesc {nullptr}; IOMemoryDescriptor *logQueueDesc {nullptr}; + + static IOExternalMethodACID sMethods[VoodooInputMT1UserClientMethodsNumMethods]; }; #endif /* VoodooInputMT1UserClient_hpp */