Programms memory adress location access?

Discussion in 'C++' started by TIM, Apr 11, 2004.

  1. TIM

    TIM Guest

    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.
     
    TIM, Apr 11, 2004
    #1
    1. Advertising

  2. TIM wrote in news:4079533f$ 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/
     
    Rob Williscroft, Apr 11, 2004
    #2
    1. Advertising

  3. TIM

    Jeff Schwab Guest

    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.
     
    Jeff Schwab, Apr 11, 2004
    #3
  4. 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.
     
    Kevin Goodsell, Apr 11, 2004
    #4
  5. * Kevin Goodsell <> 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?
     
    Alf P. Steinbach, Apr 11, 2004
    #5
  6. Alf P. Steinbach wrote:

    > * Kevin Goodsell <> 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.
     
    Kevin Goodsell, Apr 11, 2004
    #6
  7. On 2004-04-11, Alf P. Steinbach <> wrote:
    > * Kevin Goodsell <> 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:
     
    =?iso-8859-2?Q?Rados=B3aw?= Grzanka, Apr 11, 2004
    #7
  8. 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.
     
    Kevin Goodsell, Apr 11, 2004
    #8
  9. TIM

    TIM Guest

    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...
     
    TIM, Apr 12, 2004
    #9
  10. 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.
     
    Kevin Goodsell, Apr 12, 2004
    #10
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. news.rz.uni-karlsruhe.de

    comparing java programms on Linux and Windows!

    news.rz.uni-karlsruhe.de, Jul 17, 2003, in forum: Java
    Replies:
    6
    Views:
    392
    Darryl L. Pierce
    Jul 20, 2003
  2. qwertyuiop20_84

    making runeble programms?

    qwertyuiop20_84, Feb 27, 2005, in forum: Java
    Replies:
    4
    Views:
    392
    qwertyuiop20_84
    Mar 1, 2005
  3. Ulf Meinhardt
    Replies:
    0
    Views:
    1,248
    Ulf Meinhardt
    May 10, 2006
  4. Thorsten Kiefer

    java3d an fragment programms

    Thorsten Kiefer, Jul 25, 2009, in forum: Java
    Replies:
    1
    Views:
    347
    John B. Matthews
    Jul 26, 2009
  5. D. Xenakis
    Replies:
    17
    Views:
    143
    Chris Angelico
    Apr 3, 2014
Loading...

Share This Page