34 #define DBG_PROGNAME "OPENCBM-XA1541.DLL"
55 RegSetDWORD(HKEY RegKey,
char *SubKey, DWORD Value)
63 rc = RegSetValueEx(RegKey, SubKey, 0, REG_DWORD, (LPBYTE)&Value, 4);
87 RegSetEXPANDSZ(HKEY RegKey,
char *SubKey, IN LPCTSTR Value)
93 rc = RegSetValueEx(RegKey, SubKey, 0, REG_EXPAND_SZ, Value, strlen(Value)+1);
114 CreateLogRegistryKeys(IN LPCTSTR ServiceExe)
128 if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
132 REG_OPTION_NON_VOLATILE,
146 RegSetEXPANDSZ(RegKey,
"EventMessageFile", ServiceExe);
150 RegSetDWORD(RegKey,
"TypesSupported", 0x07);
197 CreateDefaultRegistryKeys(IN ULONG DefaultLpt,
198 IN ULONG IecCableType,
199 IN ULONG PermanentlyLock,
200 IN BOOL DebugFlagsDriverPresent, IN ULONG DebugFlagsDriver,
201 IN BOOL DebugFlagsDllPresent, IN ULONG DebugFlagsDll)
212 if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
220 DWORD error = GetLastError();
224 printf(
"WARNING: COULD NOT OPEN HKLM\\" CBM_REGKEY_SERVICE
" (0x%x) '%s'\n",
231 if (DefaultLpt != -1)
236 if (IecCableType != IEC_CABLETYPE_UNSPEC)
241 if (PermanentlyLock != -1)
250 if (DebugFlagsDriverPresent)
255 if (DebugFlagsDllPresent)
294 CbmInstall(IN LPCTSTR DriverName, IN LPCTSTR ServiceExe, IN BOOL AutomaticStart)
305 scManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
311 scService = CreateService(scManager, DriverName, DriverName,
312 SERVICE_ALL_ACCESS, SERVICE_KERNEL_DRIVER,
313 AutomaticStart ? SERVICE_AUTO_START : SERVICE_DEMAND_START,
314 SERVICE_ERROR_NORMAL, ServiceExe,
315 "Extended base", NULL,
"+Parallel arbitrator\0Parport\0",
318 if (scService == NULL)
320 lasterror = GetLastError();
322 if (lasterror == ERROR_SERVICE_EXISTS)
328 printf(
"WARNING: opencbm is already installed!\n");
334 printf(
"ERROR: CreateService (0x%02x) '%s'\n",
343 CloseServiceHandle(scService);
348 CreateDefaultRegistryKeys(-1, -2, -1, FALSE, 0, FALSE, 0);
350 CloseServiceHandle(scManager);
355 error = CreateLogRegistryKeys(ServiceExe);
405 IN ULONG IecCableType,
406 IN ULONG PermanentlyLock,
407 IN BOOL DebugFlagsDriverPresent, IN ULONG DebugFlagsDriver,
408 IN BOOL DebugFlagsDllPresent, IN ULONG DebugFlagsDll)
414 ret = CreateDefaultRegistryKeys(DefaultLpt, IecCableType, PermanentlyLock,
415 DebugFlagsDriverPresent, DebugFlagsDriver,
416 DebugFlagsDllPresent, DebugFlagsDll);
449 scManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
453 scService = OpenService(scManager, DriverName, SERVICE_ALL_ACCESS);
455 if (scService == NULL)
457 DWORD error = GetLastError();
464 ret = DeleteService(scService);
469 printf(
"DeleteService SUCCESS\n");
473 DWORD error = GetLastError();
479 CloseServiceHandle(scService);
486 CloseServiceHandle(scManager);
519 scManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
523 scService = OpenService(scManager, DriverName, SERVICE_ALL_ACCESS);
525 if (scService != NULL)
527 CloseServiceHandle(scService);
530 CloseServiceHandle(scManager);
BOOL CbmRemove(IN LPCTSTR DriverName)
Remove the driver.
Define makros for debugging purposes.
#define CBM_REGKEY_SERVICE
#define CBM_REGKEY_SERVICE_IECCABLE
Define the IOCTL codes for the opencbm driver.
#define CBM_REGKEY_SERVICE_DEFAULTLPT
#define CBM_REGKEY_SERVICE_PERMLOCK
#define CBM_REGKEY_SERVICE_DEBUGFLAGS
#define FUNC_LEAVE_BOOL(_xxx)
#define DBG_SUCCESS(_xxx)
BOOL CbmInstall(IN LPCTSTR DriverName, IN LPCTSTR ServiceExe, IN BOOL AutomaticStart)
Install the driver.
#define CBM_REGKEY_SERVICE_DLL_DEBUGFLAGS
BOOL cbm_driver_stop(VOID)
Stop a device driver.
BOOL cbm_driver_start(VOID)
Start a device driver.
Internal API for opencbm installation.
BOOL CbmUpdateParameter(IN ULONG DefaultLpt, IN ULONG IecCableType, IN ULONG PermanentlyLock, IN BOOL DebugFlagsDriverPresent, IN ULONG DebugFlagsDriver, IN BOOL DebugFlagsDllPresent, IN ULONG DebugFlagsDll)
Update the parameter of the driver.
Some functions for string handling.
BOOL CbmCheckPresence(IN LPCTSTR DriverName)
Check for the presence of the driver.