160 |
|
|
161 |
|
D(bug("FindLibSymbol %s in %s...\n", sym+1, lib+1)); |
162 |
|
|
163 |
< |
if (*(uint32 *)XLM_RUN_MODE == MODE_EMUL_OP) { |
163 |
> |
if (ReadMacInt32(XLM_RUN_MODE) == MODE_EMUL_OP) { |
164 |
|
M68kRegisters r; |
165 |
|
|
166 |
|
// Find shared library |
167 |
< |
static const uint16 proc1[] = { |
168 |
< |
0x558f, // subq.l #2,a7 |
169 |
< |
0x2f08, // move.l a0,-(a7) |
170 |
< |
0x2f3c, 0x7077, 0x7063, // move.l #'pwpc',-(a7) |
171 |
< |
0x2f3c, 0, 1, // move.l #kReferenceCFrag,-(a7) |
172 |
< |
0x2f09, // move.l a1,-(a7) |
173 |
< |
0x2f0a, // move.l a2,-(a7) |
174 |
< |
0x2f0b, // move.l a3,-(a7) |
175 |
< |
0x3f3c, 1, // (GetSharedLibrary) |
176 |
< |
0xaa5a, // CFMDispatch |
177 |
< |
0x301f, // move.w (a7)+,d0 |
178 |
< |
M68K_RTS |
167 |
> |
static const uint8 proc1[] = { |
168 |
> |
0x55, 0x8f, // subq.l #2,a7 |
169 |
> |
0x2f, 0x08, // move.l a0,-(a7) |
170 |
> |
0x2f, 0x3c, 0x70, 0x77, 0x70, 0x63, // move.l #'pwpc',-(a7) |
171 |
> |
0x2f, 0x3c, 0x00, 0x00, 0x00, 0x01, // move.l #kReferenceCFrag,-(a7) |
172 |
> |
0x2f, 0x09, // move.l a1,-(a7) |
173 |
> |
0x2f, 0x0a, // move.l a2,-(a7) |
174 |
> |
0x2f, 0x0b, // move.l a3,-(a7) |
175 |
> |
0x3f, 0x3c, 0x00, 0x01, // (GetSharedLibrary) |
176 |
> |
0xaa, 0x5a, // CFMDispatch |
177 |
> |
0x30, 0x1f, // move.w (a7)+,d0 |
178 |
> |
M68K_RTS >> 8, M68K_RTS & 0xff |
179 |
|
}; |
180 |
|
r.a[0] = (uint32)lib; |
181 |
|
r.a[1] = (uint32)&conn_id; |
182 |
|
r.a[2] = (uint32)&main_addr; |
183 |
|
r.a[3] = (uint32)err; |
184 |
|
Execute68k((uint32)proc1, &r); |
185 |
< |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], conn_id, main_addr)); |
185 |
> |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", (int16)r.d[0], ntohl(conn_id), ntohl((uintptr)main_addr))); |
186 |
|
if (r.d[0]) |
187 |
|
return NULL; |
188 |
|
|
189 |
|
// Find symbol |
190 |
< |
static const uint16 proc2[] = { |
191 |
< |
0x558f, // subq.l #2,a7 |
192 |
< |
0x2f00, // move.l d0,-(a7) |
193 |
< |
0x2f08, // move.l a0,-(a7) |
194 |
< |
0x2f09, // move.l a1,-(a7) |
195 |
< |
0x2f0a, // move.l a2,-(a7) |
196 |
< |
0x3f3c, 5, // (FindSymbol) |
197 |
< |
0xaa5a, // CFMDispatch |
198 |
< |
0x301f, // move.w (a7)+,d0 |
199 |
< |
M68K_RTS |
190 |
> |
static const uint8 proc2[] = { |
191 |
> |
0x55, 0x8f, // subq.l #2,a7 |
192 |
> |
0x2f, 0x00, // move.l d0,-(a7) |
193 |
> |
0x2f, 0x08, // move.l a0,-(a7) |
194 |
> |
0x2f, 0x09, // move.l a1,-(a7) |
195 |
> |
0x2f, 0x0a, // move.l a2,-(a7) |
196 |
> |
0x3f, 0x3c, 0x00, 0x05, // (FindSymbol) |
197 |
> |
0xaa, 0x5a, // CFMDispatch |
198 |
> |
0x30, 0x1f, // move.w (a7)+,d0 |
199 |
> |
M68K_RTS >> 8, M68K_RTS & 0xff |
200 |
|
}; |
201 |
< |
r.d[0] = conn_id; |
201 |
> |
r.d[0] = ntohl(conn_id); |
202 |
|
r.a[0] = (uint32)sym; |
203 |
|
r.a[1] = (uint32)&sym_addr; |
204 |
|
r.a[2] = (uint32)&sym_class; |
205 |
|
Execute68k((uint32)proc2, &r); |
206 |
< |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], sym_addr, sym_class)); |
206 |
> |
D(bug(" FindSymbol1: ret %d, sym_addr %p, sym_class %ld\n", (int16)r.d[0], ntohl((uintptr)sym_addr), ntohl(sym_class))); |
207 |
|
//!! CloseConnection()? |
208 |
|
if (r.d[0]) |
209 |
|
return NULL; |
210 |
|
else |
211 |
< |
return sym_addr; |
211 |
> |
return (void *)ntohl((uintptr)sym_addr); |
212 |
|
|
213 |
|
} else { |
214 |
|
|
218 |
|
} |
219 |
|
int16 res; |
220 |
|
res = GetSharedLibrary(lib, FOURCC('p','w','p','c'), 1, &conn_id, &main_addr, err); |
221 |
< |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, conn_id, main_addr)); |
221 |
> |
D(bug(" GetSharedLibrary: ret %d, connection ID %ld, main %p\n", res, ntohl(conn_id), ntohl((uintptr)main_addr))); |
222 |
|
if (res) |
223 |
|
return NULL; |
224 |
< |
res = FindSymbol(conn_id, sym, (void **)&sym_addr, &sym_class); |
225 |
< |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, sym_addr, sym_class)); |
224 |
> |
res = FindSymbol(ntohl(conn_id), sym, (void **)&sym_addr, &sym_class); |
225 |
> |
D(bug(" FindSymbol: ret %d, sym_addr %p, sym_class %ld\n", res, ntohl((uintptr)sym_addr), ntohl(sym_class))); |
226 |
|
//!!?? CloseConnection(&conn_id); |
227 |
|
if (res) |
228 |
|
return NULL; |
229 |
|
else |
230 |
< |
return sym_addr; |
230 |
> |
return (void *)ntohl((uintptr)sym_addr); |
231 |
|
} |
232 |
|
} |
233 |
|
|