• Einfach CDROM Laufwerk sperren?

    Spoiler anzeigen
    [autoit]


    ;Example
    #include <WinAPI.au3>

    [/autoit] [autoit][/autoit] [autoit]

    Global $Drive = DriveGetDrive('CDROM')
    If IsArray($Drive) Then
    _WinAPI_LockDevice($Drive[1], 1)
    MsgBox(0, '', 'The drive ' & StringUpper($Drive[1]) & ' is locked.')
    _WinAPI_LockDevice($Drive[1], 0)
    MsgBox(0, '', 'The drive ' & StringUpper($Drive[1]) & ' is unlocked.')
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_LockDevice($sDrive, $fLock)
    ;Yashied
    Local $hFile = _WinAPI_CreateFileEx('\\.\' & $sDrive, 3, 0xC0000000, 0x03)
    If Not $hFile Then
    Return SetError(1, 0, 0)
    EndIf
    Local $tPREVENT_MEDIA_REMOVAL = DllStructCreate('byte')
    DllStructSetData($tPREVENT_MEDIA_REMOVAL, 1, $fLock)
    Local $Ret = DllCall('kernel32.dll', 'int', 'DeviceIoControl', 'ptr', $hFile, 'dword', 0x002D4804, 'ptr', DllStructGetPtr($tPREVENT_MEDIA_REMOVAL), 'dword', DllStructGetSize($tPREVENT_MEDIA_REMOVAL), 'ptr', 0, 'dword', 0, 'dword*', 0, 'ptr', 0)
    If (@error) Or (Not $Ret[0]) Then
    $Ret = 0
    EndIf
    _WinAPI_CloseHandle($hFile)
    If Not IsArray($Ret) Then
    Return SetError(2, 0, 0)
    EndIf
    Return 1
    EndFunc ;==>_WinAPI_LockDevice

    [/autoit] [autoit][/autoit] [autoit]

    Func _WinAPI_CreateFileEx($sFile, $iCreation, $iAccess, $iShare, $iFlagsAndAttributes = 0, $tSecurity = 0, $hTemplate = 0)
    ;Yashied
    Local $Ret = DllCall('kernel32.dll', 'ptr', 'CreateFileW', 'wstr', $sFile, 'dword', $iAccess, 'dword', $iShare, 'ptr', DllStructGetPtr($tSecurity), 'dword', $iCreation, 'dword', $iFlagsAndAttributes, 'ptr', $hTemplate)
    If (@error) Or ($Ret[0] = -1) Then
    Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
    EndFunc ;==>_WinAPI_CreateFileEx

    [/autoit]

    Dann hat sich das mit CD.

    Das einzige was bleibt, ist ein USB Stick benutzen und dann halt das mit den Bytes einer .lnk File ändern, dass es ein Programm aufruft, das ginge auch noch (ist die Lücke noch vorhanden?).

  • Man könnte auch einfach einstellen, dass man in einer bestimmten Zeit unterhalb einer bestimmten Anzahl von Versuchen die richtigen Zugangsdaten eingibt und ansonsten der PC gesperrt wird bzw. der Benutzer gewechselt (Windowstaste+l), sofern man die Maus bewegt usw.
    Bis die Zugangsdaten eingegeben sind ab dem Zeitpunkt der Aktivierung des Passwortschutzes könnte auch Autorun deaktiviert werden.
    Damit man natürlich nicht dieses Zeitlimit umgehen kann usw. würde ich einfach im Hintergrund zwei Exen laufen lassen, die sich gegenseitig auf Existenz und Erreichbarkeit prüfen (damit sie nicht pausiert werden können). Man könnte sie z.B. svchost.exe oder so nennen, weil davon gibts sehr viele und bis man analysiert hat, welche die richtigen sind, ist es schon zu spät. Diese exen wiederum erhalten den Befehl vom Programm Anfangs, dass sie starten sollen und gleichzeitig nach Ablauf der vorgegebenen Zeit die Sperrung auslösen sollen bzw. wenn der Prozess des Passwortschutzes unautorisiert beendet wurde.
    Somit würde auf die Windows-Mechanismen vertraut werden und das wäre wesentlich sicherer. Alternativ könnte der PC z.B. auch in Standby, wenn das mit der Sperrung fehlschlägt, versetzt werden usw.

    Die Möglichkeiten sind grenzenlos :) :)

  • Hallo zusammen,

    hier wurde schon lange nichts mehr gepostet. Wie wurde eigentlich das Problem mit Autorun gelöst? Sollte man so etwas am besten per Registry machen? Ich habe momentan das gleiche Problem.

    Falls die sich gegenseitig startenden Exen noch benötigt werden, könnte ich damit dienen, habe da schon vor längerer Zeit etwas für mich als Grundlage für zukünftige, mögliche Projekte erstellt.

  • Man sollte vielleicht zunächst mal den Adlib Fehler bereinigen :)

    Benutz doch einfach die Registryfunctions.

  • Ich hab mal dran rumgebastelt mit Alarmton und Labelund man muss nun nicht mehr die entertaste drücken:

    Spoiler anzeigen
    [autoit]

    ;==============================================================
    ; DeskLock
    ;==============================================================
    ; Author: Sen
    ; Version: 1.0 Beta
    ;==============================================================
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <StaticConstants.au3>
    #include <EditConstants.au3>

    [/autoit] [autoit][/autoit] [autoit]

    HotKeySet("!{F4}", "_Dummy")
    HotKeySet("!x", "main")

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(10)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func main()
    #Region File Install
    DirCreate(@TempDir & "/DeskLock/")
    FileInstall("Images\TopBar.bmp", @TempDir & "/DeskLock/TopBar.bmp", 1)
    FileInstall("Images\BottomBar.bmp", @TempDir & "/DeskLock/BottomBar.bmp", 1)
    FileInstall("Images\LogIn.bmp", @TempDir & "/DeskLock/LogIn.bmp", 1)
    FileInstall("Images\Settings.bmp", @TempDir & "/DeskLock/Settings.bmp", 1)
    FileInstall("System\System.ini", @TempDir & "/DeskLock/System.ini", 0)
    FileInstall("System\WinLock.dll", @TempDir & "/DeskLock/WinLock.dll", 0)
    #EndRegion File Install

    [/autoit] [autoit][/autoit] [autoit]

    #Region GUI
    ;Main Window
    $Main = GUICreate("DeskLock", @DesktopWidth + 5, @DesktopHeight + 5, -5, -5, 0x80000000, 0x00000080)
    ;Design
    $Design_TopBar = GUICtrlCreatePic(@TempDir & "/DeskLock/TopBar.bmp", 0, 5, @DesktopWidth + 10, 22)
    $Design_BottomBar = GUICtrlCreatePic(@TempDir & "/DeskLock/BottomBar.bmp", 0, @DesktopHeight - 15, @DesktopWidth + 10, 22)
    $Design_LogIn = GUICtrlCreatePic(@TempDir & "/DeskLock/LogIn.bmp", (@DesktopWidth / 2) - 108, (@DesktopHeight / 2) - 65, 217, 131)
    ;Log-In
    $Input_Pw = GUICtrlCreateInput("", (@DesktopWidth / 2) - 95, (@DesktopHeight / 2) + 35, 190, 20, $ES_PASSWORD)
    GUICtrlSetState(-1, $GUI_HIDE)
    $Label_Pw = GUICtrlCreateLabel("Enter Password:", (@DesktopWidth / 2) - 95, (@DesktopHeight / 2) + 15, 170, 20, $SS_CENTER)
    GUICtrlSetBkColor(-1, 16382457)
    GUICtrlSetState(-1, $GUI_HIDE)
    $Settings_Pw = GUICtrlCreatePic(@TempDir & "/DeskLock/Settings.bmp", (@DesktopWidth / 2) + 75, (@DesktopHeight / 2) + 15, 20, 20)
    $alarm = GUICtrlCreateLabel("ALARM!", (@desktopwidth-300)/2, 150, 800, 400)
    GUICtrlSetFont(-1, 72)
    GUICtrlSetState(-1, $GUI_HIDE)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $GUI_SP = GUICreate("DeskLock - Change Password", @DesktopWidth / 3, @DesktopHeight / 6, -1, -1, 0x80000000 + 0x00800000)
    $SP_Dim = WinGetPos($GUI_SP)
    $SP_Design_TopBar = GUICtrlCreatePic(@TempDir & "/DeskLock/TopBar.bmp", 0, -10, @DesktopWidth + 10, 22)
    $SP_Design_BottomBar = GUICtrlCreatePic(@TempDir & "/DeskLock/BottomBar.bmp", 0, @DesktopHeight / 6 - 10, @DesktopWidth + 10, 22)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Old Password:", ($SP_Dim[2] / 10) * 0.75, ($SP_Dim[3] / 10) * 1.75 + 4)
    $SP_OldPW = GUICtrlCreateInput("", ($SP_Dim[2] / 10) * 3, ($SP_Dim[3] / 10) * 1.75, ($SP_Dim[2] / 10) * 6, -1, 0x20)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("New Password:", ($SP_Dim[2] / 10) * 0.75, ($SP_Dim[3] / 10) * 3.75 + 4)
    $SP_NewPW = GUICtrlCreateInput("", ($SP_Dim[2] / 10) * 3, ($SP_Dim[3] / 10) * 3.75, ($SP_Dim[2] / 10) * 6, -1, 0x20)

    [/autoit] [autoit][/autoit] [autoit]

    GUICtrlCreateLabel("Confirm Password:", ($SP_Dim[2] / 10) * 0.75, ($SP_Dim[3] / 10) * 5.75 + 4)
    $SP_NewPW_confirm = GUICtrlCreateInput("", ($SP_Dim[2] / 10) * 3, ($SP_Dim[3] / 10) * 5.75, ($SP_Dim[2] / 10) * 6, -1, 0x20)

    [/autoit] [autoit][/autoit] [autoit]

    $SP_SaveB = GUICtrlCreateButton("Save", ($SP_Dim[2] / 10) * 6, ($SP_Dim[3] / 10) * 7.25 + 4, ($SP_Dim[2] / 10) * 3, -1, 0x01)
    $SP_ErrorLable = GUICtrlCreateLabel("", ($SP_Dim[2] / 10) * 0.75, ($SP_Dim[3] / 10) * 7.25 + 4, ($SP_Dim[2] / 10) * 4.5, 25)
    GUISetBkColor(0xFFFFFF, $GUI_SP)

    [/autoit] [autoit][/autoit] [autoit]

    ;Settings
    GUISetBkColor(0xFFFFFF, $Main)
    WinRunTrans($Main, "Show")
    GUICtrlSetState($Design_LogIn, $GUI_DISABLE)
    Global $ActiveWin = $Main
    #EndRegion GUI

    [/autoit] [autoit][/autoit] [autoit]

    #Region StartUp
    $Pw = IniRead(@TempDir & "/DeskLock/System.ini", "DeskLock", "Pw", "passwort")
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "Desktop_Show_Hide", "int", 0)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "Taskbar_Show_Hide", "int", 0)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "TaskSwitching_Enable_Disable", "int", 0)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "TaskManager_Enable_Disable", "int", 0)
    #EndRegion StartUp
    AdlibRegister("_Secure", 200)
    #Region Schleife
    While 1
    $nMsg = GUIGetMsg(1)
    Switch $nMsg[1]
    Case $Main
    Switch $nMsg[0]
    Case $Input_Pw
    If GUICtrlRead($Input_Pw) == $Pw Then
    WinRunTrans($Main, "Hide")
    Exit
    Else
    GUICtrlSetData($Input_Pw, "")
    GUICtrlSetState($alarm, $GUI_SHOW)
    Do
    SoundSetWaveVolume(100)
    Beep(400, 200)
    Beep(500,200)
    Beep(1200, 200)
    Until GUICtrlRead($Input_Pw) == $Pw
    WinRunTrans($Main, "Hide")
    EndIf
    Case $Settings_Pw
    $ActiveWin = $GUI_SP
    ;~ WinSetOnTop($Main, "", 0)
    GUISetState(@SW_DISABLE, $Main)
    WinRunTrans($GUI_SP, "Show")
    HotKeySet("{ESC}","_HideSP")
    EndSwitch
    Case $GUI_SP
    Switch $nMsg[0]
    Case $SP_SaveB
    If GUICtrlRead($SP_OldPW) == $Pw Then
    If GUICtrlRead($SP_NewPW) == GUICtrlRead($SP_NewPW_confirm) Then
    GUICtrlSetColor($SP_ErrorLable, 32768)
    GUICtrlSetData($SP_ErrorLable, "Password changed!")
    IniWrite(@TempDir & "/DeskLock/System.ini", "DeskLock", "Pw", GUICtrlRead($SP_NewPW))
    $Pw = GUICtrlRead($SP_NewPW)
    Sleep(1000)
    _HideSP()
    Else
    _SP_ErrorMessage("New passwords did not match!",$SP_NewPW_confirm)
    EndIf
    Else
    _SP_ErrorMessage("Old password did not match!",$SP_OldPW)
    EndIf
    EndSwitch
    EndSwitch

    [/autoit] [autoit][/autoit] [autoit]

    ;~ ;Security

    [/autoit] [autoit][/autoit] [autoit]

    WEnd
    EndFunc
    #EndRegion Schleife

    [/autoit] [autoit][/autoit] [autoit]

    #Region Func's
    Func OnAutoItExit()
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "Desktop_Show_Hide", "int", 1)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "Taskbar_Show_Hide", "int", 1)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "TaskSwitching_Enable_Disable", "int", 1)
    DllCall(@TempDir & "/DeskLock/WinLock.dll", "int", "TaskManager_Enable_Disable", "int", 1)
    EndFunc ;==>OnAutoItExit
    Func _Secure()
    If Not WinActive($ActiveWin) Then WinActivate($ActiveWin)
    WinKill("Windows Task-Manager")
    WinKill("Task-Manager")
    ;~ WinSetOnTop($ActiveWin, "", 1)
    EndFunc ;==>_Secure
    Func _HideSP()
    WinRunTrans($GUI_SP, "Hide")
    GUISetState(@SW_HIDE, $GUI_SP)
    ;~ WinSetOnTop($GUI_SP, "", 0)
    If Not WinActive($Main) Then WinActivate($Main)
    $ActiveWin = $Main
    GUICtrlSetData($SP_OldPW, "")
    GUICtrlSetData($SP_NewPW, "")
    GUICtrlSetData($SP_NewPW_confirm, "")
    GUICtrlSetData($SP_ErrorLable, "")
    GUISetState(@SW_ENABLE, $Main)
    HotKeySet("{ESC}")
    EndFunc
    Func _SP_ErrorMessage($sErrorMessage,$hAlarmControl)
    GUICtrlSetColor($SP_ErrorLable, 14425700)
    GUICtrlSetData($SP_ErrorLable, $sErrorMessage)
    For $i = 0 To 2
    GUICtrlSetBkColor($hAlarmControl, 14425700)
    Sleep(500)
    GUICtrlSetBkColor($hAlarmControl, 0xFFFFFF)
    Sleep(500)
    Next
    GUICtrlSetData($hAlarmControl, "")
    EndFunc
    Func _Taskbar($Art)
    Local $value = Opt("WinTitleMatchMode", 4)
    Local $Pos = WinGetPos("classname=Shell_TrayWnd")
    Opt("WinTitleMatchMode", $value)
    If $Art = "Hoch" Then
    Return $Pos[3]
    ElseIf $Art = "Breit" Then
    Return $Pos[2]
    ElseIf $Art = "Pos" Then
    If $Pos[0] = "0" And $Pos[1] <> "0" Then
    Return "Unten"
    ElseIf $Pos[0] = "0" And $Pos[1] = "0" And $Pos[2] < $Pos[3] Then
    Return "Links"
    ElseIf $Pos[0] = "0" And $Pos[1] = "0" Then
    Return "Oben"
    Else
    Return "Rechts"
    EndIf
    EndIf
    EndFunc ;==>_Taskbar
    Func _Dummy()
    Sleep(10)
    EndFunc ;==>_Dummy
    Func WinRunTrans($Window, $Mod)
    If $Mod = "Show" Then
    GUISetState(@SW_SHOW, $Window)
    For $i = 0 To 255 Step 5
    WinSetTrans($Window, "", $i)
    Sleep(10)
    Next

    [/autoit] [autoit][/autoit] [autoit]

    ElseIf $Mod = "Hide" Then

    [/autoit] [autoit][/autoit] [autoit]

    For $i = 255 To 0 Step -5
    WinSetTrans($Window, "", $i)
    Sleep(10)
    Next
    GUISetState(@SW_HIDE, $Window)
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>WinRunTrans
    #EndRegion Func's

    [/autoit]