//---------------------------------------------------------------------- // // DriverConnect // // If under NT 4.0, we need to establish system call hooking in order // to make the changeover. // //---------------------------------------------------------------------- BOOL DriverConnect() { TCHAR Path[256]; TCHAR *File; // open the handle to the device if( !SearchPath( NULL, SYS_FILE, NULL, sizeof(Path), Path, &File ) ) { // that failed, last ditch - try current directory again. GetCurrentDirectory( sizeof Path, Path ); wsprintf( Path+lstrlen(Path), TEXT("\\%s"), SYS_FILE ); } if ( ! LoadDeviceDriver( SYS_NAME, Path, &sys_handle ) ) { // unload it in case the driver moved UnloadDeviceDriver( SYS_NAME ); if ( ! LoadDeviceDriver( SYS_NAME, Path, &sys_handle ) ) { printf("Unable to load driver: "); PrintError(); return FALSE; } } return TRUE; }
//---------------------------------------------------------------------- // // StartMyFaultDriver // // Loads and starts the driver. // //---------------------------------------------------------------------- LONG StartMyFaultDriver( HWND hDlg ) { char driverPath[MAX_PATH]; char systemRoot[MAX_PATH]; char path[MAX_PATH]; WIN32_FIND_DATA findData; HANDLE findHandle; char *file; DWORD error; char msgbuf[MAX_PATH*2]; // // Load the myfault driver // GetCurrentDirectory( sizeof path, path ); sprintf( path+lstrlen(path), "\\%s", SYS_FILE ); findHandle = FindFirstFile( path, &findData ); if( findHandle == INVALID_HANDLE_VALUE ) { if( !SearchPath( NULL, SYS_FILE, NULL, sizeof(path), path, &file ) ) { sprintf( msgbuf, "%s was not found.", SYS_FILE ); return Abort( hDlg, msgbuf, GetLastError() ); } } else FindClose( findHandle ); if( !GetEnvironmentVariable( "SYSTEMROOT", systemRoot, sizeof(systemRoot))) { strcpy( msgbuf, "Could not resolve SYSTEMROOT environment variable" ); return Abort( hDlg, msgbuf, GetLastError() ); } sprintf( driverPath, "%s\\system32\\drivers\\myfault.sys", systemRoot ); SetFileAttributes( driverPath, FILE_ATTRIBUTE_NORMAL ); CopyFile( path, driverPath, FALSE ); if( !LoadDeviceDriver( SYS_NAME, driverPath, &SysHandle, &error )) { if( !CopyFile( path, driverPath, FALSE )) { sprintf( msgbuf, "Unable to copy %s to %s\n\n" "Make sure that %s is in the current directory.", SYS_NAME, driverPath, SYS_FILE ); return Abort( hDlg, msgbuf, GetLastError() ); } SetFileAttributes( driverPath, FILE_ATTRIBUTE_NORMAL ); if( !LoadDeviceDriver( SYS_NAME, driverPath, &SysHandle, &error ) ) { UnloadDeviceDriver( SYS_NAME ); if( !LoadDeviceDriver( SYS_NAME, driverPath, &SysHandle, &error ) ) { sprintf( msgbuf, "Error loading %s:", path ); DeleteFile( driverPath ); return Abort( hDlg, msgbuf, error ); } } } return TRUE; }
int Start_MDHal( void ) { unsigned int Register; HANDLE hWD; char VersionString[255]; char Path[255]; HANDLE Device_Handle; NT=Get_Version_Informations(&VersionString[0]); Fail_BOOT=FALSE; sprintf(Path,t("Betriebssystem : %s "),VersionString); Write_Log(Path); SetDlgItemText(SplashWnd,IDC_TEXT1,VersionString); Fail_BOOT=FALSE; hWD = WD_Open(); sprintf(Path,"OrgDriverName : %s ",OrgDriverName); Write_Log(Path); sprintf(Path,"OrgDVBDriverName : %s ",OrgDVBDriverName); Write_Log(Path); if ( OrgDriverName[0] != 0x00 ) { UnloadDeviceDriver((const char *)OrgDriverName,FALSE); Sleep(500); }; if ( OrgDVBDriverName[0] != 0x00 ) { UnloadDeviceDriver((const char *)OrgDVBDriverName,FALSE); Sleep(500); }; if ( hWD == (void *)0xffffffff) { sprintf(Path,t("Starte Service-Installation")); Write_Log(Path); if ( NT == TRUE ) { Write_Log(">>>>>>>> MDHALDR.SYS For NT <<<<<<<<"); GetCurrentDirectory( sizeof (Path),Path ); strcat(Path,"\\MDHALDR.SYS"); Write_Log(Path); if ( ! LoadDeviceDriver( "MultiDec HAL-Treiber", Path, &Device_Handle,TRUE ) ) { return(-1); }; } else { Write_Log(">>>>>>>> MDHALDR.VXD For 9x <<<<<<<<"); Device_Handle=CreateFile("\\\\.\\MDHALDR.VXD",0,0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL|FILE_FLAG_DELETE_ON_CLOSE,0); if(Device_Handle==INVALID_HANDLE_VALUE){ DWORD x = GetLastError(); if ( x != 50 ) return(-2); } } } else { sprintf(Path,t("Service bereits installiert")); Write_Log(Path); WD_Close (hWD); }; // Ich benutze Windriver, und um jungo nicht weiter zu schaden, // liegt diese Funktion in einer DLL , die nur mit MultiDec läuft! // ( Andere Programme würden keine Freischaltung bekommen ) // // Sorry Jungo, aber 3500.- DM habe ich nicht, aber ich mache ab sofort // ( eigentlich schon immer ) Werbung für euch Register = Register_MDHal_Driver(); if ( Register !=0xefcf1ffe ) { sprintf(Path,t("Service - Register fehlerhaft ( Return : 0x%08x)"),Register); Write_Log(Path); return(-3); } sprintf(Path,t("Service - OK")); Write_Log(Path); return(0); };
BOOL LoadDriver(char *filename, char *drivername) { return LoadDeviceDriver( drivername , filename, &handle ); }