Underc0de - Hacking y seguridad informática

Programación General => Visual Basic => Códigos Fuentes => Mensaje iniciado por: ANTRAX en Julio 26, 2010, 01:53:44 pm

Título: Encender y Apagar Num, Caps y Scroll Lock
Publicado por: ANTRAX en Julio 26, 2010, 01:53:44 pm
Código: Visual Basic
  1. Private Type OSVERSIONINFO
  2.     dwOSVersionInfoSize As Long
  3.     dwMajorVersion As Long
  4.     dwMinorVersion As Long
  5.     dwBuildNumber As Long
  6.     dwPlatformId As Long
  7.     szCSDVersion As String * 128
  8. End Type
  9. Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
  10. Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
  11. Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
  12. Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
  13. Const VK_NUMLOCK = &H90
  14. Const VK_SCROLL = &H91
  15. Const VK_CAPITAL = &H14
  16. Const KEYEVENTF_EXTENDEDKEY = &H1
  17. Const KEYEVENTF_KEYUP = &H2
  18. Const VER_PLATFORM_WIN32_NT = 2
  19. Const VER_PLATFORM_WIN32_WINDOWS = 1
  20. Dim o As OSVERSIONINFO
  21. Dim NumLockState As Boolean
  22. Dim ScrollLockState As Boolean
  23. Dim CapsLockState As Boolean

Aca podemos modificar el estado

Código: Visual Basic
  1. Private Sub Num_Lock_Click()
  2. o.dwOSVersionInfoSize = Len(o)
  3. GetVersionEx o
  4. Dim keys(0 To 255) As Byte
  5. GetKeyboardState keys(0)
  6. NumLockState = keys(VK_NUMLOCK)
  7. If NumLockState <> True Then
  8.     'Poner numlock a on
  9.    If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  10.         'Si es Win95
  11.        keys(VK_NUMLOCK) = 1
  12.         SetKeyboardState keys(0)
  13.     ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  14.         'Si es WinNT
  15.        keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  16.         keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  17.     End If
  18.  Else
  19. 'Poner Num_Lock a Off
  20. If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  21.         keys(VK_NUMLOCK) = 0
  22.         SetKeyboardState keys(0)
  23.         ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  24.         keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  25.          keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  26.     End If
  27. End If
  28. End Sub

Lo demas es casi igual

Código: Visual Basic
  1. Private Sub Caps_Lock_Click()
  2. o.dwOSVersionInfoSize = Len(o)
  3. GetVersionEx o
  4. Dim keys(0 To 255) As Byte
  5. GetKeyboardState keys(0)
  6. CapsLockState = keys(VK_CAPITAL)
  7. If CapsLockState <> True Then
  8.     If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  9.         keys(VK_CAPITAL) = 1
  10.         SetKeyboardState keys(0)
  11.     ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  12.         keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  13.         keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  14.     End If
  15.  Else
  16.  If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  17.         keys(VK_CAPITAL) = 0
  18.         SetKeyboardState keys(0)
  19.     ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  20.         keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  21.         keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  22.     End If
  23. End If
  24. End Sub

Código: Visual Basic
  1. Private Sub Scroll_Lock_Click()
  2. o.dwOSVersionInfoSize = Len(o)
  3. GetVersionEx o
  4. Dim keys(0 To 255) As Byte
  5. GetKeyboardState keys(0)
  6. ScrollLockState = keys(VK_SCROLL)
  7. If ScrollLockState <> True Then
  8.     If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  9.         keys(VK_SCROLL) = 1
  10.         SetKeyboardState keys(0)
  11.     ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  12.         keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  13.         keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  14.     End If
  15. Else
  16. If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then
  17.         keys(VK_SCROLL) = 0
  18.         SetKeyboardState keys(0)
  19.     ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then
  20.         keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
  21.         keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0
  22.     End If
  23. End If
  24. End Sub