Skip to content

Commit

Permalink
Start trying to add 32bit support
Browse files Browse the repository at this point in the history
This doesn't actually build a 32bit binary yet
  • Loading branch information
1Revenger1 committed Jan 7, 2023
1 parent c5365f0 commit 231b7e1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 33 deletions.
33 changes: 28 additions & 5 deletions VoodooInput.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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;
};
Expand All @@ -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";
Expand Down Expand Up @@ -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;
Expand All @@ -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;
};
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IOMethod>(&VoodooInputWellspringUserClient::sSetSendFrames), kIOUCScalarIScalarO, 1, 0},
{0, (IOMethodACID) &VoodooInputWellspringUserClient::sSetSendFrames, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 1, 0},
// VoodooInputMT1UserClientMethodsGetReport
{0, reinterpret_cast<IOMethod>(&VoodooInputWellspringUserClient::sGetReport), kIOUCStructIStructO, sizeof(MTDeviceReportStruct), sizeof(MTDeviceReportStruct)},
{0, (IOMethodACID) &VoodooInputWellspringUserClient::sGetReport, kIOExternalMethodACIDPadding, kIOUCStructIStructO, sizeof(MTDeviceReportStruct), sizeof(MTDeviceReportStruct)},
// VoodooInputMT1UserClientMethodsSetReport
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCStructIStructO, 0x208, 0x208},
{0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCStructIStructO, 0x208, 0x208},
// VoodooInputMT1UserClientMethodsSetSendLogs
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 1, 0},
{0, (IOMethodACID) &VoodooInputWellspringUserClient::sNoop, kIOExternalMethodACIDPadding, kIOUCScalarIScalarO, 1, 0},
// VoodooInputMT1UserClientMethodsIssueDriverRequest
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCStructIStructO, 0x204, 0x204},
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 3, 0}, // Relative Mouse Movement
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 3, 0}, // Scroll Wheel
{0, static_cast<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 2, 0}, // Keyboard
{0, static_cast<IOMethod>(&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<IOMethod>(&VoodooInputWellspringUserClient::sNoop), kIOUCScalarIScalarO, 0, 0},
{0, static_cast<IOMethod>(&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__)

Expand Down Expand Up @@ -99,31 +118,31 @@ IOExternalMethod *VoodooInputWellspringUserClient::getTargetAndMethodForIndex(IO
}

*targetP = this;
return const_cast<IOExternalMethod *>(&sMethods[index]);
return reinterpret_cast<IOExternalMethod *>(&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;
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 */

0 comments on commit 231b7e1

Please sign in to comment.