Skip to content

Commit 11bb8e4

Browse files
committed
[RTL] Fix dynamic function tables
1 parent 9aaa898 commit 11bb8e4

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sdk/lib/rtl/amd64/dynfntbl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* PROJECT: ReactOS RTL
3-
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
44
* PURPOSE: Dynamic function table support routines
5-
* COPYRIGHT: Copyright 2022 Timo Kreuzer ([email protected])
5+
* COPYRIGHT: Copyright 2022-2025 Timo Kreuzer ([email protected])
66
*/
77

88
#include <rtl.h>
@@ -154,6 +154,10 @@ RtlAddFunctionTable(
154154
FunctionTable[i].EndAddress);
155155
}
156156

157+
/* Adjust the margins to be absolute addresses */
158+
dynamicTable->MinimumAddress += BaseAddress;
159+
dynamicTable->MaximumAddress += BaseAddress;
160+
157161
/* Insert the table into the list */
158162
RtlpInsertDynamicFunctionTable(dynamicTable);
159163

@@ -277,6 +281,7 @@ RtlpLookupDynamicFunctionEntry(
277281
PDYNAMIC_FUNCTION_TABLE dynamicTable;
278282
PRUNTIME_FUNCTION functionTable, foundEntry = NULL;
279283
PGET_RUNTIME_FUNCTION_CALLBACK callback;
284+
DWORD64 ipOffset;
280285
ULONG i;
281286

282287
AcquireDynamicFunctionTableLockShared();
@@ -304,11 +309,12 @@ RtlpLookupDynamicFunctionEntry(
304309

305310
/* Loop all entries in the function table */
306311
functionTable = dynamicTable->FunctionTable;
312+
ipOffset = ControlPc - dynamicTable->BaseAddress;
307313
for (i = 0; i < dynamicTable->EntryCount; i++)
308314
{
309315
/* Check if this entry contains the address */
310-
if ((ControlPc >= functionTable[i].BeginAddress) &&
311-
(ControlPc < functionTable[i].EndAddress))
316+
if ((ipOffset >= functionTable[i].BeginAddress) &&
317+
(ipOffset < functionTable[i].EndAddress))
312318
{
313319
foundEntry = &functionTable[i];
314320
*ImageBase = dynamicTable->BaseAddress;

0 commit comments

Comments
 (0)