Re: Is this a valid memory address?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Daniel Kaplan <NoSPam@xxxxxxxxxx> wrote:
So in my Hook I am coming up with a lot of USER defined messages:

i.e. WM_USER+1 00000000 03276801

Now granted, lParam could be garbage, it could be the sum of stuff,
or it "could be a pointer to some memory".

What I'd like to do is memcpy it's contents, if it is.

Even if it is a pointer (which you have no way of knowing), you don't
know the size of the buffer it's pointing to, anyway.

Why do you want to memcpy its contents?

Is there a way to tell that that spot is a valid pointer

Well, there's IsBadReadPtr. But of course a random garbage value may
just accidentally be a valid address.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Mysterious pointer mixed with array indices bug
    ... Converting that `char' to a `void*' is suspect, ... variable `pnew_res_names' points to some memory ... this call prints random garbage (if it prints ... some of the levels of pointer indirection -- I am usually averse ...
    (comp.lang.c)
  • Re: Local variables controversial?
    ... No garbage> no garbage collection. ... Another implemenataion would be to have another area in addition to the parameter and return stacks, with a pointer to that. ... There _is_ "garbage collection," but it reduces to the simple procedure of resetting a pointer - no moving of stuff in memory. ...
    (comp.lang.forth)
  • Re: Setting malloc pointer to NULL?
    ... some random memory address. ... you are passing a garbage pointer to free. ... It still points to the block of memory allocated by malloc(). ...
    (microsoft.public.vc.language)
  • Re: Dynamic Memory Allocation
    ... to pickout only those which are dynamically allocated. ... pointer points to dynamic, static, or automatic memory. ... I'm concentrating on pointer variables only, ... any "garbage" at all). ...
    (comp.lang.c)
  • Re: "Move memory" in no time
    ... place in memory. ... original data any more. ... So far I call memcpy and free up the original ... the space used by that pointer. ...
    (comp.os.linux.development.apps)