Detect user interactions with the console window 偵測使用者所在的終端機視窗
Control window size & position, text colors 控制視窗大小,位置,字的顏色
- API and SDK 應用程式介面&軟體開發工具包
Microsoft Win32 Application Programming Interface
API: a collection of types, constants, and functions that provide a way to directly manipulate objects through
Microsoft Platform Software Development Kit
SDK: a collection of tools, libraries, sample code, and documentation that helps programmers create applications
Platform: an operating system or a group of closely
- Translating Windows Data Types 對照windows的資料型別
Windows Type(s)
MASM Type
BOOL
DWORD
LONG
SDWORD
COLORREF,HANDLE,LPARAM,LRESULT,UINT,WNDPROC
DWORD
LPTSTR
PTR WORD
WORD
WORD
- Standard Console Handles 標準console處理
A handle is an unsigned 32-bit integer.
The following MS-Windows constants are predefined to specify the type of handle requested:
STD_INPUT_HANDLE : standard input STD_OUTPUT_HANDLE : standard output STD_ERROR_HANDLE : standard error output
- GetStdHandle
GetStdHandle returns a handle to a console stream
Specify handle type
The handle is returned in EAX
Prototype:
1
2
GetStdHandle PROTO,
nStdHandle:DWORD ; handle type
Sample call:
1
2
INVOKE GetStdHandle, STD_OUTPUT_HANDLE
mov myHandle, eax
- Console Input
The ReadConsole function provides a convenient way to read text input and put it in a buffer.
Prototype:
1
2
3
4
5
6
ReadConsole PROTO,
handle:DWORD, ; input handle
pBuffer:PTR BYTE, ; pointer to buffer
maxBytes:DWORD, ; number of chars to read
pBytesRead:PTR DWORD, ; ptr to num bytes read
notUsed:DWORD ; (not used)
- WriteConsole
The WriteConsole function writes a string to the screen, using the console output handle. It acts upon standard ASCII control characters such as tab, carriage return, and line feed.