In the course of running and debugging a program there are times when there must be a way to identify which procedure is currently executing. During normal thread execution, the current procedure must be determined any time an exception arises so that the proper handlers will be invoked. In addition, a debugger must know which procedure invocation is currently executing to enable it to find information about the current state of the execution environment.
In order to determine completely the current execution context, not only must the currently executing procedure be determined but also which instance of that procedure. This context of the current procedure together with a specific instance of that procedure invocation is called the current procedure invocation (which is often shortened to current procedure). At any point in the execution of a thread there is always exactly one procedure that is considered the current procedure.
In the Windows NT for Alpha Systems Calling Standard the value in the PC is used to indicate the current procedure by means of a lookup table (see Section 8.1, Procedure Descriptor Representation).
The following system-supplied functions may be used to obtain the address of a procedure descriptor that corresponds with any given PC within the current address space. Note that RtlLookupFunctionEntry() always returns a primary procedure descriptor while RtlLookupDirectFunctionEntry() returns the primary or secondary procedure descriptor that directly contains the given address. (A procedure descriptor directly contains an address if and only if the address is greater than or equal to the contents of the BeginAddress field and less than the contents of the EndAddress field.)
Also note that any two addresses, say PC1 and PC2, in the same address space are part of the same procedure (as defined in the introduction to Chapter 8) if and only if RtlLookupFunctionEntry(PC1) == RtlLookupFunctionEntry(PC2)
RtlLookupFunctionEntry( ControlPc )
Arguments
ControlPc
A PC value in the current address space for which the primary procedure descriptor is to be returned.
Function Value
ProcDesc
Address of the primary procedure descriptor for the procedure that corresponds to the requested PC. If the return value is null, then the PC is not currently mapped by any active procedure descriptor.
RtlLookupDirectFunctionEntry( ControlPc )
Arguments
ControlPc
A PC value in the current address space for which the direct primary or secondary procedure descriptor is to be returned.
Function Value
ProcDesc
Address of the primary or secondary procedure descriptor that directly contains the requested PC. If the return value is null, then the PC is not currently mapped by any active procedure descriptor.