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