在看罗叔的win32汇编中子类化与超类化这一章时,我写的代码。
DialogBoxParam函数调用后,只显示出两个Edit控件,看不见窗口。
CPU占用98%,应该是有死循环。
我找啊找啊找。。。。怎么就找不到呢??
各位高手帮忙看看
代码:
.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
include user32.inc
includelib user32.lib
IDD_DLG1 equ 1000
IDC_EDIT1 equ 1001
IDC_EDIT2 equ 1002
.data
szSuperEdit db 'SuperEdit',0
szEdit db 'Edit',0
szAllowedChar db '0123456789abcdefABCDEF',0
.data?
hInstance dd ?
_EditProc dd ?
.code
_SuperClass proto
_SuperEditProc proto :DWORD, :DWORD, :DWORD, :DWORD
_DlgProc proto :DWORD, :DWORD, :DWORD, :DWORD
_WinMain proc
invoke GetModuleHandle,0
mov hInstance, eax
invoke _SuperClass
invoke DialogBoxParam, hInstance, IDD_DLG1, NULL, offset _DlgProc, NULL
invoke ExitProcess,0
ret
_WinMain endp
_DlgProc proc uses ebx eax edi esi hDlg, uMsg, wParam, lParam
mov eax, uMsg
.if eax == WM_CLOSE
invoke EndDialog, hDlg, 0
.else
mov eax, FALSE
ret
.endif
mov eax, TRUE
ret
_DlgProc endp
_SuperClass proc
LOCAL @WndClass:WNDCLASSEX
invoke RtlZeroMemory,addr @WndClass, sizeof @WndClass
mov @WndClass.cbSize, sizeof @WndClass
invoke GetClassInfoEx, NULL, offset szEdit, addr @WndClass
push @WndClass.lpfnWndProc
pop _EditProc
mov @WndClass.lpfnWndProc, offset _SuperEditProc
mov @WndClass.lpszClassName, offset szSuperEdit
push hInstance
pop @WndClass.hInstance
invoke RegisterClassEx, addr @WndClass
ret
_SuperClass endp
_SuperEditProc proc uses ebx esi edi hEdit, uMsg, wParam, lParam
mov eax, uMsg
.if eax == WM_CHAR
mov eax, wParam
mov edi, offset szAllowedChar
mov ecx, sizeof szAllowedChar
repnz scasb
.if ZERO?
cmp eax, '9'
jna @F
and al, not 20H
@@:
mov wParam, eax
.else
xor eax,eax
ret
.endif
.endif
invoke CallWindowProc, _EditProc, hEdit, uMsg, wParam, lParam
ret
_SuperEditProc endp
end _WinMain
资源:
#include "C:\RadASM\masm32\include\resource.h"
#define IDD_DLG1 1000
#define IDC_EDIT1 1001
#define IDC_EDIT2 1002
IDD_DLG1 DIALOG 6,6,194,106
CAPTION "ClassModify"
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
FONT 9, "宋体"
{
CONTROL "",IDC_EDIT1,"Edit",0x50010000,28,16,144,19,0x00000200
CONTROL "",IDC_EDIT2,"SuperEdit",0x50010000,26,53,146,19,0x00000200
}
[培训]科锐逆向工程师培训第53期2025年7月8日开班!