A89: Storing pointers to functions in allocated memory...


[Prev][Next][Index][Thread]

A89: Storing pointers to functions in allocated memory...




Okay. When I compile my program, I get the following error on the third line 
"Invalid lvalue in assignment", and I can't see why it won't work. I've tried 
different methods, and some compiled but crashed the calc (at least I _THINK_ 
it was this line that crashed it, because this is the only line that messes 
with pointers...). This is my latest variation which I _think_ is the closest 
to being correct. I know I somehow need to dereference it at least once, but 
that simply causes more errors (can't dereference a void pointer). 
old_hook_handle is of type HANDLE and old_hook is of type EVENT_HANDLER. If 
the code isn't clear, I'm trying to take the pointer to a function which is 
stored in EV_hook and store that pointer to memory that I allocated.

//<code>

old_hook=EV_hook;
old_hook_handle=HeapAlloc(8);  //8 bytes should be 4 bytes 
                                                //more than I need, but just 
                                               //to be sure...
(void *)((void *)HeapDeref(old_hook_handle))=old_hook; //add a * between
                                                                              
 //the two void casts
                                                                              
 //to dereference the 
                                                                              
 //first (innermost) pointer

//</code>

It's probably just some stupid mistake I made (I've been programming for 
around 6 hours straight today and am in desperate need of some sleep :) ), 
but thanks for any help anyone can give me.

Josh



Follow-Ups: