Reading variables from non .net running processes?

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

Hello. I have two programmes both a couple of years old but not .net.

One is a DOS based programme and one is a C++ programme. They both run
under windows.

I would like to write a programme that is capable of reading variables
from these programmes.

Can you please tell me where I start with such a project? I am aware
that it probabally will not be easy, but really don't have any idea of
the topics i need to read up on in order to get this done. I understand
that both programmes are not particularly COM / ActiveX friendly.

Any advice would be greatly appreciated. Please be as specific as
possible with your answers. I really do appreciate your valuable time,
and I would be lost without this news group.

Many Thanks,

Gary.
 
I think this is exactly the starting point i was looking for.

Thanks DeveloperX.

Gary-
 
DeveloperX ... that was a cooool application !! A gold star for you!!!

Thanks
-Srinivas.
 
Can someone please explain the following to me. I understand that to
read from memory I need to import kernal32.dll? why do i need to import
this .dll? I don't understand the below code is OpenProcess a method,
with return type IntPtr? if so what is IntPtr? If it is a method,
what's the point of it? It doesn't do anything? I dont understand,
please explain as best you can. Thankyou. Please explain this below
code.


[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(
UInt32 dwDesiredAccess,
Int32 bInheritHandle,
UInt32 dwProcessId
);

[DllImport("kernel32.dll")]
public static extern Int32 ReadProcessMemory(
IntPtr hProcess,
IntPtr lpBaseAddress,
[In, Out] byte[] buffer,
UInt32 size,
out IntPtr lpNumberOfBytesRead
);

[DllImport("kernel32.dll")] public static extern Int32 CloseHandle(
IntPtr hObject
);
 
As the documentation tells you (RT[F]M), it is a pointer... what it is a
pointer *to* depends on the exact implementation, but it is used a lot with
PInvoke code

http://msdn2.microsoft.com/en-us/library/system.intptr.aspx

Can I make a suggestion? If you are unfamiliar with IntPtr (and based also
on your related questions), this task may be beyond your means to develop
and debug.

Of course, you're more than welcome to give it a whirl... but what you are
trying to do is not trivial, and could be plain 'orrible depending on what
the app is that you are attempting to talk to... for instance, the pointer
(to the variable) that you need could be determined only at runtime, so
you'd need to know how to find that pointer...

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top