Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

ReadProcessMemory не хочет читать Memory [D4, Win2k]


Kolya ©   (2002-10-20 16:18:00) 

Вот уже час ломаю голову над это api. В документации написано:

BOOL ReadProcessMemory(

HANDLE hProcess, // handle of the process whose memory is read
LPCVOID lpBaseAddress, // address to start reading
LPVOID lpBuffer, // address of buffer to place read data
DWORD nSize, // number of bytes to read
LPDWORD lpNumberOfBytesRead // address of number of bytes read
);
...
lpNumberOfBytesRead

Points to the actual number of bytes transferred into the specified buffer. If lpNumberOfBytesRead is NULL, the parameter is ignored.

Я и ставлю NULL:
ReadProcessMemory (result.hprocess,pointer(address),buffer,b_count, 0);
еще с переменной пробовал- ничего не получается, ошибка -
Types of actual and formal parameters must be identical
Объясните пожалуйста, что делаю не так?


Kolya   (2002-10-21 13:34:00) [1]

2 Игорь Шевченко
спасибо! разобрался


Игорь Шевченко   (2002-10-21 11:02:00) [2]

Смотреть, как объявлена функция ReadProcessMemory в Windows.pas - все проблемы снимаются.


Kolya   (2002-10-21 04:14:00) [3]

1 байт


[NIKEL]   (2002-10-20 19:18:00) [4]

и чего ты там читаешь? скока байт? чему равна b_count?


Kolya   (2002-10-20 18:49:00) [5]

type reedbuffer = ^Integer;

type access_info = record
error :integer;
hwindow :integer;
thread_id :integer;
process_id :integer;
hprocess :integer;
end;

var
rd: reedbuffer;
wtitle: string;

...
//создаю поинтер на буффер в который буду записывать
new(rd);
AccessProcess(1,"Test2",1110BCC,rd,1);
...
//вроде пока все правильно
function AccessProcess ( access_type :integer;
wtitle :string;
address :integer;
buffer :PByteArray;
b_count :integer
):access_info;

var temp: integer;
begin
result.error:=0;
if wtitle<>"" then
// из заголовка окна вычесляю его ProcessId
begin result.hwindow:=FindWindowA (nil,pchar(wtitle));
if result.hwindow<>0 then
begin
result.thread_id:=GetWindowThreadProcessId (result.hwindow,@result.process_id);
//открываю
result.hprocess:=OpenProcess(PROCESS_ALL_ACCESS,false,result.process_id);
if result.hprocess<>0 then
begin
// ставлю NULL
temp:= 0;
case access_type of
0 : ;
//Вот тут я и читаю память
1 : if not(ReadProcessMemory (result.hprocess,pointer(address),buffer,b_count,pointer(temp))) then
result.error:=4;
2 : if not(WriteProcessMemory (result.hprocess,pointer(address),buffer,b_count,pointer(temp))) then
result.error:=5;
else result.error:=6;
end;
CloseHandle (result.hprocess);
end
else result.error:=3;
end
else result.error:=2;
end
else result.error:=1;
end;

Вот такой код. Посмотрите, может быть я что- ни так с поинтерами делаю?


NailS   (2002-10-20 17:31:00) [6]

> ReadProcessMemory (result.hprocess,pointer(address),buffer,b_count,0);

А кто такой pointer(address) и buffer?

> еще с переменной пробовал- ничего не получается

lpNumberOfBytesRead - это адресс переменной, а не сама переменная.
А в конце полезно вызвать SysErrorMessage(GetLastError).


Юрий Зотов   (2002-10-20 17:11:00) [7]

Приведите все же свой вызов, несложно ведь. Трудно сказать "что не так", ничего не видя, понимаете?


Наверх

Титульная страница Поиск, карта сайта Написать письмо