471,582 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,582 software developers and data experts.

Programms memory adress location access?

TIM
for example i have one simple programm

int main()
{
int test = NULL;
while(1){
printf("%d\n",test);
getch();
test++;
}
return 0;
}

After compiling and running it, i want to access to its memory adress
location(under windows) from other programm(which i want to write, but
dont know how or better say, from to start :-)) and find this "test"
variable and change its value during programm run-time. How i can do it
from external programm written in C++? Any help would be appreciated. THX.
Jul 22 '05 #1
11 1509
TIM wrote in news:40**********@news.estpak.ee in comp.lang.c++:
for example i have one simple programm

int main()
{
int test = NULL;
while(1){
printf("%d\n",test);
getch();
test++;
}
return 0;
}

After compiling and running it, i want to access to its memory adress
location(under windows) from other programm(which i want to write, but
dont know how or better say, from to start :-)) and find this "test"
variable and change its value during programm run-time. How i can do
it from external programm written in C++? Any help would be
appreciated. THX.


Alas Standard C++, has nothing to say about accesing data or code
in *other* programmes.

You should ask this in a windows programming newsgroup say:

comp.os.ms-windows.programmer.win32

<off-topic>

You should IMO rethink your question, what you ask above can only
really be done by a debugger, which will require a programme
compiled with debuging information, if this is what you want to
do ask about it directly, also such things are not only os specific
but compiler specific, so ask in a newsgroup that supports your
compiler.

Some terms you might want to google up on:

IPC - Inter Process Communications
RPC - Remote Procedure Calls
COM - Component Object Model (win32 /mostly/)

</off-topic>

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #2
TIM wrote in news:40**********@news.estpak.ee in comp.lang.c++:
for example i have one simple programm

int main()
{
int test = NULL;
while(1){
printf("%d\n",test);
getch();
test++;
}
return 0;
}

After compiling and running it, i want to access to its memory adress
location(under windows) from other programm(which i want to write, but
dont know how or better say, from to start :-)) and find this "test"
variable and change its value during programm run-time. How i can do
it from external programm written in C++? Any help would be
appreciated. THX.


Alas Standard C++, has nothing to say about accesing data or code
in *other* programmes.

You should ask this in a windows programming newsgroup say:

comp.os.ms-windows.programmer.win32

<off-topic>

You should IMO rethink your question, what you ask above can only
really be done by a debugger, which will require a programme
compiled with debuging information, if this is what you want to
do ask about it directly, also such things are not only os specific
but compiler specific, so ask in a newsgroup that supports your
compiler.

Some terms you might want to google up on:

IPC - Inter Process Communications
RPC - Remote Procedure Calls
COM - Component Object Model (win32 /mostly/)

</off-topic>

HTH.

Rob.
--
http://www.victim-prime.dsl.pipex.com/
Jul 22 '05 #3
TIM wrote:
for example i have one simple programm

int main()
{
int test = NULL;
while(1){
printf("%d\n",test);
getch();
test++;
}
return 0;
}

After compiling and running it, i want to access to its memory adress
location(under windows) from other programm(which i want to write, but
dont know how or better say, from to start :-)) and find this "test"
variable and change its value during programm run-time. How i can do it
from external programm written in C++? Any help would be appreciated. THX.


Sorry, there's no standard way to do this in C++. Try asking in a
Windows group.
Jul 22 '05 #4
TIM wrote:
for example i have one simple programm

int main()
{
int test = NULL;
while(1){
printf("%d\n",test);
getch();
test++;
}
return 0;
}

After compiling and running it, i want to access to its memory adress
location(under windows) from other programm(which i want to write, but
dont know how or better say, from to start :-)) and find this "test"
variable and change its value during programm run-time. How i can do it
from external programm written in C++? Any help would be appreciated. THX.


Sorry, there's no standard way to do this in C++. Try asking in a
Windows group.
Jul 22 '05 #5
TIM wrote:
for example i have one simple programm

int main()
{
int test = NULL;
NULL is undeclared (and if it were defined the usual way, it would be
very strange to assign it to an int).
while(1){
printf("%d\n",test);
getch();
Neither of these functions are declared, so this should not compile.
test++;
This will eventually overflow, giving undefined behavior.
}
return 0;
}


-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #6
* Kevin Goodsell <us*********************@neverbox.com> schriebt:
int test = NULL;


NULL is undeclared (and if it were defined the usual way, it would be
very strange to assign it to an int).


Uhm, Kevin, this is [comp.lang.c++] you're replying in. I agree that it
is strange to use NULL in such a context, but in C++ the strangeness does
not flow from the definition of NULL, which is required to be 0 (unfortunate
in my opinion, but that's the way it turned out in the standards battle). In
C++ the strangeness flows only from convention and perhaps aesthetics.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #7
Alf P. Steinbach wrote:
* Kevin Goodsell <us*********************@neverbox.com> schriebt:
int test = NULL;


NULL is undeclared (and if it were defined the usual way, it would be
very strange to assign it to an int).

Uhm, Kevin, this is [comp.lang.c++] you're replying in. I agree that it
is strange to use NULL in such a context, but in C++ the strangeness does
not flow from the definition of NULL, which is required to be 0 (unfortunate
in my opinion, but that's the way it turned out in the standards battle). In
C++ the strangeness flows only from convention and perhaps aesthetics.


Yes, what I said wasn't really what I meant. What I meant was that
'NULL' could be some identifier that the OP created, e.g.

int NULL = 7;

In which case the code wouldn't be completely weird (though using NULL
as an identifier declared in your program is probably a bad idea, since
it is likely to conflict with the standard NULL).

If, on the other hand, the NULL in question was supposed to be the
standard NULL, then it's strange to use it with ints, since it is
intended to represent a null pointer.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #8
On 2004-04-11, Alf P. Steinbach <al***@start.no> wrote:
* Kevin Goodsell <us*********************@neverbox.com> schriebt:
> int test = NULL;


NULL is undeclared (and if it were defined the usual way, it would be
very strange to assign it to an int).


Uhm, Kevin, this is [comp.lang.c++] you're replying in. I agree that it
is strange to use NULL in such a context, but in C++ the strangeness does
not flow from the definition of NULL, which is required to be 0 (unfortunate
in my opinion, but that's the way it turned out in the standards battle). In
C++ the strangeness flows only from convention and perhaps aesthetics.


I thought NULL is platform dependend.. At least Bjarne Stroustrup writes
so.

Best Regards,
Radek.

--
"Oceniaj± mnie, choć wcale mnie nie znaj±. Dlatego jestem sam"
Shrek
email: sad<at>rpg<kropka>pl JID: ra****@jabber.atman.pl
Jul 22 '05 #9
Radosław Grzanka wrote:

I thought NULL is platform dependend.. At least Bjarne Stroustrup writes
so.


NULL expands to an implementation-defined null pointer constant. But
that's a very narrow category -- it must be an integer constant
expression with the value 0. So it could be (1 - 1) or (!!!!!!!1), but
realistically you are unlikely to find NULL defined as something other
than 0 or 0L (or something very similar).

You might be confusing NULL (a standard macro) and null pointer
constants with the concept of a pointer that is null. A null pointer
constant (such as NULL, or 0) when converted to a pointer, gives a null
pointer. The representation used for a null pointer is undefined, so
could vary from system to system. In other words, a pointer to address 0
may or may not be a null pointer, but an integer constant expression
with the value 0, when converted to a pointer, must be translated to a
null pointer (even if that means that it becomes something like 0xFF00FF00).

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #10
TIM
Kevin Goodsell wrote:
TIM wrote:
for example i have one simple programm

int main()
{
int test = NULL;

NULL is undeclared (and if it were defined the usual way, it would be
very strange to assign it to an int).
while(1){
printf("%d\n",test);
getch();

Neither of these functions are declared, so this should not compile.
test++;

This will eventually overflow, giving undefined behavior.
}
return 0;
}


-Kevin

LOL i just havent written here include files
#include <iostream>
#include <conio.h>
there is all declarations(and will compile without a problem), but
anyway thats not the question i aksed.
thx.
i just wanted to make programm such ARTMOBNEY if you heard of it...
Jul 22 '05 #11
TIM wrote:

LOL i just havent written here include files
#include <iostream>
#include <conio.h>
there is all declarations(and will compile without a problem), but
anyway thats not the question i aksed.


When posting code you should always post the *complete* code (check the
FAQ, section 5 for a more detailed discussion of how to post code). It
looks like your question was already answered. I was just commenting on
the problems with the code you posted.

For future reference <conio.h> is not standard C++, so you should not
use it in portable programs or include it in code posted here.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.
Jul 22 '05 #12

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by shyamal | last post: by
1 post views Thread by Riadh Elloumi | last post: by
11 posts views Thread by TIM | last post: by
10 posts views Thread by s.subbarayan | last post: by
3 posts views Thread by iwdu15 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by lumer26 | last post: by

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.