Показать сообщение отдельно
  #2  
Старый 26.07.2015, 14:09
qpash qpash вне форума
Прохожий
 
Регистрация: 19.02.2010
Сообщения: 2
Репутация: 10
По умолчанию

Вот получше код, но ошибка та же.

Код:
procedure TForm1.Button1Click(Sender: TObject);
var pID:Cardinal;
    op,hKernel32:Cardinal;
    GCL,DW,StrAddr,i,L,j:Cardinal;
    Str:String;
begin
 try
  pID:=StrToInt(Edit1.Text); //из edit берется идентификатор стороннего процесса
 except
  pID:=GetCurrentProcessID(); //типо если ошибка - берем идентификатор текущего процесса
 end;
 op:=OpenProcess(PROCESS_VM_READ,false,pID);
 if op<>0 then
  begin
   hKernel32:=LoadLibrary('Kernel32.dll');
   if hKernel32<>0 then
    begin
     GCL:=Cardinal(GetProcAddress(hKernel32,'GetCommandLineA'));
     FreeLibrary(hKernel32);
     if GCL<>0 then
      if ReadProcessMemory(op,Pointer(GCL+1),@DW,4,i)and(i=4)and
         ReadProcessMemory(op,Pointer(DW),@StrAddr,4,i)and(i=4) then
       begin
        L:=0;
        repeat
         j:=L;
         L:=L+Max_Path;
         SetLength(Str,L);
         if ReadProcessMemory(op,Pointer(StrAddr+j),Pointer(PChar(Str)+j),Max_Path,i) then
          begin
           for i:=j+1 to i do
            if Str[i]=#0 then DW:=0;
          end else DW:=0;
        until (DW=0);
        Caption:=trim(Str); //В caption заносим ответ
       end;
    end;
   CloseHandle(op);
  end;

end;
Ответить с цитированием