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

Last change on this file since 630 was 401, checked in by Nicholas Riley, 17 years ago

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

File size: 2.9 KB
Line 
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 ***************************************************************************/
7
8/***************************************************************************//**
9 @mainpage mach_inject
10 @author Jonathan 'Wolf' Rentzsch: <http://rentzsch.com>
11
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.
16
17 ***************************************************************************/
18
19#ifndef _mach_inject_
20#define _mach_inject_
21#include <sys/types.h>
22#include <mach/error.h>
23#include <mach/vm_types.h>
24#include <stddef.h> // for ptrdiff_t
25
26#ifdef __cplusplus
27 extern "C" {
28#endif
29
30#define err_threadEntry_image_not_found (err_local|1)
31
32#define INJECT_ENTRY injectEntry
33#define INJECT_ENTRY_SYMBOL "injectEntry"
34
35typedef void (*mach_inject_entry)( ptrdiff_t codeOffset, void *paramBlock,
36 size_t paramSize, void* dummy_pthread_data );
37
38/***************************************************************************//**
39 Starts executing threadEntry in a new thread in the process specified by
40 targetProcess.
41
42 @param threadEntry -> Required pointer to injected thread's entry
43 point.
44 @param paramBlock -> Optional pointer to block of memory to pass to
45 the injected thread.
46 @param paramSize -> Optional size of paramBlock.
47 @param targetProcess -> Required target process ID.
48 @param stackSize -> Optional stack size of threadEntry's thread. Set
49 to zero for default (currently 8K usable).
50 @result <- mach_error_t
51
52 ***************************************************************************/
53
54 mach_error_t
55mach_inject(
56 const mach_inject_entry threadEntry,
57 const void *paramBlock,
58 size_t paramSize,
59 pid_t targetProcess,
60 vm_size_t stackSize );
61
62/***************************************************************************//**
63 Given a pointer, returns its Mach-O image and image size.
64
65 @param pointer -> Required pointer.
66 @param image <- Optional returned pointer to image (really a
67 mach_header).
68 @param size <- Optional returned size of the image.
69 @param jumpTableOffset <- Optional returned offset of jump table within image (useful on intel)
70 @param jumpTableSize <- Optional returned size of jump table (useful on intel)
71 @result <- mach_error_t
72
73 ***************************************************************************/
74
75 mach_error_t
76machImageForPointer(
77 const void *pointer,
78 const void **image,
79 unsigned long *size,
80 unsigned int *jumpTableOffset,
81 unsigned int *jumpTableSize );
82
83#ifdef __cplusplus
84 }
85#endif
86#endif // _mach_inject_
Note: See TracBrowser for help on using the repository browser.