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
win32汇编环境,窗口程序中如何生成richedit控件 窗口程序中,生成richedit控件,添加文本的方法。 阅读详情

相关推荐

win32汇编环境,对 WM_MOUSEMOVE 消息的理解

理解在 WM_MOUSEMOVE 消息发生时,同时来的wParam和lParam值的含义,并取出各自的值进行运用。从这例子也可以更好的理解windows的消息机制.

一品人家的博客 1120

win32 汇编学习(三)

三:模块和句柄 1 . 程序结构模式分为两种,过程驱动方式和事件驱动方式 2. PostMessage 是把一个消息放到其他程序的消息队列中,而SendMessage 则越过消息队列直接调用目标程序的窗口过程。 3.一个应用程序为了区分地址空间中的不同模块,每个模块都有一个唯一的模块句柄来标识。取模块句柄使用的API函数是 GetModuleHandler  具体用法是:  invok...

weixin_42528089的博客 734

构建Win32汇编拖放文件窗口的实战指南

本文还有配套的精品资源,点击获取 简介:本项目通过Win32汇编语言使用Win32 API创建了一个能够处理拖放文件的窗口。项目深入介绍了Windows消息机制,特别是 WM_DROPFILES 消息的处理方法,详细说明了如何注册窗口类、创建窗口、处理拖放消息、清理资源以及启动消息循环。本项目的示例代码提供了学习和掌握Win32汇编语言与Windows API...

weixin_42504649的博客 1202

X86软件逆向分析实战(一)

对于那些“不听话”的软件,怎么办?你是想忍声吞气凑合着用?还是想“修理”一顿,让它乖乖地按照你的意思办?本课程教你“驯服”那些你看中的软件! 掌握这个技能,无论它是什么软件,只能乖乖按你的意思办! 课程内容会涉及到与X86软件逆向分析相关的各种杂项与细节实现,其中涵盖OD、CE、IDA、WinAPI、Visual Studio 2019、易语言、C/C++、C#、汇编等使用技巧与编程技巧。若你是编程初学者,认真学习本课程后,你的能力将会有极大的提升。若你是编程大佬,建议勿跳过每一节课,一定会有所收获!

掌握WIN32汇编:Iczelion教程与实例解析

Windows操作系统提供了一个庞大的API(Application Programming Interface)集合,供开发者用来执行各种任务。WIN32 API作为Windows API的一个版本,是为32位Windows平台设计的一系列底层函数和接口,它们允许程序员直接与操作系统进行交互,创建图形用户界面、处理文件系统、管理进程、控制硬件设备等。WIN32 API主要分为以下几类:用户界面(UI):涉及窗口创建、消息处理、控件绘制等,是用户交互的直接体现。图形设备接口(GDI)

weixin_29050829的博客 938

低级鼠标钩子实现:WIN32汇编实例

本文还有配套的精品资源,点击获取 简介:本项目展示了如何在Windows环境中运用WIN32汇编语言编写一个低级鼠标钩子(WH_MOUSE_LL)。通过实例,读者可以学习到Win32汇编语言的基础、鼠标钩子的原理以及实现自定义鼠标行为的技术。关键步骤包括设置钩子、编写处理程序、管理消息传递、卸载钩子以及确保线程安全。此示例代码“MouseHook”可用于直接与Windows...

weixin_35903223的博客 982

汇编,SendMessage和WM_SETTEXT

接受代码 .386.model flat,stdcalloption casemap:noneinclude user32.incincludelib user32.libincludelib kernel32.libinclude kernel32.incinclude windows.inc.data_className db "MyClass",0_szBuffer ...

weixin_30685029的博客 1268

【机器学习实战中阶】音乐流派分类-自动化分类不同音乐风格

数据下载地址:https://www.kaggle.com/datasets/andradaolteanu/gtzan-dataset-music-genre-classification/data背景音乐。专家们长期以来一直在尝试理解声音以及是什么使一首歌曲与另一首不同。如何可视化声音。是什么使一个音调与另一个不同。这个数据集希望能提供实现这些目标的机会。内容原始流派 - 包含10种流派,每种流派有100个音频文件,每个文件长度为30秒(著名的GTZAN数据集,声音的MNIST)

2150

Win32汇编笔记-消息基础

WIN32的消息机制 windows系统是一个消息驱动的OS,操作通过处理各种消息来响应用户的操作。 对于每一个带有窗口的线程,系统都会给他分配一个自己的消息队列,用于处理消息派送(Dispatch)。每个线程都用自己的消息循环来接受消息。每个线程列队默认管理最大10000个消息,修改注册表下面的键值可以修改列队中的消息数。建议的最小值是4000 HKEY_LOCAL_MACHINE...

weixin_30819163的博客 244

IVP 2021 UNETR: Transformers for 3D Medical Image Segmentation

动机 具有跟踪和扩展路径的全卷积神经网络(FCNNs)(如编码器和解码器),近年来在各种医学图像分割应用中显示出了突出的地位。在这些体系结构中,编码器通过学习全局上下文表示来扮演一个不可或缺的角色,该全局上下文表示将进一步用于解码器的语义输出预测。 卷积层作为FCNN的主要构造块,其局部性限制了此类网络学习长时空间依赖的能力。 在NLP领域,基于transformer的模型已经在各种任务中实现了最先进的基准。transformer中的自我注意机制使他们能够动态地突出词序列的重要特征并学习其长时依赖关系。这

smile909的博客 1979

ANSYS 有限元分析 接触分析

目 录一、前沿二、接触单元类三、接触单元关键选项3.1 CONTA174 KeyOption3.2 TARGE170 KeyOption四、接触分析标准步骤4.1 定义实常数4.2 定义接触和目标单元4.3 创建接触和目标单元五、接触分析实例5.1 MPC5.2 标准接触六、尾声七、参考文献 阿阳的 ANSYS 使用指南,本文仅用于个人学习,除此之外,无其他任何用途。 ANSYS 有限元分析 概述 ANSYS 有限元分析 坐标系/工作平面 ANSYS 有限元分析 几何建模 ANSY

Hulunbuir 4万+

Win32汇编语言教程

Win32汇编语言教程如需要汇编语言写程序请发E-MAIL:billows-@hotmail.com一、引言Win32应用程序一般使用C语言编程,但是在某些需要进行深层编程的情况下,例如Win32应用程序执行机制分析、病毒清除、加密解密等深层编程,或者对于某些速度要求较高的程序,需要使用汇编语言(甚至机器语言)直接编写Win32应用程序。Win32应用程序虽然和其他32位应用程序(例如32位保护模

BILL的专栏 2258

Xilinx VDMA实战:从配置到调试的完整指南

本文详细解析了Xilinx VDMA的核心原理与架构,提供了从配置到调试的完整实战指南。通过双通道独立架构、时钟域管理和寄存器配置等关键技巧,帮助开发者高效实现视频流处理。特别针对常见调试问题和性能优化方案进行深入探讨,适用于各类视频处理应用场景。

weixin_30642561的博客 176

Win32反汇编(一) 初步探索Win32反汇编 与 Ollydbg的简单使用

前言 时间:2020.8.8,一直想学逆向工程,刚好最近时间比较充足,每天除了刷算法题也可以学逆向了 . . . 此系列文章都是一些基础的文章,通过几个小例子快速的了解 Win32反汇编与OD的使用,在此作个笔记 如若对您有帮助,记得三连哟 ~ 文章目录 OD介绍 全局变量赋值的反汇编形式(包含) 函数调用的反汇编形式 加法计算与内存单元长度的修饰讲解 OD介绍 在研究反汇编之前,我们先来了解一下以后会一直用的神器: Ollydbg 1. Ollydbg 简介 Ollydbg 用作动态调试,一.

浪子花梦 3190

【微服务】SpringBoot 4.0 新特性整合项目实战应用详解

SpringBoot 4.0 新特性整合项目实战应用详解

congge 4595

uniapp [全端兼容] - 实现接入集成高德地图搜索地址及选择位置功能,搜索框检索选择地点并返回经纬度及详细省市区县街道地址,用户搜索历史及清空历史记录,选择地址自动获取周边位置列表/地图移动选点

uni-app,高德地图,h5移动端网页,微信小程序,支付宝小程序,Android安卓,苹果ios,app,nvue,Uniapp高德地图,在地图上选择或搜索指定地点,打开地图选择位置,关联地址搜索,输入地址返回附近地址列表,uniApp高德地图地址搜索,搜索框历史记录,关键字搜索,周边查询,搜索位置,uniapp对接高德实现搜索出现地址以及保存搜索记录,集成高德地图,实现精准位置选点功能,获取当前定位城市,如何实现搜索功能,获取省份城市区街道详细地址经纬度,移动选点标记位置,在地图上进行选择位置选点、搜索

🏆 前端领域优质创作者 1万+

通过win32汇编开发来理解消息机制

2、以后若控件发生事件时,窗口过程会收到通知消息,ScrollBar类的事件窗口过程会收到WM_HSCROLL消息,其它类的事件窗口过程会收到WM_COMMAND消息。通知消息:win32汇编中在窗口过程中直接监控WM_COMMAND消息(高16位是通知码,低16位是ID码),而在MFC中通过定义消息映射宏来监控。1、当建立窗口的时候,窗口过程会收到WM_CREATE消息,在这里完成子窗口(就是控件)的创建,并通过对子窗口发送控制消息来控制子窗口。),这个子窗口的父窗口的窗口过程会接收到该子窗口。

程序员人生 394

Palantir如何利用Ontology构建企业级数据地图

Palantir通过"本体论"(Ontology)技术构建动态数据地图,将多源异构数据转化为可操作的业务知识网络。该技术突破传统ETL模式,建立覆盖全组织的语义层,将原始数据映射为"客户""订单"等业务对象及其关联关系,形成可推理的语义网络。核心Foundry平台提供本体管理工具(OMA)和开发套件(OSDK),支持从数据连接到应用开发的全流程。虽然采用专有实现而非标准本体语言,但该架构成功解决了数据孤岛问题,赋能复杂决策分析

Learning 1804

win32 汇编学习(2):消息框

这一次,我们将用汇编语言写一个 Windows 程序,程序运行时将弹出一个消息框并显示"你好,我的第一个Win32汇编程序"。 理论知识 Windows 为编写应用程序提供了大量的资源。其中最重要的是Windows API (Application Programming Interface)。 Windows API是一大组功能强大的函数,它们本身驻扎在 Windows 中供人们随时调...

ai74583的博客 291

抖音中动态生成msToken的方法

抖音中动态生成msToken的方法

sh_moranliunian的博客 2490

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

【Win32汇编】学习Win32汇编

本文主要是梳理了一下Win32的基础知识。因为有的内容和16位汇编基本一样,就没有详细说明,可以参考之前的汇编语言的博客。

Arcus 5189

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

汇编:调用Win32 API

在32位汇编程序中使用 Win32 API 是很常见的,特别是在开发 Windows 应用程序时调用的频率很高,Win32 API 提供了访问 Windows 操作系统功能的接口,包括窗口、消息处理、文件操作、网络通信等等。调用 Win32 API 函数:使用适当的调用约定(例如 stdcall)来调用 Win32 API 函数,并正确传递参数。声明外部函数:声明要调用的 Win32 API 函数,以便汇编器知道函数的名称和参数类型。:这两行代码定义了字符串,用于作为消息框的文本和标题。

WolvenSec的博客 1228

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

WIN32汇编: 6.处理键盘消息

第六课 处理键盘输入消息在本课中,我们将要学习WINDOWS程序是如何处理键盘消息的。理论:因为大多数的PC只有一个键盘,所以所有运行中的WINDOWS程序必须共用它。WINDOWS 将负责把击键消息送到具有输入焦点的那个应用程序中去。尽管屏幕上可能同时有几个应用程序窗口,但一个时刻仅有一个窗口有输入焦点。有输入焦点的那个应用程序的标题条总是高亮度显示的。 实际上您可以从两个角

GodDragon的专栏 1354
上一篇: WIN32汇编之菜单、加速键、快捷键
下一篇: 分布式计算-故障模型及故障检测
deepfuture
博客等级 码龄17年 211粉丝 1287原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值