Closed kernel-dev closed 2 years ago
Had a look at this, two things:
ffi
module to interface w/ IOKit (the same way this package currently uses the ffi to interface w/ the objc runtime).Thank you a lot for the quick response. Apologies for the misleading issue, though, I had originally thought you could bundle it in Obj-C? I remember using it.
Otherwise, thank you. It's immensely appreciated :+1:
An update:
I notice that you are importing frameworks with this format:
/System/Library/Frameworks/{NAME}.framework
;Meaning, IOKit
should technically be applicable to this rule?
It's supposedly an Obj-C framework, as far as I've been told.
It can also be found under /System/Library/Frameworks
:
It imports the framework just fine, but it can't import values from it properly.
A .framework
can contain Objective-C and/or C code. In the case of IOKit, I'd be surprised if it contains any Objective-C code, tbh.
The symbol you tried to access above, IOServiceMatching
, is itself defined as a C function, meaning that, even if IOKit were to contain ObjC code, this package wouldn't be able to access this function.
This package currently only supports accessing Objective-C symbols (primarily classes). You should be able to use the ffi-napi
and ref-napi
packages to interact with IOKit, though. You can have a look at the runtime.js
file to see an example of how this would work. Essentially, you just have to define the signature of the function you want to access, bring in the library from somewhere (this might be the most difficult part, they moved a bunch of frameworks into the shared dyld cache in Big Sur...), and then can call it almost as if it were a "normal" function.
I see!
Thank you for the elaboration, it means a lot :+1:
I'll likely create an IOKit wrapper as a Node lib and share it so that it's more accessible for anyone who wishes to use it 👍
Sorry to contact you over this, but is it possible that I'd be allowed to contact you over Twitter? I've got some questions I'd like to ask regarding my implementations for IOKit that I'm not sure how to resolve; if you have any free time, and are willing to spare your free time to do so.
Thank you in advance.
Sure
After importing IOKit using
objc.import("IOKit")
, it throws an error when attempting to access a function that would otherwise be a part of the library. For example,IOServiceMatching
;Error stack:
Additional information:
21C5021h
)4.4.3
16.9.0
I'm not sure if I'm just doing something incorrectly, or if it's not meant to do this.
UPDATE:
This will also fail, but with a different error:
Stack: