Article View: borland.public.cppbuilder.nativeapi
Article #17217ReadProcessMemory
From: RaynorPao
Date: Thu, 03 Apr 2003 12:33
Date: Thu, 03 Apr 2003 12:33
36 lines
2009 bytes
2009 bytes
Hi all:
I want to read memory from a process...the code is as below:
BYTE buf[4];
DWORD addr;
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb=sizeof(STARTUPINFO);
if(!CreateProcess("c:\\winnt\\notepad.exe", 0, 0, 0, 0,
CREATE_NEW_CONSOLE, 0, 0, &si, &pi))
{
ShowMessage("could not create process - "+IntToStr(GetLastError()));
}
WaitForInputIdle(pi.hProcess, INFINITE);
addr=0;
DWORD dummy;
if(!ReadProcessMemory(pi.hProcess, 0, buf, 4, &dummy))
{
ShowMessage("could not read process memory -
"+IntToStr(GetLastError()));
ShowMessage("dummy = "+IntToStr(dummy));
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
But, this line "ReadProcessMemory" occurs error at runtime.
And the error code is 299 (Only part of a ReadProcessMemory or
WriteProcessMemory request was completed. ).
Is there something wrong what I do? I have no idea...Please help me.
Thanks.
RaynorPao.
Technical Details
Message-ID:
<3e8c2645@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,e9c405100fa0e95a,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-03 04:18:20 PST From: "RaynorPao" <RaynorPao.nospam@nospam.pchome.com.tw> Newsgroups: borland.public.cppbuilder.nativeapi Subject: ReadProcessMemory Date: Thu, 3 Apr 2003 20:33:30 +0800 Lines: 38 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 NNTP-Posting-Host: 61.221.176.28 Message-ID: <3e8c2645@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1049372229 61.221.176.28 (3 Apr 2003 04:17:09 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.news2me.com!ken-transit.news.telstra.net!news.telstra.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail