> Could you not do some sort of detection magic, to see if a class name or 
> class exists prior to manually either calling that functions, or using 
> NSBundle to load the plugins ?

In practice, "detection magic" is non-trivial :)  Figuring out what classes a 
bundle will create is tricky.  You get to load the bundle in memory not as an 
executable, parse out the mach-o headery bits, figure out which of the images 
is the one for your process, then parse its objc section to see what it 
defines.  Then (or in parallel) interrogate your current runtime, and make sure 
there are no collisions with the file you're inspecting and what you've already 
got loaded.  And if there are no collisions, you can try to load the image...

...And then you hope that they aren't doing dynamic class creation, because 
you'll have a hard time figuring that out.  And then you resort to inspecting 
their symbol table to see if they're making any objc runtime calls, and you 
hope that they aren't using dyld functions to resolve them, and if they are you 
then have to check for dyld's entry points too, and you also have to hope that 
they aren't divining them by fishing them out by manually traversing their 
in-memory image (which will have some linkage bits for free).

...And then if you're feeling really industrious, you can shim the objc runtime 
calls to create classes, thinking you'll nail them at load time and do 
something sensible.  Except that they can have a load-time C function detect 
and/or modify your shim.  So then you go and muck with madvise and friends to 
see who's messing with your bits, only to find that ultimately everything you 
can do they can undo, and you remember how great protected memory is, and how 
much nicer it would be if we had even more of it :)

I've done stuff that will require one to complete the first paragraph, and a 
sentence or two from the second, and pieces of the third.  It's a tricky 
problem, and there isn't really a good solution to it.  If you're writing an 
App, and you know for certain that you don't need the user's installed plugins, 
it's possible a [QCPlugin dontLoadUserPlugins] method would fix you up, but if 
you're writing middle ware that'll just get in the way of someone else who does 
need them...

--
Christopher Wright
christopher_wri...@apple.com



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      (Quartzcomposer-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to