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

Last change on this file since 153 was 153, checked in by Nicholas Riley, 18 years ago

Integrates SCPatch and mach_inject; unfinished, buggy.

File size: 2.7 KB
Line 
1/****************************************************************************************
2 mach_inject.h $Revision: 1.1.1.1 $
3
4 Copyright (c) 2003 Red Shed Software. All rights reserved.
5 by Jonathan 'Wolf' Rentzsch (jon * redshed * net)
6
7 ************************************************************************************/
8
9/************************************************************************************/ /**
10 @mainpage mach_inject
11 @author Jonathan 'Wolf' Rentzsch (jon * redshed * net)
12
13 This package, coded in C to the Mach API, allows you to "inject" code into an
14 arbitrary process. "Injection" means both 1) copying over the necessary code into the
15 target's address space and 2) remotely creating a new thread to execute the code.
16
17 ************************************************************************************/
18
19#ifndef _mach_inject_
20#define _mach_inject_
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#include <sys/types.h>
27#include <mach/error.h>
28#include <mach/vm_types.h>
29#include <stddef.h>
30
31#define err_threadEntry_image_not_found (err_local|1)
32#define err_threadEntry_init_failed (err_local|2)
33
34#define INJECT_ENTRY injectEntry
35#define INJECT_ENTRY_SYMBOL "injectEntry"
36
37typedef void (*mach_inject_entry)( ptrdiff_t codeOffset, void *paramBlock, size_t paramSize );
38
39/************************************************************************************//**
40 Starts executing threadEntry in a new thread in the process specified by
41 targetProcess.
42
43 @param threadEntry -> Required pointer to injected thread's entry point.
44 @param paramBlock -> Optional pointer to block of memory to pass to the
45 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 to zero
49 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 mach_header).
67 @param size <- Optional returned size of the image.
68 @result <- mach_error_t
69
70 ************************************************************************************/
71
72 mach_error_t
73machImageForPointer(
74 const void *pointer,
75 const void **image,
76 unsigned long *size );
77
78#ifdef __cplusplus
79}
80#endif
81
82#endif // _mach_inject_
Note: See TracBrowser for help on using the repository browser.