-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSerialBaudRate.asm
94 lines (67 loc) · 3.35 KB
/
SerialBaudRate.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
; Written by Four-F ([email protected])
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.386
.model flat, stdcall
option casemap:none
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; I N C L U D E F I L E S
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\w2k\ntdll.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\w2k\ntdll.lib
include \masm32\include\w2k\ntddk.inc
include \masm32\include\w2k\ntstatus.inc
include \masm32\include\w2k\ntddser.inc
include \masm32\Macros\Strings.mac
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; E Q U A T E S
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; windows.inc can't be included because of ntddk.inc
OPEN_EXISTING equ 3
MB_ICONHAND equ 10h
MB_ICONSTOP equ MB_ICONHAND
MB_ICONINFORMATION equ 40h
INVALID_HANDLE_VALUE equ -1
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; C O D E
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
.code
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; start
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
start proc
local status:NTSTATUS
local oa:OBJECT_ATTRIBUTES
local us:UNICODE_STRING
local iosb:IO_STATUS_BLOCK
local hDevice:HANDLE
local sbr:SERIAL_BAUD_RATE
local dwBytesReturned:DWORD
local buffer[128]:BYTE
CCOUNTED_UNICODE_STRING "\\Device\\Serial0", g_usSerialDeviceName, 4
InitializeObjectAttributes addr oa, addr g_usSerialDeviceName, OBJ_CASE_INSENSITIVE, NULL, NULL
invoke ZwOpenFile, addr hDevice, FILE_READ_ACCESS, addr oa, addr iosb, \
FILE_SHARE_READ + FILE_SHARE_WRITE + FILE_SHARE_DELETE, 0
.if eax == STATUS_SUCCESS
invoke DeviceIoControl, hDevice, IOCTL_SERIAL_GET_BAUD_RATE, NULL, 0, \
addr sbr, sizeof sbr, addr dwBytesReturned, NULL
.if eax != 0
invoke wsprintf, addr buffer, $CTA0("Current Baud Rate: %d"), sbr.BaudRate
invoke MessageBox, NULL, addr buffer, $CTA0("\\Device\\Serial0 Info"), MB_ICONINFORMATION
.endif
invoke ZwClose, hDevice
.else
invoke MessageBox, NULL, $CTA0("Couldn't open serial device."), NULL, MB_ICONSTOP
.endif
invoke ExitProcess, 0
start endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
end start