GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 27-Mar-2005, 18:07
thejustman85 thejustman85 is offline
New Member
 
Join Date: Mar 2005
Posts: 6
thejustman85 is on a distinguished road

Simple Program


Is there a way I can make a very simple C program recieve inputs, that will become variables, from program X running on my computer? Then, The program I am going to make will simply print text on the screen in a text window of program X and hit enter based on some logic operators. I am running windows xp if that makes a difference. thanks,
justin
  #2  
Old 28-Mar-2005, 14:25
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by thejustman85
Is there a way I can make a very simple C program recieve inputs, that will become variables, from program X running on my computer? Then, The program I am going to make will simply print text on the screen in a text window of program X and hit enter based on some logic operators. I am running windows xp if that makes a difference. thanks,
justin
No. It's not simple... The program I did similar to this took knowledge of winsock and a bunch of API's.
__________________

Age is unimportant -- except in cheese
  #3  
Old 29-Mar-2005, 02:50
thejustman85 thejustman85 is offline
New Member
 
Join Date: Mar 2005
Posts: 6
thejustman85 is on a distinguished road
I downloaded a program called Tsearch that searches the memory in use by the program I want my program to communicate with. What I want to do is have my program look at certain memory addresses and base on their values, do something. How can I get my program to search the other program's memory in use? thank, justin

ps, i think im making progress....

I used this

int z = 1985;
printf("%d",&z);

and it gave me a memory address of a variable I made. if I can do this, couldnt I read from a memory address of another program, then based on its value, print something to another memory address?
Last edited by thejustman85 : 29-Mar-2005 at 03:23. Reason: rememberd something extra
  #4  
Old 29-Mar-2005, 05:13
Dr. Evil Dr. Evil is offline
Member
 
Join Date: Oct 2004
Location: Netherlands
Posts: 120
Dr. Evil will become famous soon enough
If you're trying to read info from another program currently running, I'd recommend using the ReadProcessMemory() function. There's also a WriteProcessMemory, if you need to change values.
  #5  
Old 29-Mar-2005, 16:53
thejustman85 thejustman85 is offline
New Member
 
Join Date: Mar 2005
Posts: 6
thejustman85 is on a distinguished road
Ok here is an example...

CPP / C++ / C Code:
#include <stdio.h>


main()
{
int z = 1985;
printf("%d\n",z);
printf("This is the memory address of 1985 %d",&z);
printf("\nEnter the value you want to put at this address\n");
scanf("%d", 37814108);
printf("Value after new entry %d",z);


  return 0;
}

...Now after I run the program once I get 37814108. I dont know if that will be the same address always but I just did it for an example. How can I use ReadProcessMemory() function to get the value at an address and use it as a variable? I dont really understand the information provided on the link in the previous post. help
justin
  #6  
Old 30-Mar-2005, 00:10
Dr. Evil Dr. Evil is offline
Member
 
Join Date: Oct 2004
Location: Netherlands
Posts: 120
Dr. Evil will become famous soon enough
If you want an examle of using ReadProcessMemory() to hex dump another processes running memory then I'd recommend going here.
  #7  
Old 30-Mar-2005, 01:29
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,243
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
From your questions, the real answer is:
No you can't. You need more knowledge over and above the basic syntax of C. You need to learn more about inter-process communication and other high level programming techniques. Take your learning a little slower.

A program cannot read the memory from another program. The OS protects running programs from prying.
__________________

Age is unimportant -- except in cheese
  #8  
Old 30-Mar-2005, 07:56
Dr. Evil Dr. Evil is offline
Member
 
Join Date: Oct 2004
Location: Netherlands
Posts: 120
Dr. Evil will become famous soon enough
Quote:
A program cannot read the memory from another program. The OS protects running programs from prying.
Umm... Didn't you see the link I posted? It sure looks like you can to me.
  #9  
Old 04-Apr-2005, 09:04
thejustman85 thejustman85 is offline
New Member
 
Join Date: Mar 2005
Posts: 6
thejustman85 is on a distinguished road
Code:
#include <stdio.h> main() { int *x; x = 4825101; printf("%d",*x); return 0; }

This gives me an error when I run it. Why cant i print the int value of this memory address. Its an address of another program, but why wont it work?
  #10  
Old 04-Apr-2005, 09:52
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,702
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by thejustman85

This gives me an error when I run it. Why cant i print the int value of this memory address. Its an address of another program, but why wont it work?


Assuming you are running your program in a hosted environment (Windows, Linux, etc.) contrasted with an embedded non-hosted environment: this is not the address of another program. Furthermore, you are only allowed to access memory within the space that the operating system gives you. (Your program variables, functions, etc. plus whatever memory you get through library allocation programs such as malloc().) When you run your C program, the operating system maps a particular area of memory to your program's memory space. Addresses that you get (by printing out values of pointers, for example) are "virtual addresses". User programs such as your example have no way of knowing what's in any particular physical memory address at any time.

When you run a particular program, it is assigned a place in physical memory and loaded there by the operating system. The next time you run the program, it might go into a completely different physical address.

Bottom line: With 'modern' operating systems (Windows XP, Linux) user programs like your example can not directly access physical resources (memory, i/o port addresses, etc.)

Now, operating systems typically have ways of hooking debug programs into other processes, and I invite you to search msdn.com for "Basic Debugging" topics (that's not for debugging BASIC programs, but an overview and technical exposition of methods for observing and correcting programs running under Windows operating systems).

Your first post in this thread began this way:
Quote:
Originally Posted by thejustman85
Is there a way I can make a very simple C program recieve inputs, that will become variables, from program X running on my computer?

Now "simple" is kind of subjective, but if I had to give a simple answer to your simple question, I would have to say, "It depends on what you mean by 'simple'."

Regards,

Dave

"Things should be made as simple as possible, but no simpler."
---Albert Einstein
 
 

Recent GIDBlogToyota - 2008 September Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[TUTORIAL] Calling an external program in C (Linux) dsmith C Programming Language 4 22-Apr-2005 13:30
Help with simple math table program (was a SIMPLE program) Bubba C Programming Language 3 09-Mar-2005 12:40
Help with a simple program matthewbarr C Programming Language 3 10-Feb-2005 10:08
Help with a simple program. bluedragon27 C Programming Language 1 16-Nov-2004 15:40
How to write simple program like ........? laputa9000 C++ Forum 3 29-Oct-2003 12:09

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:04.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.