Changeset 401 for trunk


Ignore:
Timestamp:
02/24/08 09:41:47 (17 years ago)
Author:
Nicholas Riley
Message:

Update mach_inject to build and run on Leopard without #define DARWIN_UNIX03 0.

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  
    1818#include <mach-o/fat.h> // for fat structure decoding
    1919#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()
    2122// for mmap()
    2223#include <sys/types.h>
     
    146147               
    147148                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) );
    151152               
    152153                ASSERT_CAST( unsigned int, remoteStack );
    153                 remoteThreadState.r1 = (unsigned int) remoteStack;
     154                remoteThreadState.__r1 = (unsigned int) remoteStack;
    154155               
    155156                ASSERT_CAST( unsigned int, imageOffset );
    156                 remoteThreadState.r3 = (unsigned int) imageOffset;
     157                remoteThreadState.__r3 = (unsigned int) imageOffset;
    157158               
    158159                ASSERT_CAST( unsigned int, remoteParamBlock );
    159                 remoteThreadState.r4 = (unsigned int) remoteParamBlock;
     160                remoteThreadState.__r4 = (unsigned int) remoteParamBlock;
    160161               
    161162                ASSERT_CAST( unsigned int, paramSize );
    162                 remoteThreadState.r5 = (unsigned int) paramSize;
     163                remoteThreadState.__r5 = (unsigned int) paramSize;
    163164               
    164165                ASSERT_CAST( unsigned int, 0xDEADBEEF );
    165                 remoteThreadState.lr = (unsigned int) 0xDEADBEEF;
     166                remoteThreadState.__lr = (unsigned int) 0xDEADBEEF;
    166167               
    167168#if 0
    168169                printf( "remoteCode start: %p\n", (void*) remoteCode );
    169170                printf( "remoteCode size: %ld\n", imageSize );
    170                 printf( "remoteCode pc: %p\n", (void*) remoteThreadState.srr0 );
     171                printf( "remoteCode pc: %p\n", (void*) remoteThreadState.__srr0 );
    171172                printf( "remoteCode end: %p\n",
    172173                        (void*) (((char*)remoteCode)+imageSize) );
     
    207208               
    208209                // set remote Program Counter
    209                 remoteThreadState.eip = (unsigned int) (remoteCode);
    210                 remoteThreadState.eip += threadEntryOffset; 
     210                remoteThreadState.__eip = (unsigned int) (remoteCode);
     211                remoteThreadState.__eip += threadEntryOffset; 
    211212               
    212213                // set remote Stack Pointer
    213214                ASSERT_CAST( unsigned int, remoteStack );
    214                 remoteThreadState.esp = (unsigned int) remoteStack;
     215                remoteThreadState.__esp = (unsigned int) remoteStack;
    215216               
    216217#if 0
     
    289290                                int fd = open (imageName, O_RDONLY);
    290291                                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                                }
    292297                               
    293298                                struct fat_header* fatHeader = (struct fat_header *)fileImage;
  • trunk/Cocoa/F-Script Anywhere/Source/mach_inject/mach_inject.h

    r342 r401  
    1919#ifndef         _mach_inject_
    2020#define         _mach_inject_
    21 #define __DARWIN_UNIX03 0
    2221#include <sys/types.h>
    2322#include <mach/error.h>
Note: See TracChangeset for help on using the changeset viewer.