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

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汇编程序源码级调试_VS2019_vs2019win32汇编_vs2019win32汇编_Win32汇编程序_汇编语言

    总之,"WIN32汇编程序源码级调试_VS2019"涵盖了使用汇编语言开发Win32应用程序的关键技术,包括设置VS2019项目、调用Win32 API、使用MASM汇编器和调试技巧。通过学习和实践,开发者可以提高对计算机底层运作的理解,...

    学习win32汇编-初级入门

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

    Win32汇编 Win32汇编

    在深入探讨之前,让我们先明确一点:Win32汇编并不是一个独立的语言,而是指使用Intel x86架构上的汇编语言来编写针对Windows 32位环境的应用程序。在Windows系统中,API(应用程序编程接口)调用通常是通过汇编代码...

    Win32汇编语言教程

    在计算机编程领域,尽管C语言是开发Win32应用程序的常见选择,但在特定情况下,如系统底层操作、性能优化或病毒分析等,汇编语言显得更为重要。Win32汇编语言与32位保护模式DOS程序的汇编语言有区别,它涉及到...

    x86_64-8.1.0-release-win32-seh-rt_v6-rev0.rar

    MinGW-w64是一个开源项目,它的目标是提供一个与GCC(GNU Compiler Collection)兼容的编译环境,使得开发者能够在Windows系统上编译原生的Win32和Win64应用程序。这个项目不仅包含了C和C++编译器,还包含其他构建...

    Win32汇编写的俄罗斯方块小程序

    Win32汇编是针对Windows操作系统API(应用程序接口)进行编程的一种汇编语言。开发者可以直接调用Windows API函数,如窗口创建、消息处理、图形绘制等,从而构建复杂的Windows应用程序。 在创建俄罗斯方块游戏中,...

    WIN32汇编程序设计详尽教程

    与传统的DOS编程不同,Win32汇编语言利用了Windows操作系统提供的API(应用程序接口)来实现功能,使得程序设计更为复杂且功能强大。此教程旨在帮助学习者从基础入手,逐步掌握Win32汇编语言的各个方面,通过实例...

    Win32汇编语言程序设计教程

    《Win32汇编语言程序设计教程》是一本专注于教授如何使用汇编语言在Windows 32位环境下编写程序的专业教程。汇编语言是计算机科学的基础之一,它是一种低级编程语言,允许程序员直接控制硬件资源,对于理解计算机...

    Win32汇编语言程序设计

    《Win32汇编语言程序设计》是由罗云彬撰写的一本深入探讨Win32平台汇编语言编程的专业书籍。这本书旨在帮助读者理解和掌握在Windows操作系统环境下,如何使用汇编语言进行程序设计。通过学习本书,读者将能够利用...

    Win32汇编教程

    在《Win32汇编教程》中,iczelion详尽地讲解了如何使用汇编语言与Win32 API相结合,创建Windows应用程序。教程内容包括但不限于: 1. **基础篇**:介绍汇编语言的基本概念,如指令集、寄存器、寻址方式等。讲解MASM...

    win32汇编服务管理程序

    “服务”则指的是Windows操作系统中运行在后台的进程,负责提供特定的功能或支持其他应用程序。 【压缩包子文件的文件名称列表】: 1. `ServicesManager.Inc`:这可能是一个包含汇编语言宏定义和服务管理相关常量的...

    win32汇编语言程序设计

    在Windows平台上,通过Win32 API,汇编语言程序员可以访问系统服务,创建复杂的应用程序。 Windows 32位汇编语言程序设计的关键知识点包括: 1. **基本概念**:理解汇编语言的基本元素,如指令、寄存器、操作码、...

    win32汇编程序设计教程

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

    Win32汇编源码

    1. **Win32 API**:Win32 API(应用程序接口)是微软为Windows操作系统提供的一个庞大的函数库,它包含了创建和管理窗口、处理消息、访问系统资源等所有功能。使用汇编语言调用这些API函数,可以实现对Windows系统的...

    罗云彬--win32汇编教程源码

    《罗云彬--Win32汇编教程源码》是一份珍贵的学习资源,它包含了罗云彬在其《Win32汇编教程》一书中提到的各种示例代码。这份压缩包文件是针对那些想要深入理解汇编语言,特别是针对Windows 32位平台汇编编程的初学者...

    win32汇编工具打包

    在IT领域,汇编语言是一种低级编程语言,它与计算机硬件紧密相关,直接对应于机器指令。在Windows 32位环境下,汇编语言被...通过实践这些示例,你可以逐步掌握Win32汇编的使用,以及如何创建和打包自己的应用程序。

    Win32 汇编计算器

    首先,我们要理解Win32 API(应用程序接口),它是Windows操作系统提供的一组函数,用于开发基于Windows的应用程序。在汇编语言中使用Win32 API,我们需要定义函数调用约定,例如stdcall约定,其中被调用者负责清理...

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

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

    罗云彬win32汇编教程

    2. **Win32 API接口**:详细介绍如何调用Windows API函数,如窗口创建、消息处理、内存管理、文件操作等,这些是构建Windows应用程序的基础。 3. **过程调用约定**:讲解stdcall和fastcall等调用约定,理解参数传递...

    罗云彬的win32下汇编语言程序设计(电子版)

    1. **Win32汇编环境**:设置汇编语言的开发环境,包括使用MASM汇编器、链接器和其他相关工具。 2. **Windows API**:理解并使用Windows API函数,如CreateWindow、SendMessage、DispatchMessage等,这些函数是构建...

Global site tag (gtag.js) - Google Analytics