Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
What I got:
a mixed mode C# dll, that has C# code which in turn calls a native method in the same dll, that im interested in
The calling:
int num3 = <Module>.fn_GetBitArray((byte*)(&$ArrayType$$$BY0DC@E), (byte*)(&$ArrayType$$$BY05E2), ref nHardwareType);
as IL
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) )
with a definition like this (ILSpy)
// <Module>
[SuppressUnmanagedCodeSecurity]
[MethodImpl(MethodImplOptions.Unmanaged | MethodImplOptions.PreserveSig)]
public unsafe static extern uint fn_GetBitArray(byte*, byte*, uint*);
Im not sure how to continue from here. When I load this in IDA, I can choose .NET loader, where I can see all the C# code and the call, but not the offset of the "external" function, and then I can choose x86 mode, but all function are numbered through (sub_XXXXXXXX), so I NEED the offset.
Question:
How can I find out, how exactly this call is resolved and retrieve the destination function?
PS: im pretty sure its really not imported, because no other dll contains the function name string (wrote a quick tool to search by hex patterns) and all imports are related to other things. also ollydbg confuses the hell out of me in respect to IL, normal c/c++ fine, but (maybe as side question) how do I find the IL function names there?!
thanks in advance for your time
greetz WV
–
–
after looking around the solution was easy. yes, the code gets loaded at different places, but the segment offset is the same. so I used ILDASM and loaded the dll, my function now said:
.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
so I went to IDA and found it at 0x1003FD80, how nice^^
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.