aboutsummaryrefslogtreecommitdiff
path: root/SrcShared/Patches/EmPatchModuleTypes.h
blob: 6ffb475c2d67411cd923ae3b6e10f64368090b6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
	Copyright (c) 2001 PocketPyro, Inc.
	Portions Copyright (c) Palm, Inc.
	All rights reserved.

	This file is part of the Palm OS Emulator.

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.
\* ===================================================================== */

#ifndef EmPatchModuleTypes_h
#define EmPatchModuleTypes_h

#include "EmPatchIf.h"			// HeadpatchProc, TailpatchProc, IEmPatchModule
#include "EmStructs.h"			// SystemCallContext


// ======================================================================
// At compile time, the list of functions we want to head- and tailpatch
// are stored in an array of ProtoPatchTableEntries.  At runtime, these
// compact arrays are expanded by PatchModule into a sparse array
// so that the function dispatch number can be used to look up the
// patch function.
// ======================================================================

struct ProtoPatchTableEntry
{
	uint16			fTrapWord;
	HeadpatchProc	fHeadpatch;
	TailpatchProc	fTailpatch;
};


// ===========================================================================
//		InstalledLibPatchEntry
// ===========================================================================
// Structure used to hold tail-patch information.

class InstalledLibPatchEntry
{
	public:
								InstalledLibPatchEntry (void) :
									fIsDirty (true),
									fTableP (NULL)
								{
								}

		bool					IsDirty (void) const
								{
									return fIsDirty;
								}

		void					SetDirty (bool dirty = true)
								{
									fIsDirty = dirty;
								}

		IEmPatchModule*			GetPatchTableP (void) const
								{
									return fTableP;
								}

		void					SetPatchTableP (IEmPatchModule* tableP)
								{
									fTableP = tableP;
								}

	private:
		bool					fIsDirty;
		IEmPatchModule*			fTableP;
};

typedef vector<InstalledLibPatchEntry> PatchedLibIndex;


// ===========================================================================
//		¥ TailpatchType
// ===========================================================================
// Structure used to hold tail-patch information.

struct TailpatchType
{
	SystemCallContext	fContext;
	int32 				fCount;
	TailpatchProc		fTailpatch;
};

typedef vector<TailpatchType>		TailPatchIndex;

#endif // EmPatchModuleTypes_h