Welcome, Guest. Please login or register.

Author Topic: Any OS legal way to traverse an exec memory pool?  (Read 4621 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Any OS legal way to traverse an exec memory pool?
« on: February 11, 2007, 08:45:17 PM »
Quote
Let's assume you are using CreatePool() / DeletePool() to manage memory allocation. If you wanted to traverse the allocations made so far so that you could, for example write to a debug log, is there any OS legal way to access the memory list?

No.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Any OS legal way to traverse an exec memory pool?
« Reply #1 on: February 11, 2007, 11:55:31 PM »
@CrazyProg

Uh, if it's your program calling the functions why the heck would you want to patch exec?

Karlos already said it:
Quote
As it happens, I am wrapping the pool and I have a tiny header for each allocation (I never use it for trivial allocation of a few bytes anyway), so as far as I can see there's no reason I couldn't add basic prev / next node pointers in there.

And this is exactly what he should do.

But the original question, if there is a OS legal way to traverse the allocated memory in a pool. There isn't (for the obvious reason: Memory pool is a "black box", it's internal implementation can change at any time, and has in the past already. AmigaOS 3.9 BB2 introduced new binary tree memory pools).

Anyway, there is a fatal flaw in patching the system in a way you call the original function, and then examine the result: There is no way to be 100% sure the function has returned. In this case, even if you remove the patch the code could still be executing, and your function could be landed long after the executable has been unloaded by shell or workbench. Adding some call counter won't help either, as you could still get rescheduler after you subtract the counter and before executing the final 'return from subroutine'. As such, there is no safe way to remove patches like this.
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show all replies
    • http://www.iki.fi/sintonen/
Re: Any OS legal way to traverse an exec memory pool?
« Reply #2 on: February 12, 2007, 08:01:00 PM »
@Karlos

Sounds like a plan. The similar system I implemented also had walls (that is some running pattern before and after the allocated area). Af memory free I'd check for wall hits and report them.

Also, PoolWatch could be useful in some cases.