Hello,
I've made a program that handles doing a registration dialog for our protected
apps. The protection works by encrypting the original Mach-O executable and
attaching a stub. This stub attempts to load a licence file. If it's not
present, it vfork()/execve()'s this app.
A typical protected app bundle looks like so:
ProtectedApp.app
+- Contents
+- MacOS
| +- ProtectedApp (the original app's binary, now protected)
| +- RegDialog (the binary for the registration dialog)
+- Resources
+- RegDialog.nib
+- <whatever else the app had in here>
The info.plist remains unchanged from the original ProtectedApp.app. The only
changes are to the app's executable, and the addition of the RegDialog
executable and it's nib.
On 10.5, this works fine, when the protected app invokes RegDialog it functions
normally.
On 10.4, when RegDialog is run, no icon appears in the Dock, and although the
window in RegDialog appears, the window does not get made frontmost and does
not get focus. Keyboard focus doesn't work even if you click in text fields,
and as such the dialog is unusable.
I am not using NSApplicationMain() as this would attempt to load the original
app's nib. Instead I do this:
int main(int argc, char *argv[])
{
[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
if ([NSBundle loadNibNamed:@"RegDialog" owner:NSApp]) // Load our
bundle
{
NSData *icon_data = [NSData dataWithBytes:Security_icns_data
length:sizeof(Security_icns_data)];
NSImage *icon = [[NSImage alloc] initWithData:icon_data];
if (icon)
[NSApp setApplicationIconImage:icon];
[NSApp run];
}
else
{
ShowDialog(NSCriticalAlertStyle, "Couldn't load
RegDialog.nib\n\nTry reinstalling the application. If this fails please contact
Support.");
return 1; // Stop stub relaunching us
}
return 0;
}
As you can see, I load the nib myself. I also set a custom icon from data
embedded in the executable, but that's not important. ShowDialog is a routine
that uses an NSAlert to display a dialog.
A similar effect occurs on 10.5 if i just have a RegDialog binary and
RegDialog.nib in the same folder, and I run RegDialog from Terminal. It opens
and loads but the window doesn't get focus.
Inside it's own bundle, RegDialog.app, it all works, but I don't really want to
have to drop an app bundle inside the protected app's bundle to make it work.
What's going on? What is NSApp trying to do that falls over when it's not in a
bundle, or in another apps bundle on 10.4?
--
Best regards,
Peter mailto:[email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]