调用关机菜单
相关的例子:下载>>> 作者:山原依纲 于2009-3-17上传 

根据资料看,系统关机重启动菜单在Shell32.dll中。这个函数是微软未公开的。处于60(十进制)的位置。

我们用RUNDLL32.EXE可以直接验证一下: rundll32.exe shell32.dll #60

注意必须写作 #60 ,其余的会不认识哦~ 可以正常出现对话框。


RUNDLL32.EXE的用法如下:

RUNDLL32.EXE <dll的文件名>,<入口地址> <可选参数>

根据资料中的描述,我们可以编写汇编语言程序调用之:

 

;MASMPlus 代码模板 - 普通的 Windows 程序代码

.386
.Model Flat, StdCall
Option Casemap :None

Include windows.inc
Include user32.inc
Include kernel32.inc
Include gdi32.inc

includelib gdi32.lib
IncludeLib user32.lib
IncludeLib kernel32.lib
include macro.asm

WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD

.DATA
szClassName db "MASMPlus_Class",0
szDll db "shell32.dll",0
szFunName db 60h,0
hDllInstance dd 0
.DATA?
hInstance dd ?
.CODE
START:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke WinMain,hInstance,NULL,NULL,SW_SHOWDEFAULT
invoke ExitProcess,0

WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCAL wc :WNDCLASSEX
LOCAL msg :MSG
local hWnd :HWND

mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW or CS_BYTEALIGNWINDOW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,offset szClassName
invoke LoadIcon,hInst,100
mov wc.hIcon,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
mov wc.hIconSm,0
invoke RegisterClassEx, ADDR wc
invoke CreateWindowEx,NULL,ADDR szClassName,CTXT("http://www.aogosoft.com"),WS_OVERLAPPEDWINDOW,200,200,400,200,NULL,NULL,hInst,NULL
mov hWnd,eax
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd

StartLoop:
invoke GetMessage,ADDR msg,NULL,0,0
cmp eax, 0
je ExitLoop
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
jmp StartLoop
ExitLoop:

mov eax,msg.wParam
ret
WinMain endp

WndProc proc hWin:DWORD,uMsg:DWORD,wParam :DWORD,lParam :DWORD
.if uMsg==WM_CREATE
invoke LoadLibrary,addr szDll
.if eax!=0
mov hDllInstance,eax
invoke GetProcAddress,hDllInstance,60
push hWin
call eax
.endif
.elseif uMsg == WM_DESTROY
.if hDllInstance!=0
invoke FreeLibrary,hDllInstance
.endif
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
.endif
ret
WndProc endp

END START

参考:

1.RUNDLL32的用法:http://vlaurie.com/computers2/Articles/rundll32.htm

2. Windows“未公开”函数介绍(一)
http://www.frontfree.net/view/article_220.html

3.何杨斌 C#打开系统的关机/重启对话框 http://blog.csdn.net/heyangbin/archive/2008/11/18/3327719.aspx

4.MSDN GetProcAddress Function 的介绍
http://msdn.microsoft.com/en-us/library/ms683212(VS.85).aspx


<<<上一篇
欢迎访问AoGo汇编小站:http://www.aogosoft.com
下一篇>>>