Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Heap and Stack manipulation (http://www.go4expert.com/forums/heap-stack-manipulation-t16269/)

vsachar 19Feb2009 15:38

Heap and Stack manipulation
 
Hi all,

This is my first post here.
My team and I are creating a project where we need to access the stack segment of the application and manipulate the pointers in it. Also, we are looking for a way to specify how much heap an application can use and divide this heap into segments. We're doing this for a garbage collector for C++.

If there is any information about the above, any links or practical knowledge, we'd welcome it. We're also looking at assembly code integration with C++ but are not sure it's what we want.

Thanks in advance for any help.

xpi0t0s 19Feb2009 18:11

Re: Heap and Stack manipulation
 
There's almost certainly going to be a better way to do it, for instance you can write your own memory management functions and redirect new/delete/malloc/free/realloc etc to those new routines.

But in any case the stack and heap addresses can be determined simply by taking the address of variables, and of course anything you do in this area is going to be extremely dependent on the exact version of compiler and platform you're using.

vsachar 20Feb2009 19:24

Re: Heap and Stack manipulation
 
What we need is to access the stack segment of the application.

This Garbage Collector runs for an application and uses the overloaded new operator.
This collector is in c++ for WinXP environment using vc++ compiler.

Also, we need to divide the heap into user defined size. Is there any way to do that?

Thanks in advance.

xpi0t0s 20Feb2009 21:40

Re: Heap and Stack manipulation
 
Not without your own custom memory allocations. For example how would char *str=malloc(100) know which heap division to use? You'd need something like char *str=malloc(100,USE_DIV_3),and that doesn't exist.


All times are GMT +5.5. The time now is 17:14.