`
deepfuture
  • 浏览: 4333451 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:79428
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:68376
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:101498
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:281206
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:14608
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:65559
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:31320
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:45206
社区版块
存档分类
最新评论

win32汇编-送消息给其它应用程序

阅读更多

2个函数
invoke postmessage,hwnd,msg,wparam,lparam
invoke sendmessage,hwnd,msg,wparam,lparam
对于不同的MSG,WPARAM和LPARAM所代表的信息是不同的
1、postmessage

MSDN

The PostMessage function places (posts) a message in the messagequeue associated with the thread that created the specified windowand returns without waiting for the thread to process themessage.
这个函数将消息送到指定窗口的线程后马上返回而不等待,sendmessage必须等该消息被处理后才能返回。

To post a message in the message queue associate with a thread, usethe PostThreadMessage function.


Syntax

BOOL PostMessage( HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
Parameters

hWnd
[in] Handle to the window whose window procedure is to receive themessage. The following values have special meanings.

HWND_BROADCAST
The message is posted to all top-level windows in the system,including disabled or invisible unowned windows, overlappedwindows, and pop-up windows. The message is not posted to childwindows
送给系统的的所有顶层主窗口,不会送到子窗口

.
NULL
The function behaves like a call to PostThreadMessage with thedwThreadId parameter set to the identifier of the currentthread.

Msg
[in] Specifies the message to be posted.
wParam
[in] Specifies additional message-specific information.
lParam
[in] Specifies additional message-specific information.
Return Value

If the function succeeds, the return value is nonzero.成功返回非0

If the function fails, the return value is zero. To get extendederror information, call GetLastError. 错误返回0




Remarks

Messages in a message queue are retrieved by calls to theGetMessage or PeekMessage function.

Applications that need to communicate using HWND_BROADCAST shoulduse the RegisterWindowMessage function to obtain a unique messagefor inter-application communication.

The system only does marshalling for system messages (those in therange 0 to WM_USER). To send other messages (those above WM_USER)to another process, you must do custom marshalling.

If you send a message in the range below WM_USER to theasynchronous message functions (PostMessage, SendNotifyMessage, andSendMessageCallback), its message parameters cannot includepointers. Otherwise, the operation will fail. The functions willreturn before the receiving thread has had a chance to process themessage and the sender will free the memory before it isused.

Do not post the WM_QUIT message using PostMessage; use thePostQuitMessage function.

Windows 2000/XP: There is a limit of 10,000 posted messages permessage queue. This limit should be sufficiently large. If yourapplication exceeds the limit, it should be redesigned to avoidconsuming so many system resources. To adjust this limit, modifythe following registry key:

2、SendMessage Function

--------------------------------------------------------------------------------

The SendMessage function sends the specified message to a window orwindows. It calls the window procedure for the specified window anddoes not return until the window procedure has processed themessage.
发送消息给窗口,并调用指定窗口的窗口过程,到窗口过程处理该消息才返回。  
To send a message and return immediately, use theSendMessageCallback or SendNotifyMessage function. To post amessage to a thread's message queue and return immediately, use thePostMessage or PostThreadMessage function.


Syntax

LRESULT SendMessage( HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
Parameters

hWnd
[in] Handle to the window whose window procedure will receive themessage. If this parameter is HWND_BROADCAST, the message is sentto all top-level windows in the system, including disabled orinvisible unowned windows, overlapped windows, and pop-up windows;but the message is not sent to child windows.
Msg
[in] Specifies the message to be sent.
wParam
[in] Specifies additional message-specific information.
lParam
[in] Specifies additional message-specific information.
Return Value

The return value specifies the result of the message processing; itdepends on the message sent.


Remarks

Applications that need to communicate using HWND_BROADCAST shoulduse the RegisterWindowMessage function to obtain a unique messagefor inter-application communication.

The system only does marshalling for system messages (those in therange 0 to WM_USER). To send other messages (those above WM_USER)to another process, you must do custom marshalling.

If the specified window was created by the calling thread, thewindow procedure is called immediately as a subroutine. If thespecified window was created by a different thread, the systemswitches to that thread and calls the appropriate window procedure.Messages sent between threads are processed only when the receivingthread executes message retrieval code. The sending thread isblocked until the receiving thread processes the message. However,the sending thread will process incoming nonqueued messages whilewaiting for its message to be processed. To prevent this, useSendMessageTimeout with SMTO_BLOCK set. For more information onnonqueued messages, see Nonqueued Messages.
==============
一个发送消息的子程序,将消息发送到打开的记事本窗口中。
szdestclass db 'notepad',0
_sndtontoepad proc _lpsz
local @hwinntoepad
pushad

invoke findwindow,addrszdestclass,null;找到指定应用程序即WINDOWS的记事本程序的句柄
===================
;关于findwindow

msdn
The FindWindow function retrieves a handle to the top-level windowwhose class name and window name match the specified strings. Thisfunction does not search child windows. This function does notperform a case-sensitive search.
获得顶层窗口的句柄,不查找子窗口,查找时不分大小写

To search child windows, beginning with a specified child window,use the FindWindowEx function.


Syntax

HWND FindWindow(
  LPCTSTR lpClassName,;窗口类名
LPCTSTR lpWindowName;窗口标题名称
);
Parameters

lpClassName窗口类名
[in] Pointer to a null-terminated string that specifies the classname or a class atom created by a previous call to theRegisterClass or RegisterClassEx function. The atom must be in thelow-order word of lpClassName; the high-order word must bezero.
If lpClassName points to a string, it specifies the window classname. The class name can be any name registered with RegisterClassor RegisterClassEx, or any of the predefined control-classnames.

If lpClassName is NULL, it finds any window whose title matches thelpWindowName parameter. 如果窗口类名为NULL,则按标题名称查找

lpWindowName窗口标题名称 
[in] Pointer to a null-terminated string that specifies the windowname (the window's title). If this parameter is NULL, all windownames match.
Return Value

If the function succeeds, the return value is a handle to thewindow that has the specified class name and window name.

If the function fails, the return value is NULL. To get extendederror information, call GetLastError.




Remarks

If the lpWindowName parameter is not NULL, FindWindow calls theGetWindowText function to retrieve the window name for comparison.For a description of a potential problem that can arise, see theRemarks for GetWindowText.
举例:☆☆☆☆☆☆☆☆☆
To check if the Microsoft IntelliType version 1.x software isrunning, call FindWindow as follows:

FindWindow("MSITPro::EventQueue",NULL);
To check if the IntelliType version 2.0 software is running, callFindWindow as follows:

FindWindow("Type32_Main_Window", NULL);
If the IntelliType software is running, it sends WM_APPCOMMANDmessages to the application. Otherwise the application must installa hook to receive WM_APPCOMMAND messages.
☆☆☆☆☆☆☆☆☆☆
Microsoft Windows 95 or later: FindWindowW is supported by theMicrosoft Layer for Unicode (MSLU). To use this, you must addcertain files to your application, as outlined in Microsoft Layerfor Unicode on Windows 95/98/Me Systems.

===========
.if eax
mov ecx,eax

  invokechildwindowfrompoint,ecx,20,20
.endif

;☆☆☆☆☆☆关于childwindowfrompoint
ChildWindowFromPoint Function

--------------------------------------------------------------------------------


The ChildWindowFromPoint function determines which, if any, of thechild windows belonging to a parent window contains the specifiedpoint. The search is restricted to immediate child windows,grandchildren, and deeper descendant windows are notsearched.
获取处在父窗口指定位置的子窗口的句柄。

Syntax

HWND ChildWindowFromPoint( HWND hWndParent,
POINT Point
);
Parameters

hWndParent
[in] Handle to the parent window.
Point
[in] Specifies a POINT structure that defines the clientcoordinates (relative to hWndParent of the point to bechecked.
Return Value

The return value is a handle to the child window that contains thepoint, even if the child window is hidden or disabled. If the pointlies outside the parent window, the return value is NULL. If thepoint is within the parent window but not within any child window,the return value is a handle to the parent window.
;☆☆☆☆☆☆☆
.if eax ;获得了子窗口即编辑窗口的指针
mov @hwinnotepad,eax
mov esi,_lpsz
@@:
loadsb;将数据送向累加器,数据在ds:esi中,而movs中,目的地址为es:dsi
or al,al
jz @F ;如果结束符号是0,则表示字符串结束退出循环
movzx eax,al
invoke postmessage,@hwinnotepad,WM_CHAR,eax,1
jmp @B
@@:
.endif
popad
ret
_setndtonotepad endp
0
0
分享到:
评论

相关推荐

    学习win32汇编-初级入门

    Win32应用程序虽然和其他32位应用程序(例如32位保护模式DOS程序)一样可以使用386汇编语言和保护模式编程,但是Win32应用程序的执行机制与其他32位应用程序有一定的差别,例如消息循环、动态链接等,Win32汇编语言...

    win32汇编程序设计教程

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Win32汇编语言程序设计(罗云彬)chm

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    罗云斌win32汇编.rar

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Win32汇编语言编程(罗云彬编)

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Windows环境下32位汇编语言程序设计

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Windows环境下32位汇编语言程序设计(典藏版)分卷压缩:Part1/2

    本书作者有十多年的汇编编程经验,很清楚初学者在哪些地方会遇到问题,所以本书在系统全面地介绍Win32汇编编程的同时,也穿插了很多作者的经验之谈,使读者能够快速入门并最终熟练地写出各种Windows应用程序。...

    masm32软件 win32汇编 MASM32是面向WIN32程序开发的

    MASM32是面向WIN32程序开发的,MASM611是面向DOS的,MASM32不使用中断调用了,而是使用微软的应用程序开发接口API和其他高级开发语言差不多了。而MASM611才是使用中断。 解压后大约15M 而压缩后才3.4M 分享学习的...

    Win32汇编语言程序设计

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    win32asm汇编语言-罗云彬

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Win32环境下汇编语言程序设计+罗云彬(完整版)

    Windows环境下32位汇编语言是一种全新的编程语言...本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。

    Win32汇编语言教程

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Win32汇编语言 罗云彬

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    win32汇编语言教程

    Windows 把每一个 Win32 应用程序放到分开的虚拟地址空间中去运行,也就是说每一个应用程序都拥有其相互独立的 4GB 地址空间,当然这倒不是说它们都拥有 4GB 的物理地址空间,而只是说能够在 4GB 的范围内寻址。...

    windows环境下32位汇编语言程序设计

    前言 ...本书主要的内容将放在32位宏汇编对比DOS汇编所不同的部分,以及Win32应用程序的汇编实现上。不求全面,只求精也!(说句老实话,也不敢对自己不精通的地方妄加评论,以免破坏自己的良好形象。

    Windows环境下32位汇编语言程序设计(chm格式)

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

    Windows环境下32位汇编语言程序设计:罗云彬2013最新版随书资源

    《Windows环境下32位汇编语言程序设计》从编写应用程序的角度,从“HelloWorld"这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。Windows环境下32位...

    Window 32位汇编语言程序设计

    本书从编写应用程序的角度,从“Hello World!”这个简单的例子开始到编写多线程、注册表和网络通信等复杂的程序,通过60多个实例逐渐深入Win32汇编语言的方方面面。本书作者罗云彬拥有十余年汇编语言编程经验,是...

Global site tag (gtag.js) - Google Analytics