IOMasterPort problem lazarus / 15-macOS - Mac OS X ---------------------------------------------------------------------- dick · 2009-02-03 23:22 Hi, I want write a AP to call driver(Kext), I have written c like that    // Returns the mach port used to initiate communication with IOKit.     kernResult = IOMasterPort(MACH_PORT_NULL, &masterPort);            if (kernResult != KERN_SUCCESS)     {         printf( "IOMasterPort returned %d\n", kernResult);         return 0;     }     is ok on Xcode, but fail on Lazarus, I cannot find IOKit definition. Can give some help ? Thanks Dick ---------------------------------------------------------------------- Phil · 2009-02-04 00:54 Not sure if I understand what you want. Are you trying to rewrite that code in Pascal? If so, what failed on Lazarus? Compiling? Linking? On Mac, you need to link against the IOKit.framework. Thanks. -Phil ---------------------------------------------------------------------- dick · 2009-02-04 01:33 Hi, Phil  yes, I try to rewrite that code in pascal.  In Lazarau , IOMasterPort is included which unit?  In Lazarau , how to link IOKit.framework ?  Many tks Dick ---------------------------------------------------------------------- Phil · 2009-02-04 02:31 On the Linking tab, check Pass Options and enter this in the box: -framework IOKit Or if compiling from the command line with FPC, just add this switch: -k'-framework IOKit' Offhand I doubt if IOKit is in any unit, but you can declare its functions as external just like with any library. See this file: /system/library/frameworks/iokit.framework/version/current/headers/IOK itLib.h Thanks. -Phil ---------------------------------------------------------------------- dick · 2009-02-04 15:27 Hi, Phil I need to rewrite   function IOMasterPort( bootstrapPort:mach_port_t;var masterPort:mach_port_t ):boolean;external name '_IOMasterPort'; Do anyone have IOKit.pas?? Dick ---------------------------------------------------------------------- Phil · 2009-02-04 15:38 I don't believe there is any IOKit.pas. You'll have to define the function externally yourself in Pascal. What you have is a good start. You may need to declare it cdecl if it uses C parameter passing. Also define mach_port and mach_port_t to equivalent Pascal types (maybe LongInt if these are 4-byte types). And maybe the return type should be wider. Thanks. -Phil ---------------------------------------------------------------------- dick · 2009-02-05 00:19 Hi, Phil I understood, I have to define some functions and types by myself . Like C convert to pascal in win32 API. Many tks. Dick