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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
|
/* -*- mode: C++; tab-width: 4 -*- */
/* ===================================================================== *\
Copyright (c) 1998-2001 Palm, Inc. or its subsidiaries.
Copyright (c) 2001 PocketPyro, 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 EmPatchState_h
#define EmPatchState_h
#include "ChunkFile.h"
#include "EmPalmHeap.h"
#include "EmPatchModuleTypes.h"
#include "PreferenceMgr.h" // PrefKeyType
#include <vector>
#include <map>
const UInt32 kOSUndeterminedVersion = ~0;
typedef map<emuptr, EmPalmHeap*> EmHeapMap;
// Structure used to hold information about the currently
// running Palm OS application (as recorded when SysAppStartup
// is called).
struct EmuAppInfo
{
Int16 fCmd; // launch code
DmOpenRef fDB;
UInt16 fCardNo;
LocalID fDBID;
UInt16 fMemOwnerID;
emuptr fStackP;
emuptr fStackEndP;
long fStackSize;
char fName[dmDBNameLength];
char fVersion[256]; // <gulp> I hope this is big enough...
};
typedef vector<EmuAppInfo> EmuAppInfoList;
// Structure used to keep track of the context in which
// memory chunks were allocated.
struct EmTrackedChunk
{
emuptr ptr;
bool isHandle;
EmStackFrameList stackCrawl;
};
typedef list<EmTrackedChunk> EmTrackedChunkList;
struct EmPatchStateData
{
public:
EmPatchStateData () :
fUIInitialized (false),
fUIReset (false),
fEvtGetEventCalled (false),
fAutoAcceptBeamDialogs (false),
fTimeToQuit (false),
fLastEvtTrap (0),
fOSVersion (0),
fEncoding (0),
fSysBinarySearchCount (0),
fQuitAppCardNo (0),
fQuitAppDbID (0),
fNextAppCardNo (0),
fNextAppDbID (0),
fHeapInitialized (false),
fMemMgrCount (0),
fMemSemaphoreCount (0),
fMemSemaphoreReserveTime (0),
fResizeOrigSize (0),
fHeapID (0)
{
}
bool fUIInitialized;
bool fUIReset;
bool fEvtGetEventCalled;
bool fAutoAcceptBeamDialogs;
bool fTimeToQuit;
uint16 fLastEvtTrap;
uint32 fOSVersion;
uint32 fEncoding;
long fSysBinarySearchCount;
uint16 fQuitAppCardNo;
LocalID fQuitAppDbID;
uint16 fNextAppCardNo;
LocalID fNextAppDbID;
EmuAppInfoList fCurAppInfo;
bool fHeapInitialized;
long fMemMgrCount;
Bool fMemMgrLeaks;
long fMemSemaphoreCount;
unsigned long fMemSemaphoreReserveTime;
uint32 fResizeOrigSize;
uint16 fHeapID;
EmHeapMap fRememberedHeaps;
EmTrackedChunkList fTrackedChunks;
};
class EmPatchState
{
public:
static Err Initialize (void);
static Err Dispose (void);
static Err Reset (void);
enum PersistencePhase
{
PSPersistAll, // save/load all
PSPersistStep1, // Backward compatability step 1
PSPersistStep2 // Backward compatability step 2
};
static Err Save (EmStreamChunk &s, long version = 1, PersistencePhase pass = PSPersistAll);
static Err Load (EmStreamChunk &s, long version = 1, PersistencePhase pass = PSPersistAll);
static Err SaveCurAppInfo (EmStreamChunk &s);
static Err LoadCurAppInfo (EmStreamChunk &s);
static uint16 GetLastEvtTrap (void);
static EmuAppInfo GetCurrentAppInfo (void);
static EmuAppInfo GetRootAppInfo (void);
static Err AddAppInfo (EmuAppInfo &newAppInfo);
static Err RemoveCurAppInfo (void);
static Err SetLastEvtTrap (uint16 lastEvtTrap);
static Err SetEvtGetEventCalled (bool wasCalled);
static Err SetQuitApp (UInt16 cardNo, LocalID dbID);
static void SetTimeToQuit (void);
static void MemMgrLeaksPrefsChanged (PrefKeyType, void*);
static Err CollectCurrentAppInfo (emuptr appInfoP, EmuAppInfo &newAppInfo);
static UInt32 OSVersion (void);
static void SetOSVersion (UInt32 version);
static UInt32 OSMajorMinorVersion (void);
static UInt32 OSMajorVersion (void);
static UInt32 OSMinorVersion (void);
static void SetSwitchApp (UInt16 cardNo, LocalID dbID);
static Bool DatabaseInfoHasStackInfo(void);
static Bool HasWellBehavedMemSemaphoreUsage (void);
// Bugs fixed in 3.0.
static Bool HasFindShowResultsBug (void);
static Bool HasSysBinarySearchBug (void);
// Bugs fixed in 3.1
static Bool HasGrfProcessStrokeBug (void);
static Bool HasMenuHandleEventBug (void);
// Bugs fixed in 3.2
static Bool HasBackspaceCharBug (void);
static Bool HasDeletedStackBug (void);
static Bool HasFindSaveFindStrBug (void);
static Bool HasFldDeleteBug (void);
static Bool HasFntDefineFontBug (void);
static Bool HasNetPrvTaskMainBug (void);
static Bool HasNetPrvSettingSetBug (void);
// Bugs fixed in 3.3
static Bool HasECValidateFieldBug (void);
// Bugs fixed in 3.5
static Bool HasConvertDepth1To2BWBug(void);
// Bugs fixed in 4.0
static Bool HasSelectItemBug (void);
static Bool HasSyncNotifyBug (void);
// Bugs fixed in ???
static Bool HasPrvDrawSliderControlBug (void);
static Bool GetAutoAcceptBeamDialogs (void);
static Bool AutoAcceptBeamDialogs (Bool newState);
static UInt16 GetROMCharEncoding (void);
static Bool EvtGetEventCalled (void);
static Bool IsInSysBinarySearch (void);
static void EnterSysBinarySearch (void);
static void ExitSysBinarySearch (void);
static uint16 GetQuitAppCardNo (void);
static LocalID GetQuitAppDbID (void);
static void SetEncoding (uint32 encoding);
static Bool IsPCInMemMgr (void);
static void EnterMemMgr (const char* fnName);
static void ExitMemMgr (const char* fnName);
static Bool UIInitialized (void);
static void SetUIInitialized (Bool value = true);
static void SetUIReset (Bool value = true);
static void SetHeapInitialized (Bool value = true);
static Bool UIReset (void);
static Bool HeapInitialized (void);
// inline functions
static uint16 GetNextAppCardNo (void)
{
return fgData.fNextAppCardNo;
}
static LocalID GetNextAppDbID (void)
{
return fgData.fNextAppDbID;
}
static void SetNextAppCardNo (uint16 cardno)
{
fgData.fNextAppCardNo = cardno;
}
static void SetNextAppDbID (LocalID id)
{
fgData.fNextAppDbID = id;
}
public:
static EmPatchStateData fgData;
};
#endif // EmPatchState_h
|