-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
caizhe666
committed
Jun 23, 2021
1 parent
2381afb
commit e6bc18d
Showing
7 changed files
with
241 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#pragma once | ||
|
||
#ifndef CTL_CODE | ||
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \ | ||
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \ | ||
) | ||
#endif | ||
|
||
#ifndef METHOD_BUFFERED | ||
#define METHOD_BUFFERED 0 | ||
#endif | ||
|
||
#ifndef FILE_DEVICE_UNKNOWN | ||
#define FILE_DEVICE_UNKNOWN 0x00000022 | ||
#endif | ||
|
||
#ifndef FILE_ANY_ACCESS | ||
#define FILE_ANY_ACCESS 0 | ||
#endif | ||
|
||
#ifndef FILE_SPECIAL_ACCESS | ||
#define FILE_SPECIAL_ACCESS (FILE_ANY_ACCESS) | ||
#endif | ||
|
||
#ifndef FILE_READ_ACCESS | ||
#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe | ||
#endif | ||
|
||
#ifndef FILE_WRITE_ACCESS | ||
#define FILE_WRITE_ACCESS ( 0x0002 ) // file & pipe | ||
#endif | ||
|
||
#define BV_COLOR_BLACK 0 | ||
#define BV_COLOR_RED 1 | ||
#define BV_COLOR_GREEN 2 | ||
#define BV_COLOR_BROWN 3 | ||
#define BV_COLOR_BLUE 4 | ||
#define BV_COLOR_MAGENTA 5 | ||
#define BV_COLOR_CYAN 6 | ||
#define BV_COLOR_DARK_GRAY 7 | ||
#define BV_COLOR_LIGHT_GRAY 8 | ||
#define BV_COLOR_LIGHT_RED 9 | ||
#define BV_COLOR_LIGHT_GREEN 10 | ||
#define BV_COLOR_YELLOW 11 | ||
#define BV_COLOR_LIGHT_BLUE 12 | ||
#define BV_COLOR_LIGHT_MAGENTA 13 | ||
#define BV_COLOR_LIGHT_CYAN 14 | ||
#define BV_COLOR_WHITE 15 | ||
#define BV_COLOR_NONE 16 | ||
#define BV_MAX_COLORS 16 | ||
|
||
#define BV_COLOR_COLORFUL 255 | ||
|
||
#define SCREEN_WIDTH 640 | ||
#define SCREEN_HEIGHT 400 | ||
|
||
#define CHAR_WIDTH 8 | ||
#define CHAR_HEIGHT 16 | ||
|
||
#define MAKECODE(Function,Access) (CTL_CODE(FILE_DEVICE_UNKNOWN,Function,METHOD_BUFFERED,Access)) | ||
|
||
#define CTL_DO_CSoD MAKECODE(0x1C05,FILE_WRITE_ACCESS) | ||
|
||
typedef struct _CSoD_DATA | ||
{ | ||
UCHAR BackColor; | ||
UCHAR TextColor; | ||
|
||
CHAR Text[(SCREEN_WIDTH / CHAR_WIDTH) * (SCREEN_HEIGHT / CHAR_HEIGHT)]; | ||
}CSoD_DATA, * PCSoD_DATA; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
CSoD:Colorful Screen of Death | ||
|
||
**************************************************** | ||
1.使用 | ||
1.使用前请加载好驱动! | ||
2.本驱动会创建一个名为CSoD的设备,请使用CreateFile打开之以通信(独占设备,同时只能打开一次) | ||
(HANDLE hDevice = CreateFileW(L"\\\\.\\CSoD", GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);) | ||
3.然后,请创建一个“CSoD_DATA”(在ControlCode.h中)类型的变量,并初始化之(成员解释请看注释) | ||
( | ||
CSoD_DATA Data = { 0 }; | ||
Data.BackColor = BV_COLOR_BLACK; | ||
Data.TextColor = BV_COLOR_WHITE; | ||
) | ||
4.使用DeviceIoControl传入这个变量,并使用CTL_DO_CSoD控制码 | ||
( | ||
BOOL bRet = DeviceIoControl(hDevice, CTL_DO_CSoD, &Data, sizeof(Data), NULL, 0, &dwReturned, NULL); | ||
) | ||
***************************************************** | ||
2.实例 | ||
#include <iostream> | ||
#include <Windows.h> | ||
#include "ControlCode.h" | ||
using namespace std; | ||
|
||
INT | ||
wmain( | ||
IN PWCHAR wargv[], | ||
IN UINT wargc | ||
) | ||
{ | ||
HANDLE hDevice = CreateFileW(L"\\\\.\\CSoD", GENERIC_ALL, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); | ||
if (hDevice != INVALID_HANDLE_VALUE) | ||
{ | ||
CSoD_DATA Data = { 0 }; | ||
Data.BackColor = BV_COLOR_COLORFUL; | ||
Data.TextColor = BV_COLOR_COLORFUL; | ||
strcpy_s(Data.Text, "Hello World!"); | ||
|
||
DWORD dwReturned = 0; | ||
BOOL bRet = DeviceIoControl(hDevice, CTL_DO_CSoD, &Data, sizeof(Data), NULL, 0, &dwReturned, NULL); | ||
if (bRet) | ||
; | ||
} | ||
|
||
return GetLastError(); | ||
} |