source: trunk/Cocoa/F-Script Anywhere/Source/mach_inject/mach_inject.h@ 342

Last change on this file since 342 was 342, checked in by rchin, 17 years ago

Leopard compatibility changes:

  • Removed some icon caching code that was causing crashes (not sure we really needed those optimizations anyway -- doesn't appear to affect performance)
  • Added code to automatically try to add certificate to keychain, for new code signing behavior (replaces previous procmod nonesense).
  • Note that the enclosed public certificate is mine, and so it will need to be signed by me. In the case that someone else wants to distribute this binary, please replace Certficiate.cer with your own public certificate, and then make sure o code sign the binary after it is built.
File size: 2.9 KB
RevLine 
[217]1/*******************************************************************************
2 mach_inject.h
3 Copyright (c) 2003-2005 Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
4 Some rights reserved: <http://creativecommons.org/licenses/by/2.0/>
5
6 ***************************************************************************/
[153]7
[217]8/***************************************************************************//**
[153]9 @mainpage mach_inject
[217]10 @author Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
[153]11
[217]12 This package, coded in C to the Mach API, allows you to "inject" code into
13 an arbitrary process. "Injection" means both 1) copying over the necessary
14 code into the target's address space and 2) remotely creating a new thread
15 to execute the code.
[153]16
[217]17 ***************************************************************************/
[153]18
19#ifndef _mach_inject_
20#define _mach_inject_
[342]21#define __DARWIN_UNIX03 0
[153]22#include <sys/types.h>
23#include <mach/error.h>
24#include <mach/vm_types.h>
[217]25#include <stddef.h> // for ptrdiff_t
[153]26
[217]27#ifdef __cplusplus
28 extern "C" {
29#endif
30
[153]31#define err_threadEntry_image_not_found (err_local|1)
32
33#define INJECT_ENTRY injectEntry
34#define INJECT_ENTRY_SYMBOL "injectEntry"
35
[217]36typedef void (*mach_inject_entry)( ptrdiff_t codeOffset, void *paramBlock,
37 size_t paramSize, void* dummy_pthread_data );
[153]38
[217]39/***************************************************************************//**
[153]40 Starts executing threadEntry in a new thread in the process specified by
41 targetProcess.
42
[217]43 @param threadEntry -> Required pointer to injected thread's entry
44 point.
45 @param paramBlock -> Optional pointer to block of memory to pass to
46 the injected thread.
[153]47 @param paramSize -> Optional size of paramBlock.
48 @param targetProcess -> Required target process ID.
[217]49 @param stackSize -> Optional stack size of threadEntry's thread. Set
50 to zero for default (currently 8K usable).
[153]51 @result <- mach_error_t
52
[217]53 ***************************************************************************/
[153]54
55 mach_error_t
56mach_inject(
57 const mach_inject_entry threadEntry,
58 const void *paramBlock,
59 size_t paramSize,
60 pid_t targetProcess,
61 vm_size_t stackSize );
62
[217]63/***************************************************************************//**
[153]64 Given a pointer, returns its Mach-O image and image size.
65
[217]66 @param pointer -> Required pointer.
67 @param image <- Optional returned pointer to image (really a
68 mach_header).
69 @param size <- Optional returned size of the image.
70 @param jumpTableOffset <- Optional returned offset of jump table within image (useful on intel)
71 @param jumpTableSize <- Optional returned size of jump table (useful on intel)
72 @result <- mach_error_t
[153]73
[217]74 ***************************************************************************/
[153]75
76 mach_error_t
77machImageForPointer(
78 const void *pointer,
79 const void **image,
[217]80 unsigned long *size,
81 unsigned int *jumpTableOffset,
82 unsigned int *jumpTableSize );
[153]83
[217]84#ifdef __cplusplus
85 }
[153]86#endif
87#endif // _mach_inject_
Note: See TracBrowser for help on using the repository browser.