Skip to content

Commit 06cf769

Browse files
committed
Added fix for user marshal parsing issue.
1 parent 580ce1d commit 06cf769

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

NtApiDotNet/Ndr/NdrSimpleTypes.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,19 @@ internal static IntPtr GetTargetAddress(SafeLoadLibraryHandle curr_module, IntPt
337337
case 0xE9:
338338
ptr = ptr + 5 + System.Runtime.InteropServices.Marshal.ReadInt32(ptr + 1);
339339
break;
340-
// lea rax, ofs import - Delay load 64bit
340+
// REX prefix, could be a lea rax, ofs import - Delay load 64bit or a jmp.
341341
case 0x48:
342342
{
343-
if (!Environment.Is64BitProcess || System.Runtime.InteropServices.Marshal.ReadByte(ptr + 1) != 0x8D || System.Runtime.InteropServices.Marshal.ReadByte(ptr + 2) != 0x05)
343+
if (!Environment.Is64BitProcess)
344+
{
345+
return ptr;
346+
}
347+
start_byte = System.Runtime.InteropServices.Marshal.ReadByte(ptr + 1);
348+
if (start_byte == 0xFF)
349+
{
350+
return GetTargetAddress(curr_module, ptr + 1);
351+
}
352+
if (start_byte != 0x8D || System.Runtime.InteropServices.Marshal.ReadByte(ptr + 2) != 0x05)
344353
{
345354
return ptr;
346355
}

0 commit comments

Comments
 (0)