Skip to content

Commit

Permalink
Add mach_inject code directly
Browse files Browse the repository at this point in the history
  • Loading branch information
zerodivisi0n committed Feb 7, 2013
1 parent 808e12c commit 009ab20
Show file tree
Hide file tree
Showing 110 changed files with 11,678 additions and 0 deletions.
16 changes: 16 additions & 0 deletions mach_inject/.gitignore
@@ -0,0 +1,16 @@
build

*.pbxuser
*.perspectivev3
*.mode1v3
*.mode2v3
!default.pbxuser
!default.perspectivev3
!default.mode1v3
!default.mode2v3
xcuserdata

*~.nib
*~.xib

.DS_Store
26 changes: 26 additions & 0 deletions mach_inject/DisposeWindow+Beep/DisposeWindow+Beep.c
@@ -0,0 +1,26 @@
#include <Carbon/Carbon.h>
#include <AudioToolbox/AudioToolbox.h>
#include "mach_override.h"

// Override type & global.
typedef void (*DisposeWindowProc)( WindowRef window );
DisposeWindowProc gDisposeWindow;

// Funky Protos.
void DisposeWindowOverride( WindowRef window );

__attribute__((constructor))
void load()
{
printf( "DisposeWindow+Beep loaded\n" );
if (mach_override( "_DisposeWindow", NULL, DisposeWindowOverride, (void**) &gDisposeWindow ) != 0) {
printf("Override failed!\n");
}
}

void DisposeWindowOverride( WindowRef window ) {
printf( "beep!\n" );
fflush(0);
AudioServicesPlayAlertSound(kSystemSoundID_UserPreferredAlert);
gDisposeWindow( window );
}
@@ -0,0 +1,336 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 42;
objects = {

/* Begin PBXBuildFile section */
10246EDB0FE737AD00EA5607 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 10246EDA0FE737AD00EA5607 /* AudioToolbox.framework */; };
79ACC9A607FD4A8A00D4147B /* mach_override.c in Sources */ = {isa = PBXBuildFile; fileRef = 79ACC9A407FD4A8A00D4147B /* mach_override.c */; };
79ACC9A707FD4A8A00D4147B /* mach_override.h in Headers */ = {isa = PBXBuildFile; fileRef = 79ACC9A507FD4A8A00D4147B /* mach_override.h */; };
8D01CCC80486CAD60068D4B7 /* DisposeWindow+Beep_Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 32BAE0B30371A71500C91783 /* DisposeWindow+Beep_Prefix.pch */; };
8D01CCCA0486CAD60068D4B7 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
8D01CCCC0486CAD60068D4B7 /* DisposeWindow+Beep.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB77B2FE8417CDC02AAC07 /* DisposeWindow+Beep.c */; settings = {ATTRIBUTES = (); }; };
8D01CCCE0486CAD60068D4B7 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = /System/Library/Frameworks/Carbon.framework; sourceTree = "<absolute>"; };
08FB77B2FE8417CDC02AAC07 /* DisposeWindow+Beep.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = "DisposeWindow+Beep.c"; sourceTree = "<group>"; };
10246EDA0FE737AD00EA5607 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = /System/Library/Frameworks/AudioToolbox.framework; sourceTree = "<absolute>"; };
32BAE0B30371A71500C91783 /* DisposeWindow+Beep_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "DisposeWindow+Beep_Prefix.pch"; sourceTree = "<group>"; };
79ACC9A407FD4A8A00D4147B /* mach_override.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = mach_override.c; path = ../mach_override/mach_override.c; sourceTree = SOURCE_ROOT; };
79ACC9A507FD4A8A00D4147B /* mach_override.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = mach_override.h; path = ../mach_override/mach_override.h; sourceTree = SOURCE_ROOT; };
8D01CCD10486CAD60068D4B7 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
8D01CCD20486CAD60068D4B7 /* DisposeWindow+Beep.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "DisposeWindow+Beep.bundle"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
8D01CCCD0486CAD60068D4B7 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8D01CCCE0486CAD60068D4B7 /* Carbon.framework in Frameworks */,
10246EDB0FE737AD00EA5607 /* AudioToolbox.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
089C166AFE841209C02AAC07 /* DisposeWindow+Beep */ = {
isa = PBXGroup;
children = (
08FB77ADFE841716C02AAC07 /* Source */,
089C167CFE841241C02AAC07 /* Resources */,
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */,
19C28FB4FE9D528D11CA2CBB /* Products */,
);
name = "DisposeWindow+Beep";
sourceTree = "<group>";
};
089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = {
isa = PBXGroup;
children = (
08EA7FFBFE8413EDC02AAC07 /* Carbon.framework */,
10246EDA0FE737AD00EA5607 /* AudioToolbox.framework */,
);
name = "External Frameworks and Libraries";
sourceTree = "<group>";
};
089C167CFE841241C02AAC07 /* Resources */ = {
isa = PBXGroup;
children = (
8D01CCD10486CAD60068D4B7 /* Info.plist */,
089C167DFE841241C02AAC07 /* InfoPlist.strings */,
);
name = Resources;
sourceTree = "<group>";
};
08FB77ADFE841716C02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
08FB77B2FE8417CDC02AAC07 /* DisposeWindow+Beep.c */,
79ACC9A407FD4A8A00D4147B /* mach_override.c */,
79ACC9A507FD4A8A00D4147B /* mach_override.h */,
32BAE0B30371A71500C91783 /* DisposeWindow+Beep_Prefix.pch */,
);
name = Source;
sourceTree = "<group>";
};
19C28FB4FE9D528D11CA2CBB /* Products */ = {
isa = PBXGroup;
children = (
8D01CCD20486CAD60068D4B7 /* DisposeWindow+Beep.bundle */,
);
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
8D01CCC70486CAD60068D4B7 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
8D01CCC80486CAD60068D4B7 /* DisposeWindow+Beep_Prefix.pch in Headers */,
79ACC9A707FD4A8A00D4147B /* mach_override.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */

/* Begin PBXNativeTarget section */
8D01CCC60486CAD60068D4B7 /* DisposeWindow+Beep */ = {
isa = PBXNativeTarget;
buildConfigurationList = 33B2ACCA092857D7004B1632 /* Build configuration list for PBXNativeTarget "DisposeWindow+Beep" */;
buildPhases = (
8D01CCC70486CAD60068D4B7 /* Headers */,
8D01CCC90486CAD60068D4B7 /* Resources */,
8D01CCCB0486CAD60068D4B7 /* Sources */,
8D01CCCD0486CAD60068D4B7 /* Frameworks */,
8D01CCCF0486CAD60068D4B7 /* Rez */,
);
buildRules = (
);
dependencies = (
);
name = "DisposeWindow+Beep";
productInstallPath = "$(HOME)/Library/Bundles";
productName = "DisposeWindow+Beep";
productReference = 8D01CCD20486CAD60068D4B7 /* DisposeWindow+Beep.bundle */;
productType = "com.apple.product-type.bundle";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
089C1669FE841209C02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 33B2ACCE092857D7004B1632 /* Build configuration list for PBXProject "DisposeWindow+Beep" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 089C166AFE841209C02AAC07 /* DisposeWindow+Beep */;
projectDirPath = "";
projectRoot = "";
targets = (
8D01CCC60486CAD60068D4B7 /* DisposeWindow+Beep */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
8D01CCC90486CAD60068D4B7 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D01CCCA0486CAD60068D4B7 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXRezBuildPhase section */
8D01CCCF0486CAD60068D4B7 /* Rez */ = {
isa = PBXRezBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXRezBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
8D01CCCB0486CAD60068D4B7 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8D01CCCC0486CAD60068D4B7 /* DisposeWindow+Beep.c in Sources */,
79ACC9A607FD4A8A00D4147B /* mach_override.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXVariantGroup section */
089C167DFE841241C02AAC07 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
089C167EFE841241C02AAC07 /* English */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */

/* Begin XCBuildConfiguration section */
33B2ACCB092857D7004B1632 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1 = x86_64;
COPY_PHASE_STRIP = NO;
DEBUGGING_SYMBOLS = YES;
FRAMEWORK_SEARCH_PATHS = "";
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_ENABLE_TRIGRAPHS = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DisposeWindow+Beep_Prefix.pch";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = NO;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_STYLE = Bundle;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
PRODUCT_NAME = "DisposeWindow+Beep";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = bundle;
ZERO_LINK = YES;
};
name = Development;
};
33B2ACCC092857D7004B1632 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_64_BIT_PRE_XCODE_3_1 = x86_64;
COPY_PHASE_STRIP = YES;
FRAMEWORK_SEARCH_PATHS = "";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_ENABLE_TRIGRAPHS = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DisposeWindow+Beep_Prefix.pch";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = NO;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_STYLE = Bundle;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
PRODUCT_NAME = "DisposeWindow+Beep";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = bundle;
ZERO_LINK = NO;
};
name = Deployment;
};
33B2ACCD092857D7004B1632 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = "";
GCC_ENABLE_TRIGRAPHS = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "DisposeWindow+Beep_Prefix.pch";
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = NO;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_STYLE = Bundle;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = "";
OTHER_REZFLAGS = "";
PRODUCT_NAME = "DisposeWindow+Beep";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
);
WRAPPER_EXTENSION = bundle;
};
name = Default;
};
33B2ACCF092857D7004B1632 /* Development */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Development;
};
33B2ACD0092857D7004B1632 /* Deployment */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Deployment;
};
33B2ACD1092857D7004B1632 /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
};
name = Default;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
33B2ACCA092857D7004B1632 /* Build configuration list for PBXNativeTarget "DisposeWindow+Beep" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33B2ACCB092857D7004B1632 /* Development */,
33B2ACCC092857D7004B1632 /* Deployment */,
33B2ACCD092857D7004B1632 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
33B2ACCE092857D7004B1632 /* Build configuration list for PBXProject "DisposeWindow+Beep" */ = {
isa = XCConfigurationList;
buildConfigurations = (
33B2ACCF092857D7004B1632 /* Development */,
33B2ACD0092857D7004B1632 /* Deployment */,
33B2ACD1092857D7004B1632 /* Default */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
};
/* End XCConfigurationList section */
};
rootObject = 089C1669FE841209C02AAC07 /* Project object */;
}
5 changes: 5 additions & 0 deletions mach_inject/DisposeWindow+Beep/DisposeWindow+Beep_Prefix.pch
@@ -0,0 +1,5 @@
//
// Prefix header for all source files of the 'DisposeWindow+Beep' target in the 'DisposeWindow+Beep' project.
//

#include <Carbon/Carbon.h>
Binary file not shown.

0 comments on commit 009ab20

Please sign in to comment.