27 |
|
#include "xlowmem.h" |
28 |
|
#include "emul_op.h" |
29 |
|
#include "macos_util.h" |
30 |
+ |
#include "thunks.h" |
31 |
|
|
32 |
|
#define DEBUG 0 |
33 |
|
#include "debug.h" |
151 |
|
* lib and sym must be Pascal strings! |
152 |
|
*/ |
153 |
|
|
154 |
< |
void *FindLibSymbol(char *lib, char *sym) |
154 |
> |
void *FindLibSymbol(char *lib_str, char *sym_str) |
155 |
|
{ |
156 |
< |
uint32 conn_id = 0; |
157 |
< |
void *main_addr = NULL; |
158 |
< |
char err[256] = ""; |
159 |
< |
uint32 *sym_addr = NULL; |
160 |
< |
uint32 sym_class = 0; |
156 |
> |
SheepVar32 conn_id = 0; |
157 |
> |
SheepVar32 main_addr = 0; |
158 |
> |
SheepArray<256> err; |
159 |
> |
WriteMacInt8(err.addr(), 0); |
160 |
> |
SheepVar32 sym_addr = 0; |
161 |
> |
SheepVar32 sym_class = 0; |
162 |
|
|
163 |
< |
D(bug("FindLibSymbol %s in %s...\n", sym+1, lib+1)); |
163 |
> |
SheepString lib(lib_str); |
164 |
> |
SheepString sym(sym_str); |
165 |
> |
|
166 |
> |
D(bug("FindLibSymbol %s in %s...\n", sym.value()+1, lib.value()+1)); |
167 |
|
|
168 |
|
if (ReadMacInt32(XLM_RUN_MODE) == MODE_EMUL_OP) { |
169 |
|
M68kRegisters r; |
182 |
|
0x30, 0x1f, // move.w (a7)+,d0 |
183 |
|
M68K_RTS >> 8, M68K_RTS & 0xff |
184 |
|
}; |
185 |
< |
r.a[0] = (uint32)lib; |
186 |
< |
r.a[1] = (uint32)&conn_id; |
187 |
< |
r.a[2] = (uint32)&main_addr; |
188 |
< |
r.a[3] = (uint32)err; |
185 |
> |
r.a[0] = lib.addr(); |
186 |
> |
r.a[1] = conn_id.addr(); |
187 |
> |
r.a[2] = main_addr.addr(); |
188 |
> |
r.a[3] = err.addr(); |
189 |
|
Execute68k((uint32)proc1, &r); |
190 |
< |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id, main_addr)); |
190 |
> |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id.value(), main_addr.value())); |
191 |
|
if (r.d[0]) |
192 |
|
return NULL; |
193 |
|
|
203 |
|
0x30, 0x1f, // move.w (a7)+,d0 |
204 |
|
M68K_RTS >> 8, M68K_RTS & 0xff |
205 |
|
}; |
206 |
< |
r.d[0] = conn_id; |
207 |
< |
r.a[0] = (uint32)sym; |
208 |
< |
r.a[1] = (uint32)&sym_addr; |
209 |
< |
r.a[2] = (uint32)&sym_class; |
206 |
> |
r.d[0] = conn_id.value(); |
207 |
> |
r.a[0] = sym.addr(); |
208 |
> |
r.a[1] = sym_addr.addr(); |
209 |
> |
r.a[2] = sym_class.addr(); |
210 |
|
Execute68k((uint32)proc2, &r); |
211 |
< |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr, sym_class)); |
211 |
> |
D(bug(" FindSymbol1: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr.value(), sym_class.value())); |
212 |
|
//!! CloseConnection()? |
213 |
|
if (r.d[0]) |
214 |
|
return NULL; |
215 |
|
else |
216 |
< |
return sym_addr; |
216 |
> |
return (void *)sym_addr.value(); |
217 |
|
|
218 |
|
} else { |
219 |
|
|
222 |
|
return 0; |
223 |
|
} |
224 |
|
int16 res; |
225 |
< |
res = GetSharedLibrary(lib, FOURCC('p','w','p','c'), 1, &conn_id, &main_addr, err); |
226 |
< |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id, main_addr)); |
225 |
> |
res = GetSharedLibrary(lib.value(), FOURCC('p','w','p','c'), 1, (uint32 *)conn_id.addr(), (void **)main_addr.addr(), (char *)err.addr()); |
226 |
> |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id.value(), main_addr.value())); |
227 |
|
if (res) |
228 |
|
return NULL; |
229 |
< |
res = FindSymbol(conn_id, sym, (void **)&sym_addr, &sym_class); |
230 |
< |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr, sym_class)); |
229 |
> |
res = FindSymbol(conn_id.value(), sym.value(), (void **)sym_addr.addr(), (uint32 *)sym_class.addr()); |
230 |
> |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr.value(), sym_class.value())); |
231 |
|
//!!?? CloseConnection(&conn_id); |
232 |
|
if (res) |
233 |
|
return NULL; |
234 |
|
else |
235 |
< |
return sym_addr; |
235 |
> |
return (void *)sym_addr.value(); |
236 |
|
} |
237 |
|
} |
238 |
|
|