⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enumerator.cls

📁 Windows超级黑客得到windows运行程序的信息,很经典的
💻 CLS
📖 第 1 页 / 共 3 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Enumerator"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Description = "Use this Class to perform all of the enumeration functions. This class also has many functions to do with windows in general, plus a few explicit to the edit control."
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit
'
'  I have been to great troubles to learn all of the techniques in this program.
'  I have spent many, many hours and late nights coding the many functions which I
'  have included. As much as I resent it, Planet Source Code requires that I put
'  the source code in the zip file. So I have placed it in here for you to view.
'  Please use it wisely. And give me credit for all of the hard work that I have
'  done. My biggest fear is that somebody will do an almost straight rip of this
'  code, and take the credit for themselves. Please do not let this happening. I'm
'  placing a lot of trust there. So please, use this program, use this code, and
'  give me credit for it. If anybody rips all my routines, then my secret spy's
'  (and I have a lot of them, as soon as I hire them) will tell me, and I'll get
'  into my private jet (as soon as I buy it) and track you down over the whole
'  world and eventually KILL YOU. You get the idea? Thanks. Read on for something
'  a little more interesting!
'
' Code is Copyright Jolyon Bloomfield, February 2000
'

' A series of declares that drive this class around...
Private Const MAX_PATH& = 260
Private Const PROCESS_ALL_ACCESS = 0

Private Const TH32CS_SNAPPROCESS = 2&
Private Const TH32CS_SNAPTHREAD = 4&

' ShowWindow() Commands
Private Const SW_HIDE = 0
Private Const SW_SHOWNORMAL = 1
Private Const SW_NORMAL = 1
Private Const SW_SHOWMINIMIZED = 2
Private Const SW_SHOWMAXIMIZED = 3
Private Const SW_MAXIMIZE = 3
Private Const SW_SHOWNOACTIVATE = 4
Private Const SW_SHOW = 5
Private Const SW_MINIMIZE = 6
Private Const SW_SHOWMINNOACTIVE = 7
Private Const SW_SHOWNA = 8
Private Const SW_RESTORE = 9
Private Const SW_SHOWDEFAULT = 10
Private Const SW_MAX = 10

' For GetWindowLong
Private Const GWL_WNDPROC = (-4)
Private Const GWL_HINSTANCE = (-6)
Private Const GWL_HWNDPARENT = (-8)
Private Const GWL_STYLE = (-16)
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_USERDATA = (-21)
Private Const GWL_ID = (-12)

' GetClassLong indexes
Private Const GCL_WNDPROC = (-24)
Private Const GCL_STYLE = (-26)
Private Const GCL_MENUNAME = (-8)
Private Const GCL_HMODULE = (-16)
Private Const GCL_HICON = (-14)
Private Const GCL_HCURSOR = (-12)
Private Const GCL_HBRBACKGROUND = (-10)
Private Const GCL_CBWNDEXTRA = (-18)
Private Const GCL_CBCLSEXTRA = (-20)

' SetWindowPos Flags
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOREDRAW = &H8
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_FRAMECHANGED = &H20        '  The frame changed: send WM_NCCALCSIZE
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOCOPYBITS = &H100
Private Const SWP_NOOWNERZORDER = &H200      '  Don't do owner Z ordering

' SetWindowPos() hwndInsertAfter values
Private Const HWND_TOP = 0
Private Const HWND_BOTTOM = 1
Private Const HWND_TOPMOST = -1
Private Const HWND_NOTOPMOST = -2

'
' Note: All of the Window's Styles, Window's Extended Styles,
' Window's messages, etc, etc, etc, messages, are stored in modConst.Bas
'

' All of the data types that this class requires (+ some in the global module)
Private Type THREADENTRY32
  lSize As Long
  lUsage As Long
  lThreadID As Long
  lOwnerProcessID As Long
  lBasePri As Long
  lDeltaPri As Long
  lFlags As Long
End Type

Private Type WINDOWPLACEMENT
  Length As Long
  flags As Long
  showCmd As Long
  ptMinPosition As POINTAPI
  ptMaxPosition As POINTAPI
  rcNormalPosition As RECT
End Type

Private Type PROCESSENTRY32
  dwSize As Long
  cntUsage As Long
  th32ProcessID As Long
  th32DefaultHeapID As Long
  th32ModuleID As Long
  cntThreads As Long
  th32ParentProcessID As Long
  pcPriClassBase As Long
  dwFlags As Long
  szexeFile As String * MAX_PATH
End Type

Private Type ThreadIt
  ID As Long
  Process As Long
End Type

Private Type Winded
  hWnd As Long
  Parent As Long
  StringParentUse As String
  ClassName As String
  Text As String
  UseMe As Boolean
  Thread As Long
  Process As Long
  DisplayText As String
End Type

Public Enum EnumPos
  Normal = 0
  Maximized = 1
  Minimized = 2
End Enum

Public Enum Relations
  GW_HWNDFIRST = 0
  GW_HWNDLAST = 1
  GW_HWNDNEXT = 2
  GW_HWNDPREV = 3
  GW_OWNER = 4
  GW_CHILD = 5
End Enum

' What a heck of a lot of declares!!!
Private Declare Function GetLastError Lib "kernel32" () As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long
Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapshot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, lProcessId As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByRef lParam() As Long) As Long
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByRef lParam() As Long) As Long
Private Declare Function IsWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function GetMenu Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
Private Declare Function IsMenu Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function MoveWindow Lib "user32" (ByVal hWnd As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Private Declare Function SetWindowPlacement Lib "user32" (ByVal hWnd As Long, lpwndpl As WINDOWPLACEMENT) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function EnableWindow Lib "user32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function SetActiveWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function Thread32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As THREADENTRY32) As Long
Private Declare Function Thread32Next Lib "kernel32" (ByVal hSnapshot As Long, uThread As THREADENTRY32) As Long
Private Declare Function IsHungThread Lib "user32" (ByVal lThreadID As Long) As Long
Private Declare Function SetParentA Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function IsZoomed Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function IsIconic Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FlashWindow Lib "user32" (ByVal hWnd As Long, ByVal bInvert As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hWnd As Long, ByVal wFlag As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hdc As Long) As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As Any, ByVal bErase As Long) As Long
Private Declare Function UpdateWindow Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function GetClassLong Lib "user32" Alias "GetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long

' These are the three enumerations.
Private WindsEnum() As Long
Private ThreadsEnum() As ThreadIt
Private ProcessEnum() As Long

' Other variables of sorts
Private mvarEnumsReady As Boolean
Private mvarNewEnum As ReEnumType
Private DoingSomething As Boolean

'
' Sets how EnumIt looks after enumerations that are already there.
'
Public Property Let NewEnum(ByVal EnumNew As ReEnumType)
Attribute NewEnum.VB_Description = "Sets what to do when a function is called that requires an enumeration to be present, but the enumeration doesn't exits."
mvarNewEnum = EnumNew
End Property
Public Property Get NewEnum() As ReEnumType
NewEnum = mvarNewEnum
End Property

'
' Returns a window's process from it's hWnd
'
Public Function WindProcess(ByVal hWnd As Long) As Long
Dim Temp As Long
Temp = GetWindowThreadProcessId(hWnd, WindProcess)
End Function

'
' Returns a window's thread from it's hWnd
'
Public Function WindThread(ByVal hWnd As Long) As Long
Dim Temp As Long
WindThread = GetWindowThreadProcessId(hWnd, Temp)
End Function

'
' Returns the module path for a process through it's processId
'
Public Function ProcessName(ByVal ProcessID As Long) As String

Dim uProcess As PROCESSENTRY32
Dim rProcessFound As Long
Dim hSnapshot As Long
Dim i As Integer

uProcess.dwSize = Len(uProcess)
hSnapshot = CreateToolhelpSnapshot(TH32CS_SNAPPROCESS, 0&)
rProcessFound = ProcessFirst(hSnapshot, uProcess)

Do While rProcessFound
  If uProcess.th32ProcessID = ProcessID Then ProcessName = FixApi(uProcess.szexeFile): Call CloseHandle(hSnapshot): Exit Function
  rProcessFound = ProcessNext(hSnapshot, uProcess)
Loop

ProcessName = ""

Call CloseHandle(hSnapshot)

End Function

'
' Returns the parent of a window
'
Public Function ParentWind(ByVal hWnd As Long) As Long
ParentWind = GetParent(hWnd)
End Function

'
' Returns the desktop window
'
Public Function DesktopWind() As Long
DesktopWind = GetDesktopWindow()
End Function

'
' Formats a long value into hexedecimal, using 8 characters
'
Public Function Format8(ByVal Value As Long) As String
Format8 = String(8 - Len(Trim(Hex(Value))), "0") & Trim(Hex(Value))
End Function

'
' Returns an enumeration of processes
'
Public Sub ReturnProcessEnum(ByRef Process() As Long)

If (EnumsReady = False Or NewEnum = 1) And DoingSomething = False Then EnumAll

Dim i As Long
ReDim Process(LBound(ProcessEnum) To UBound(ProcessEnum)) As Long

For i = LBound(ProcessEnum) To UBound(ProcessEnum)
  Process(i) = ProcessEnum(i)
Next i

End Sub

'

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -