gpt4 book ai didi

c# - 使用 IDA 或 Olly 从混合模式 dll 中检索 native 函数地址

转载 作者:行者123 更新时间:2023-11-28 05:46:10 30 4
gpt4 key购买 nike

这是我的第一个问题,所以请不要对我太苛刻:)

我得到的:

一个混合模式的 C# dll,它有 C# 代码,它又调用同一个 dll 中的 native 方法,我感兴趣

召唤:

int num3 = <Module>.fn_GetBitArray((byte*)(&$ArrayType$$$BY0DC@E), (byte*)(&$ArrayType$$$BY05E2), ref nHardwareType);

作为伊尔

IL_0117: stind.i1
IL_0118: ldloca.s 9
IL_011a: ldloca.s 8
IL_011c: ldloca.s 7
IL_011e: call uint32 modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl) '<Module>'::fn_GetBitArray(uint8*, uint8*, uint32* modopt([mscorlib]System.Runtime.CompilerServices.IsImplicitlyDereferenced) )

有这样的定义(ILSpy)

// <Module>
[SuppressUnmanagedCodeSecurity]
[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig)]
public unsafe static extern uint fn_GetBitArray(byte*, byte*, uint*);

我不确定如何从这里继续。当我在 IDA 中加载它时,我可以选择 .NET 加载器,我可以在其中看到所有 C# 代码和调用,但看不到“外部”函数的偏移量,然后我可以选择 x86 模式,但所有函数都已编号通过 (sub_XXXXXXXX),所以我需要偏移量。

问题:我怎样才能知道这个调用是如何解析的并检索目标函数?

PS:我很确定它真的没有导入,因为没有其他 dll 包含函数名称字符串(写了一个快速工具来按十六进制模式搜索)并且所有导入都与其他事物相关。 ollydbg 在 IL 方面也让我感到困惑,正常的 c/c++ 很好,但是(可能是附带问题)我如何在那里找到 IL 函数名称?!

预先感谢您的宝贵时间

格雷茨 WV

最佳答案

环顾四周后,解决方案很简单。是的,代码在不同的地方加载,但段偏移量是相同的。所以我使用 ILDASM 并加载了 dll,我的函数现在说:

.method public static pinvokeimpl(/* No map */) 
uint32 modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)
fn_GetBitArray(uint8* A_0,
uint8* A_1,
uint32* modopt([mscorlib]System.Runtime.CompilerServices.IsImplicitlyDereferenced) A_2) native unmanaged preservesig
{
.custom instance void [mscorlib]System.Security.SuppressUnmanagedCodeSecurityAttribute::.ctor() = ( 01 00 00 00 )
// Embedded native code
// Disassembly of native methods is not supported.
// Managed TargetRVA = 0x0003FD80
} // end of method 'Global Functions'::fn_GetBitArray

于是我去IDA,在0x1003FD80找到了,真不错^^

关于c# - 使用 IDA 或 Olly 从混合模式 dll 中检索 native 函数地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36157788/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com