📄 ioctldecoder.bat
字号:
.endif
.if ecx == 0
invoke wsprintf, addr buffer, $CTA0("0x%04X"), eax
.else
invoke wsprintf, addr buffer, $CTA0("0x%04X (%s)"), eax, ecx
.endif
lea eax, buffer
.endif
invoke SetDlgItemText, g_hDlg, IDE_DEVICE, eax
; Function Code
mov eax, ebx
and eax, 011111111111100y
shr eax, 2
invoke wsprintf, addr buffer, addr g_szHex, eax
invoke SetDlgItemText, g_hDlg, IDE_FUNCTION, addr buffer
; Method
mov eax, ebx
and eax, 011y
invoke SetDlgItemText, g_hDlg, IDE_METHOD, g_aszMethods[eax * sizeof LPSTR]
; Access
mov eax, ebx
and eax, 1100000000000000y
shr eax, 14
invoke SetDlgItemText, g_hDlg, IDE_ACCESS, g_aszAccesses[eax * sizeof LPSTR]
; Bitfield
invoke DwToBinStr, ebx, addr buffer, 32
invoke SetDlgItemText, g_hDlg, IDE_BITS, addr buffer
.else
invoke ClearText, uActiveControl
.endif
ret
Refresh endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; D I A L O G P R O C E D U R E
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
DlgProc proc uses ebx hDlg:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
local lf:LOGFONT
local ps:PAINTSTRUCT
local bm:BITMAP
local hdc:HDC
local buffer[256]:CHAR
mov eax, uMsg
.if eax == WM_COMMAND
mov eax, $LOWORD(wParam)
.if eax == IDCANCEL
invoke EndDialog, hDlg, 0
.elseif eax == IDE_IOCTL
invoke GetFocus
.if eax == g_hwndEditIoctl
mov eax, $HIWORD(wParam)
.if eax == EN_CHANGE
invoke GetWindowTextLength, g_hwndEditIoctl
.if eax == 8
invoke Refresh, IDE_IOCTL
.else
invoke ClearText, IDE_IOCTL
.endif
.endif
.endif
.elseif eax == IDE_MNEMONIC
invoke GetFocus
.if eax == g_hwndEditMnemonic
mov eax, $HIWORD(wParam)
.if eax == EN_CHANGE
;invoke GetWindowTextLength, g_hwndEditMnemonic
;.if eax == 8
invoke Refresh, IDE_MNEMONIC
;.else
; invoke ClearText
;.endif
.endif
.endif
.endif
.elseif eax == WM_NOTIFY
mov eax, lParam
.if [NMHDR ptr [eax]].code == UDN_DELTAPOS
invoke SendMessage, g_hwndEditIoctl, WM_GETTEXT, sizeof buffer, addr buffer
invoke htodw, addr buffer
mov ebx, eax
mov eax, lParam
mov eax, (NMHDR ptr [eax]).hwndFrom
.if eax == g_hwndSpinFunction
mov eax, ebx
and eax, 011111111111100y ; Extract function code
shr eax, 2
mov ecx, lParam
mov ecx, (NM_UPDOWN ptr [ecx]).iDelta
add eax, ecx
and eax, 0111111111111y ; Mask function code
shl eax, 2
and ebx, not 011111111111100y
or ebx, eax
.elseif eax == g_hwndSpinMethod
mov eax, ebx
and eax, 011y ; Extract method
mov ecx, lParam
mov ecx, (NM_UPDOWN ptr [ecx]).iDelta
add eax, ecx
and eax, 011y
and ebx, not 011y ; Mask method
or ebx, eax
.elseif eax == g_hwndSpinAccess
mov eax, ebx
and eax, 01100000000000000y ; Extract access
shr eax, 14
mov ecx, lParam
mov ecx, (NM_UPDOWN ptr [ecx]).iDelta
add eax, ecx
and eax, 011y
shl eax, 14
and ebx, not 01100000000000000y ; Mask access
or ebx, eax
.endif
invoke wsprintf, addr buffer, $CTA0("%08X"), ebx
invoke SendMessage, g_hwndEditIoctl, WM_SETTEXT, 0, addr buffer
invoke Refresh, IDE_IOCTL
.endif
.elseif eax == WM_INITDIALOG
mrm g_hDlg, hDlg
invoke SetWindowText, hDlg, $CTA0("I/O Control Code Decoder")
; Set Dialog Icon
invoke LoadIcon, g_hInstance, IDI_ICON
invoke SendMessage, hDlg, WM_SETICON, ICON_BIG, eax
; Set static font
mov g_hwndStaticMnemonics, $invoke(GetDlgItem, hDlg, IDC_RECOGNIZES_XXX_MNEMONICS)
mov g_hFontOld1, $invoke(SendMessage, g_hwndStaticMnemonics, WM_GETFONT, 0, 0)
invoke GetObject, g_hFontOld1, sizeof LOGFONT, addr lf
or lf.lfWeight, FW_BOLD
invoke CreateFontIndirect, addr lf
mov g_hFontBold, eax
invoke SendMessage, g_hwndStaticMnemonics, WM_SETFONT, g_hFontBold, FALSE
mov eax, g_cbaMnemonics
xor edx, edx
mov ecx, sizeof MNEMONIC
div ecx
invoke wsprintf, addr buffer, $CTA0("Recognizes %d mnemonics"), eax
invoke SetWindowText, g_hwndStaticMnemonics, addr buffer
mov g_hwndEditIoctl, $invoke(GetDlgItem, hDlg, IDE_IOCTL)
mov g_hwndEditMnemonic, $invoke(GetDlgItem, hDlg, IDE_MNEMONIC)
; Thnx to James Brown for idea
invoke MaskEditControl, g_hwndEditIoctl, $CTA0("0123456789abcdefABCDEF"), TRUE
invoke SendMessage, g_hwndEditIoctl, EM_LIMITTEXT, 8, 0
; Init with zero
invoke SendMessage, g_hwndEditIoctl, WM_SETTEXT, 0, $CTA0("0")
invoke CreateUpDownControl, WS_CHILD + WS_BORDER + WS_VISIBLE + UDS_ALIGNRIGHT, \
375, 107, 20, 20, hDlg, 0, g_hInstance, NULL, 0FFFh, 0, 0
mov g_hwndSpinFunction, eax
invoke CreateUpDownControl, WS_CHILD + WS_BORDER + WS_VISIBLE + UDS_ALIGNRIGHT, \
375, 136, 20, 20, hDlg, 0, g_hInstance, NULL, 3, 0, 0
mov g_hwndSpinMethod, eax
invoke CreateUpDownControl, WS_CHILD + WS_BORDER + WS_VISIBLE + UDS_ALIGNRIGHT, \
375, 165, 20, 20, hDlg, 0, g_hInstance, NULL, 3, 0, 0
mov g_hwndSpinAccess, eax
mov g_hbmp, $invoke(LoadBitmap, g_hInstance, IDI_BMP)
; Get size of bmp
invoke GetObject, g_hbmp, sizeof BITMAP, addr bm
push bm.bmWidth
pop g_BmpDimension.Siz.x
push bm.bmHeight
pop g_BmpDimension.Siz.y
mov hdc, $invoke(GetDC, hDlg)
mov g_hMemDC, $invoke(CreateCompatibleDC, eax)
invoke ReleaseDC, hDlg, hdc
; Create and set font for bitfield
mov g_hFontOld2, $invoke(SendDlgItemMessage, hDlg, IDE_BITS, WM_GETFONT, 0, 0)
invoke GetObject, g_hFontOld2, sizeof LOGFONT, addr lf
lea ecx, lf.lfFaceName
invoke lstrcpy, ecx, $CTA0("Courier New")
invoke CreateFontIndirect, addr lf
mov g_hFontCourier, eax
invoke SendDlgItemMessage, hDlg, IDE_BITS, WM_SETFONT, g_hFontCourier, FALSE
; Expose some example
invoke SendMessage, g_hwndEditIoctl, WM_SETTEXT, 0, $CTA0("000B0000")
invoke Refresh, IDE_IOCTL
;invoke SetDlgItemText, g_hDlg, IDE_BITS, $CTA0("10101010101010101010101010101010")
;invoke SetDlgItemText, g_hDlg, IDE_MNEMONIC, $CTA0("IOCTL_INTERNAL_UNREGISTER_FOR_REMOVAL_RELATIONS")
; Add about menu
push ebx
invoke GetSystemMenu, hDlg, FALSE
mov ebx, eax
invoke InsertMenu, ebx, -1, MF_BYPOSITION + MF_SEPARATOR, 0, 0
invoke InsertMenu, ebx, -1, MF_BYPOSITION + MF_STRING, IDM_ABOUT, offset szAbout
pop ebx
.elseif eax == WM_CTLCOLORSTATIC
mov eax, lParam
.if eax == g_hwndStaticMnemonics
invoke SetTextColor, wParam, $invoke(GetSysColor, COLOR_3DSHADOW)
.endif
invoke SetBkMode, wParam, TRANSPARENT
invoke GetSysColorBrush, COLOR_3DFACE
ret
.elseif eax == WM_PAINT
mov hdc, $invoke(BeginPaint, hDlg, addr ps)
invoke DrawTransparent, hdc, g_hMemDC, g_hbmp, addr g_BmpDimension
invoke EndPaint, hDlg, addr ps
.elseif eax == WM_DESTROY
;invoke SendMessage, g_hwndBits, WM_SETFONT, g_hFontOld, FALSE
invoke DeleteObject, g_hMemDC
invoke DeleteObject, g_hbmp
invoke SendMessage, g_hwndStaticMnemonics, WM_SETFONT, g_hFontOld1, FALSE
invoke DeleteObject, g_hFontBold
invoke SendDlgItemMessage, hDlg, IDE_BITS, WM_SETFONT, g_hFontOld2, FALSE
invoke DeleteObject, g_hFontCourier
.elseif eax == WM_SYSCOMMAND
.if wParam == IDM_ABOUT
invoke MessageBox, hDlg, addr szWrittenBy, addr szAbout, MB_ICONINFORMATION
.endif
xor eax, eax
ret
.else
xor eax, eax
ret
.endif
xor eax, eax
inc eax
ret
DlgProc endp
IFDEF DEBUG
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; PrintConsole
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
PrintConsole proc psz:LPSTR, dwAttributes:DWORD
local csbi:CONSOLE_SCREEN_BUFFER_INFO
local cb:DWORD
.if dwAttributes != 0
invoke GetConsoleScreenBufferInfo, g_hConsoleOutput, addr csbi
invoke SetConsoleTextAttribute, g_hConsoleOutput, dwAttributes
.endif
.if psz != NULL
invoke lstrlen, psz
.if eax
mov ecx, eax
invoke WriteFile, g_hConsoleOutput, psz, ecx, addr cb, NULL
.endif
.endif
.if dwAttributes != 0
movzx eax, csbi.wAttributes
invoke SetConsoleTextAttribute, g_hConsoleOutput, eax
.endif
ret
PrintConsole endp
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; CheckDuplicates
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CheckDuplicates proc uses esi edi ebx
local buffer[256]:CHAR
local CodeInQuestion:DWORD
local cch:UINT
local fBad:BOOL
and fBad, FALSE
invoke AllocConsole
.if eax != FALSE
invoke GetStdHandle, STD_INPUT_HANDLE
mov g_hConsoleInput, eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov g_hConsoleOutput, eax
.if ( g_hConsoleInput != INVALID_HANDLE_VALUE ) && ( g_hConsoleOutput != INVALID_HANDLE_VALUE )
;:::::::::::::::::::
; Check values first
;:::::::::::::::::::
mov ebx, g_cbaMnemonics
shr ebx, 3 ; / sizeof MNEMONIC
; ecx = number of entries in g_aszMnemonics array
lea edi, g_aszMnemonics
assume edi:ptr MNEMONIC
.while ebx
dec ebx ; zerobased index
mov eax, [edi].ioctl[ebx * sizeof MNEMONIC]
mov CodeInQuestion, eax
mov esi, g_cbaMnemonics
shr esi, 3 ; / sizeof MNEMONIC
; ecx = number of entries in g_aszMnemonics array
.while esi
dec esi ; zerobased index
mov eax, [edi].ioctl[esi * sizeof MNEMONIC]
.if ( eax == CodeInQuestion ) && ( esi != ebx )
mov fBad, TRUE ; set bad flag
invoke wsprintf, addr buffer, $CTA0("\n%03d: %08X "), ebx, [edi].ioctl[ebx * sizeof MNEMONIC]
invoke PrintConsole, addr buffer, 0
invoke PrintConsole, [edi].lpstr[ebx * sizeof MNEMONIC], 0
invoke PrintConsole, $CTA0("\n"), 0
invoke wsprintf, addr buffer, $CTA0("%03d: %08X "), esi, [edi].ioctl[esi * sizeof MNEMONIC]
invoke PrintConsole, addr buffer, 0
invoke PrintConsole, [edi].lpstr[esi * sizeof MNEMONIC], 0
invoke PrintConsole, $CTA0("\n"), 0
.endif
.endw
.endw
assume edi:nothing
.if fBad
invoke PrintConsole, $CTA0("\nPress any key to continue..."), 0
invoke ReadConsole, g_hConsoleInput, addr buffer, 5, addr cch, 0
.endif
invoke FreeConsole
.else
invoke MessageBox, NULL, $CTA0("Couldn't get console handles"), NULL, MB_OK
.endif
.else
invoke MessageBox, NULL, $CTA0("Couldn't allocate console"), NULL, MB_OK
.endif
ret
CheckDuplicates endp
ENDIF ; DEBUG
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
; start
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
start:
IFDEF DEBUG
invoke CheckDuplicates
ENDIF
mov g_hInstance, $invoke(GetModuleHandle, NULL)
invoke DialogBoxParam, g_hInstance, IDD_MAIN, NULL, addr DlgProc, 0
invoke ExitProcess, 0
end start
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
;
;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:make
set exe=IoctlDecoder
:makerc
if exist rsrc.obj goto final
\masm32\bin\rc /v rsrc.rc
\masm32\bin\cvtres /machine:ix86 rsrc.res
if errorlevel 0 goto final
echo.
pause
exit
:final
rem Use DEBUG or RELEASE to make appropriate build
set conf=RELEASE
if exist rsrc.res del rsrc.res
\masm32\bin\ml /nologo /c /coff ioctls.asm
\masm32\bin\ml /nologo /c /coff /D%conf% %exe%.bat
\masm32\bin\link /nologo /subsystem:windows /merge:POINTERS=.rdata %exe%.obj ioctls.obj rsrc.obj
del %exe%.obj
echo.
pause
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -