- Код: Выделить всё
Option Explicit
Private Declare Function NtQuerySystemInformation Lib "ntdll.dll" (ByVal infoClass As Long, ByVal Buffer As Long, ByVal BufferSize As Long, ByVal Ret As Long) As Long
Private Declare Function VirtualAlloc Lib "kernel32.dll" (ByVal Address As Long, ByVal dwSize As Long, ByVal AllocationType As Long, ByVal Protect As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDst As Long, ByVal pSrc As long, ByVal ByteLen As Long)
Private Const DRIVER_INFORMATION = 11
Private Const PAGE_READWRITE = &H4
Private Const MEM_RELEASE = &H8000
Private Const MEM_COMMIT = &H1000
Private Sub Command1_Click()
Dim Ret As Long
Dim Buffer As Long
Dim NumDrivers As Long
Dim Temp As Long
NtQuerySystemInformation DRIVER_INFORMATION, 0, 0, VarPtr(Ret)
Buffer = VirtualAlloc(0, Ret * 2, MEM_COMMIT, PAGE_READWRITE)
NtQuerySystemInformation DRIVER_INFORMATION, Buffer, Ret * 2, VarPtr(Ret)
CopyMemory ByVal varPtr(NumDrivers), ByVal Buffer, 4
MsgBox NumDrivers
Buffer = Buffer + 12
CopyMemory Byval VarPtr(Temp), ByVal Buffer, 4 'Пытаюсь читать, читается...
MsgBox Temp
End Sub
1) Здесь, в буфере (смещение 12) начинаются драйвера... Правильно?
2) Если первые 4 байта, в буфере - это DWORD количество драйверов, то (12 - 4) = 8. Это что?