Mono.Cecil提供了一种使用method.IsPInvokeImpl检查方法是否为pinvoke的方法,还为method.PInvokeInfo提供了更多信息。我怎样才能找到dll名称?
发布于 2019-01-09 21:38:43
P/Invoke方法的IL如下所示(例如,kernel32!LockFile):
.method assembly hidebysig static pinvokeimpl("kernel32.dll" lasterr winapi)
bool LockFile (
class Microsoft.Win32.SafeHandles.SafeFileHandle handle,
int32 offsetLow,
int32 offsetHigh,
int32 countLow,
int32 countHigh
) cil managed preservesig
{
}Mono.Cecil镜像PInvokeInfo类中的pinvokeimpl元数据,第一个字符串打包为ModuleReference。因此,method.PInvokeInfo.Module.Name给出了DLL/dylib名称。
https://stackoverflow.com/questions/54110832
复制相似问题