如何将 EM_GETTEXTRANGE 与 WriteProcessMemory 和 ReadProcessMemory 一起使用 [英] how to use EM_GETTEXTRANGE with WriteProcessMemory and ReadProcessMemory

查看:22
本文介绍了如何将 EM_GETTEXTRANGE 与 WriteProcessMemory 和 ReadProcessMemory 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 c# 中使用 EM_GETTEXTRANGE 和 WriteProcessMemory 和 ReadProcessMemory

i need to use EM_GETTEXTRANGE with WriteProcessMemory and ReadProcessMemory in c#

我已经得到了单词的开始位置和结束位置,但是我不能使用这个EM_GETTEXTRANGE 获取单词

i already get the start position and the end position of word but i can't use this EM_GETTEXTRANGE to get the word

任何人都可以帮助我

推荐答案

您需要更多的 pinvoke.首先,您需要在目标进程中分配内存,以便它可以读写 TEXTRANGE 结构值.这需要 OpenProcess 和 VirtualAllocEx.现在您需要初始化结构,首要任务是为 lpstrText 成员获取内存.VirtualAllocEx 再次分配一个足够大的缓冲区来存储字符串,WriteProcessMemory 来初始化结构.

You need a bunch more pinvoke. First off, you need to allocate memory in the target process so it can read and write the TEXTRANGE structure value. That requires OpenProcess and VirtualAllocEx. Now you need to initialize the structure, first order of business is to get memory for the lpstrText member. VirtualAllocEx again to allocate a buffer large enough to store the string, WriteProcessMemory to initialize the structure.

现在您可以调用 SendMessage 了.ReadProcessMemory 读回 lpstrText.使用两次 VirtualFreeEx 和 CloseHandle 进行清理以关闭进程句柄.

Now your ready to call SendMessage. ReadProcessMemory to read the lpstrText back. Cleanup with two times VirtualFreeEx and CloseHandle to close the process handle.

大约有一百种射脚的方法.这是 codeproject.com 上流行的一种代码,我知道它在那里,但最近他们的搜索完全停止了.祝你好运!

About a hundred ways to shoot the foot. This is popular kind of code at codeproject.com, I know it is there but their search is completely borked as of late. Good luck!

这篇关于如何将 EM_GETTEXTRANGE 与 WriteProcessMemory 和 ReadProcessMemory 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆