C# “不支持的单声道函数”;System.Security.Principal.WindowsIdentity.GetCurrent(bool)";使用UNITY3D和MATLAB';mwsarray.DLL

C# “不支持的单声道函数”;System.Security.Principal.WindowsIdentity.GetCurrent(bool)";使用UNITY3D和MATLAB';mwsarray.DLL,c#,matlab,mono,unity3d,windows-identity,C#,Matlab,Mono,Unity3d,Windows Identity,问题始于对一个还不受支持的mono函数的函数调用。调用来自一个名为MWARRY.DLL(.net版本2.x)的关闭matlab DLL,该DLL通常与VS.net一起使用,如果使用.net 3.5,则该DLL有效 函数为:[mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent(bool) 我可以想出一些可能的解决方案,但我不确定如何做到: 反编译dll并用类似的工作函数替换字节码:[mscorlib]System.Secur

问题始于对一个还不受支持的mono函数的函数调用。调用来自一个名为MWARRY.DLL(.net版本2.x)的关闭matlab DLL,该DLL通常与VS.net一起使用,如果使用.net 3.5,则该DLL有效

函数为:[mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent(bool)

我可以想出一些可能的解决方案,但我不确定如何做到:

  • 反编译dll并用类似的工作函数替换字节码:[mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent() 请注意,没有向函数传递布尔值
  • 编译mono并自己编写函数
  • 使用旧版本的MWARRY.DLL(找不到,但可能仍使用相同的代码)
  • 对于反编译,我使用了IDA。 我在下面找到了调用第一个函数CIL+HEX的位置

    loc_38B1:    
    ldsfld  native     
    int [mscorlib]System.IntPtr::Zero   
    stloc.s 7    
    ldc.i4.0
    stloc.s 8
    ldc.i4.1
    stloc.s 9
    ldc.i4.1
    call    class [mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent(bool)
    stloc.s 0xA
    call    void [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::PrepareConstrainedRegions()
      .try {
    ldc.i4.0
    stloc.s 0xB
    br      loc_3982
    
    调用和stloc命令的十六进制:

    28 96 00 00 0A 
    
    loc_3AE:
    call    class [mscorlib]System.Security.Principal.WindowsIdentity [mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent()
    callvirt class System.String [mscorlib]System.Security.Principal.WindowsIdentity::get_Name()
    stloc.s 8
    ldc.i4.1
    
    我还编译和反编译了我自己的dll,调用这两个函数只是为了查看另一个命令在字节码中的外观:

    28 96 00 00 0A 
    
    loc_3AE:
    call    class [mscorlib]System.Security.Principal.WindowsIdentity [mscorlib]System.Security.Principal.WindowsIdentity::GetCurrent()
    callvirt class System.String [mscorlib]System.Security.Principal.WindowsIdentity::get_Name()
    stloc.s 8
    ldc.i4.1
    
    自定义编译/反编译行的十六进制粗体:

    28  00 00 0A 6F 1B 00 00 0A  13 08 17
    
    我想知道是否有人对建议的解决方案路径有想法,或者有什么想法?

    这已经解决了

    使用.net reflector提取mwarray.dll可以从visual studio内部更改代码


    在第330行附近的MCR()类中,有一个对getcurrent()的调用。替换为=null

    Mono程序集(MSCORLIB)很可能是经过签名的,因此它们不能被篡改(排除选项1)。此外,依赖为不同环境编译的代码可能会导致其他问题(如果代码使用5个以上未实现的Mono方法怎么办?如果您在2个月后发现这一点怎么办?依赖此功能真的值得吗?)我将修复所有5个问题。如果我不先尝试,我永远也不会知道。我不需要更改mscorelib,我只需要更改mwarray.dll。我的观点是,在这种特定情况下,您依赖的库不是非常健壮。也许您应该考虑从这个库中需要哪些功能,并在其他库中查找它。移植我的代码太多了。它功能强大,速度非常快。