Changeset 219 for trunk


Ignore:
Timestamp:
05/09/06 09:13:54 (18 years ago)
Author:
rchin
Message:

Fixed commit of nib file.

Added support for automatic injection into apps.

Location:
trunk/Cocoa/F-Script Anywhere/Source
Files:
1 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cocoa/F-Script Anywhere/Source/English.lproj/MainMenu.nib/info.nib

    r217 r219  
    44<dict>
    55        <key>IBDocumentLocation</key>
    6         <string>113 87 356 240 0 0 1280 1002 </string>
     6        <string>133 139 356 240 0 0 1440 878 </string>
    77        <key>IBEditorPositions</key>
    88        <dict>
    99                <key>29</key>
    10                 <string>53 213 232 44 0 0 1280 1002 </string>
     10                <string>61 185 232 44 0 0 1440 878 </string>
    1111        </dict>
    1212        <key>IBFramework Version</key>
     
    1818        </array>
    1919        <key>IBSystem Version</key>
    20         <string>8H14</string>
     20        <string>8I1119</string>
    2121</dict>
    2222</plist>
  • trunk/Cocoa/F-Script Anywhere/Source/F-Script Anywhere.xcodeproj/project.pbxproj

    r218 r219  
    869869                        isa = XCBuildConfiguration;
    870870                        buildSettings = {
     871                                ARCHS = (
     872                                        ppc,
     873                                        i386,
     874                                );
    871875                                COPY_PHASE_STRIP = YES;
    872876                                FRAMEWORK_SEARCH_PATHS = /Volumes/Ti/Library/Frameworks;
     
    922926                        isa = XCBuildConfiguration;
    923927                        buildSettings = {
     928                                ARCHS = (
     929                                        ppc,
     930                                        i386,
     931                                );
    924932                                COPY_PHASE_STRIP = YES;
    925933                                GCC_ENABLE_FIX_AND_CONTINUE = NO;
     
    988996                        isa = XCBuildConfiguration;
    989997                        buildSettings = {
     998                                ARCHS = (
     999                                        ppc,
     1000                                        i386,
     1001                                );
    9901002                                COPY_PHASE_STRIP = YES;
    9911003                                FRAMEWORK_SEARCH_PATHS = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
  • trunk/Cocoa/F-Script Anywhere/Source/FSAAppList.h

    r153 r219  
    3434    NSMutableDictionary *appsByPID;
    3535    NSMutableSet *patchedApps;
    36     NSMutableSet *patchingApps;   
     36    NSMutableSet *patchingApps;
     37        NSMutableArray *alwaysApps;
    3738    IBOutlet NSButton *installButton;
    3839    IBOutlet NSTableView *tableView;
     40        BOOL finishedLaunch;
    3941}
    4042
  • trunk/Cocoa/F-Script Anywhere/Source/FSAAppList.m

    r153 r219  
    2525*/
    2626
     27#include <sys/types.h>
     28#include <sys/sysctl.h>
    2729#import "FSAAppList.h"
    2830#import "FSAnywhere.h"
     
    3941NSString * const FSATableColumnIdentifier_appNameAndIcon = @"appNameAndIcon";
    4042NSString * const FSATableColumnIdentifier_checkMark = @"checkMark";
     43NSString * const FSATableColumnIdentifier_always = @"always";
    4144
    4245NSString *FSACheckMarkCharacter;
     
    5255    NULL
    5356};
     57
     58static int sysctlbyname_with_pid (const char *name, pid_t pid,
     59                                                                  void *oldp, size_t *oldlenp,
     60                                                                  void *newp, size_t newlen);
     61int is_pid_native (pid_t pid);
    5462
    5563@implementation FSAAppList
     
    8492    patchingApps = [[NSMutableSet alloc] init];
    8593    appsByPID = [[NSMutableDictionary alloc] init];
     94        if(!([[NSUserDefaults standardUserDefaults] objectForKey:@"AlwaysApps"]))
     95                alwaysApps = [[NSMutableArray array] retain];
     96        else
     97                alwaysApps = [[NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"AlwaysApps"]] retain];
    8698
    8799    [[tableView tableColumnWithIdentifier: FSATableColumnIdentifier_appNameAndIcon]
     
    91103            setDataCell: [[[NSImageCell alloc] init] autorelease]];
    92104    [window setResizeIncrements: NSMakeSize(1, [tableView cellHeight])];
     105        [tableView setTarget:self];
     106        [tableView setAction:@selector(clickInTable:)];
    93107
    94108    [self update];
     
    169183        return NO;
    170184    return appContainsLibMatching([bundleExecutableLoc fileSystemRepresentation], FSACocoaFrameworks);
     185}
     186
     187-(BOOL)appIsNative:(DeVercruesseProcess *)app
     188{
     189        return is_pid_native([app pid]);
    171190}
    172191
     
    212231         ( ( [app isCocoa] && ![self appIsPEF: app]) ||
    213232           ( [app isCarbon] && [self appIsCocoa: app]))) {
    214         [cocoaApps addObject: app];
    215     }
    216     [appsByPID setObject: app forKey: [NSNumber numberWithInt: [app pid]]];
     233                if([self appIsNative:app]){
     234                        [cocoaApps addObject: app];
     235                        if(finishedLaunch){
     236                                if([alwaysApps containsObject:[app name]] && ![patchedApps containsObject:app])
     237                                        [NSApp installBundleInAppWithPID:[app pid]];
     238                        }
     239                }
     240    }
     241    [appsByPID setObject: app forKey: [NSNumber numberWithInt: [app pid]]];     
    217242}
    218243
     
    333358                return FSAEllipsisImage;
    334359        }
    335     }
     360    } else if([columnIdentifier isEqualToString:FSATableColumnIdentifier_always]){
     361                if([alwaysApps containsObject:[[cocoaApps objectAtIndex: rowIndex] name]])
     362                        return [NSNumber numberWithBool:YES];
     363                else
     364                        return [NSNumber numberWithBool:NO];
     365        }
    336366    return nil;
    337367}
     
    418448}
    419449
     450- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
     451{
     452        id anApp;
     453        id e = [cocoaApps objectEnumerator];
     454        while(anApp = [e nextObject]){
     455                if([alwaysApps containsObject:[anApp name]] && ![patchedApps containsObject:anApp]){
     456                        [NSApp installBundleInAppWithPID:[anApp pid]];
     457                }
     458        }
     459        finishedLaunch = YES;
     460}
     461
    420462- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender;
    421463{
     
    423465}
    424466
     467-(void)clickInTable:(id)sender
     468{
     469        if([sender clickedColumn] == 2){
     470                if([sender clickedRow] >= 0){
     471                        NSString *appName = [[cocoaApps objectAtIndex:[sender clickedRow]] name];
     472                        if(![alwaysApps containsObject:appName]){
     473                                [NSApp installBundleInAppWithPID:[appName pid]];
     474                                [alwaysApps addObject:appName];
     475                        } else
     476                                [alwaysApps removeObject:appName];
     477                        [[NSUserDefaults standardUserDefaults] setObject:alwaysApps forKey:@"AlwaysApps"];
     478                }
     479        }
     480}
     481
    425482@end
     483
     484static int sysctlbyname_with_pid (const char *name, pid_t pid,
     485                                                                  void *oldp, size_t *oldlenp,
     486                                                                  void *newp, size_t newlen)
     487{
     488    if (pid == 0) {
     489        if (sysctlbyname(name, oldp, oldlenp, newp, newlen) == -1)  {
     490            fprintf(stderr, "sysctlbyname_with_pid(0): sysctlbyname  failed:"
     491                                        "%s\n", strerror(errno));
     492            return -1;
     493        }
     494    } else {
     495        int mib[CTL_MAXNAME];
     496        size_t len = CTL_MAXNAME;
     497        if (sysctlnametomib(name, mib, &len) == -1) {
     498            fprintf(stderr, "sysctlbyname_with_pid: sysctlnametomib  failed:"
     499                                        "%s\n", strerror(errno));
     500            return -1;
     501        }
     502        mib[len] = pid;
     503        len++;
     504        if (sysctl(mib, len, oldp, oldlenp, newp, newlen) == -1)  {
     505            fprintf(stderr, "sysctlbyname_with_pid: sysctl  failed:"
     506                    "%s\n", strerror(errno));
     507            return -1;
     508        }
     509    }
     510    return 0;
     511}
     512
     513int is_pid_native (pid_t pid)
     514{
     515    int ret = 0;
     516    size_t sz = sizeof(ret);
     517       
     518    if (sysctlbyname_with_pid("sysctl.proc_native", pid,
     519                                                          &ret, &sz, NULL, 0) == -1) {
     520                if (errno == ENOENT) {
     521            // sysctl doesn't exist, which means that this version of Mac OS
     522            // pre-dates Rosetta, so the application must be native.
     523            return 1;
     524        }
     525        fprintf(stderr, "is_pid_native: sysctlbyname_with_pid  failed:"
     526                "%s\n", strerror(errno));
     527        return -1;
     528    }
     529    return ret;
     530}       
  • trunk/Cocoa/F-Script Anywhere/Source/SCPatch/SCPatchController/SCPatchController.cpp

    r217 r219  
    436436        // Find the loader
    437437        CFURLRef loaderURL = NULL;
    438 #if defined(__ppc__) || defined(__ppc64__)
    439438        if(!err)
    440439                if((loaderURL = CFBundleCopyResourceURL(mBundle, CFSTR("SCPatchLoader"), CFSTR("bundle"), NULL)) == NULL)
    441440                        err = err_couldnt_find_injection_bundle;
    442 #else
    443         if(!err)
    444                 if((loaderURL = CFBundleCopyResourceURL(mBundle, CFSTR("SCPatchLoader-intel"), CFSTR("bundle"), NULL)) == NULL)
    445                         err = err_couldnt_find_injection_bundle;
    446 #endif 
    447441
    448442#if 0
Note: See TracChangeset for help on using the changeset viewer.