summaryrefslogtreecommitdiffstats
path: root/third_party/mach_override
diff options
context:
space:
mode:
authorrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-20 17:31:46 +0000
committerrsesek@chromium.org <rsesek@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-20 17:31:46 +0000
commitd5d9d2ee8b7aa79b1cf259df18cecc42c7a84472 (patch)
tree74c122069c49906ace6af68f6dd304cbf86f2909 /third_party/mach_override
parent45f9adb0aebb394594a949e3312901219b62ac04 (diff)
downloadchromium_src-d5d9d2ee8b7aa79b1cf259df18cecc42c7a84472.zip
chromium_src-d5d9d2ee8b7aa79b1cf259df18cecc42c7a84472.tar.gz
chromium_src-d5d9d2ee8b7aa79b1cf259df18cecc42c7a84472.tar.bz2
Roll third_party/mach_override to 87f491f8acef924d2ba90dd55fc23ad64f9d5bbd.
BUG=none TEST=none Review URL: http://codereview.chromium.org/7693006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97582 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party/mach_override')
-rw-r--r--third_party/mach_override/README.chromium11
-rw-r--r--third_party/mach_override/mach_override.c32
2 files changed, 29 insertions, 14 deletions
diff --git a/third_party/mach_override/README.chromium b/third_party/mach_override/README.chromium
index fad7a93..0e7e394 100644
--- a/third_party/mach_override/README.chromium
+++ b/third_party/mach_override/README.chromium
@@ -2,8 +2,8 @@ Name: mach_override
Short Name: Part of the mach_star project
Version: Unknown
URL: https://github.com/rentzsch/mach_star
-Date: 07/22/2011
-Revision: 51ae3d199463fa84548f466d649f0821d579fdaf
+Date: 08/19/2011
+Revision: 87f491f8acef924d2ba90dd55fc23ad64f9d5bbd
License: MIT
Security Critical: Yes
@@ -11,7 +11,7 @@ Security Critical: Yes
Description:
This is the mach_override part of mach_star, namely:
- https://github.com/rentzsch/mach_star/tree/51ae3d199463fa84548f466d649f0821d579fdaf
+ https://github.com/rentzsch/mach_star/tree/87f491f8acef924d2ba90dd55fc23ad64f9d5bbd
This package is used to replace framework functions with different
implementations at run time.
@@ -19,7 +19,4 @@ implementations at run time.
Local Modifications:
-Added the instructions to |possibleInstructions| for the very short
-malloc_error_break() on 10.5 so that it can be overriden on that platform.
-
-Print errors using fprintf() to stderr, rather than printf() to stdout.
+None. All local changes have been upstreamed.
diff --git a/third_party/mach_override/mach_override.c b/third_party/mach_override/mach_override.c
index 3920026..8a4cf95 100644
--- a/third_party/mach_override/mach_override.c
+++ b/third_party/mach_override/mach_override.c
@@ -170,6 +170,23 @@ mach_override_ptr(
assert( originalFunctionAddress );
assert( overrideFunctionAddress );
+ // this addresses overriding such functions as AudioOutputUnitStart()
+ // test with modified DefaultOutputUnit project
+#if defined(__x86_64__) || defined(__i386__)
+ for(;;){
+ if(*(unsigned char*)originalFunctionAddress==0xE9) // jmp .+0x????????
+ originalFunctionAddress=(void*)((char*)originalFunctionAddress+5+*(int32_t *)((char*)originalFunctionAddress+1));
+#if defined(__x86_64__)
+ else if(*(uint16_t*)originalFunctionAddress==0x25FF) // jmp qword near [rip+0x????????]
+ originalFunctionAddress=*(void**)((char*)originalFunctionAddress+6+*(int32_t *)((uint16_t*)originalFunctionAddress+1));
+#elif defined(__i386__)
+ else if(*(uint16_t*)originalFunctionAddress==0x25FF) // jmp *0x????????
+ originalFunctionAddress=**(void***)((uint16_t*)originalFunctionAddress+1);
+#endif
+ else break;
+ }
+#endif
+
long *originalFunctionPtr = (long*) originalFunctionAddress;
mach_error_t err = err_none;
@@ -296,18 +313,18 @@ mach_override_ptr(
if( reentryIsland )
err = setBranchIslandTarget_i386( reentryIsland,
(void*) ((char *)originalFunctionPtr+eatenCount), originalInstructions );
+ // try making islands executable before planting the jmp
+#if defined(__x86_64__) || defined(__i386__)
+ if( !err )
+ err = makeIslandExecutable(escapeIsland);
+ if( !err && reentryIsland )
+ err = makeIslandExecutable(reentryIsland);
+#endif
if ( !err )
atomic_mov64((uint64_t *)originalFunctionPtr, jumpRelativeInstruction);
}
#endif
-#if defined(__i386__) || defined(__x86_64__)
- if ( !err )
- err = makeIslandExecutable( escapeIsland );
- if ( !err && reentryIsland )
- err = makeIslandExecutable( reentryIsland );
-#endif
-
// Clean up on error.
if( err ) {
if( reentryIsland )
@@ -604,6 +621,7 @@ eatKnownInstructions(
// if all instruction matches failed, we don't know current instruction then, stop here
if (!curInstructionKnown) {
allInstructionsKnown = false;
+ fprintf(stderr, "mach_override: some instructions unknown! Need to update mach_override.c\n");
break;
}