summaryrefslogtreecommitdiffstats
path: root/third_party/mach_override/chromium.diff
blob: 650c2b8ddb3e988d5cee8fa43753a73db6f3ba59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
--- ../../mach_star/mach_override/mach_override.c	2011-04-11 09:35:25.000000000 -0700
+++ third_party/mach_override/mach_override.c	2011-04-11 16:09:56.000000000 -0700
@@ -145,36 +145,6 @@
 #pragma mark	-
 #pragma mark	(Interface)
 
-	mach_error_t
-mach_override(
-		char *originalFunctionSymbolName,
-		const char *originalFunctionLibraryNameHint,
-		const void *overrideFunctionAddress,
-		void **originalFunctionReentryIsland )
-{
-	assert( originalFunctionSymbolName );
-	assert( strlen( originalFunctionSymbolName ) );
-	assert( overrideFunctionAddress );
-	
-	//	Lookup the original function's code pointer.
-	long	*originalFunctionPtr;
-	if( originalFunctionLibraryNameHint )
-		_dyld_lookup_and_bind_with_hint(
-			originalFunctionSymbolName,
-			originalFunctionLibraryNameHint,
-			(void*) &originalFunctionPtr,
-			NULL );
-	else
-		_dyld_lookup_and_bind(
-			originalFunctionSymbolName,
-			(void*) &originalFunctionPtr,
-			NULL );
-	
-	//printf ("In mach_override\n");
-	return mach_override_ptr( originalFunctionPtr, overrideFunctionAddress,
-		originalFunctionReentryIsland );
-}
-
 #if defined(__x86_64__)
 mach_error_t makeIslandExecutable(void *address) {
 	mach_error_t err = err_none;
@@ -563,6 +533,7 @@
 	{ 0x2, {0xFF, 0xFF}, {0x89, 0xE5} },				                // mov %esp,%ebp
 	{ 0x1, {0xFF}, {0x53} },							// push %ebx
 	{ 0x3, {0xFF, 0xFF, 0x00}, {0x83, 0xEC, 0x00} },	                        // sub 0x??, %esp
+	{ 0x3, {0xFF, 0xFF, 0x00}, {0x81, 0xEC, 0x00} },	                        // sub 0x??, %esp with 32bit immediate
 	{ 0x1, {0xFF}, {0x57} },							// push %edi
 	{ 0x1, {0xFF}, {0x56} },							// push %esi
 	{ 0x0 }
@@ -584,7 +555,7 @@
 {
 	Boolean match = true;
 	
-	int i;
+	size_t i;
 	for (i=0; i<instruction->length; i++) {
 		unsigned char mask = instruction->mask[i];
 		unsigned char constraint = instruction->constraint[i];
@@ -617,7 +588,7 @@
 		// See if instruction matches one  we know
 		AsmInstructionMatch* curInstr = possibleInstructions;
 		do { 
-			if (curInstructionKnown = codeMatchesInstruction(ptr, curInstr)) break;
+			if ((curInstructionKnown = codeMatchesInstruction(ptr, curInstr))) break;
 			curInstr++;
 		} while (curInstr->length > 0);
 		
@@ -665,10 +636,9 @@
 #endif
 
 #if defined(__i386__)
-asm(		
+__asm(
 			".text;"
 			".align 2, 0x90;"
-			".globl _atomic_mov64;"
 			"_atomic_mov64:;"
 			"	pushl %ebp;"
 			"	movl %esp, %ebp;"
@@ -708,4 +678,4 @@
     *targetAddress = value;
 }
 #endif
-#endif
\ No newline at end of file
+#endif
--- ../../mach_star/mach_override/mach_override.h	2011-04-11 09:35:25.000000000 -0700
+++ third_party/mach_override/mach_override.h	2011-04-11 15:43:33.000000000 -0700
@@ -57,42 +57,6 @@
 */
 #define	err_cannot_override	(err_local|1)
 
-/***************************************************************************//**
-	Dynamically overrides the function implementation referenced by
-	originalFunctionSymbolName with the implentation pointed to by
-	overrideFunctionAddress. Optionally returns a pointer to a "reentry island"
-	which, if jumped to, will resume the original implementation.
-	
-	@param	originalFunctionSymbolName		->	Required symbol name of the
-												function to override (with
-												overrideFunctionAddress).
-												Remember, C function name
-												symbols are prepended with an
-												underscore.
-	@param	originalFunctionLibraryNameHint	->	Optional name of the library
-												which contains
-												originalFunctionSymbolName. Can
-												be NULL, but this may result in
-												the wrong function being
-												overridden and/or a crash.
-	@param	overrideFunctionAddress			->	Required address to the
-												overriding function.
-	@param	originalFunctionReentryIsland	<-	Optional pointer to pointer to
-												the reentry island. Can be NULL.
-	@result									<-	err_cannot_override if the
-												original function's
-												implementation begins with the
-												'mfctr' instruction.
-
-	***************************************************************************/
-	 
-    mach_error_t
-mach_override(
-    char *originalFunctionSymbolName,
-    const char *originalFunctionLibraryNameHint,
-    const void *overrideFunctionAddress,
-    void **originalFunctionReentryIsland );
-
 /************************************************************************************//**
 	Dynamically overrides the function implementation referenced by
 	originalFunctionAddress with the implentation pointed to by overrideFunctionAddress.
@@ -154,4 +118,4 @@
 #ifdef	__cplusplus
 	}
 #endif
-#endif	//	_mach_override_
\ No newline at end of file
+#endif	//	_mach_override_