打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
WriteProcessMemory in Windows7

WriteProcessMemory in Windows7

Asked by: MelissaCGSolved by:
Hello Experts,

I was just looking at some posts in a forum and saw one interesting about manipulating a listview of another app. Actually the listviw is from the taskmgr in this code, but that's just for learning purposes i guess, since it's such an ugly code that noone could actually use it for bad things... Well, anyway, i tried it in my Windows 7 x64 Home Premium with UAC and DEP off and its not working... The string with the processes names are blank. I think it's something with write/readprocessmemory because i tested the handles and they arent nil... My friend tested in a windows XP and it worked... What might be wrong here??

unit Unit1;interfaceuses  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,  Dialogs, StdCtrls, commctrl, ExtCtrls;type  TForm1 = class(TForm)    Button1: TButton;    procedure Button1Click(Sender: TObject);  private    { Private declarations }  public    { Public declarations }  end;var  Form1: TForm1;implementation{$R *.dfm}{Fun??o para pegar o texto do Item da ListView}function PegaTexto(s: string): string;varc: Char;i: integer;Src,Dst: PChar;begini:=length(s);SetLength(Result,i);Src:=pointer(s);Dst:=pointer(Result);While i <> 0 do  begin  c:=Src^;  if (c>='A') and (c<='Z') then    Inc(c,32);  Dst^:=c;  Inc(Src);  Inc(Dst);  Dec(i);  end;end;procedure Esconde(proc: string);vardwSize,dwNumBytes,PID,hProc: Cardinal;PLocalShared,PSysShared: PlvItem;h: THandle;iCount,i: integer;szTemp: string;begin{Pega o Handle da ListView}h:=FindWindow('#32770',nil);h:=FindWindowEx(h,0,'#32770',nil);h:=FindWindowEx(h,0,'SysListView32',nil);{Pega o número de itens da ListView}iCount:=SendMessage(h, LVM_GETITEMCOUNT,0,0);for i:=0 to iCount-1 do  begin  {Define o tamanho de cada item da ListView}  dwSize:=sizeof(LV_ITEM) + sizeof(CHAR) * MAX_PATH;  {Abre um espa?o na memória do NOSSO programa para o PLocalShared}  PLocalShared:=VirtualAlloc(nil, dwSize, MEM_RESERVE + MEM_COMMIT, PAGE_READWRITE);  {Pega o PID do processo taskmgr}  GetWindowThreadProcessId(h,@PID);  {Abre o processo taskmgr}  hProc:=OpenProcess(PROCESS_ALL_ACCESS,false,PID);  {Abre um espa?o na memória do taskmgr para o PSysShared}  PSysShared:=VirtualAllocEx(hProc, nil, dwSize, MEM_RESERVE OR MEM_COMMIT, PAGE_READWRITE);  {Define as propriedades do PLocalShared}  PLocalShared.mask:=LVIF_TEXT;  PLocalShared.iItem:=0;  PLocalShared.iSubItem:=0;  PLocalShared.pszText:=LPTSTR(dword(PSysShared) + sizeof(LV_ITEM));  PLocalShared.cchTextMax:=100;  {Escreve PLocalShared no espa?o de memória que abriu no taskmgr}  WriteProcessMemory(hProc,PSysShared,PLocalShared,1024,dwNumBytes);  {Pega o texto to item i e passa pro PSysShared}  SendMessage(h,LVM_GETITEMTEXT,i,LPARAM(PSysShared));  {Passa o PSysShared para o PLocalShared}  ReadProcessMemory(hProc,PSysShared,PLocalShared,1024,dwNumBytes);  {Passa o texto do Item para szTemp}  szTemp:=pchar(dword(PLocalShared)+sizeof(LV_ITEM));  {Se esse texto contiver a string proc deleta o item}  if pos(proc,PegaTexto(szTemp)) > 0 then    ListView_DeleteItem(h,i);  {Libera os espa?os de memória utilizados}  VirtualFree(pLocalShared, 0, MEM_RELEASE);  VirtualFreeEx(hProc, pSysShared, 0, MEM_RELEASE);  {Fecha o handle do processo}  CloseHandle(hProc);  end;end;procedure TForm1.Button1Click(Sender: TObject);beginesconde('notepad.exe');end;end.                                  
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:92:93:94:95:96:97:98:99:100:101:102:103:104:105:106:107:108:109:110:111:112:113:114:115:116:117:118:

Select allOpen in new window

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
打造无DLL版穿墙Downloader
Fibratus:一款功能强大的Windows内核漏洞利用和跟踪工具
VB.NET自动操作其他程序(1)
Linux PS 命令详解
ActiveX启动下载者(delphi)
修复Windows7无法打开任务管理器的故障
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服