473,473 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ReadProcessMemory fails with 299,...

Hi,

can someone postme a running sample of the
ReadProcessMemory(...) function. I would
like to dump the complete memory of the main
module in my application e.g MyApplication.exe
into a file. Here is a working example of the API
import call:

[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[Out()] byte[] lpBuffer,
int dwSize,
out int lpNumberOfBytesRead
);

The point is, that i get always a 299 (i know what it means!)
for this call:

Process p = Process.GetCurrentProcess();
string MemoryDumpFileName = p.MainModule.FileName + ".mem";
byte[] ProcessMemory = new byte[p.MainModule.ModuleMemorySize];
int NumberOfBytesRead = 0;

....
hProcess =
DRWin32APIClass.OpenProcess(DRWin32APIClass.Proces sAccessFlags.QueryInformation
|
DRWin32APIClass.ProcessAccessFlags.VMOperation |
DRWin32APIClass.ProcessAccessFlags.VMRead,
false,
(uint) p.Id);
bool _ret = DRWin32APIClass.ReadProcessMemory(p.Handle,
p.MainModule.BaseAddress,
ProcessMemory,
p.MainModule.ModuleMemorySize,
out NumberOfBytesRead);

_ret is false (GetLastError=299) and lpNumberOfBytesRead is 0, why?
I also enabled any possible privilige in my application including debugging!
Handle to process and ID is valid, confirmed!

Thanks is advance,..

Regards

Kerem
--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Latest Project: http://www.codeplex.com/restarts
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."

Oct 15 '08 #1
0 1736

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Luke | last post by:
I am trying to convert some VB6 projects to VB.NET, however I'm having trouble finding documentation of a new format for some functions, in specific ReadProcessMemory. Since .NET no longer supports...
2
by: pangel83 | last post by:
I've been trying for days to write a piece of VB.NET code that will read from winamp's memory space the paths of the files from the current winamp playlist. The GETPLAYLISTFILE command of the...
6
by: kenneth fleckenstein nielsen | last post by:
Hi guru's It runs ok on my developmaschine, and on the test server that i've set up. but fails after installing on the customers server. I made a XML webservice that does these steps: a) access a...
7
by: SevDer | last post by:
Hi I have a class library that needs to download the HTML in a specific page of ours with provided querystring. When I open this URL with any browser, it loads fine. When I do WebRequest from Web...
1
by: comp.lang.php | last post by:
Consider my code: if ($this->isSuccessful && is_file($_FILES)) { // STEP 6: MOVE RESUME TO DIRECTORY $uuid = $this->sfug->getUUID(); if (!$uuid) $this->sfug->setUUID(); $uuid =...
2
by: Richard Hsu | last post by:
// code #include "stdio.h" int status(FILE * f) { printf("ftell:%d, feof:%s\n", ftell(f), feof(f) != 0 ? "true" : "false"); } int case1() { FILE * f = fopen("c:\\blah", "wb+"); int i = 5;
2
by: Anbu | last post by:
Sorry for cross posting the query. But I need a resolution as early as possible. I have developed an application to authenticate the user based on LDAP Search and authentication. The Windows...
12
by: Jim Rodgers | last post by:
I have a big asp file that has an error under certain conditions -- totally repeatable. However, it only fails when I set response.buffer = True at the top. WHen I set it False in order to debug...
5
by: Evolution445 | last post by:
Hi all, I got a problem with my code to check a game's chat position and write text to the game when a command is written by someone on the chat. I haven't figured out yet how to make it send keys...
0
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, can someone postme a running sample of the ReadProcessMemory(...) function. I would like to dump the complete memory of the main module in my application e.g MyApplication.exe into a file....
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.