Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2002.10.31;
Скачать: [xml.tar.bz2];

Вниз

ReadProcessMemory не хочет читать Memory   Найти похожие ветки 

 
Kolya   (2002-10-20 16:18) [0]

Вот уже час ломаю голову над это 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
Объясните пожалуйста, что делаю не так?


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

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


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

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

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

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

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


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

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;

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


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

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


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

1 байт


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

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


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

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



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2002.10.31;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.009 c
1-101280
Wiznik
2002-10-22 16:12
2002.10.31
Помогите, малость туплю:))


1-101339
Lony
2002-10-20 15:55
2002.10.31
WebBrowser


4-101568
Eugene
2002-09-18 13:59
2002.10.31
Наверное глупый вопрос, но все таки как


3-101157
Roma111
2002-10-11 10:45
2002.10.31
Кодировка поля БД


14-101492
Николай Быков
2002-10-11 16:11
2002.10.31
Си плюс плюсы





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский