def initialize_iokit_functions_and_variables(): """ This handles the importing of specific functions and variables from the IOKit framework. IOKit is not natively bridged in PyObjC, and so the methods must be found and encoded manually to gain their functionality in Python. After calling this function, the following IOKit functions are available: IOServiceGetMatchingServices Look up the registered IOService objects that match the given dict. IODisplayCreateInfoDictionary Returns a dictionary with information about display hardware. IODisplayGetFloatParameter Finds a float value for a given parameter. IODisplaySetFloatParameter Sets a float value for a given parameter. IOServiceMatching Returns a dictionary that specifies an IOService class match. IOIteratorNext Finds the next object in an iteration. And the following variables are available: kIODisplayNoProductName Prevents IODisplayCreateInfoDictionary from including the kIODisplayProductName property. kIOMasterPortDefault The default mach port used to initiate communication with IOKit. kIODisplayBrightnessKey The key used to get brightness from IODisplayGetFloatParameter. kDisplayVendorID kDisplayProductID kDisplaySerialNumber These are keys used to access display information. """ # Grab the IOKit framework. iokit = objc.initFrameworkWrapper( "IOKit", frameworkIdentifier="com.apple.iokit", frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"), globals=globals() ) # These are the functions we're going to need. functions = [ ("IOServiceGetMatchingServices", b"iI@o^I"), ("IODisplayCreateInfoDictionary", b"@II"), ("IODisplayGetFloatParameter", b"iII@o^f"), ("IODisplaySetFloatParameter", b"iII@f"), ("IOServiceMatching", b"@or*", "", dict( # This one is obnoxious. The "*" gets pythonified as a char, not a # char*, so we have to make it interpret as a string. arguments= { 0: dict(type=objc._C_PTR + objc._C_CHAR_AS_TEXT, c_array_delimited_by_null=True, type_modifier=objc._C_IN) } )), ("IOIteratorNext", "II"), ] # Variables we'll need. variables = [ ("kIODisplayNoProductName", b"I"), ("kIOMasterPortDefault", b"I"), ("kIODisplayBrightnessKey", b"*"), ("kDisplayVendorID", b"*"), ("kDisplayProductID", b"*"), ("kDisplaySerialNumber", b"*"), ] # Load the things! objc.loadBundleFunctions(iokit, globals(), functions) objc.loadBundleVariables(iokit, globals(), variables) # Set this key for later use. global kDisplayBrightness kDisplayBrightness = CoreFoundation.CFSTR(kIODisplayBrightnessKey)
def __init__( self, queue_size=1000, btsnooplog_filename="btsnoop.log", log_level="info", data_directory=".", replay=False, ): super(macOSCore, self).__init__( queue_size, btsnooplog_filename, log_level, data_directory=data_directory, replay=replay, ) self.doublecheck = False self.iobe = None self.serial = None if not replay: import objc # type: ignore objc.initFrameworkWrapper( "IOBluetoothExtended", frameworkIdentifier= "de.tu-darmstadt.seemoo.IOBluetoothExtended", frameworkPath=objc.pathForFramework( filepath + "/../macos/IOBluetoothExtended.framework"), globals=globals(), ) self.hciport = -1
def getIOKit(): """ This handles the importing of specific functions and variables from the IOKit framework. IOKit is not natively bridged in PyObjC, so the methods must be found and encoded manually to gain their functionality in Python. :return: A dictionary containing several IOKit functions and variables. """ global iokit if not iokit: # iokit may have already been instantiated, in which case, nothing needs to be done # The dictionary which will contain all of the necessary functions and variables from IOKit iokit = {} # Retrieve the IOKit framework iokitBundle = objc.initFrameworkWrapper( "IOKit", frameworkIdentifier="com.apple.iokit", frameworkPath=objc.pathForFramework( "/System/Library/Frameworks/IOKit.framework"), globals=globals()) # The IOKit functions to be retrieved functions = [ ("IOServiceGetMatchingServices", b"iI@o^I"), ("IODisplayCreateInfoDictionary", b"@II"), ("IODisplayGetFloatParameter", b"iII@o^f"), ("IODisplaySetFloatParameter", b"iII@f"), ("IOServiceRequestProbe", b"iII"), ("IOIteratorNext", b"II"), ] # The IOKit variables to be retrieved variables = [ ("kIODisplayNoProductName", b"I"), ("kIOMasterPortDefault", b"I"), ("kIODisplayOverscanKey", b"*"), ("kDisplayVendorID", b"*"), ("kDisplayProductID", b"*"), ("kDisplaySerialNumber", b"*"), ] # Load functions from IOKit.framework into our iokit objc.loadBundleFunctions(iokitBundle, iokit, functions) # Bridge won't put straight into iokit, so globals() objc.loadBundleVariables(iokitBundle, globals(), variables) # Move only the desired variables into iokit for var in variables: key = "{}".format(var[0]) if key in globals(): iokit[key] = globals()[key] # A few IOKit variables that have been deprecated, but whose values # still work as intended in IOKit functions iokit["kDisplayBrightness"] = CoreFoundation.CFSTR("brightness") iokit["kDisplayUnderscan"] = CoreFoundation.CFSTR("pscn") return iokit
''' Python mapping for the SystemConfiguration framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper("SystemConfiguration", frameworkIdentifier="com.apple.SystemConfiguration", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/SystemConfiguration.framework"), globals=globals()) from SystemConfiguration._manual import * SCBondInterfaceRef = SCNetworkInterfaceRef SCVLANInterfaceRef = SCNetworkInterfaceRef
''' Python mapping for the CoreLocation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "CoreLocation", frameworkIdentifier="com.apple.corelocation", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreLocation.framework"), globals=globals())
''' Python mapping for the SearchKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreFoundation import * __bundle__ = _objc.initFrameworkWrapper( "SearchKit", frameworkIdentifier="com.apple.SearchKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework" ), globals=globals()) try: SKIndexGetTypeID SKDocumentRef except NameError: # SKIndexGetTypeID is documented, but not actually exported by Leopard. Try to # emulate the missing functionality. # # See also radar:6525606. # def workaround(): from Foundation import NSMutableData, NSAutoreleasePool
''' Python mapping for the InstallerPlugins framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper("InstallerPlugins", frameworkIdentifier="com.apple.InstallerPlugins", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/InstallerPlugins.framework"), globals=globals())
''' Python mapping for the InputMethodKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc #import Carbon from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "InputMethodKit", frameworkIdentifier="com.apple.InputMethodKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/InputMethodKit.framework"), globals=globals())
""" Python mapping for the XgridFoundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. """ import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "XgridFoundation", frameworkIdentifier="com.apple.xgrid.foundation", frameworkPath=_objc.pathForFramework("/System/Library/Frameworks/XgridFoundation.framework"), globals=globals(), )
''' Python mapping for the CoreFoundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc import CoreFoundation._inlines __bundle__ = _objc.initFrameworkWrapper("CoreFoundation", frameworkIdentifier="com.apple.CoreFoundation", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreFoundation.framework"), globals=globals(), scan_classes=False) #from CoreFoundation._CFArray import * from CoreFoundation._CFBag import * from CoreFoundation._CFBinaryHeap import * from CoreFoundation._CFBitVector import * from CoreFoundation._CFCalendar import * from CoreFoundation._CFDictionary import * from CoreFoundation._CFTree import * from CoreFoundation._CFFileDescriptor import * from CoreFoundation._CFMachPort import * from CoreFoundation._CFMessagePort import * from CoreFoundation._CFNumber import * from CoreFoundation._CFReadStream import *
''' Python mapping for the JavaScriptCore framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreFoundation import * __bundle__ = _objc.initFrameworkWrapper( "JavaScriptCore", frameworkIdentifier="com.apple.JavaScriptCore", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/WebKit.framework/Frameworks/JavaScriptCore.framework" ), globals=globals())
''' Python mapping for the ImageKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * from Foundation import * #from Quartz.QuartzCore import * __bundle__ = _objc.initFrameworkWrapper( "ImageKit", frameworkIdentifier="com.apple.imageKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/Quartz.framework/Frameworks/ImageKit.framework" ), frameworkResourceName="Quartz.ImageKit", globals=globals())
""" Python mapping for the CoreVideo framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. """ import objc as _objc from CoreFoundation import * __bundle__ = _objc.initFrameworkWrapper( "CoreVideo", frameworkIdentifier="com.apple.CoreVideo", frameworkPath=_objc.pathForFramework("/System/Library/Frameworks/CoreVideo.framework"), globals=globals(), frameworkResourceName="Quartz.CoreVideo", scan_classes=False, ) from Quartz.CoreVideo._CVPixelBuffer import *
import sys sys.path.insert(0, sys.argv[1]) import objc if not objc.__file__.startswith(sys.argv[1]): print("Loaded objc from unexpected path") sys.exit(1) passed = True g = {} objc.initFrameworkWrapper("AddressBook", "/System/Library/Frameworks/AddressBook.framework", "com.apple.AddressBook.framework", g, scan_classes=False) if 'ABAddPropertiesAndTypes' not in g: print("Cannot find 'ABAddPropertiesAndTypes'") passed = False else: func = g['ABAddPropertiesAndTypes'] if not isinstance(func, objc.function): print("'ABAddPropertiesAndTypes' not an objc.function") passed = False else: if func.__metadata__() != { 'retval': { 'already_retained': False, 'already_cfretained': False,
''' Python mapping for the LaunchServices framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * #import AE #import CoreServices try: __bundle__ = _objc.initFrameworkWrapper("LaunchServices", frameworkIdentifier="com.apple.LaunchServices", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework"), globals=globals()) except ImportError: __bundle__ = _objc.initFrameworkWrapper("LaunchServices", frameworkIdentifier="com.apple.LaunchServices", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework"), globals=globals()) # # Load an undocumented, yet announced function. This function was announced # in TN2029 (http://developer.apple.com/technotes/tn/tn2029.html) _objc.loadBundleFunctions( __bundle__, globals(),
''' Python mapping for the Foundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc __bundle__ = _objc.initFrameworkWrapper("CGL", frameworkIdentifier="com.apple.opengl", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/OpenGL.framework"), globals=globals())
frameworkIdentifier="com.apple.IOBluetooth", frameworkPath=objc.pathForFramework( "/System/Library/Frameworks/IOBluetooth.framework" ), metadict=globals()) locals_ = locals() for variable_name in dir(io_bluetooth): locals_[variable_name] = getattr(io_bluetooth, variable_name) else: try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper("IOBluetooth", frameworkIdentifier="com.apple.IOBluetooth", frameworkPath=objc.pathForFramework( "/System/Library/Frameworks/IOBluetooth.framework"), globals=globals()) except (AttributeError, ValueError): # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("IOBluetooth", globals(), bundle_path=objc.pathForFramework('/System/Library/Frameworks/IOBluetooth.framework')) # Sets selector signatures in order to receive arguments correctly from # PyObjC methods. These MUST be set, otherwise the method calls won't work # at all, mostly because you can't pass by pointers in Python. # set to return int, and take an unsigned char output arg # i.e. in python: return (int, unsigned char) and accept no args
''' Python mapping for the ScreenSaver framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * from ScreenSaver._inlines import _inline_list_ __bundle__ = _objc.initFrameworkWrapper("ScreenSaver", frameworkIdentifier="com.apple.ScreenSaver", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ScreenSaver.framework"), globals=globals(), inlineTab=_inline_list_)
''' Python mapping for the WebKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper("WebKit", frameworkIdentifier="com.apple.WebKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/WebKit.framework"), globals=globals())
# pylint: enable=no-name-in-module class AttrDict(dict): """Attribute Dictionary""" __getattr__ = dict.__getitem__ __setattr__ = dict.__setitem__ NetFS = AttrDict() # pylint: disable=invalid-name # Can cheat and provide 'None' for the identifier, it'll just use # frameworkPath instead. # scan_classes=False means only add the contents of this Framework. # pylint: disable=invalid-name NetFS_bundle = initFrameworkWrapper( 'NetFS', frameworkIdentifier=None, frameworkPath=pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False) # pylint: enable=invalid-name # https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html # Fix NetFSMountURLSync signature del NetFS['NetFSMountURLSync'] loadBundleFunctions(NetFS_bundle, NetFS, [('NetFSMountURLSync', b'i@@@@@@o^@')]) def mount_share(share_path): """Mounts a share at /Volumes Args: share_path: String URL with all auth info to connect to file share.
import sys import objc sys.path.insert(0, sys.argv[1]) if not objc.__file__.startswith(sys.argv[1]): print("Loaded objc from unexpected path") sys.exit(1) passed = True g = {} objc.initFrameworkWrapper( "AddressBook", "/System/Library/Frameworks/AddressBook.framework", "com.apple.AddressBook.framework", g, scan_classes=False, ) if "ABAddPropertiesAndTypes" not in g: print("Cannot find 'ABAddPropertiesAndTypes'") passed = False else: func = g["ABAddPropertiesAndTypes"] if not isinstance(func, objc.function): print("'ABAddPropertiesAndTypes' not an objc.function") passed = False else:
import os # import subprocess import objc as _objc # basepath = subprocess.run(["xcode-select", "-p"], # capture_output=True).stdout.decode("utf8").strip() # macossdk="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" basepath = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer" macossdk = os.path.join(basepath, "SDKs", "MacOSX.sdk") name = "MetalKit" p = os.path.join(macossdk, "System", "Library", "Frameworks", name + ".framework") if not os.path.isdir(p): raise Exception("framework path does not exists: " + p) __bundle__ = _objc.initFrameworkWrapper( name, frameworkIdentifier="com.apple." + name, frameworkPath=_objc.pathForFramework(p), globals=globals())
''' Python mapping for the SyncServices framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreData import * __bundle__ = _objc.initFrameworkWrapper("SyncServices", frameworkIdentifier="com.apple.syncservices", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/SyncServices.framework"), globals=globals())
''' Python mapping for the BWToolkit framework. ''' import objc as _objc __bundle__ = _objc.initFrameworkWrapper("BWToolkitFramework", frameworkIdentifier="com.brandonwalkin.BWToolkitFramework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/BWToolkitFramework.framework"), globals=globals())
See http://pyobjc.sourceforge.net for details on how to access Objective-C classes through PyObjC. """ import objc import os.path _FRAMEWORK_PATH = u'/Library/Frameworks/LightAquaBlue.framework' if not os.path.isdir(_FRAMEWORK_PATH): raise ImportError("Cannot load LightAquaBlue framework, not found at" + \ _FRAMEWORK_PATH) try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper("LightAquaBlue", frameworkIdentifier="com.blammit.LightAquaBlue", frameworkPath=objc.pathForFramework(_FRAMEWORK_PATH), globals=globals()) except AttributeError: # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("LightAquaBlue", globals(), bundle_path=objc.pathForFramework(_FRAMEWORK_PATH)) # return int, take (object, object, object, output unsigned char, output int) # i.e. in python: return (int, char, int), take (object, object, object) objc.setSignatureForSelector("BBServiceAdvertiser", "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:", "i@0:@@@o^Co^I") # set to take (6-char array, unsigned char, object)
''' Python mapping for the AddressBook framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper("AddressBook", frameworkIdentifier="com.apple.AddressBook.framework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/AddressBook.framework"), globals=globals()) # Implementation of functions that cannot be wrapped automaticly. #from AddressBook._callback import *
""" Python mapping for the AppKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. """ import objc as _objc from Foundation import * from AppKit._inlines import _inline_list_ __bundle__ = _objc.initFrameworkWrapper( "AppKit", frameworkIdentifier="com.apple.AppKit", frameworkPath=_objc.pathForFramework("/System/Library/Frameworks/AppKit.framework"), globals=globals(), inlineTab=_inline_list_, ) # NSApp is a global variable that can be changed in ObjC, # somewhat emulate that (it is *not* possible to assign to # NSApp in Python) from AppKit._nsapp import NSApp # Import some manually maintained helper code: from AppKit._appmain import * from AppKit._nsbezierpath import * from AppKit._nsfont import * from AppKit._nsquickdrawview import * from AppKit._nsbezierpath import *
''' Python mapping for the CoreLocation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper("CoreLocation", frameworkIdentifier="com.apple.corelocation", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreLocation.framework"), globals=globals())
''' Python mapping for the Foundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc #import ApplicationServices from CoreFoundation import * from Foundation._inlines import _inline_list_ __bundle__ = _objc.initFrameworkWrapper("Foundation", frameworkIdentifier="com.apple.Foundation", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/Foundation.framework"), globals=globals(), inlineTab=_inline_list_) # Import the various manually maintained bits: from Foundation._functiondefines import * from Foundation._NSDecimal import * from Foundation._nsinvocation import * from Foundation._functioncallbacks import * from Foundation._typecode import * from Foundation._nscoder import * from Foundation._data import * from Foundation._netservice import * from Foundation._string import * import Foundation._nsobject
''' Python mapping for the InterfaceBuilderKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper("InterfaceBuilderKit", frameworkIdentifier="com.apple.InterfaceBuilderKit", frameworkPath=_objc.pathForFramework( "/Developer/Library/Frameworks/InterfaceBuilderKit.framework"), globals=globals())
''' Python mapping for the InstallerPlugins framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper( "InstallerPlugins", frameworkIdentifier="com.apple.InstallerPlugins", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/InstallerPlugins.framework"), globals=globals())
This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' __version__ = "Custom" import objc as _objc from Foundation import * from AppKit._inlines import _inline_list_ __bundle__ = _objc.initFrameworkWrapper( "AppKit", frameworkIdentifier="com.apple.AppKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/AppKit.framework"), globals=globals(), inlineTab=_inline_list_) # NSApp is a global variable that can be changed in ObjC, # somewhat emulate that (it is *not* possible to assign to # NSApp in Python) from AppKit._nsapp import NSApp # Import some manually maintained helper code: from AppKit._appmain import * from AppKit._nsbezierpath import * from AppKit._nsfont import * from AppKit._nsquickdrawview import * from AppKit._nsbezierpath import *
''' Python mapping for the CalendarStore framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "CalendarStore", frameworkIdentifier="com.apple.CalendarStore", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CalendarStore.framework"), globals=globals())
''' Python mapping for the ImageIO framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc import CoreFoundation #from Quartz.CoreGraphics import * __bundle__ = _objc.initFrameworkWrapper( "ImageIO", frameworkIdentifier="com.apple.ImageIO.framework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ImageIO.framework" ), globals=globals(), frameworkResourceName="Quartz.ImageIO", scan_classes=False)
''' Python mapping for the PreferencePanes framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper("PreferencePanes", frameworkIdentifier="com.apple.frameworks.preferencepanes", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/PreferencePanes.framework"), globals=globals())
''' Python mapping for the PreferencePanes framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper( "PreferencePanes", frameworkIdentifier="com.apple.frameworks.preferencepanes", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/PreferencePanes.framework"), globals=globals())
""" Python mapping for the Foundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. """ import objc as _objc __bundle__ = _objc.initFrameworkWrapper( "CGL", frameworkIdentifier="com.apple.opengl", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/OpenGL.framework"), globals=globals(), )
''' Python mapping for the Message framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "Message", frameworkIdentifier="com.apple.MessageFramework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/Message.framework"), globals=globals())
''' Python mapping for the ExceptionHandling framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper("ExceptionHandling", frameworkIdentifier="com.apple.ExceptionHandling", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ExceptionHandling.framework"), globals=globals())
#!/usr/bin/python import objc name = 'TouchSQL' path = '/Users/schwa/Library/Frameworks/TouchSQL.framework' identifier = 'com.touchcode.TouchSQL' d = dict() x = objc.initFrameworkWrapper(frameworkName=name, frameworkPath=path, frameworkIdentifier=identifier, globals=globals())
""" import objc import os.path _FRAMEWORK_PATH = os.path.expanduser( '~') + u'/Library/Frameworks/LightAquaBlue.framework' if not os.path.isdir(_FRAMEWORK_PATH): raise ImportError("Cannot load LightAquaBlue framework, not found at" + \ _FRAMEWORK_PATH) try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper( "LightAquaBlue", frameworkIdentifier="com.blammit.LightAquaBlue", frameworkPath=objc.pathForFramework(_FRAMEWORK_PATH), globals=globals()) except AttributeError: # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("LightAquaBlue", globals(), bundle_path=objc.pathForFramework(_FRAMEWORK_PATH)) # return int, take (object, object, object, output unsigned char, output int) # i.e. in python: return (int, char, int), take (object, object, object) objc.setSignatureForSelector( "BBServiceAdvertiser", "addRFCOMMServiceDictionary:withName:UUID:channelID:serviceRecordHandle:",
import objc as _objc __bundle__ = _objc.initFrameworkWrapper( "OpenDirectory", frameworkIdentifier="com.apple.OpenDirectory", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/OpenDirectory.framework" ), globals=globals() )
''' Python mapping for the AppleScriptObjC framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * __bundle__ = _objc.initFrameworkWrapper( "AppleScriptObjC", frameworkIdentifier="com.apple.AppleScriptObjC", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/AppleScriptObjC.framework"), globals=globals())
ES_CONTINUOUS = 0x80000000 ES_SYSTEM_REQUIRED = 0x00000001 ES_AWAYMODE_REQUIRED = 0x00000040 #SetThreadExecutionState returns 0 when failed, which is ignored. The function should be supported from windows XP and up. if prevent: # For Vista and up we use ES_AWAYMODE_REQUIRED to prevent a print from failing if the PC does go to sleep # As it's not supported on XP, we catch the error and fallback to using ES_SYSTEM_REQUIRED only if ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_AWAYMODE_REQUIRED) == 0: ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED) else: ctypes.windll.kernel32.SetThreadExecutionState(ES_CONTINUOUS) elif sys.platform.startswith('darwin'): import objc bundle = objc.initFrameworkWrapper("IOKit", frameworkIdentifier="com.apple.iokit", frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"), globals=globals()) foo = objc.loadBundleFunctions(bundle, globals(), [("IOPMAssertionCreateWithName", b"i@I@o^I")]) foo = objc.loadBundleFunctions(bundle, globals(), [("IOPMAssertionRelease", b"iI")]) def preventComputerFromSleeping(frame, prevent): if prevent: success, preventComputerFromSleeping.assertionID = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, "Cura is printing", None) if success != kIOReturnSuccess: preventComputerFromSleeping.assertionID = None else: if hasattr(preventComputerFromSleeping, "assertionID"): if preventComputerFromSleeping.assertionID is not None: IOPMAssertionRelease(preventComputerFromSleeping.assertionID) preventComputerFromSleeping.assertionID = None else: def preventComputerFromSleeping(frame, prevent):
''' Python mapping for the ServiceManagement framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreFoundation import * #from Security import * __bundle__ = _objc.initFrameworkWrapper( "ServiceManagement", frameworkIdentifier="com.apple.bsd.ServiceManagement", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ServiceManagement.framework"), globals=globals())
''' Python mapping for the LatentSemanticMapping framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from Foundation import * #import CoreServices __bundle__ = _objc.initFrameworkWrapper("LatentSemanticMapping", frameworkIdentifier="com.apple.speech.LatentSemanticMappingFramework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/LatentSemanticMapping.framework"), globals=globals())
('LSSharedFileListInsertItemURL', '^{OpaqueLSSharedFileListItemRef=}^{OpaqueLSSharedFileListRef=}^{OpaqueLSSharedFileListItemRef=}^{__CFString=}^{OpaqueIconRef=}^{__CFURL=}^{__CFDictionary=}^{__CFArray=}'), ('kLSSharedFileListItemBeforeFirst', '^{OpaqueLSSharedFileListItemRef=}'),] loadBundleFunctions(SFL_bundle, globals(), functions) else: from LaunchServices import kLSSharedFileListItemBeforeFirst, LSSharedFileListCreate, LSSharedFileListCopySnapshot, LSSharedFileListItemCopyDisplayName, LSSharedFileListItemResolve, LSSharedFileListItemMove, LSSharedFileListItemRemove, LSSharedFileListRemoveAllItems, LSSharedFileListInsertItemURL # Shoutout to Mike Lynn for the mount_share function below, allowing for the scripting of mounting network shares. # See his blog post for more details: http://michaellynn.github.io/2015/08/08/learn-you-a-better-pyobjc-bridgesupport-signature/ class attrdict(dict): __getattr__ = dict.__getitem__ __setattr__ = dict.__setitem__ NetFS = attrdict() # Can cheat and provide 'None' for the identifier, it'll just use frameworkPath instead # scan_classes=False means only add the contents of this Framework NetFS_bundle = initFrameworkWrapper('NetFS', frameworkIdentifier=None, frameworkPath=pathForFramework('NetFS.framework'), globals=NetFS, scan_classes=False) def mount_share(share_path): # Mounts a share at /Volumes, returns the mount point or raises an error sh_url = CFURLCreateWithString(None, share_path, None) # Set UI to reduced interaction open_options = {NetFS.kNAUIOptionKey: NetFS.kNAUIOptionNoUI} # Allow mounting sub-directories of root shares mount_options = {NetFS.kNetFSAllowSubMountsKey: True} # Mount! result, output = NetFS.NetFSMountURLSync(sh_url, None, None, None, open_options, mount_options, None) # Check if it worked if result != 0: raise Exception('Error mounting url "%s": %s' % (share_path, output)) # Return the mountpath return str(output[0])
''' Python mapping for the CoreFoundation framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreFoundation._inlines import _inline_list_ __bundle__ = _objc.initFrameworkWrapper( "CoreFoundation", frameworkIdentifier="com.apple.CoreFoundation", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreFoundation.framework"), globals=globals(), scan_classes=False, inlineTab=_inline_list_) from CoreFoundation._CoreFoundation import * # # 'Emulation' for CFArray contructors # def _setup(): NSArray = objc.lookUpClass('NSArray') NSMutableArray = objc.lookUpClass('NSMutableArray') def CFArrayCreate(allocator, values, numvalues, callbacks):
''' Python mapping for the SearchKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from CoreFoundation import * __bundle__ = _objc.initFrameworkWrapper("SearchKit", frameworkIdentifier="com.apple.SearchKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/CoreServices.framework/Frameworks/SearchKit.framework"), globals=globals()) try: SKIndexGetTypeID except NameError: # SKIndexGetTypeID is documented, but not actually exported by Leopard. Try to # emulate the missing functionality. # # See also radar:6525606. # def workaround(): from Foundation import NSMutableData, NSAutoreleasePool pool = NSAutoreleasePool.alloc().init() try: rI = SKIndexCreateWithMutableData(NSMutableData.data(),
''' Python mapping for the CoreText framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc #import ATS from CoreFoundation import * import Foundation from Quartz import * __bundle__ = _objc.initFrameworkWrapper( "CoreText", frameworkIdentifier="com.apple.CoreText", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreText.framework" ), globals=globals()) from CoreText._manual import *
Nokia 6600 >>> See http://developer.apple.com/documentation/DeviceDrivers/Reference/IOBluetoothUI/index.html for Apple's IOBluetoothUI documentation. See http://pyobjc.sourceforge.net for details on how to access Objective-C classes through PyObjC. """ import objc try: # mac os 10.5 loads frameworks using bridgesupport metadata __bundle__ = objc.initFrameworkWrapper( "IOBluetoothUI", frameworkIdentifier="com.apple.IOBluetoothUI", frameworkPath=objc.pathForFramework( "/System/Library/Frameworks/IOBluetoothUI.framework"), globals=globals()) except AttributeError: # earlier versions use loadBundle() and setSignatureForSelector() objc.loadBundle("IOBluetoothUI", globals(), bundle_path=objc.pathForFramework( u'/System/Library/Frameworks/IOBluetoothUI.framework')) del objc
''' Python mapping for the Automator framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * __bundle__ = _objc.initFrameworkWrapper( "Automator", frameworkIdentifier="com.apple.AutomatorFramework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/Automator.framework"), globals=globals())
''' Python mapping for the ImageKit framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc from AppKit import * from Foundation import * #from Quartz.QuartzCore import * __bundle__ = _objc.initFrameworkWrapper("ImageKit", frameworkIdentifier="com.apple.imageKit", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/Quartz.framework/Frameworks/ImageKit.framework"), frameworkResourceName="Quartz.ImageKit", globals=globals())
import socket import Queue import hci from pwn import * from core import InternalBlue import objc import binascii import os filepath = os.path.dirname(os.path.abspath(__file__)) objc.initFrameworkWrapper("IOBluetoothExtended", frameworkIdentifier="de.tu-darmstadt.seemoo.IOBluetoothExtended", frameworkPath=objc.pathForFramework(filepath+"/../macos-framework/IOBluetoothExtended.framework"), globals=globals()) class macOSCore(InternalBlue): NSNotificationCenter = objc.lookUpClass('NSNotificationCenter') def __init__(self, queue_size=1000, btsnooplog_filename='btsnoop.log', log_level='info', fix_binutils='True', data_directory="."): super(macOSCore, self).__init__(queue_size, btsnooplog_filename, log_level, fix_binutils, data_directory=".") self.doublecheck = False self.iobe = None def device_list(self): """ Get a list of connected devices """
''' Python mapping for the ImageIO framework. This module does not contain docstrings for the wrapped code, check Apple's documentation for details on how to use these functions and classes. ''' import objc as _objc import CoreFoundation #from Quartz.CoreGraphics import * __bundle__ = _objc.initFrameworkWrapper("ImageIO", frameworkIdentifier="com.apple.ImageIO.framework", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/ImageIO.framework"), globals=globals(), frameworkResourceName="Quartz.ImageIO", scan_classes=False)
from subprocess import Popen, PIPE import getopt import os import sys import traceback import uuid import xml.parsers.expat """ OpenDirectory.framework """ import objc as _objc __bundle__ = _objc.initFrameworkWrapper( "OpenDirectory", frameworkIdentifier="com.apple.OpenDirectory", frameworkPath=_objc.pathForFramework( "/System/Library/Frameworks/OpenDirectory.framework"), globals=globals()) # DS attributes we need kDSStdRecordTypeUsers = "dsRecTypeStandard:Users" kDSStdRecordTypeGroups = "dsRecTypeStandard:Groups" kDSStdRecordTypePlaces = "dsRecTypeStandard:Places" kDSStdRecordTypeResources = "dsRecTypeStandard:Resources" kDS1AttrGeneratedUID = "dsAttrTypeStandard:GeneratedUID" kDSNAttrRecordName = "dsAttrTypeStandard:RecordName" eDSExact = 0x2001 sys_root = "/Applications/Server.app/Contents/ServerRoot"
#!/usr/bin/python import objc name = 'TouchSQL' path = '/Users/schwa/Library/Frameworks/TouchSQL.framework' identifier = 'com.touchcode.TouchSQL' d = dict() x = objc.initFrameworkWrapper(frameworkName = name, frameworkPath = path, frameworkIdentifier = identifier, globals = globals())