| N F O _ I S C H I L D O F P R O C ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
AMIGA - NFO_#?
----------------------------------------------------------------------------
NAME
nfo_ischildofproc() - Checks if particular task/child
belongs to this process.
SYNOPSIS
res = nfo_ischildofproc(child, proc);
LONG nfo_ischildofproc(struct Task *, struct Process *);
FUNCTION
This function tries to determine if examined task is a
child of "this" process.
INPUTS
child - Pointer to a Task. Checked item.
proc - Pointer to a Process. Reference.
RETURNS
Returns 0 if the task is not a child of this process or
or PC or LFRA(negative value) if it is.
BASES
SysBase, (DOSBase)
NOTES
You must really post-confirm somehow that this function
did its job right. Detecting children of a handler proc
is simple though as you can compare the names in most
cases.
This function may also return 0 if task has no standard
stack or if process does not contain any seglists or if
'proc' is not really a process.
Function will call 'Forbid()' / 'Permit()' pair during
examining.
Its up to you to check if task or process are valid!
This is not necessary if you are calling this function
taking task addresses from iterator though.
This code may be able to find 'proc' as 'child' if you
are passing 'child' as received from task iterator when
'proc' is not you!
This function is sort of universal. Besides its concept
can also be used to find a parent of a child. All you
have to do is to pass different processes while 'child'
is same.
This func. will be unable to locate the child if it was
granted a copy of parent's fake seglist! RexxMaster is
known to do something like that.
SEE ALSO
nfo_issegremote()
EXAMPLE
None.
BUGS
-1-
Warning! If there are multiple processes who are using
residently loaded or ROM seglist, and these processes
have children then all the children(independently of the
respective parent) and these processes will be assumed
'proc' children! This kinda sucks, and i have no idea
how to fix this...
A simple workaround for handlers is to compare device
name against taskname, which seems to work in most cases
but may/will be totally untrue for other programs.
I have studied pretty much whole 'exec/' directory of
includes, was stack sniffing, even overlooking AROS code
and i did not find a thing that would allow to easily
distinguish shared seglist processes. This seems really
hopeless :-( .
-2-
As this function compares the PC against code segment it
may be totally wrong in case CPU gets transferred beyond
this segment...
All is just fine when there are single JSR ops to outter
code. But when they nest, such as when OS function wraps
other OS function, like 'WaitPort() wraps 'Wait()' for
instance then things change badly...
-3-
Happily not only the PC is taken into account, but sadly
stack gets examined heuristically for the existence of
local function return address within 10 first LONGs by
BYTE stepping. This sucks, but that is still better than
nothing.
----------------------------------------------------------------------------
| |
| |