| 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 |
#define EMU_QTX_API |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
#include "config.h" |
|---|
| 37 |
|
|---|
| 38 |
#include <assert.h> |
|---|
| 39 |
#include <errno.h> |
|---|
| 40 |
#include <fcntl.h> |
|---|
| 41 |
#include <stdio.h> |
|---|
| 42 |
#include <stdlib.h> |
|---|
| 43 |
#include <string.h> |
|---|
| 44 |
#include <unistd.h> |
|---|
| 45 |
#include <sys/mman.h> |
|---|
| 46 |
#include <inttypes.h> |
|---|
| 47 |
|
|---|
| 48 |
#include "wine/windef.h" |
|---|
| 49 |
#include "wine/winerror.h" |
|---|
| 50 |
#include "wine/heap.h" |
|---|
| 51 |
#include "wine/module.h" |
|---|
| 52 |
#include "wine/pe_image.h" |
|---|
| 53 |
#include "wine/debugtools.h" |
|---|
| 54 |
|
|---|
| 55 |
#undef HAVE_LIBDL |
|---|
| 56 |
|
|---|
| 57 |
#ifdef HAVE_LIBDL |
|---|
| 58 |
#include <dlfcn.h> |
|---|
| 59 |
#include "wine/elfdll.h" |
|---|
| 60 |
#endif |
|---|
| 61 |
#include "win32.h" |
|---|
| 62 |
#include "driver.h" |
|---|
| 63 |
|
|---|
| 64 |
#ifdef EMU_QTX_API |
|---|
| 65 |
#include "wrapper.h" |
|---|
| 66 |
static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags); |
|---|
| 67 |
static int report_func_ret(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags); |
|---|
| 68 |
#endif |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
modref_list* local_wm=NULL; |
|---|
| 75 |
|
|---|
| 76 |
HANDLE SegptrHeap; |
|---|
| 77 |
|
|---|
| 78 |
WINE_MODREF* MODULE_FindModule(LPCSTR m) |
|---|
| 79 |
{ |
|---|
| 80 |
modref_list* list=local_wm; |
|---|
| 81 |
TRACE("FindModule: Module %s request\n", m); |
|---|
| 82 |
if(list==NULL) |
|---|
| 83 |
return NULL; |
|---|
| 84 |
|
|---|
| 85 |
while(!strstr(list->wm->filename, m)) |
|---|
| 86 |
{ |
|---|
| 87 |
TRACE("%s: %x\n", list->wm->filename, list->wm->module); |
|---|
| 88 |
list=list->prev; |
|---|
| 89 |
if(list==NULL) |
|---|
| 90 |
return NULL; |
|---|
| 91 |
} |
|---|
| 92 |
TRACE("Resolved to %s\n", list->wm->filename); |
|---|
| 93 |
return list->wm; |
|---|
| 94 |
} |
|---|
| 95 |
|
|---|
| 96 |
static void MODULE_RemoveFromList(WINE_MODREF *mod) |
|---|
| 97 |
{ |
|---|
| 98 |
modref_list* list=local_wm; |
|---|
| 99 |
if(list==0) |
|---|
| 100 |
return; |
|---|
| 101 |
if(mod==0) |
|---|
| 102 |
return; |
|---|
| 103 |
if((list->prev==NULL)&&(list->next==NULL)) |
|---|
| 104 |
{ |
|---|
| 105 |
free(list); |
|---|
| 106 |
local_wm=NULL; |
|---|
| 107 |
|
|---|
| 108 |
return; |
|---|
| 109 |
} |
|---|
| 110 |
for(;list;list=list->prev) |
|---|
| 111 |
{ |
|---|
| 112 |
if(list->wm==mod) |
|---|
| 113 |
{ |
|---|
| 114 |
if(list->prev) |
|---|
| 115 |
list->prev->next=list->next; |
|---|
| 116 |
if(list->next) |
|---|
| 117 |
list->next->prev=list->prev; |
|---|
| 118 |
if(list==local_wm) |
|---|
| 119 |
local_wm=list->prev; |
|---|
| 120 |
free(list); |
|---|
| 121 |
return; |
|---|
| 122 |
} |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
} |
|---|
| 126 |
|
|---|
| 127 |
WINE_MODREF *MODULE32_LookupHMODULE(HMODULE m) |
|---|
| 128 |
{ |
|---|
| 129 |
modref_list* list=local_wm; |
|---|
| 130 |
TRACE("LookupHMODULE: Module %X request\n", m); |
|---|
| 131 |
if(list==NULL) |
|---|
| 132 |
{ |
|---|
| 133 |
TRACE("LookupHMODULE failed\n"); |
|---|
| 134 |
return NULL; |
|---|
| 135 |
} |
|---|
| 136 |
while(m!=list->wm->module) |
|---|
| 137 |
{ |
|---|
| 138 |
|
|---|
| 139 |
|
|---|
| 140 |
list=list->prev; |
|---|
| 141 |
if(list==NULL) |
|---|
| 142 |
{ |
|---|
| 143 |
TRACE("LookupHMODULE failed\n"); |
|---|
| 144 |
return NULL; |
|---|
| 145 |
} |
|---|
| 146 |
} |
|---|
| 147 |
TRACE("LookupHMODULE hit %p\n", list->wm); |
|---|
| 148 |
return list->wm; |
|---|
| 149 |
} |
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 |
static WIN_BOOL MODULE_InitDll( WINE_MODREF *wm, DWORD type, LPVOID lpReserved ) |
|---|
| 155 |
{ |
|---|
| 156 |
WIN_BOOL retv = TRUE; |
|---|
| 157 |
|
|---|
| 158 |
static LPCSTR typeName[] = { "PROCESS_DETACH", "PROCESS_ATTACH", |
|---|
| 159 |
"THREAD_ATTACH", "THREAD_DETACH" }; |
|---|
| 160 |
assert( wm ); |
|---|
| 161 |
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
if ( ( wm->flags & WINE_MODREF_DONT_RESOLVE_REFS ) |
|---|
| 166 |
|| ( wm->flags & WINE_MODREF_LOAD_AS_DATAFILE ) ) |
|---|
| 167 |
return TRUE; |
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
TRACE("(%s,%s,%p) - CALL\n", wm->modname, typeName[type], lpReserved ); |
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
switch ( wm->type ) |
|---|
| 174 |
{ |
|---|
| 175 |
case MODULE32_PE: |
|---|
| 176 |
retv = PE_InitDLL( wm, type, lpReserved ); |
|---|
| 177 |
break; |
|---|
| 178 |
|
|---|
| 179 |
case MODULE32_ELF: |
|---|
| 180 |
|
|---|
| 181 |
break; |
|---|
| 182 |
|
|---|
| 183 |
default: |
|---|
| 184 |
ERR("wine_modref type %d not handled.\n", wm->type ); |
|---|
| 185 |
retv = FALSE; |
|---|
| 186 |
break; |
|---|
| 187 |
} |
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 |
|
|---|
| 191 |
|
|---|
| 192 |
TRACE("(%p,%s,%p) - RETURN %d\n", wm, typeName[type], lpReserved, retv ); |
|---|
| 193 |
|
|---|
| 194 |
return retv; |
|---|
| 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 |
static WIN_BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved ) |
|---|
| 230 |
{ |
|---|
| 231 |
WIN_BOOL retv = TRUE; |
|---|
| 232 |
int i; |
|---|
| 233 |
assert( wm ); |
|---|
| 234 |
|
|---|
| 235 |
|
|---|
| 236 |
if ( ( wm->flags & WINE_MODREF_MARKER ) |
|---|
| 237 |
|| ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) ) |
|---|
| 238 |
return retv; |
|---|
| 239 |
|
|---|
| 240 |
TRACE("(%s,%p) - START\n", wm->modname, lpReserved ); |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
wm->flags |= WINE_MODREF_MARKER; |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 |
|
|---|
| 252 |
|
|---|
| 253 |
if(local_wm) |
|---|
| 254 |
{ |
|---|
| 255 |
local_wm->next = (modref_list*) malloc(sizeof(modref_list)); |
|---|
| 256 |
local_wm->next->prev=local_wm; |
|---|
| 257 |
local_wm->next->next=NULL; |
|---|
| 258 |
local_wm->next->wm=wm; |
|---|
| 259 |
local_wm=local_wm->next; |
|---|
| 260 |
} |
|---|
| 261 |
else |
|---|
| 262 |
{ |
|---|
| 263 |
local_wm = (modref_list*)malloc(sizeof(modref_list)); |
|---|
| 264 |
local_wm->next=local_wm->prev=NULL; |
|---|
| 265 |
local_wm->wm=wm; |
|---|
| 266 |
} |
|---|
| 267 |
|
|---|
| 268 |
wm->flags &= ~WINE_MODREF_MARKER; |
|---|
| 269 |
|
|---|
| 270 |
if ( retv ) |
|---|
| 271 |
{ |
|---|
| 272 |
retv = MODULE_InitDll( wm, DLL_PROCESS_ATTACH, lpReserved ); |
|---|
| 273 |
if ( retv ) |
|---|
| 274 |
wm->flags |= WINE_MODREF_PROCESS_ATTACHED; |
|---|
| 275 |
} |
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
TRACE("(%s,%p) - END\n", wm->modname, lpReserved ); |
|---|
| 279 |
|
|---|
| 280 |
return retv; |
|---|
| 281 |
} |
|---|
| 282 |
|
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 |
static void MODULE_DllProcessDetach( WINE_MODREF* wm, WIN_BOOL bForceDetach, LPVOID lpReserved ) |
|---|
| 291 |
{ |
|---|
| 292 |
|
|---|
| 293 |
modref_list* l = local_wm; |
|---|
| 294 |
wm->flags &= ~WINE_MODREF_PROCESS_ATTACHED; |
|---|
| 295 |
MODULE_InitDll( wm, DLL_PROCESS_DETACH, lpReserved ); |
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
|
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 |
|
|---|
| 303 |
} |
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
static WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags ) |
|---|
| 317 |
{ |
|---|
| 318 |
DWORD err = GetLastError(); |
|---|
| 319 |
WINE_MODREF *pwm; |
|---|
| 320 |
int i; |
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
SetLastError( ERROR_FILE_NOT_FOUND ); |
|---|
| 324 |
TRACE("Trying native dll '%s'\n", libname); |
|---|
| 325 |
pwm = PE_LoadLibraryExA(libname, flags); |
|---|
| 326 |
#ifdef HAVE_LIBDL |
|---|
| 327 |
if(!pwm) |
|---|
| 328 |
{ |
|---|
| 329 |
TRACE("Trying ELF dll '%s'\n", libname); |
|---|
| 330 |
pwm=(WINE_MODREF*)ELFDLL_LoadLibraryExA(libname, flags); |
|---|
| 331 |
} |
|---|
| 332 |
#endif |
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 |
if(pwm) |
|---|
| 336 |
{ |
|---|
| 337 |
|
|---|
| 338 |
TRACE("Loaded module '%s' at 0x%08x, \n", libname, pwm->module); |
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
pwm->refCount++; |
|---|
| 342 |
|
|---|
| 343 |
SetLastError( err ); |
|---|
| 344 |
return pwm; |
|---|
| 345 |
} |
|---|
| 346 |
|
|---|
| 347 |
|
|---|
| 348 |
WARN("Failed to load module '%s'; error=0x%08lx, \n", libname, GetLastError()); |
|---|
| 349 |
return NULL; |
|---|
| 350 |
} |
|---|
| 351 |
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 |
|
|---|
| 355 |
|
|---|
| 356 |
|
|---|
| 357 |
static WIN_BOOL MODULE_FreeLibrary( WINE_MODREF *wm ) |
|---|
| 358 |
{ |
|---|
| 359 |
TRACE("(%s) - START\n", wm->modname ); |
|---|
| 360 |
|
|---|
| 361 |
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 |
|
|---|
| 365 |
MODULE_DllProcessDetach( wm, FALSE, NULL ); |
|---|
| 366 |
|
|---|
| 367 |
PE_UnloadLibrary(wm); |
|---|
| 368 |
|
|---|
| 369 |
TRACE("END\n"); |
|---|
| 370 |
|
|---|
| 371 |
return TRUE; |
|---|
| 372 |
} |
|---|
| 373 |
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags) |
|---|
| 378 |
{ |
|---|
| 379 |
WINE_MODREF *wm = 0; |
|---|
| 380 |
char* listpath[] = { "", "", "/usr/lib/win32", "/usr/local/lib/win32", "/usr/lib/codecs", "/usr/local/lib/codecs", 0 }; |
|---|
| 381 |
extern char* def_path; |
|---|
| 382 |
char path[512]; |
|---|
| 383 |
char checked[2000]; |
|---|
| 384 |
int i = -1; |
|---|
| 385 |
|
|---|
| 386 |
checked[0] = 0; |
|---|
| 387 |
if(!libname) |
|---|
| 388 |
{ |
|---|
| 389 |
SetLastError(ERROR_INVALID_PARAMETER); |
|---|
| 390 |
return 0; |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
wm=MODULE_FindModule(libname); |
|---|
| 394 |
if(wm) return wm->module; |
|---|
| 395 |
|
|---|
| 396 |
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 |
while (wm == 0 && listpath[++i]) |
|---|
| 400 |
{ |
|---|
| 401 |
if (i < 2) |
|---|
| 402 |
{ |
|---|
| 403 |
if (i == 0) |
|---|
| 404 |
|
|---|
| 405 |
strncpy(path, libname, 511); |
|---|
| 406 |
else |
|---|
| 407 |
|
|---|
| 408 |
strncpy(path, def_path, 300); |
|---|
| 409 |
} |
|---|
| 410 |
else if (strcmp(def_path, listpath[i])) |
|---|
| 411 |
|
|---|
| 412 |
strncpy(path, listpath[i], 300); |
|---|
| 413 |
else |
|---|
| 414 |
continue; |
|---|
| 415 |
|
|---|
| 416 |
if (i > 0) |
|---|
| 417 |
{ |
|---|
| 418 |
strcat(path, "/"); |
|---|
| 419 |
strncat(path, libname, 100); |
|---|
| 420 |
} |
|---|
| 421 |
path[511] = 0; |
|---|
| 422 |
wm = MODULE_LoadLibraryExA( path, hfile, flags ); |
|---|
| 423 |
|
|---|
| 424 |
if (!wm) |
|---|
| 425 |
{ |
|---|
| 426 |
if (checked[0]) |
|---|
| 427 |
strcat(checked, ", "); |
|---|
| 428 |
strcat(checked, path); |
|---|
| 429 |
checked[1500] = 0; |
|---|
| 430 |
|
|---|
| 431 |
} |
|---|
| 432 |
} |
|---|
| 433 |
if ( wm ) |
|---|
| 434 |
{ |
|---|
| 435 |
if ( !MODULE_DllProcessAttach( wm, NULL ) ) |
|---|
| 436 |
{ |
|---|
| 437 |
WARN_(module)("Attach failed for module '%s', \n", libname); |
|---|
| 438 |
MODULE_FreeLibrary(wm); |
|---|
| 439 |
SetLastError(ERROR_DLL_INIT_FAILED); |
|---|
| 440 |
MODULE_RemoveFromList(wm); |
|---|
| 441 |
wm = NULL; |
|---|
| 442 |
} |
|---|
| 443 |
} |
|---|
| 444 |
|
|---|
| 445 |
if (!wm) |
|---|
| 446 |
printf("Win32 LoadLibrary failed to load: %s\n", checked); |
|---|
| 447 |
|
|---|
| 448 |
if (strstr(libname,"vp31vfw.dll") && wm) |
|---|
| 449 |
{ |
|---|
| 450 |
int i; |
|---|
| 451 |
|
|---|
| 452 |
|
|---|
| 453 |
if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10001000) { |
|---|
| 454 |
fprintf(stderr, "VP3 DLL found\n"); |
|---|
| 455 |
for (i=0;i<18;i++) ((char*)0x10004bd6)[i]=0x90; |
|---|
| 456 |
} |
|---|
| 457 |
} |
|---|
| 458 |
|
|---|
| 459 |
|
|---|
| 460 |
if (strstr(libname,"vp5vfw.dll") && wm) |
|---|
| 461 |
{ |
|---|
| 462 |
int i; |
|---|
| 463 |
if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003930) { |
|---|
| 464 |
for (i=0;i<3;i++) ((char*)0x10004e86)[i]=0x90; |
|---|
| 465 |
for (i=0;i<3;i++) ((char*)0x10005a23)[i]=0x90; |
|---|
| 466 |
for (i=0;i<3;i++) ((char*)0x10005bff)[i]=0x90; |
|---|
| 467 |
} else { |
|---|
| 468 |
fprintf(stderr, "Unsupported VP5 version\n"); |
|---|
| 469 |
return 0; |
|---|
| 470 |
} |
|---|
| 471 |
} |
|---|
| 472 |
|
|---|
| 473 |
if (strstr(libname,"vp6vfw.dll") && wm) |
|---|
| 474 |
{ |
|---|
| 475 |
int i; |
|---|
| 476 |
if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003ef0) { |
|---|
| 477 |
|
|---|
| 478 |
for (i=0;i<6;i++) ((char*)0x10007268)[i]=0x90; |
|---|
| 479 |
for (i=0;i<6;i++) ((char*)0x10007e83)[i]=0x90; |
|---|
| 480 |
for (i=0;i<6;i++) ((char*)0x1000806a)[i]=0x90; |
|---|
| 481 |
} else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10004120) { |
|---|
| 482 |
|
|---|
| 483 |
for (i=0;i<6;i++) ((char*)0x10007688)[i]=0x90; |
|---|
| 484 |
for (i=0;i<6;i++) ((char*)0x100082c3)[i]=0x90; |
|---|
| 485 |
for (i=0;i<6;i++) ((char*)0x100084aa)[i]=0x90; |
|---|
| 486 |
} else if (PE_FindExportedFunction(wm, "DriverProc", TRUE)==(void*)0x10003e70) { |
|---|
| 487 |
|
|---|
| 488 |
for (i=0;i<6;i++) ((char*)0x10007559)[i]=0x90; |
|---|
| 489 |
for (i=0;i<6;i++) ((char*)0x100081c3)[i]=0x90; |
|---|
| 490 |
for (i=0;i<6;i++) ((char*)0x1000839e)[i]=0x90; |
|---|
| 491 |
} else { |
|---|
| 492 |
fprintf(stderr, "Unsupported VP6 version\n"); |
|---|
| 493 |
return 0; |
|---|
| 494 |
} |
|---|
| 495 |
} |
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 |
if (strstr(libname,"wmvadvd.dll") && wm) |
|---|
| 499 |
{ |
|---|
| 500 |
|
|---|
| 501 |
|
|---|
| 502 |
if (PE_FindExportedFunction(wm, "CreateInstance", TRUE)==(void*)0x08c4b812) { |
|---|
| 503 |
|
|---|
| 504 |
*((char*)0x08c48b0f)=0xeb; |
|---|
| 505 |
} else { |
|---|
| 506 |
fprintf(stderr, "Unsupported WMVA version\n"); |
|---|
| 507 |
return 0; |
|---|
| 508 |
} |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
if (strstr(libname,"QuickTime.qts") && wm) |
|---|
| 512 |
{ |
|---|
| 513 |
void** ptr; |
|---|
| 514 |
void *dispatch_addr; |
|---|
| 515 |
int i; |
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
dispatch_addr = PE_FindExportedFunction(wm, "theQuickTimeDispatcher", TRUE); |
|---|
| 519 |
if (dispatch_addr == (void *)0x62924c30) |
|---|
| 520 |
{ |
|---|
| 521 |
fprintf(stderr, "QuickTime5 DLLs found\n"); |
|---|
| 522 |
ptr = (void **)0x62b75ca4; |
|---|
| 523 |
for (i=0;i<5;i++) ((char*)0x6299e842)[i]=0x90; |
|---|
| 524 |
for (i=0;i<28;i++) ((char*)0x6299e86d)[i]=0x90; |
|---|
| 525 |
for (i=0;i<5;i++) ((char*)0x6299e898)[i]=0x90; |
|---|
| 526 |
for (i=0;i<9;i++) ((char*)0x6299e8ac)[i]=0x90; |
|---|
| 527 |
for (i=0;i<106;i++) ((char*)0x62a61b10)[i]=0x90; |
|---|
| 528 |
#if 0 |
|---|
| 529 |
|
|---|
| 530 |
for (i=0;i<5;i++) ((char*)0x629487c5)[i]=0x90; |
|---|
| 531 |
for (i=0;i<5;i++) ((char*)0x6294b275)[i]=0x90; |
|---|
| 532 |
for (i=0;i<5;i++) ((char*)0x629a24b1)[i]=0x90; |
|---|
| 533 |
for (i=0;i<5;i++) ((char*)0x629afc5a)[i]=0x90; |
|---|
| 534 |
for (i=0;i<5;i++) ((char*)0x62af799c)[i]=0x90; |
|---|
| 535 |
for (i=0;i<5;i++) ((char*)0x62af7efe)[i]=0x90; |
|---|
| 536 |
for (i=0;i<5;i++) ((char*)0x62afa33e)[i]=0x90; |
|---|
| 537 |
#endif |
|---|
| 538 |
|
|---|
| 539 |
#if 0 |
|---|
| 540 |
|
|---|
| 541 |
for (i=0;i<47;i++) ((char*)0x62afa3b8)[i]=0x90; |
|---|
| 542 |
for (i=0;i<47;i++) ((char*)0x62af7f78)[i]=0x90; |
|---|
| 543 |
for (i=0;i<77;i++) ((char*)0x629a13d5)[i]=0x90; |
|---|
| 544 |
((char *)0x6288e0ae)[0] = 0xc3; |
|---|
| 545 |
for (i=0;i<24;i++) ((char*)0x6287a1ad)[i]=0x90; |
|---|
| 546 |
#endif |
|---|
| 547 |
} else if (dispatch_addr == (void *)0x6693b330) |
|---|
| 548 |
{ |
|---|
| 549 |
fprintf(stderr, "QuickTime6 DLLs found\n"); |
|---|
| 550 |
ptr = (void **)0x66bb9524; |
|---|
| 551 |
for (i=0;i<5;i++) ((char *)0x66a730cc)[i]=0x90; |
|---|
| 552 |
for (i=0;i<28;i++) ((char *)0x66a730f7)[i]=0x90; |
|---|
| 553 |
for (i=0;i<5;i++) ((char *)0x66a73122)[i]=0x90; |
|---|
| 554 |
for (i=0;i<9;i++) ((char *)0x66a73131)[i]=0x90; |
|---|
| 555 |
for (i=0;i<96;i++) ((char *)0x66aac852)[i]=0x90; |
|---|
| 556 |
} else if (dispatch_addr == (void *)0x6693c3e0) |
|---|
| 557 |
{ |
|---|
| 558 |
fprintf(stderr, "QuickTime6.3 DLLs found\n"); |
|---|
| 559 |
ptr = (void **)0x66bca01c; |
|---|
| 560 |
for (i=0;i<5;i++) ((char *)0x66a68f6c)[i]=0x90; |
|---|
| 561 |
for (i=0;i<28;i++) ((char *)0x66a68f97)[i]=0x90; |
|---|
| 562 |
for (i=0;i<5;i++) ((char *)0x66a68fc2)[i]=0x90; |
|---|
| 563 |
for (i=0;i<9;i++) ((char *)0x66a68fd1)[i]=0x90; |
|---|
| 564 |
for (i=0;i<96;i++) ((char *)0x66ab4722)[i]=0x90; |
|---|
| 565 |
} else |
|---|
| 566 |
{ |
|---|
| 567 |
fprintf(stderr, "Unsupported QuickTime version (%p)\n", |
|---|
| 568 |
dispatch_addr); |
|---|
| 569 |
return 0; |
|---|
| 570 |
} |
|---|
| 571 |
|
|---|
| 572 |
fprintf(stderr,"QuickTime.qts patched!!! old entry=%p\n",ptr[0]); |
|---|
| 573 |
|
|---|
| 574 |
#ifdef EMU_QTX_API |
|---|
| 575 |
report_entry = report_func; |
|---|
| 576 |
report_ret = report_func_ret; |
|---|
| 577 |
wrapper_target=ptr[0]; |
|---|
| 578 |
ptr[0]=wrapper; |
|---|
| 579 |
#endif |
|---|
| 580 |
} |
|---|
| 581 |
|
|---|
| 582 |
return wm ? wm->module : 0; |
|---|
| 583 |
} |
|---|
| 584 |
|
|---|
| 585 |
|
|---|
| 586 |
|
|---|
| 587 |
|
|---|
| 588 |
|
|---|
| 589 |
HMODULE WINAPI LoadLibraryA(LPCSTR libname) { |
|---|
| 590 |
return LoadLibraryExA(libname,0,0); |
|---|
| 591 |
} |
|---|
| 592 |
|
|---|
| 593 |
|
|---|
| 594 |
|
|---|
| 595 |
|
|---|
| 596 |
WIN_BOOL WINAPI FreeLibrary(HINSTANCE hLibModule) |
|---|
| 597 |
{ |
|---|
| 598 |
WIN_BOOL retv = FALSE; |
|---|
| 599 |
WINE_MODREF *wm; |
|---|
| 600 |
|
|---|
| 601 |
wm=MODULE32_LookupHMODULE(hLibModule); |
|---|
| 602 |
|
|---|
| 603 |
if ( !wm || !hLibModule ) |
|---|
| 604 |
{ |
|---|
| 605 |
SetLastError( ERROR_INVALID_HANDLE ); |
|---|
| 606 |
return 0; |
|---|
| 607 |
} |
|---|
| 608 |
else |
|---|
| 609 |
retv = MODULE_FreeLibrary( wm ); |
|---|
| 610 |
|
|---|
| 611 |
MODULE_RemoveFromList(wm); |
|---|
| 612 |
|
|---|
| 613 |
|
|---|
| 614 |
if (local_wm == NULL) my_garbagecollection(); |
|---|
| 615 |
|
|---|
| 616 |
return retv; |
|---|
| 617 |
} |
|---|
| 618 |
|
|---|
| 619 |
|
|---|
| 620 |
|
|---|
| 621 |
|
|---|
| 622 |
|
|---|
| 623 |
|
|---|
| 624 |
static void MODULE_DecRefCount( WINE_MODREF *wm ) |
|---|
| 625 |
{ |
|---|
| 626 |
int i; |
|---|
| 627 |
|
|---|
| 628 |
if ( wm->flags & WINE_MODREF_MARKER ) |
|---|
| 629 |
return; |
|---|
| 630 |
|
|---|
| 631 |
if ( wm->refCount <= 0 ) |
|---|
| 632 |
return; |
|---|
| 633 |
|
|---|
| 634 |
--wm->refCount; |
|---|
| 635 |
TRACE("(%s) refCount: %d\n", wm->modname, wm->refCount ); |
|---|
| 636 |
|
|---|
| 637 |
if ( wm->refCount == 0 ) |
|---|
| 638 |
{ |
|---|
| 639 |
wm->flags |= WINE_MODREF_MARKER; |
|---|
| 640 |
|
|---|
| 641 |
for ( i = 0; i < wm->nDeps; i++ ) |
|---|
| 642 |
if ( wm->deps[i] ) |
|---|
| 643 |
MODULE_DecRefCount( wm->deps[i] ); |
|---|
| 644 |
|
|---|
| 645 |
wm->flags &= ~WINE_MODREF_MARKER; |
|---|
| 646 |
} |
|---|
| 647 |
} |
|---|
| 648 |
|
|---|
| 649 |
|
|---|
| 650 |
|
|---|
| 651 |
|
|---|
| 652 |
FARPROC WINAPI GetProcAddress( HMODULE hModule, LPCSTR function ) |
|---|
| 653 |
{ |
|---|
| 654 |
return MODULE_GetProcAddress( hModule, function, TRUE ); |
|---|
| 655 |
} |
|---|
| 656 |
|
|---|
| 657 |
#ifdef DEBUG_QTX_API |
|---|
| 658 |
|
|---|
| 659 |
|
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 |
|
|---|
| 663 |
struct ComponentParameters { |
|---|
| 664 |
unsigned char flags; |
|---|
| 665 |
unsigned char paramSize; |
|---|
| 666 |
short what; |
|---|
| 667 |
long params[1]; |
|---|
| 668 |
}; |
|---|
| 669 |
typedef struct ComponentParameters ComponentParameters; |
|---|
| 670 |
|
|---|
| 671 |
static char* component_func(int what){ |
|---|
| 672 |
if (what < 0) |
|---|
| 673 |
switch(what){ |
|---|
| 674 |
case -1: return "kComponentOpenSelect"; |
|---|
| 675 |
case -2: return "kComponentCloseSelect"; |
|---|
| 676 |
case -3: return "kComponentCanDoSelect"; |
|---|
| 677 |
case -4: return "kComponentVersionSelect"; |
|---|
| 678 |
case -5: return "kComponentRegisterSelect"; |
|---|
| 679 |
case -6: return "kComponentTargetSelect"; |
|---|
| 680 |
case -7: return "kComponentUnregisterSelect"; |
|---|
| 681 |
} |
|---|
| 682 |
|
|---|
| 683 |
if (what >= 0 && what <= 0xff) |
|---|
| 684 |
switch(what & 0xff){ |
|---|
| 685 |
case 0: return "kImageCodecGetCodecInfoSelect"; |
|---|
| 686 |
case 1: return "kImageCodecGetCompressionTimeSelect"; |
|---|
| 687 |
case 2: return "kImageCodecGetMaxCompressionSizeSelect"; |
|---|
| 688 |
case 3: return "kImageCodecPreCompressSelect"; |
|---|
| 689 |
case 4: return "kImageCodecBandCompressSelect"; |
|---|
| 690 |
case 5: return "kImageCodecPreDecompressSelect"; |
|---|
| 691 |
case 6: return "kImageCodecBandDecompressSelect"; |
|---|
| 692 |
case 7: return "kImageCodecBusySelect"; |
|---|
| 693 |
|
|---|
| 694 |
case 0x10: return "kImageCodecIsImageDescriptionEquivalentSelect"; |
|---|
| 695 |
case 0x12: return "kImageCodecDisposeMemorySelect"; |
|---|
| 696 |
case 0x14: return "kImageCodecNewImageBufferMemorySelect"; |
|---|
| 697 |
case 0x28: return "kImageCodecRequestGammaLevelSelect"; |
|---|
| 698 |
} |
|---|
| 699 |
|
|---|
| 700 |
|
|---|
| 701 |
|
|---|
| 702 |
if (what >= 0x200 && what <= 0x2ff) |
|---|
| 703 |
switch(what & 0xff){ |
|---|
| 704 |
case 0: return "Preflight"; |
|---|
| 705 |
case 1: return "Initialize"; |
|---|
| 706 |
case 2: return "BeginBand"; |
|---|
| 707 |
case 3: return "DrawBand"; |
|---|
| 708 |
case 4: return "EndBand"; |
|---|
| 709 |
case 5: return "QueueStarting"; |
|---|
| 710 |
case 6: return "QueueStopping"; |
|---|
| 711 |
} |
|---|
| 712 |
|
|---|
| 713 |
return "???"; |
|---|
| 714 |
} |
|---|
| 715 |
|
|---|
| 716 |
static int c_level=0; |
|---|
| 717 |
|
|---|
| 718 |
static int dump_component(char* name,int type,void* _orig, ComponentParameters *params,void** glob){ |
|---|
| 719 |
int ( *orig)(ComponentParameters *params, void** glob) = _orig; |
|---|
| 720 |
int ret,i; |
|---|
| 721 |
|
|---|
| 722 |
fprintf(stderr,"%*sComponentCall: %s flags=0x%X size=%d what=0x%X %s\n",3*c_level,"",name,params->flags, params->paramSize, params->what, component_func(params->what)); |
|---|
| 723 |
|
|---|
| 724 |
for(i=0;i<params->paramSize/4;i++) |
|---|
| 725 |
fprintf(stderr,"%*s param[%d] = 0x%X\n",3*c_level,"",i,params->params[i]); |
|---|
| 726 |
|
|---|
| 727 |
++c_level; |
|---|
| 728 |
ret=orig(params,glob); |
|---|
| 729 |
--c_level; |
|---|
| 730 |
|
|---|
| 731 |
if(ret>=0x1000) |
|---|
| 732 |
fprintf(stderr,"%*s return=0x%X\n",3*c_level,"",ret); |
|---|
| 733 |
else |
|---|
| 734 |
fprintf(stderr,"%*s return=%d\n",3*c_level,"",ret); |
|---|
| 735 |
return ret; |
|---|
| 736 |
} |
|---|
| 737 |
|
|---|
| 738 |
#define DECL_COMPONENT(sname,name,type) \ |
|---|
| 739 |
static void* real_ ## sname = NULL; \ |
|---|
| 740 |
static int fake_ ## sname(ComponentParameters *params,void** glob){ \ |
|---|
| 741 |
return dump_component(name,type,real_ ## sname, params, glob); \ |
|---|
| 742 |
} |
|---|
| 743 |
|
|---|
| 744 |
#include "qt_comp.h" |
|---|
| 745 |
|
|---|
| 746 |
#undef DECL_COMPONENT |
|---|
| 747 |
|
|---|
| 748 |
#include "qt_fv.h" |
|---|
| 749 |
|
|---|
| 750 |
#endif |
|---|
| 751 |
|
|---|
| 752 |
#ifdef EMU_QTX_API |
|---|
| 753 |
|
|---|
| 754 |
static uint32_t ret_array[4096]; |
|---|
| 755 |
static int ret_i=0; |
|---|
| 756 |
|
|---|
| 757 |
static int report_func(void *stack_base, int stack_size, reg386_t *reg, uint32_t *flags) |
|---|
| 758 |
{ |
|---|
| 759 |
#ifdef DEBUG_QTX_API |
|---|
| 760 |
int i; |
|---|
| 761 |
int* dptr; |
|---|
| 762 |
void* pwrapper=NULL; |
|---|
| 763 |
void* pptr=NULL; |
|---|
| 764 |
char* pname=NULL; |
|---|
| 765 |
int plen=-1; |
|---|
| 766 |
|
|---|
| 767 |
|
|---|
| 768 |
dptr=0x62b67ae0;dptr+=2*((reg->eax>>16)&255); |
|---|
| 769 |
|
|---|
| 770 |
if(dptr[0]&255){ |
|---|
| 771 |
dptr=dptr[1];dptr+=4*(reg->eax&65535); |
|---|
| 772 |
|
|---|
| 773 |
pwrapper=dptr[1]; pptr=dptr[0]; plen=dptr[2]; |
|---|
| 774 |
} else { |
|---|
| 775 |
pwrapper=0x62924910; |
|---|
| 776 |
switch(dptr[1]){ |
|---|
| 777 |
case 0x629248d0: |
|---|
| 778 |
dptr=0x62b672c0;dptr+=2*(reg->eax&65535); |
|---|
| 779 |
|
|---|
| 780 |
pptr=dptr[0]; plen=dptr[1]; |
|---|
| 781 |
break; |
|---|
| 782 |
case 0x62924e40: |
|---|
| 783 |
dptr=0x62b67c70;dptr+=2*(reg->eax&65535); |
|---|
| 784 |
|
|---|
| 785 |
pptr=dptr[0]; plen=dptr[1]; |
|---|
| 786 |
break; |
|---|
| 787 |
case 0x62924e60: |
|---|
| 788 |
dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535); |
|---|
| 789 |
|
|---|
| 790 |
pptr=dptr[0]; plen=dptr[1]; |
|---|
| 791 |
break; |
|---|
| 792 |
case 0x62924e80: |
|---|
| 793 |
dptr=0x62b68108;if(reg->eax&0x8000) dptr+=2*(reg->eax|0xffff0000); else dptr+=2*(reg->eax&65535); |
|---|
| 794 |
|
|---|
| 795 |
pptr=dptr[0]; plen=dptr[1]; |
|---|
| 796 |
break; |
|---|
| 797 |
default: |
|---|
| 798 |
printf("FUNC: unknown ptr & psize!\n"); |
|---|
| 799 |
pwrapper=dptr[1]; |
|---|
| 800 |
} |
|---|
| 801 |
} |
|---|
| 802 |
|
|---|
| 803 |
for(i=0;qt_fv_list[i].name;i++){ |
|---|
| 804 |
if(qt_fv_list[i].id==reg->eax){ |
|---|
| 805 |
pname=qt_fv_list[i].name; |
|---|
| 806 |
break; |
|---|
| 807 |
} |
|---|
| 808 |
} |
|---|
| 809 |
|
|---|
| 810 |
printf("FUNC[%X/%s]: wrapper=%p func=%p len=%d\n",reg->eax, |
|---|
| 811 |
pname?pname:"???",pwrapper,pptr,plen); |
|---|
| 812 |
|
|---|
| 813 |
printf("FUNC: caller=%p ebx=%p\n",((uint32_t *)stack_base)[0],reg->ebx); |
|---|
| 814 |
|
|---|
| 815 |
if(pname) |
|---|
| 816 |
printf("%*sENTER(%d): %s(",ret_i*2,"",ret_i,pname); |
|---|
| 817 |
else |
|---|
| 818 |
printf("%*sENTER(%d): %X(",ret_i*2,"",ret_i,reg->eax); |
|---|
| 819 |
for (i=0;i<plen/4;i++){ |
|---|
| 820 |
unsigned int val=((uint32_t *)stack_base)[1+i]; |
|---|
| 821 |
unsigned char* fcc=&val; |
|---|
| 822 |
&nb |
|---|