The system I am working on contains dynamically created
code, and therefore has no unwind information registered
for it. If it is on the call stack and a C program
attempts to 'longjmp' to a point on the call stack higher
than tyhe dynamic code the longjmp hangs somewhere in the
operating system. I assume it is because of the lack of
unwind information for the code(debuggers don't display
anything above the dynamic code either), so I need a
mechanism to allow unwind information for the code to be
registered with the operating system to allow the longjmp
to succeed.
MSDN contains a section 'Windows NT For Alpha Systems
Calling Standard 1.11', which documents low-level routines
for stack unwinding on the Alpha platform, and indeed the
Windows DDK contains a header file ntia64.h which has
functions for the Itanium similar to those documented for
the Alpha, but the function I believe I would need to use
to be able to register unwind information,
RtlAddFunctionTable, is not exported from the system DLLs
as far as I can tell, though it is in the header file.
Is there documentation on doing what I have described, or
some mechanism available that would allow me to do it ?
I would be very grateful for any information anybody can
provide.
Thank you for posting your question here. I'm currently researching your
problem and will follow up in a day or two.
Sincerely
Dan Ruder
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
Sorry that it took longer than anticipated. Our development group gave us
the following information, which may help you. These functions are
available for you to use, but beware that they are exported directly from
NTDLL.DLL, and may change in the future. Since there isn't an import
library for you to link to, you will want to use LoadLibrary/GetProcAddress
in your code.
There are two functions one can use for this both are exported from ntdll.
For the first function you can pass in a normal function similar to that
generated by a compiler. The second function can used if the generated code
is more dynamic. In this case the the function tables are generated on the
fly as the unwind occurs. This api is new and might still change a bit.
BOOLEAN
RtlAddFunctionTable(
IN PRUNTIME_FUNCTION FunctionTable,
IN ULONG EntryCount,
IN ULONGLONG BaseAddress,
IN ULONGLONG TargetGp
)
/*++
Routine Description:
Add a dynamic function table to the dynamic function table list. Dynamic
function tables describe code generated at run-time. The dynamic
function
tables are searched via a call to RtlLookupDynamicFunctionEntry().
Normally this is only invoked via calls to RtlpLookupFunctionEntry().
The FunctionTable entries need not be sorted in any particular order.
The
list is scanned for a Min and Max address range and whether or not it is
sorted. If the latter RtlLookupDynamicFunctionEntry() uses a binary
search, otherwise it uses a linear search.
The dynamic function entries will be searched only after a search
through the static function entries associated with all current
process images has failed.
Arguments:
FunctionTable Address of an array of function entries where
each element is of type RUNTIME_FUNCTION.
EntryCount The number of function entries in the array
BaseAddress Base address to calculate the real address of the
function table entry
TargetGp return back to RtlpLookupFunctionEntry for future
query.
Return value:
TRUE if RtlAddFunctionTable completed successfully
FALSE if RtlAddFunctionTable completed unsuccessfully
--*/
BOOLEAN
RtlInstallFunctionTableCallback (
IN ULONG64 TableIdentifier,
IN ULONG64 BaseAddress,
IN ULONG Length,
IN ULONG64 TargetGp,
IN PGET_RUNTIME_FUNCTION_CALLBACK Callback,
IN PVOID Context,
IN PCWSTR OutOfProcessCallbackDll OPTIONAL
)
/*++
Routine Description:
This function adds a dynamic function table to the dynamic function
table
list. A dynamic function table describe code that is generated at
runtime.
Arguments:
TableIdentifier - Supplies a value that identifies the dynamic function
table callback.
N.B. The two low order bits of this value must be set.
BaseAddress - Supplies the base address of the code region covered by
callback function.
Length - Supplies the length of code region covered by the callback
function.
TargetGp - Supplies the target GP value for functions covered by the
callback function.
Callback - Supplies the address of the callback function that will be
called to get function table entries for the functions covered by
the specified region.
Context - Supplies a context parameter that will be passed to the
callback
routine.
OutOfProcessCallbackDll - Supplies an optional pointer to the path name
of
a DLL that can be used by the debugger to obtain function table
entries
from outside the process.
Return Value
If the function table is successfully installed, then TRUE is returned.
Otherwise, FALSE is returned.
--*/