Adding IOConnectCallMethod simple examples

This commit is contained in:
Karmaz95
2024-12-25 01:29:41 +01:00
parent a49923016b
commit 24cd4ccb58
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#include <IOKit/IOKitLib.h>
#include <stdio.h>
int main() {
// Get service
io_service_t service = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("AppleJPEGDriver"));
// Connect to service
io_connect_t connect;
kern_return_t kr = IOServiceOpen(service, mach_task_self(), 1, &connect);
IOObjectRelease(service);
// Call external method
kr = IOConnectCallMethod(connect, 0, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL);
printf("Method call result: 0x%x\n", kr);
// Cleanup
IOServiceClose(connect);
return 0;
}

View File

@@ -0,0 +1,10 @@
import iokitlib
# Get service and connect
iokit = iokitlib.iokit()
conn = iokit.open_service(b"AppleJPEGDriver", 1)
print(f"Connection handle: {conn}")
# Call external method
kr = iokit.connect_call_method(conn, 0, None, None, None, None)
print(f"Method call result: {kr}")