晚上写程序的时候又遇到了一个问题,我想写一个菜单程序,用RadASM向导生成一个Win32App程序,然后里面有一个Menu.Rc和Menu.Asm,Menu.inc
我先在Menu.Rc中输入
#define IDM_TEST 1
#define IDM_HELLO 2
#define IDM_GOODBYE 3
#define IDM_EXIT 4
FirstMenu MENU
{
popup "&PopUp"
{
menuitem "&Say Hello",IDM_HELLO
menuitem "Say &GoodBye",IDM_GOODBYE
menuitem SEPARATOR
menuitem "E&xit",IDM_EXIT
}
menuitem "&Test",IDM_TEST
}
然后在Menu.Asm中输入
.386
.model flat,stdcall
option casemap:none
WinMain proto:DWORD,:DWORD,:DWORD,:DWORD
include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib
.data
ClassName db "SimpleWinClass",0
AppName db "Our First Window",0
MenuName db "FirstMenu",0
Test_string db "You selected Test menu item",0
Hello_string db "Hello, my friend",0
Goodbye_string db "See you again,bye",0
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.const
IDM_TEST equ 1
IDM_HELLO equ 2
IDM_GOODBYE equ 3
IDM_EXIT equ 4
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL hwnd:HWND
LOCAL msg:MSG
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_WINDOW+1
mov wc.lpszMenuName,offset MenuName
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateWindowEx,NULL,ADDR ClassName,ADDR AppName,\
WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,\
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,\
hInst,NULL
mov hwnd,eax
invoke ShowWindow,hwnd,SW_SHOWNORMAL
invoke UpdateWindow,hwnd
.while TRUE
invoke GetMessage,ADDR msg,NULL,0,0
.BREAK .IF(!eax)
invoke DispatchMessage,ADDR msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
.if uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.elseif uMsg==WM_COMMAND
mov eax,wParam
.if ax==IDM_TEST
invoke MessageBox,NULL,ADDR Test_string,OFFSET AppName,MB_OK
.elseif ax==IDM_HELLO
invoke MessageBox,NULL,ADDR Hello_string,OFFSET AppName,MB_OK
.elseif ax==IDM_GOODBYE
invoke MessageBox,NULL,ADDR Goodbye_string,OFFSET AppName,MB_OK
.else
invoke DestroyWindow,hWnd
.endif
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
编译运行时出现了下面错误,不知道怎么解决,求高人指点!!
E:\masm32\bin\ML.EXE /c /coff /Cp /nologo /I"E:\masm32\include" "Menu.asm"
Assembling: Menu.asm
E:\masm32\bin\LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /LIBPATH:"E:\masm32\lib" /OUT:"Menu.exe" "Menu.obj" "Menu.res"
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
LINK : fatal error LNK1181: cannot open input file "Menu.res"
构建时发生错误.
总共编译时间 500 ms
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)