|
|
1.1 ! root 1: /**************************************************************************** ! 2: ! 3: * ! 4: * drvproc.c ! 5: * ! 6: * Copyright (c) 1991-1992 Microsoft Corporation. All Rights Reserved. ! 7: * ! 8: ***************************************************************************/ ! 9: ! 10: #include <windows.h> ! 11: #include <mmsystem.h> ! 12: #include "registry.h" ! 13: #include "sndblst.h" ! 14: ! 15: /* Temp definition until DefDriverProc gets properly defined */ ! 16: ! 17: ! 18: LONG APIENTRY DefDriverProc(DWORD dwDriverIdentifier, ! 19: HANDLE hDriver, ! 20: UINT message, // Bug in ptypes32.h ! 21: LONG lParam1, ! 22: LONG lParam2); ! 23: ! 24: /*************************************************************************** ! 25: * @doc INTERNAL ! 26: * ! 27: * @api LRESULT | DriverProc | The entry point for an installable driver. ! 28: * ! 29: * @parm DWORD | dwDriverId | For most messages, <p dwDriverId> is the DWORD ! 30: * value that the driver returns in response to a <m DRV_OPEN> message. ! 31: * Each time that the driver is opened, through the <f DrvOpen> API, ! 32: * the driver receives a <m DRV_OPEN> message and can return an ! 33: * arbitrary, non-zero value. The installable driver interface ! 34: * saves this value and returns a unique driver handle to the ! 35: * application. Whenever the application sends a message to the ! 36: * driver using the driver handle, the interface routes the message ! 37: * to this entry point and passes the corresponding <p dwDriverId>. ! 38: * This mechanism allows the driver to use the same or different ! 39: * identifiers for multiple opens but ensures that driver handles ! 40: * are unique at the application interface layer. ! 41: * ! 42: * The following messages are not related to a particular open ! 43: * instance of the driver. For these messages, the dwDriverId ! 44: * will always be zero. ! 45: * ! 46: * DRV_LOAD, DRV_FREE, DRV_ENABLE, DRV_DISABLE, DRV_OPEN ! 47: * ! 48: * @parm HDRVR | hDriver | This is the handle returned to the ! 49: * application by the driver interface. ! 50: * ! 51: * @parm UINT | uiMessage | The requested action to be performed. Message ! 52: * values below <m DRV_RESERVED> are used for globally defined messages. ! 53: * Message values from <m DRV_RESERVED> to <m DRV_USER> are used for ! 54: * defined driver protocols. Messages above <m DRV_USER> are used ! 55: * for driver specific messages. ! 56: * ! 57: * @parm LPARAM | lParam1 | Data for this message. Defined separately for ! 58: * each message ! 59: * ! 60: * @parm LPARAM | lParam2 | Data for this message. Defined separately for ! 61: * each message ! 62: * ! 63: * @rdesc Defined separately for each message. ! 64: ***************************************************************************/ ! 65: LRESULT DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2) ! 66: { ! 67: switch (uiMessage) { ! 68: case DRV_LOAD: ! 69: D1("DRV_LOAD"); ! 70: ! 71: /* ! 72: Sent to the driver when it is loaded. Always the first ! 73: message received by a driver. ! 74: ! 75: dwDriverID is 0L. ! 76: lParam1 is 0L. ! 77: lParam2 is 0L. ! 78: ! 79: Return 0L to fail the load. ! 80: ! 81: DefDriverProc will return NON-ZERO so we don't have to ! 82: handle DRV_LOAD ! 83: */ ! 84: ! 85: return (LRESULT)1L; ! 86: ! 87: case DRV_FREE: ! 88: D1("DRV_FREE"); ! 89: ! 90: /* ! 91: Sent to the driver when it is about to be discarded. This ! 92: will always be the last message received by a driver before ! 93: it is freed. ! 94: ! 95: dwDriverID is 0L. ! 96: lParam1 is 0L. ! 97: lParam2 is 0L. ! 98: ! 99: Return value is ignored. ! 100: */ ! 101: ! 102: return (LRESULT)1L; ! 103: ! 104: case DRV_OPEN: ! 105: D1("DRV_OPEN"); ! 106: ! 107: /* ! 108: Sent to the driver when it is opened. ! 109: ! 110: dwDriverID is 0L. ! 111: ! 112: lParam1 is a far pointer to a zero-terminated string ! 113: containing the name used to open the driver. ! 114: ! 115: lParam2 is passed through from the drvOpen call. ! 116: ! 117: Return 0L to fail the open. ! 118: ! 119: DefDriverProc will return ZERO so we do have to ! 120: handle the DRV_OPEN message. ! 121: */ ! 122: ! 123: // ! 124: // See if we can get access to our registry node ! 125: // ! 126: ! 127: DrvCreateServicesNode(STR_DRIVERNAME, ! 128: SoundDriverTypeNormal, ! 129: &RegAccess, ! 130: FALSE); // Don't create ! 131: ! 132: return (LRESULT)1L; ! 133: ! 134: case DRV_CLOSE: ! 135: D1("DRV_CLOSE"); ! 136: ! 137: /* ! 138: Sent to the driver when it is closed. Drivers are unloaded ! 139: when the close count reaches zero. ! 140: ! 141: dwDriverID is the driver identifier returned from the ! 142: corresponding DRV_OPEN. ! 143: ! 144: lParam1 is passed through from the drvClose call. ! 145: ! 146: lParam2 is passed through from the drvClose call. ! 147: ! 148: Return 0L to fail the close. ! 149: ! 150: DefDriverProc will return ZERO so we do have to ! 151: handle the DRV_CLOSE message. ! 152: */ ! 153: ! 154: DrvCloseServiceManager(&RegAccess); ! 155: ! 156: return (LRESULT)1L; ! 157: ! 158: case DRV_ENABLE: ! 159: D1("DRV_ENABLE"); ! 160: ! 161: /* ! 162: Sent to the driver when the driver is loaded or reloaded ! 163: and whenever Windows is enabled. Drivers should only ! 164: hook interrupts or expect ANY part of the driver to be in ! 165: memory between enable and disable messages ! 166: ! 167: dwDriverID is 0L. ! 168: lParam1 is 0L. ! 169: lParam2 is 0L. ! 170: ! 171: Return value is ignored. ! 172: */ ! 173: ! 174: //return (LRESULT)(Enable() ? 1L : 0L); ! 175: ! 176: return 1L; ! 177: ! 178: case DRV_DISABLE: ! 179: D1("DRV_DISABLE"); ! 180: ! 181: /* ! 182: Sent to the driver before the driver is freed. ! 183: and whenever Windows is disabled ! 184: ! 185: dwDriverID is 0L. ! 186: lParam1 is 0L. ! 187: lParam2 is 0L. ! 188: ! 189: Return value is ignored. ! 190: */ ! 191: ! 192: // Disable(); ! 193: return (LRESULT)1L; ! 194: ! 195: case DRV_QUERYCONFIGURE: ! 196: D1("DRV_QUERYCONFIGURE"); ! 197: ! 198: /* ! 199: Sent to the driver so that applications can ! 200: determine whether the driver supports custom ! 201: configuration. The driver should return a ! 202: non-zero value to indicate that configuration ! 203: is supported. ! 204: ! 205: dwDriverID is the value returned from the DRV_OPEN ! 206: call that must have succeeded before this message ! 207: was sent. ! 208: ! 209: lParam1 is passed from the app and is undefined. ! 210: lParam2 is passed from the app and is undefined. ! 211: ! 212: Return 0L to indicate configuration NOT supported. ! 213: */ ! 214: ! 215: // ! 216: // Check to see if we can access the registry. ! 217: // Note thta this may be a config immediately after install ! 218: // so we may not have a service or node yet ! 219: // ! 220: ! 221: return (LRESULT)DrvAccess(&RegAccess); ! 222: ! 223: case DRV_CONFIGURE: ! 224: D1("DRV_CONFIGURE"); ! 225: ! 226: /* ! 227: Sent to the driver so that it can display a custom ! 228: configuration dialog box. ! 229: ! 230: lParam1 is passed from the app. and should contain ! 231: the parent window handle in the loword. ! 232: lParam2 is passed from the app and is undefined. ! 233: ! 234: Return value is undefined. ! 235: ! 236: Drivers should create their own section in system.ini. ! 237: The section name should be the driver name. ! 238: */ ! 239: ! 240: return (LRESULT)Config((HWND)lParam1, ghModule); ! 241: ! 242: case DRV_INSTALL: ! 243: ! 244: /* ! 245: * See if we can support install ! 246: */ ! 247: ! 248: if (!DrvAccess(&RegAccess)) { ! 249: ConfigErrorMsgBox((HWND)lParam1, IDS_INSUFFICIENT_PRIVILEGE); ! 250: return (LRESULT)DRVCNF_CANCEL; ! 251: } ! 252: ! 253: /* ! 254: * Set a flag so that config knows we're installing something ! 255: */ ! 256: ! 257: bInstall = TRUE; ! 258: ! 259: D1("DRV_INSTALL"); ! 260: return (LRESULT)DRVCNF_RESTART; ! 261: ! 262: case DRV_REMOVE: ! 263: /* ! 264: * See if we can support removal ! 265: */ ! 266: ! 267: if (!DrvAccess(&RegAccess)) { ! 268: ConfigErrorMsgBox((HWND)lParam1, IDS_INSUFFICIENT_PRIVILEGE); ! 269: return (LRESULT)DRVCNF_CANCEL; ! 270: } ! 271: ! 272: D1("DRV_REMOVE"); ! 273: return ConfigRemove((HWND)lParam1); ! 274: ! 275: default: ! 276: return DefDriverProc(dwDriverID, hDriver,uiMessage,lParam1,lParam2); ! 277: } ! 278: } ! 279: ! 280: ! 281: /**************************************************************************** ! 282: * @doc INTERNAL ! 283: * ! 284: * @api int | DllEntryPoint | Library initialization code. ! 285: * ! 286: * @parm HANDLE | hModule | Our module handle. ! 287: * ! 288: * @parm DWORD | Reason | The reason we've been called ! 289: * ! 290: * @parm LPVOID | lpReserved | Extra data. ! 291: * ! 292: * @rdesc Returns 1 if the initialization was successful and 0 otherwise. ! 293: ***************************************************************************/ ! 294: ! 295: BOOL DllEntryPoint(HANDLE hModule, DWORD Reason, LPVOID lpReserved) ! 296: { ! 297: switch (Reason) { ! 298: ! 299: case DLL_PROCESS_ATTACH: ! 300: // ! 301: // We're being loaded - save our handle ! 302: // ! 303: ! 304: ghModule = hModule; ! 305: ! 306: return TRUE; ! 307: ! 308: default: ! 309: return TRUE; ! 310: } ! 311: ! 312: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.