Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SandCastle 0.0.1

  • Loading branch information...
commit 2e1cc31c264b65dd19e8c593d954e0ea4b93e543 1 parent cf8589b
@westbaer authored
View
43 CPDistributedMessagingCenter.h
@@ -0,0 +1,43 @@
+/**
+ * This header is generated by class-dump-z 0.1-11s.
+ * class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
+ *
+ * Source: /System/Library/PrivateFrameworks/AppSupport.framework/AppSupport
+ */
+
+#import <Foundation/Foundation.h>
+
+@class NSLock, NSMutableDictionary, NSOperationQueue, NSString, NSDictionary, NSError;
+
+@interface CPDistributedMessagingCenter : NSObject {
+ NSString* _centerName;
+ NSLock* _lock;
+ unsigned _sendPort;
+ CFMachPortRef _invalidationPort;
+ NSOperationQueue* _asyncQueue;
+ CFRunLoopSourceRef _serverSource;
+ NSString* _requiredEntitlement;
+ NSMutableDictionary* _callouts;
+}
++(CPDistributedMessagingCenter*)centerNamed:(NSString*)serverName;
+-(id)_initWithServerName:(NSString*)serverName;
+// inherited: -(void)dealloc;
+-(NSString*)name;
+-(unsigned)_sendPort;
+-(void)_serverPortInvalidated;
+-(BOOL)sendMessageName:(NSString*)name userInfo:(NSDictionary*)info;
+-(NSDictionary*)sendMessageAndReceiveReplyName:(NSString*)name userInfo:(NSDictionary*)info;
+-(NSDictionary*)sendMessageAndReceiveReplyName:(NSString*)name userInfo:(NSDictionary*)info error:(NSError**)error;
+-(void)sendMessageAndReceiveReplyName:(NSString*)name userInfo:(NSDictionary*)info toTarget:(id)target selector:(SEL)selector context:(void*)context;
+-(BOOL)_sendMessage:(id)message userInfo:(id)info receiveReply:(id*)reply error:(id*)error toTarget:(id)target selector:(SEL)selector context:(void*)context;
+-(BOOL)_sendMessage:(id)message userInfoData:(id)data oolKey:(id)key oolData:(id)data4 receiveReply:(id*)reply error:(id*)error;
+-(void)runServerOnCurrentThread;
+-(void)runServerOnCurrentThreadProtectedByEntitlement:(id)entitlement;
+-(void)stopServer;
+-(void)registerForMessageName:(NSString*)messageName target:(id)target selector:(SEL)selector;
+-(void)unregisterForMessageName:(NSString*)messageName;
+-(void)_dispatchMessageNamed:(id)named userInfo:(id)info reply:(id*)reply auditToken:(id*)token;
+-(BOOL)_isTaskEntitled:(id*)entitled;
+-(id)_requiredEntitlement;
+@end
+
View
12 Makefile
@@ -0,0 +1,12 @@
+TWEAK_NAME = sandcastle
+sandcastle_LOGOS_FILES = Tweak.xm
+sandcastle_PRIVATE_FRAMEWORKS = AppSupport
+sandcastle_CFLAGS=-I.
+
+SUBPROJECTS = client
+
+client_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries
+
+include framework/makefiles/common.mk
+include framework/makefiles/aggregate.mk
+include framework/makefiles/tweak.mk
View
52 Tweak.xm
@@ -0,0 +1,52 @@
+#include <CPDistributedMessagingCenter.h>
+
+@interface SandCastleObserver : NSObject {
+ CPDistributedMessagingCenter *center;
+}
+
+@end
+
+@implementation SandCastleObserver
+
+- (id)init {
+ if((self = [super init])) {
+ center = [[CPDistributedMessagingCenter centerNamed:@"me.haunold.sandcastle.center"] retain];
+ [center runServerOnCurrentThread];
+ [center registerForMessageName:@"MoveNotification" target:self selector:@selector(handleMove:userInfo:)];
+ [center registerForMessageName:@"RemoveNotification" target:self selector:@selector(handleRemove:userInfo:)];
+ }
+
+ return self;
+}
+
+- (void)handleMove:(NSString *)name userInfo:(NSDictionary *)userInfo {
+ NSLog(@"handleMove:%@ userInfo:%@", name, userInfo);
+ // TODO: Add Safety Checks or something
+ [[NSFileManager defaultManager] copyItemAtPath:[userInfo objectForKey:@"SandCastleTemporaryFile"] toPath:[userInfo objectForKey:@"SandCastleResolvedPath"] error:nil];
+ [[NSFileManager defaultManager] removeItemAtPath:[userInfo objectForKey:@"SandCastleTemporaryFile"] error:nil];
+}
+
+- (void)handleRemove:(NSString *)name userInfo:(NSDictionary *)userInfo {
+ NSLog(@"handleRemove:%@ userInfo:%@", name, userInfo);
+ // TODO: Add Safety Checks or something
+ [[NSFileManager defaultManager] removeItemAtPath:[userInfo objectForKey:@"SandCastleResolvedPath"] error:nil];
+}
+
+- (void)dealloc {
+ [center release];
+ [super dealloc];
+}
+
+@end
+
+static SandCastleObserver *observer = nil;
+
+static __attribute__((constructor)) void YourTubeHDInitialize() {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ %init;
+
+ observer = [[SandCastleObserver alloc] init];
+
+ [pool release];
+}
View
9 client/Makefile
@@ -0,0 +1,9 @@
+TWEAK_NAME = sandcastleclient
+sandcastleclient_LOGOS_FILES = Tweak.xm
+sandcastleclient_CFLAGS=-I.. -I.
+sandcastleclient_PRIVATE_FRAMEWORKS = AppSupport
+
+
+include ../framework/makefiles/common.mk
+include ../framework/makefiles/tweak.mk
+
View
14 client/SandCastle.h
@@ -0,0 +1,14 @@
+#include <Foundation/Foundation.h>
+
+@class SandCastle, CPDistributedMessagingCenter;
+
+@interface SandCastle : NSObject {
+ CPDistributedMessagingCenter *center;
+}
+
++ (SandCastle *)sharedInstance;
+- (NSString *)temporaryPathForFileName:(NSString *)fileName;
+- (void)moveTemporaryFile:(NSString *)file toResolvedPath:(NSString *)path;
+- (void)removeItemAtResolvedPath:(NSString *)path;
+
+@end
View
88 client/Tweak.xm
@@ -0,0 +1,88 @@
+#include <CPDistributedMessagingCenter.h>
+#include <SandCastle.h>
+
+static SandCastle *sharedInstance = nil;
+
+@implementation SandCastle
+
+- (id)init {
+ if((self = [super init])) {
+ center = [CPDistributedMessagingCenter centerNamed:@"me.haunold.sandcastle.center"];
+ }
+
+ return self;
+}
+
+- (NSString *)temporaryPathForFileName:(NSString *)fileName {
+ CFUUIDRef uuidObj = CFUUIDCreate(nil);
+ NSString *newUUID = (NSString *)CFUUIDCreateString(nil, uuidObj);
+ CFRelease(uuidObj);
+ return [@"/var/mobile/Library/Preferences" stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [newUUID autorelease], [fileName pathExtension]]];
+}
+
+- (void)moveTemporaryFile:(NSString *)file toResolvedPath:(NSString *)path {
+ NSDictionary *_params = [NSDictionary dictionaryWithObjectsAndKeys: file, @"SandCastleTemporaryFile",
+ path, @"SandCastleResolvedPath",
+ nil, nil];
+
+ [center sendMessageName:@"MoveNotification" userInfo:_params];
+}
+
+- (void)removeItemAtResolvedPath:(NSString *)path {
+ NSDictionary *_params = [NSDictionary dictionaryWithObjectsAndKeys: path, @"SandCastleResolvedPath",
+ nil, nil];
+
+ [center sendMessageName:@"RemoveNotification" userInfo:_params];
+}
+
+#pragma mark -
+#pragma mark Singleton Stuff
+
++ (SandCastle *)sharedInstance {
+ @synchronized(self) {
+ if (sharedInstance == nil)
+ sharedInstance = [[SandCastle alloc] init];
+ }
+ return sharedInstance;
+}
+
++ (id)allocWithZone:(NSZone *)zone {
+ @synchronized(self) {
+ if (sharedInstance == nil) {
+ sharedInstance = [super allocWithZone:zone];
+ return sharedInstance;
+ }
+ }
+ return nil;
+}
+
+- (id)copyWithZone:(NSZone *)zone {
+ return self;
+}
+
+- (id)retain {
+ return self;
+}
+
+- (unsigned)retainCount {
+ return UINT_MAX;
+}
+
+- (void)release { }
+
+- (id)autorelease {
+ return self;
+}
+
+@end
+
+
+static __attribute__((constructor)) void YourTubeHDInitialize() {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ %init;
+
+ [SandCastle sharedInstance];
+
+ [pool release];
+}
View
10 layout/DEBIAN/control
@@ -0,0 +1,10 @@
+Package: sandcastle
+Name: sandcastle
+Depends: mobilesubstrate
+Version: 0.0.1
+Architecture: iphoneos-arm
+Description: Access nearly every directory from a sandboxed application.
+Maintainer: Nicolas Haunold <westbaer@gmail.com>
+Author: Nicolas Haunold <westbaer@gmail.com>
+Section: Development
+Tag: role:hacker
View
1  layout/Library/MobileSubstrate/DynamicLibraries/sandcastle.plist
@@ -0,0 +1 @@
+Filter = {Bundles = ("com.apple.springboard");};
Please sign in to comment.
Something went wrong with that request. Please try again.