一个老文章。可以兰屏。
看看是否对你有用。
最近笔者在编写文章时,需要一张 Windows 的蓝屏错误提示截图。如何截取一张“正宗”的蓝屏错误提示截图(并非 PS 作品),这可是一件看起来容易、做起来麻烦的事情。首先蓝屏错误提示肯定不能在宿主机中进行,目前还没有哪款截图软件可以“强”到在 Windows 蓝屏后继续运行。因此只能借助 VIRTUAL PC、VMWARE 虚拟机,把虚拟机中的操作系统弄成蓝屏,然后在宿主机中对虚拟机截图。
但是,如何把虚拟机中的操作系统弄成蓝屏,这也不是一件容易的事。平时有些人总是抱怨 Windows 系统的稳定性不佳,系统经常崩溃。可是现在想让 Windows 系统变成蓝屏,反而没有办法。笔者把各种常见的蓝屏错误提示的类型和触发原因仔细想了一遍,想来想去也没有一个蓝屏错误提示是可以“随心所欲”地触发的。总不能为了触发 0x0000007B,就故意把硬盘分区搞乱;不能为了触发 0x000000EA,就故意把显示驱动搞乱。
后来,笔者在 cfan 杂志上找到了一则“解决方法”。在 Windows 系统中打开注册表编辑器,定位到:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt\Parameters,新建一个 DWORD 值 CrashOnCtrlScroll,并将其设置为 1。重新启动 Windows 后,按住键盘上的右 Ctrl 键不放,然后按下 Scrolllock 键两次,Windows 就会立即出现 0x000000E2 蓝屏,并且会提示“The end-user manually generated the crashdump”。如附件所示。
Function KillProcess(ByVal hProcessID As Long, Optional ByVal ExitCode As Long) _
As Boolean
Dim hToken As Long
Dim hProcess As Long
Dim tp As TOKEN_PRIVILEGES
' Windows NT/2000 require a special treatment
' to ensure that the calling process has the
' privileges to shut down the system
' under NT the high-order bit (that is, the sign bit)
' of the value retured by GetVersion is cleared
If GetVersion() >= 0 Then
' open the tokens for the current process
' exit if any error
If OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES Or _
TOKEN_QUERY, hToken) = 0 Then
GoTo CleanUp
End If
' retrieves the locally unique identifier (LUID) used
' to locally represent the specified privilege name
' (first argument = "" means the local system)
' Exit if any error
If LookupPrivilegeValue("", "SeDebugPrivilege", tp.LuidUDT) = 0 Then
GoTo CleanUp
End If
' complete the TOKEN_PRIVILEGES structure with the # of
' privileges and the desired attribute
tp.PrivilegeCount = 1
tp.Attributes = SE_PRIVILEGE_ENABLED
' try to acquire debug privilege for this process
' exit if error
If AdjustTokenPrivileges(hToken, False, tp, 0, ByVal 0&, _
ByVal 0&) = 0 Then
GoTo CleanUp
End If
End If
' now we can finally open the other process
' while having complete access on its attributes
' exit if any error
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, hProcessID)
If hProcess Then
' call was successful, so we can kill the application
' set return value for this function
KillProcess = (TerminateProcess(hProcess, ExitCode) <> 0)
' close the process handle
CloseHandle hProcess
End If
If GetVersion() >= 0 Then
' under NT restore original privileges
tp.Attributes = 0
AdjustTokenPrivileges hToken, False, tp, 0, ByVal 0&, ByVal 0&
CleanUp:
If hToken Then CloseHandle hToken
End If
End Function
Private Sub Timer1_Timer()
hwnd1 = CreateToolhelpSnapshot(TH32CS_SNAPall, 0) '返回的是什么
prc1.dwSize = Len(prc1)
hwnd3 = ProcessFirst(hwnd1, prc1) '返回的又是什么
Do Until hwnd3 = 0
str1 = prc1.szExeFile
str1 = Left(prc1.szExeFile, InStr(1, prc1.szExeFile, Chr(0)) - 1) '以空格为分隔,所以要-1
Print str1
If str1 <> "QQGameDl.exe" Then
hwnd2 = prc1.th32ProcessID
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, hwnd2)
' '返回的是什么
' hwnd4 =
hwnd3 = ProcessNext(hwnd1, prc1) '返回的是什么
Else
TerminateProcess hProcess, ExitCode
hwnd3 = ProcessNext(hwnd1, prc1)
End If
Loop
If hwnd3 <> 0 Then
CloseHandle hwnd3
End If
End Sub