zoukankan      html  css  js  c++  java
  • Eziriz.Net.Reactor使用注意事项

    1) 保护参数配置

    image

    2) 注册表访问

    using System.Security.Permissions;
    
    [RegistryPermissionAttribute(SecurityAction.PermitOnly, All = @"HKEY_LOCAL_MACHINESOFTWAREMicrosoftJet4.0EnginesJet 4.0")]
    private static void UpdateOS32RegisterItem()
    {
     	using (RegistryKey currentKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftJet4.0EnginesJet 4.0", true))
    	{
    		currentKey.SetValue("MaxLocksPerFile", 0xF4240, RegistryValueKind.DWord);
    		currentKey.Close();
    	}
    }
    

    该种写法混淆后会出现如下的错误:

    image

    解决方法:

    添加 应用程序清单文件,在其中加入

    <?xml version="1.0" encoding="utf-8"?>
    <asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
      <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
          <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
            <!-- UAC 清单选项
                如果希望更改 Windows 用户帐户控制级别,请用以下节点之一替换 
                requestedExecutionLevel 节点。
    
            <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
            <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
            <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />
    
                如果您希望利用文件和注册表虚拟化提供
                向后兼容性,请删除 requestedExecutionLevel 节点。
            -->
            <requestedExecutionLevel level="asInvoker" uiAccess="false" />
            <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
          </requestedPrivileges>
        </security>
      </trustInfo>
    </asmv1:assembly>
    

    修改代码,如下:

    private static void UpdateOS32RegisterItem()
     {
    	System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent();
    	System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal( identity );
    	if (principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
    	{
    		using (RegistryKey currentKey = Registry.LocalMachine.OpenSubKey(@"SOFTWAREMicrosoftJet4.0EnginesJet 4.0", true))
    		{
    			currentKey.SetValue("MaxLocksPerFile", 0xF4240, RegistryValueKind.DWord);
    			currentKey.Close();
    		}
    	}
     }
    
  • 相关阅读:
    ABAP的HTTP_GET和Linux的curl
    SAP CRM点了附件的超链接后报错的处理方式
    一个JSON字符串和文件处理的命令行神器jq,windows和linux都可用
    如何在Ubuntu里安装Helm
    如何实现Windows宿主系统和虚拟机ubuntu系统文件互相访问
    如何安装Virtual Box的VBox Guest Additions扩展程序
    最简单的教程:在Ubuntu操作系统里安装Docker
    在ubuntun虚拟机里安装goLang语言编程环境
    hi35183e增加exfat文件系统的支持
    可以返回执行结果的system函数加强版本
  • 原文地址:https://www.cnblogs.com/janehlp/p/5379203.html
Copyright © 2011-2022 走看看