- Timestamp:
- Sep 5, 2001, 12:30:21 PM (24 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/winmm/driver.c
r5433 r6639 1 1 /* -*- tab-width: 8; c-basic-offset: 4 -*- */ 2 2 3 /* 3 /* $Id: driver.c,v 1.2 2001-09-05 10:30:21 bird Exp $ 4 * 4 5 * WINE Drivers functions 5 6 * … … 32 33 DEFAULT_DEBUG_CHANNEL(driver); 33 34 34 static LPWINE_DRIVER 35 static LPWINE_DRIVER lpDrvItemList = NULL; 35 36 36 37 /* TODO list : 37 * - LoadModule count and clean up is not handled correctly (it's not a38 * 39 */ 40 41 /************************************************************************** 42 * DRIVER_GetNumberOfModuleRefs[internal]38 * - LoadModule count and clean up is not handled correctly (it's not a 39 * problem as long as FreeLibrary is not working correctly) 40 */ 41 42 /************************************************************************** 43 * DRIVER_GetNumberOfModuleRefs [internal] 43 44 * 44 45 * Returns the number of open drivers which share the same module. 45 46 */ 46 static WORDDRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)47 { 48 LPWINE_DRIVER 49 WORD 47 static WORD DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv) 48 { 49 LPWINE_DRIVER lpDrv; 50 WORD count = 0; 50 51 51 52 if (lpNewDrv->dwFlags & WINE_GDF_16BIT) ERR("OOOch"); 52 53 for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) { 53 54 55 56 54 if (!(lpDrv->dwFlags & WINE_GDF_16BIT) && 55 lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule) { 56 count++; 57 } 57 58 } 58 59 return count; … … 60 61 61 62 /************************************************************************** 62 * DRIVER_FindFromHDrvr[internal]63 * 63 * DRIVER_FindFromHDrvr [internal] 64 * 64 65 * From a hDrvr being 32 bits, returns the WINE internal structure. 65 66 */ 66 LPWINE_DRIVER 67 { 68 LPWINE_DRIVER 67 LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr) 68 { 69 LPWINE_DRIVER d = (LPWINE_DRIVER)hDrvr; 69 70 70 71 if (hDrvr && HeapValidate(GetProcessHeap(), 0, d) && d->dwMagic == WINE_DI_MAGIC) { 71 72 return d; 72 73 } 73 74 return NULL; … … 76 77 #ifndef __WIN32OS2__ 77 78 /************************************************************************** 78 * DRIVER_MapMsg32To16[internal]79 * DRIVER_MapMsg32To16 [internal] 79 80 * 80 81 * Map a 32 bit driver message to a 16 bit driver message. … … 86 87 static int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2) 87 88 { 88 int 89 89 int ret = -1; 90 90 91 switch (wMsg) { 91 92 case DRV_LOAD: … … 96 97 case DRV_REMOVE: 97 98 case DRV_EXITSESSION: 98 case DRV_EXITAPPLICATION: 99 case DRV_EXITAPPLICATION: 99 100 case DRV_POWER: 100 case DRV_CLOSE: 101 case DRV_OPEN: 102 103 104 105 101 case DRV_CLOSE: /* should be 0/0 */ 102 case DRV_OPEN: /* pass thru */ 103 /* lParam1 and lParam2 are not used */ 104 ret = 0; 105 break; 106 break; 106 107 case DRV_CONFIGURE: 107 108 case DRV_INSTALL: 108 /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used, 109 * lParam2 is a pointer to DRVCONFIGINFO 110 111 112 LPDRVCONFIGINFO16 113 LPDRVCONFIGINFO 114 115 116 LPSTRstr1, str2;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 109 /* lParam1 is a handle to a window (conf) or to a driver (inst) or not used, 110 * lParam2 is a pointer to DRVCONFIGINFO 111 */ 112 if (*lParam2) { 113 LPDRVCONFIGINFO16 dci16 = (LPDRVCONFIGINFO16)SEGPTR_ALLOC(sizeof(DRVCONFIGINFO16)); 114 LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)(*lParam2); 115 116 if (dci16) { 117 LPSTR str1, str2; 118 119 dci16->dwDCISize = sizeof(DRVCONFIGINFO16); 120 121 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCISectionName)) != NULL && 122 (str2 = SEGPTR_STRDUP(str1)) != NULL) { 123 dci16->lpszDCISectionName = SEGPTR_GET(str2); 124 if (!HeapFree(GetProcessHeap(), 0, str1)) 125 FIXME("bad free line=%d\n", __LINE__); 126 } else { 127 return -2; 128 } 129 if ((str1 = HEAP_strdupWtoA(GetProcessHeap(), 0, dci32->lpszDCIAliasName)) != NULL && 130 (str2 = SEGPTR_STRDUP(str1)) != NULL) { 131 dci16->lpszDCIAliasName = SEGPTR_GET(str2); 132 if (!HeapFree(GetProcessHeap(), 0, str1)) 133 FIXME("bad free line=%d\n", __LINE__); 134 } else { 135 return -2; 136 } 137 } else { 138 return -2; 139 } 140 *lParam2 = (LPARAM)SEGPTR_GET(dci16); 141 ret = 1; 142 } else { 143 ret = 0; 144 } 145 break; 145 146 default: 146 147 148 149 147 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) { 148 FIXME("Unknown message 0x%04x\n", wMsg); 149 } 150 ret = 0; 150 151 } 151 152 return ret; … … 153 154 154 155 /************************************************************************** 155 * DRIVER_UnMapMsg32To16[internal]156 * DRIVER_UnMapMsg32To16 [internal] 156 157 * 157 158 * UnMap a 32 bit driver message to a 16 bit driver message. … … 162 163 static int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2) 163 164 { 164 int 165 165 int ret = -1; 166 166 167 switch (wMsg) { 167 168 case DRV_LOAD: … … 176 177 case DRV_OPEN: 177 178 case DRV_CLOSE: 178 179 180 case DRV_CONFIGURE: 179 /* lParam1 and lParam2 are not used */ 180 break; 181 case DRV_CONFIGURE: 181 182 case DRV_INSTALL: 182 183 184 LPDRVCONFIGINFO16dci16 = MapSL(lParam2);185 186 187 188 189 190 191 192 193 194 183 /* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */ 184 if (lParam2) { 185 LPDRVCONFIGINFO16 dci16 = MapSL(lParam2); 186 187 if (!SEGPTR_FREE(MapSL(dci16->lpszDCISectionName))) 188 FIXME("bad free line=%d\n", __LINE__); 189 if (!SEGPTR_FREE(MapSL(dci16->lpszDCIAliasName))) 190 FIXME("bad free line=%d\n", __LINE__); 191 if (!SEGPTR_FREE(dci16)) 192 FIXME("bad free line=%d\n", __LINE__); 193 } 194 ret = 0; 195 break; 195 196 default: 196 197 198 199 197 if (!((wMsg >= 0x800 && wMsg < 0x900) || (wMsg >= 0x4000 && wMsg < 0x4100))) { 198 FIXME("Unknown message 0x%04x\n", wMsg); 199 } 200 ret = 0; 200 201 } 201 202 return ret; … … 204 205 205 206 /************************************************************************** 206 * DRIVER_SendMessage[internal]207 */ 208 static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, 209 207 * DRIVER_SendMessage [internal] 208 */ 209 static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg, 210 LPARAM lParam1, LPARAM lParam2) 210 211 { 211 212 #ifndef __WIN32OS2__ 212 213 if (lpDrv->dwFlags & WINE_GDF_16BIT) { 213 LRESULTret;214 intmap = 0;215 TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n", 216 217 218 219 220 221 222 223 224 225 214 LRESULT ret; 215 int map = 0; 216 TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n", 217 lpDrv->d.d16.hDriver16, msg, lParam1, lParam2); 218 219 if ((map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) >= 0) { 220 ret = SendDriverMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2); 221 if (map == 1) 222 DRIVER_UnMapMsg32To16(msg, lParam1, lParam2); 223 } else { 224 ret = 0; 225 } 226 return ret; 226 227 } 227 228 #endif 228 TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n", 229 229 TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n", 230 lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); 230 231 return lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2); 231 232 } 232 233 233 234 /************************************************************************** 234 * SendDriverMessage[WINMM.19]235 * SendDriverMessage [WINMM.19] 235 236 */ 236 237 LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1, 237 238 { 239 LPWINE_DRIVER 240 LRESULT 241 238 LPARAM lParam2) 239 { 240 LPWINE_DRIVER lpDrv; 241 LRESULT retval = 0; 242 242 243 TRACE("(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2); 243 244 244 245 if ((lpDrv = DRIVER_FindFromHDrvr(hDriver)) != NULL) { 245 246 retval = DRIVER_SendMessage(lpDrv, msg, lParam1, lParam2); 246 247 } else { 247 248 WARN("Bad driver handle %u\n", hDriver); 248 249 } 249 250 TRACE("retval = %ld\n", retval); 250 251 251 252 return retval; 252 253 } 253 254 254 255 /************************************************************************** 255 * DRIVER_RemoveFromList[internal]256 * DRIVER_RemoveFromList [internal] 256 257 * 257 258 * Generates all the logic to handle driver closure / deletion 258 259 * Removes a driver struct to the list of open drivers. 259 260 */ 260 static BOOLDRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)261 static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv) 261 262 { 262 263 if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) { 263 264 265 266 267 } 268 264 if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) { 265 DRIVER_SendMessage(lpDrv, DRV_DISABLE, 0L, 0L); 266 DRIVER_SendMessage(lpDrv, DRV_FREE, 0L, 0L); 267 } 268 } 269 269 270 if (lpDrv->lpPrevItem) 270 271 lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem; 271 272 else 272 273 lpDrvItemList = lpDrv->lpNextItem; 273 274 if (lpDrv->lpNextItem) 274 275 lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem; 275 276 276 277 return TRUE; … … 278 279 279 280 /************************************************************************** 280 * DRIVER_AddToList[internal]281 * DRIVER_AddToList [internal] 281 282 * 282 283 * Adds a driver struct to the list of open drivers. 283 284 * Generates all the logic to handle driver creation / open. 284 285 */ 285 static BOOLDRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2)286 static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lParam2) 286 287 { 287 288 lpNewDrv->dwMagic = WINE_DI_MAGIC; 288 289 /* First driver to be loaded for this module, need to load correctly the module */ 289 290 if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { 290 291 292 293 294 295 296 297 291 if (DRIVER_GetNumberOfModuleRefs(lpNewDrv) == 0) { 292 if (DRIVER_SendMessage(lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) { 293 TRACE("DRV_LOAD failed on driver 0x%08lx\n", (DWORD)lpNewDrv); 294 return FALSE; 295 } 296 /* returned value is not checked */ 297 DRIVER_SendMessage(lpNewDrv, DRV_ENABLE, 0L, 0L); 298 } 298 299 } 299 300 300 301 lpNewDrv->lpNextItem = NULL; 301 302 if (lpDrvItemList == NULL) { 302 303 303 lpDrvItemList = lpNewDrv; 304 lpNewDrv->lpPrevItem = NULL; 304 305 } else { 305 LPWINE_DRIVER lpDrv = lpDrvItemList;/* find end of list */306 307 308 309 310 306 LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */ 307 while (lpDrv->lpNextItem != NULL) 308 lpDrv = lpDrv->lpNextItem; 309 310 lpDrv->lpNextItem = lpNewDrv; 311 lpNewDrv->lpPrevItem = lpDrv; 311 312 } 312 313 313 314 if (!(lpNewDrv->dwFlags & WINE_GDF_16BIT)) { 314 315 316 317 318 319 320 321 315 /* Now just open a new instance of a driver on this module */ 316 lpNewDrv->d.d32.dwDriverID = DRIVER_SendMessage(lpNewDrv, DRV_OPEN, lParam1, lParam2); 317 318 if (lpNewDrv->d.d32.dwDriverID == 0) { 319 TRACE("DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv); 320 DRIVER_RemoveFromList(lpNewDrv); 321 return FALSE; 322 } 322 323 } 323 324 return TRUE; … … 325 326 326 327 /************************************************************************** 327 * DRIVER_GetLibName[internal]328 * 329 */ 330 BOOL 328 * DRIVER_GetLibName [internal] 329 * 330 */ 331 BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz) 331 332 { 332 333 /* should also do some registry diving */ … … 335 336 336 337 /************************************************************************** 337 * DRIVER_TryOpenDriver32[internal]338 * DRIVER_TryOpenDriver32 [internal] 338 339 * 339 340 * Tries to load a 32 bit driver whose DLL's (module) name is fn 340 341 */ 341 LPWINE_DRIVER 342 { 343 LPWINE_DRIVER 344 HMODULE 345 LPSTR 346 LPCSTR 342 LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2) 343 { 344 LPWINE_DRIVER lpDrv = NULL; 345 HMODULE hModule = 0; 346 LPSTR ptr; 347 LPCSTR cause = 0; 347 348 348 349 TRACE("('%s', %08lX);\n", fn, lParam2); 349 350 350 351 if ((ptr = strchr(fn, ' ')) != NULL) { 351 352 353 352 *ptr++ = '\0'; 353 while (*ptr == ' ') ptr++; 354 if (*ptr == '\0') ptr = NULL; 354 355 } 355 356 … … 378 379 #ifdef __WIN32OS2__ 379 380 /************************************************************************** 380 * DRIVER_OpenDriverA[internal]381 * DRIVER_OpenDriverA [internal] 381 382 * (0,1,DRV_LOAD ,0 ,0) 382 383 * (0,1,DRV_ENABLE,0 ,0) … … 384 385 * 385 386 */ 386 static LPWINE_DRIVERDRIVER_TryOpenDriver16(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam)387 static LPWINE_DRIVER DRIVER_TryOpenDriver16(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam) 387 388 { 388 389 LPWINE_DRIVER lpDrv = NULL; 389 char 390 char drvName[128]; 390 391 LPCSTR cause = 0; 391 392 392 393 TRACE("Entering DRIVER_OpenDriverA: lpDriverName: %s lpSectionName: %s\n",lpDriverName,lpSectionName); 393 394 … … 396 397 397 398 if (lpSectionName == NULL) { 398 399 400 399 lstrcpynA(drvName, lpDriverName, sizeof(drvName)); 400 lpDrv = DRIVER_TryOpenDriver32(lpDriverName, lParam); 401 if (!lpDrv) { 401 402 if (GetPrivateProfileStringA("Drivers32", lpDriverName, "", drvName, 402 403 sizeof(drvName), "SYSTEM.INI")) { 403 404 404 lpDrv = DRIVER_TryOpenDriver32(drvName, lParam); 405 lpDrv = DRIVER_TryOpenDriver32(drvName, lParam); 405 406 } 406 407 } 407 408 } else {/* of if (lpSectionName == NULL) */ 408 409 //dprintf(("driver name %x '%s'\n",drvName,drvName)); 409 drvName[0]=0; 410 411 410 drvName[0]=0; 411 412 if (GetPrivateProfileStringA(lpSectionName, lpDriverName, "", drvName, 412 413 sizeof(drvName)-1, "SYSTEM.INI")) { 413 414 #if 0 414 415 dprintf(("driver name %x '%s'\n",drvName,drvName)); 415 #endif 416 #endif 416 417 lpDrv = DRIVER_TryOpenDriver32(drvName, lParam); 417 418 }/* GetPrivate... */ 418 419 } 419 420 if (!lpDrv) 420 421 422 else 423 421 TRACE("OpenDriverA: Failed to open driver %s from section %s\n", lpDriverName, lpSectionName); 422 423 else 424 TRACE("OpenDriverA success: Driver handle => %08x\n", lpDrv); 424 425 425 426 return lpDrv; … … 432 433 #else 433 434 /************************************************************************** 434 * DRIVER_TryOpenDriver16[internal]435 * DRIVER_TryOpenDriver16 [internal] 435 436 * 436 437 * Tries to load a 16 bit driver whose DLL's (module) name is lpFileName. 437 438 */ 438 static LPWINE_DRIVERDRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)439 { 440 LPWINE_DRIVER 441 LPCSTR 439 static LPWINE_DRIVER DRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2) 440 { 441 LPWINE_DRIVER lpDrv = NULL; 442 LPCSTR cause = 0; 442 443 443 444 TRACE("('%s', %08lX);\n", sn, lParam2); 444 445 445 446 lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER)); 446 447 if (lpDrv == NULL) {cause = "OOM"; goto exit;} 447 448 448 449 /* FIXME: shall we do some black magic here on sn ? 449 * 450 * 450 * drivers32 => drivers 451 * mci32 => mci 451 452 * ... 452 453 */ … … 467 468 468 469 /************************************************************************** 469 * OpenDriverA[WINMM.15]470 * OpenDriverA [WINMM.15] 470 471 * (0,1,DRV_LOAD ,0 ,0) 471 472 * (0,1,DRV_ENABLE,0 ,0) 472 473 * (0,1,DRV_OPEN ,buf[256],0) 473 474 */ 474 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam2) 475 { 476 LPWINE_DRIVER 477 char 478 LPCSTR 475 HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lParam2) 476 { 477 LPWINE_DRIVER lpDrv = NULL; 478 char libName[128]; 479 LPCSTR lsn = lpSectionName; 479 480 480 481 TRACE("(%s, %s, 0x%08lx);\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName), lParam2); 481 482 482 483 if (lsn == NULL) { 483 484 485 486 487 484 lstrcpynA(libName, lpDriverName, sizeof(libName)); 485 486 if ((lpDrv = DRIVER_TryOpenDriver32(libName, lParam2))) 487 goto the_end; 488 lsn = "Drivers32"; 488 489 } 489 490 if (DRIVER_GetLibName(lpDriverName, lsn, libName, sizeof(libName)) && 490 491 491 (lpDrv = DRIVER_TryOpenDriver32(libName, lParam2))) 492 goto the_end; 492 493 493 494 if (!(lpDrv = DRIVER_TryOpenDriver16(lpDriverName, lpSectionName, lParam2))) 494 495 TRACE("Failed to open driver %s from system.ini file, section %s\n", lpDriverName, lpSectionName); 495 496 496 497 the_end: 497 if (lpDrv) 498 if (lpDrv) TRACE("=> %08lx\n", (DWORD)lpDrv); 498 499 return (DWORD)lpDrv; 499 500 } 500 501 501 502 /************************************************************************** 502 * OpenDriverW[WINMM.15]503 * OpenDriverW [WINMM.15] 503 504 */ 504 505 HDRVR WINAPI OpenDriverW(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam) 505 506 { 506 LPSTR 507 LPSTR 508 HDRVR 509 507 LPSTR dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName); 508 LPSTR sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName); 509 HDRVR ret = OpenDriverA(dn, sn, lParam); 510 510 511 if (dn) HeapFree(GetProcessHeap(), 0, dn); 511 512 if (sn) HeapFree(GetProcessHeap(), 0, sn); … … 514 515 515 516 /************************************************************************** 516 * CloseDriver[WINMM.4]517 * CloseDriver [WINMM.4] 517 518 */ 518 519 LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2) 519 520 { 520 LPWINE_DRIVER 521 LPWINE_DRIVER lpDrv; 521 522 522 523 TRACE("(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2); 523 524 524 525 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { 525 526 #ifndef __WIN32OS2__ 526 527 528 527 if (lpDrv->dwFlags & WINE_GDF_16BIT) 528 CloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2); 529 else 529 530 #endif 530 531 532 533 534 531 DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2); 532 if (DRIVER_RemoveFromList(lpDrv)) { 533 HeapFree(GetProcessHeap(), 0, lpDrv); 534 return TRUE; 535 } 535 536 } 536 537 WARN("Failed to close driver\n"); … … 539 540 540 541 /************************************************************************** 541 * GetDriverFlags[WINMM.13]542 * GetDriverFlags [WINMM.13] 542 543 * [in] hDrvr handle to the driver 543 544 * 544 545 * Returns: 545 * 546 * 547 * 546 * 0x00000000 if hDrvr is an invalid handle 547 * 0x80000000 if hDrvr is a valid 32 bit driver 548 * 0x90000000 if hDrvr is a valid 16 bit driver 548 549 * 549 550 * native WINMM doesn't return those flags 550 * 551 * 552 */ 553 DWORD 554 { 555 LPWINE_DRIVER 556 DWORD 551 * 0x80000000 for a valid 32 bit driver and that's it 552 * (I may have mixed up the two flags :-( 553 */ 554 DWORD WINAPI GetDriverFlags(HDRVR hDrvr) 555 { 556 LPWINE_DRIVER lpDrv; 557 DWORD ret = 0; 557 558 558 559 TRACE("(%04x)\n", hDrvr); 559 560 560 561 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { 561 562 ret = WINE_GDF_EXIST | lpDrv->dwFlags; 562 563 } 563 564 return ret; … … 565 566 566 567 /************************************************************************** 567 * GetDriverModuleHandle[WINMM.14]568 * GetDriverModuleHandle [WINMM.14] 568 569 */ 569 570 HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr) 570 571 { 571 LPWINE_DRIVER 572 HMODULE 573 572 LPWINE_DRIVER lpDrv; 573 HMODULE hModule = 0; 574 574 575 TRACE("(%04x);\n", hDrvr); 575 576 576 577 if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) { 577 578 578 if (!(lpDrv->dwFlags & WINE_GDF_16BIT)) 579 hModule = lpDrv->d.d32.hModule; 579 580 } 580 581 TRACE("=> %04x\n", hModule); … … 584 585 #ifndef __WIN32OS2__ 585 586 /************************************************************************** 586 * DrvOpen[MMSYSTEM.1100]587 * DrvOpen [MMSYSTEM.1100] 587 588 */ 588 589 HDRVR16 WINAPI DrvOpen16(LPSTR lpDriverName, LPSTR lpSectionName, LPARAM lParam) … … 592 593 593 594 /************************************************************************** 594 * DrvClose[MMSYSTEM.1101]595 * DrvClose [MMSYSTEM.1101] 595 596 */ 596 597 LRESULT WINAPI DrvClose16(HDRVR16 hDrv, LPARAM lParam1, LPARAM lParam2) … … 600 601 601 602 /************************************************************************** 602 * DrvSendMessage[MMSYSTEM.1102]603 * DrvSendMessage [MMSYSTEM.1102] 603 604 */ 604 605 LRESULT WINAPI DrvSendMessage16(HDRVR16 hDrv, WORD msg, LPARAM lParam1, 605 606 LPARAM lParam2) 606 607 { 607 608 return SendDriverMessage16(hDrv, msg, lParam1, lParam2); … … 609 610 610 611 /************************************************************************** 611 * DrvGetModuleHandle[MMSYSTEM.1103]612 * DrvGetModuleHandle [MMSYSTEM.1103] 612 613 */ 613 614 HANDLE16 WINAPI DrvGetModuleHandle16(HDRVR16 hDrv) … … 617 618 618 619 /************************************************************************** 619 * DrvDefDriverProc[MMSYSTEM.1104]620 */ 621 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg, 622 620 * DrvDefDriverProc [MMSYSTEM.1104] 621 */ 622 LRESULT WINAPI DrvDefDriverProc16(DWORD dwDriverID, HDRVR16 hDrv, WORD wMsg, 623 DWORD dwParam1, DWORD dwParam2) 623 624 { 624 625 return DefDriverProc16(dwDriverID, hDrv, wMsg, dwParam1, dwParam2); … … 627 628 628 629 /************************************************************************** 629 * DefDriverProc[WINMM.5]630 * DefDriverProc [WINMM.5] 630 631 */ 631 632 LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv, 632 633 UINT Msg, LPARAM lParam1, LPARAM lParam2) 633 634 { 634 635 switch (Msg) { … … 648 649 #ifndef __WIN32OS2__ 649 650 /************************************************************************** 650 * DriverProc[MMSYSTEM.6]651 */ 652 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg, 653 651 * DriverProc [MMSYSTEM.6] 652 */ 653 LRESULT WINAPI DriverProc16(DWORD dwDevID, HDRVR16 hDrv, WORD wMsg, 654 DWORD dwParam1, DWORD dwParam2) 654 655 { 655 656 TRACE("dwDevID=%08lx hDrv=%04x wMsg=%04x dwParam1=%08lx dwParam2=%08lx\n", 656 657 dwDevID, hDrv, wMsg, dwParam1, dwParam2); 657 658 658 659 return DrvDefDriverProc16(dwDevID, hDrv, wMsg, dwParam1, dwParam2); … … 662 663 #ifdef __WIN32OS2__ 663 664 /************************************************************************** 664 * DriverCallback[MMSYSTEM.31]665 */ 666 BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, 667 UINT wMsg, DWORD dwUser, DWORD dwParam1, 668 665 * DriverCallback [MMSYSTEM.31] 666 */ 667 BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev, 668 UINT wMsg, DWORD dwUser, DWORD dwParam1, 669 DWORD dwParam2) 669 670 { 670 671 TRACE("DriverCallback (%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n", 671 672 dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2); 672 673 673 674 switch (uFlags & DCB_TYPEMASK) { 674 675 case DCB_NULL: 675 676 677 678 676 TRACE("Null !\n"); 677 if (dwCallBack) 678 WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack); 679 break; 679 680 case DCB_WINDOW: 680 681 682 683 684 681 TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev); 682 if (!IsWindow(dwCallBack)) 683 return FALSE; 684 PostMessageA((HWND)dwCallBack, wMsg, hDev, dwParam1); 685 break; 685 686 case DCB_TASK: /* aka DCB_THREAD */ 686 687 688 687 TRACE("Task(%04lx) !\n", dwCallBack); 688 PostThreadMessageA(dwCallBack, wMsg, hDev, dwParam1); 689 break; 689 690 case DCB_FUNCTION: 690 691 692 691 TRACE("Function (32 bit) !\n"); 692 ((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2); 693 break; 693 694 case DCB_EVENT: 694 695 696 695 TRACE("Event(%08lx) !\n", dwCallBack); 696 SetEvent((HANDLE)dwCallBack); 697 break; 697 698 case 6: /* I would dub it DCB_MMTHREADSIGNAL */ 698 699 700 701 702 699 /* this is an undocumented DCB_ value used for mmThreads 700 * loword of dwCallBack contains the handle of the lpMMThd block 701 * which dwSignalCount has to be incremented 702 */ 703 { 703 704 #ifdef __WIN32OS2__ 704 WINE_MMTHREAD*lpMMThd = (WINE_MMTHREAD*)dwCallBack;705 WINE_MMTHREAD* lpMMThd = (WINE_MMTHREAD*)dwCallBack; 705 706 #else 706 WINE_MMTHREAD*lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) );707 WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) ); 707 708 #endif 708 709 709 710 711 712 713 714 715 break; 710 TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd); 711 /* same as mmThreadSignal16 */ 712 InterlockedIncrement(&lpMMThd->dwSignalCount); 713 SetEvent(lpMMThd->hEvent); 714 /* some other stuff on lpMMThd->hVxD */ 715 } 716 break; 716 717 #if 0 717 718 case 4: 718 719 719 /* this is an undocumented DCB_ value for... I don't know */ 720 break; 720 721 #endif 721 722 default: 722 723 723 WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK); 724 return FALSE; 724 725 } 725 726 TRACE("Done\n"); -
trunk/src/winmm/initterm.cpp
r6375 r6639 1 /* 1 /* $Id: initterm.cpp,v 1.19 2001-09-05 10:30:21 bird Exp $ 2 * 2 3 * WINMM DLL entry point 3 4 * -
trunk/src/wnaspi32/initterm.cpp
r5135 r6639 1 /* 1 /* $Id: initterm.cpp,v 1.7 2001-09-05 10:28:28 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 52 53 case DLL_PROCESS_ATTACH: 53 54 aspi = new scsiObj(); 54 55 56 57 58 55 if(aspi == NULL) { 56 dprintf(("WNASPI32: LibMain; can't allocate aspi object!")); 57 return FALSE; 58 } 59 if(aspi->init(65535) == FALSE) 59 60 { 60 61 62 63 64 65 66 61 delete aspi; 62 aspi = NULL; 63 dprintf(("WNASPI32: LibMain; can't init aspi object!")); 64 return FALSE; 65 } 66 dprintf(("WNASPI32: LibMain; aspi object created successfully")); 67 return TRUE; 67 68 68 69 case DLL_THREAD_ATTACH: 69 70 case DLL_THREAD_DETACH: 70 71 return TRUE; 71 72 72 73 case DLL_PROCESS_DETACH: 73 74 75 76 77 78 79 74 if(aspi) { 75 aspi->close(); 76 delete aspi; 77 aspi = NULL; 78 } 79 ctordtorTerm(); 80 return TRUE; 80 81 } 81 82 return FALSE; … … 107 108 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 108 109 109 110 if(dllHandle == 0) 111 110 dllHandle = RegisterLxDll(hModule, LibMain, (PVOID)&_Resource_PEResTab); 111 if(dllHandle == 0) 112 return 0UL; 112 113 113 114 break; 114 115 case 1: 115 116 if(dllHandle) { 116 117 UnregisterLxDll(dllHandle); 117 118 } 118 119 break; -
trunk/src/wnetap32/oslibnet.cpp
r4394 r6639 1 /* $Id */2 /*1 /* $Id: oslibnet.cpp,v 1.4 2001-09-05 10:27:54 bird Exp $ 2 * 3 3 * Wrappers for OS/2 Netbios/Network/LAN API 4 4 * … … 66 66 case NERR_BadEventName: return NERR_BadEventName; 67 67 case NERR_BASE + 44: return NERR_BASE + 44; // NERR_DupNameReboot 68 68 69 69 // ... 70 70 71 71 case NO_ERROR: //0 72 72 return ERROR_SUCCESS_W; … … 208 208 * Name : NET_API_STATUS OSLibNetWkstaGetInfo 209 209 * Purpose : 210 * Parameters: 210 * Parameters: 211 211 * Variables : 212 212 * Result : … … 218 218 219 219 DWORD OSLibNetWkstaGetInfo (const unsigned char * pszServer, 220 unsigned long ulLevel, 220 unsigned long ulLevel, 221 221 unsigned char * pbBuffer, 222 unsigned long ulBuffer, 223 unsigned long * pulTotalAvail) 222 unsigned long ulBuffer, 223 unsigned long * pulTotalAvail) 224 224 { 225 225 USHORT sel = RestoreOS2FS(); 226 226 227 227 APIRET rc = error2WinError(Net32WkstaGetInfo(pszServer, ulLevel, pbBuffer, ulBuffer, pulTotalAvail)); 228 228 SetFS(sel); … … 234 234 * Name : NET_API_STATUS OSLibNetStatisticsGet 235 235 * Purpose : 236 * Parameters: 236 * Parameters: 237 237 * Variables : 238 238 * Result : -
trunk/src/ws2_32/initterm.cpp
r5664 r6639 1 /* 1 /* $Id: initterm.cpp,v 1.2 2001-09-05 10:27:06 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 36 37 #include <initdll.h> 37 38 38 #define DBG_LOCALLOG 39 #define DBG_LOCALLOG DBG_initterm 39 40 #include "dbglocal.h" 40 41 … … 52 53 { 53 54 case DLL_PROCESS_ATTACH: 54 55 return TRUE; 55 56 56 57 case DLL_THREAD_ATTACH: 57 58 case DLL_THREAD_DETACH: 58 59 return TRUE; 59 60 60 61 case DLL_PROCESS_DETACH: 61 62 62 ctordtorTerm(); 63 return TRUE; 63 64 } 64 65 return FALSE; … … 91 92 CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed 98-03-18 05:28:48*/ 92 93 93 94 if(dllHandle == 0) 95 94 dllHandle = RegisterLxDll(hModule, OdinLibMain, (PVOID)&_Resource_PEResTab); 95 if(dllHandle == 0) 96 return 0UL; 96 97 97 98 break; 98 99 case 1 : 99 100 if(dllHandle) { 100 101 UnregisterLxDll(dllHandle); 101 102 } 102 103 break; -
trunk/src/wsock32/initterm.cpp
r6375 r6639 1 /* 1 /* $Id: initterm.cpp,v 1.17 2001-09-05 10:26:30 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 36 37 #include <initdll.h> 37 38 38 #define DBG_LOCALLOG 39 #define DBG_LOCALLOG DBG_initterm 39 40 #include "dbglocal.h" 40 41 -
trunk/src/wsock32/initwsock32.cpp
r6401 r6639 1 /* 1 /* $Id: initwsock32.cpp,v 1.3 2001-09-05 10:26:30 bird Exp $ 2 * 2 3 * DLL entry point 3 4 * … … 36 37 #include <initdll.h> 37 38 38 #define DBG_LOCALLOG 39 #define DBG_LOCALLOG DBG_initterm 39 40 #include "dbglocal.h" 40 41 … … 68 69 ParseLogStatusWSOCK32(); 69 70 70 71 if(dllHandle == 0) 72 71 dllHandle = RegisterLxDll(hModule, NULL, (PVOID)&wsock32_PEResTab); 72 if(dllHandle == 0) 73 return 0UL; 73 74 74 75 break; 75 76 case 1 : 76 77 if(dllHandle) { 77 78 UnregisterLxDll(dllHandle); 78 79 } 79 80 break;
Note:
See TracChangeset
for help on using the changeset viewer.