Changeset 401
- Timestamp:
- 02/24/08 09:41:47 (17 years ago)
- Location:
- trunk/Cocoa/F-Script Anywhere/Source/mach_inject
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/F-Script Anywhere/Source/mach_inject/mach_inject.c
r217 r401 18 18 #include <mach-o/fat.h> // for fat structure decoding 19 19 #include <mach-o/arch.h> // to know which is local arch 20 #include <fcntl.h> // for open/close 20 #include <fcntl.h> // for open() 21 #include <unistd.h> // for close() 21 22 // for mmap() 22 23 #include <sys/types.h> … … 146 147 147 148 ASSERT_CAST( unsigned int, remoteCode ); 148 remoteThreadState. srr0 = (unsigned int) remoteCode;149 remoteThreadState. srr0 += threadEntryOffset;150 assert( remoteThreadState. srr0 < (remoteCode + imageSize) );149 remoteThreadState.__srr0 = (unsigned int) remoteCode; 150 remoteThreadState.__srr0 += threadEntryOffset; 151 assert( remoteThreadState.__srr0 < (remoteCode + imageSize) ); 151 152 152 153 ASSERT_CAST( unsigned int, remoteStack ); 153 remoteThreadState. r1 = (unsigned int) remoteStack;154 remoteThreadState.__r1 = (unsigned int) remoteStack; 154 155 155 156 ASSERT_CAST( unsigned int, imageOffset ); 156 remoteThreadState. r3 = (unsigned int) imageOffset;157 remoteThreadState.__r3 = (unsigned int) imageOffset; 157 158 158 159 ASSERT_CAST( unsigned int, remoteParamBlock ); 159 remoteThreadState. r4 = (unsigned int) remoteParamBlock;160 remoteThreadState.__r4 = (unsigned int) remoteParamBlock; 160 161 161 162 ASSERT_CAST( unsigned int, paramSize ); 162 remoteThreadState. r5 = (unsigned int) paramSize;163 remoteThreadState.__r5 = (unsigned int) paramSize; 163 164 164 165 ASSERT_CAST( unsigned int, 0xDEADBEEF ); 165 remoteThreadState. lr = (unsigned int) 0xDEADBEEF;166 remoteThreadState.__lr = (unsigned int) 0xDEADBEEF; 166 167 167 168 #if 0 168 169 printf( "remoteCode start: %p\n", (void*) remoteCode ); 169 170 printf( "remoteCode size: %ld\n", imageSize ); 170 printf( "remoteCode pc: %p\n", (void*) remoteThreadState. srr0 );171 printf( "remoteCode pc: %p\n", (void*) remoteThreadState.__srr0 ); 171 172 printf( "remoteCode end: %p\n", 172 173 (void*) (((char*)remoteCode)+imageSize) ); … … 207 208 208 209 // set remote Program Counter 209 remoteThreadState. eip = (unsigned int) (remoteCode);210 remoteThreadState. eip += threadEntryOffset;210 remoteThreadState.__eip = (unsigned int) (remoteCode); 211 remoteThreadState.__eip += threadEntryOffset; 211 212 212 213 // set remote Stack Pointer 213 214 ASSERT_CAST( unsigned int, remoteStack ); 214 remoteThreadState. esp = (unsigned int) remoteStack;215 remoteThreadState.__esp = (unsigned int) remoteStack; 215 216 216 217 #if 0 … … 289 290 int fd = open (imageName, O_RDONLY); 290 291 size_t mapSize = *size; 291 char * fileImage = mmap (NULL, mapSize, PROT_READ, MAP_FILE, fd, 0); 292 void *fileImage = mmap(NULL, mapSize, PROT_READ, MAP_PRIVATE | MAP_FILE, fd, 0); 293 if (fileImage == (void *)-1) { 294 fprintf(stderr, "mmap failed: %s (%s)\n", imageName, strerror(errno)); 295 return err_threadEntry_image_not_found; 296 } 292 297 293 298 struct fat_header* fatHeader = (struct fat_header *)fileImage; -
trunk/Cocoa/F-Script Anywhere/Source/mach_inject/mach_inject.h
r342 r401 19 19 #ifndef _mach_inject_ 20 20 #define _mach_inject_ 21 #define __DARWIN_UNIX03 022 21 #include <sys/types.h> 23 22 #include <mach/error.h>
Note:
See TracChangeset
for help on using the changeset viewer.