forked from tonioni/WinUAE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoduleripper.cpp
143 lines (123 loc) · 2.89 KB
/
moduleripper.cpp
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
/*
* UAE - The Un*x Amiga Emulator
*
* Pro-Wizard glue code
*
* Copyright 2004 Toni Wilen
*/
#include "sysconfig.h"
#include "sysdeps.h"
#ifdef PROWIZARD
#include "options.h"
#include "memory.h"
#include "moduleripper.h"
#include "gui.h"
#include "uae.h"
static int got, canceled;
static void mc (uae_u8 *d, uaecptr s, int size)
{
int i;
for (i = 0; i < size; i++)
d[i] = get_byte (s++);
}
#ifdef _WIN32
static LONG WINAPI ExceptionFilter (struct _EXCEPTION_POINTERS * pExceptionPointers, DWORD ec)
{
return EXCEPTION_EXECUTE_HANDLER;
}
#endif
void moduleripper (void)
{
int size;
uae_u8 *buf, *p;
size = currprefs.chipmem_size;
size += currprefs.fastmem_size;
size += currprefs.bogomem_size;
size += currprefs.mbresmem_low_size;
size += currprefs.mbresmem_high_size;
size += currprefs.z3fastmem_size;
size += currprefs.z3fastmem2_size;
buf = p = xmalloc (uae_u8, size);
if (!buf)
return;
memcpy (p, chipmemory, currprefs.chipmem_size);
p += currprefs.chipmem_size;
mc (p, fastmem_start, currprefs.fastmem_size);
p += currprefs.fastmem_size;
mc (p, bogomem_start, currprefs.bogomem_size);
p += currprefs.bogomem_size;
mc (p, a3000lmem_start, currprefs.mbresmem_low_size);
p += currprefs.mbresmem_low_size;
mc (p, a3000hmem_start, currprefs.mbresmem_high_size);
p += currprefs.mbresmem_high_size;
mc (p, z3fastmem_start, currprefs.z3fastmem_size);
p += currprefs.z3fastmem_size;
mc (p, z3fastmem_start + currprefs.z3fastmem_size, currprefs.z3fastmem2_size);
p += currprefs.z3fastmem2_size;
got = 0;
canceled = 0;
#ifdef _WIN32
__try {
#endif
prowizard_search (buf, size);
#ifdef _WIN32
} __except(ExceptionFilter (GetExceptionInformation (), GetExceptionCode ())) {
write_log (L"prowizard scan crashed\n");
}
#endif
if (!got)
notify_user (NUMSG_MODRIP_NOTFOUND);
else if (!canceled)
notify_user (NUMSG_MODRIP_FINISHED);
xfree (buf);
}
extern "C"
{
FILE *moduleripper_fopen (const char *aname, const char *amode)
{
TCHAR tmp2[MAX_DPATH];
TCHAR tmp[MAX_DPATH];
TCHAR *name, *mode;
FILE *f;
fetch_ripperpath (tmp, sizeof tmp);
name = au (aname);
mode = au (amode);
_stprintf (tmp2, L"%s%s", tmp, name);
f = _tfopen (tmp2, mode);
xfree (mode);
xfree (name);
return f;
}
FILE *moduleripper2_fopen (const char *name, const char *mode, const char *aid, int addr, int size)
{
TCHAR msg[MAX_DPATH], msg2[MAX_DPATH];
TCHAR *id;
int ret;
if (canceled)
return NULL;
got++;
translate_message (NUMSG_MODRIP_SAVE, msg);
id = au (aid);
_stprintf (msg2, msg, id, addr, size);
ret = gui_message_multibutton (2, msg2);
xfree (id);
if (ret < 0)
canceled = 1;
if (ret < 0 || ret != 1)
return NULL;
return moduleripper_fopen (name, mode);
}
void pw_write_log (const char *format,...)
{
}
}
#else
FILE *moduleripper_fopen (const char *name, const char *mode)
{
return NULL;
}
FILE *moduleripper2_fopen (const char *name, const char *mode, const char *id)
{
return NULL;
}
#endif