简体   繁体   English

如何比较两个可执行文件?

[英]How to compare between two executable files?

I have a file which doesn't require UAC Warning. 我有一个不需要UAC警告的文件。 I copied the file to another location using C#.NET 我使用C#.NET将文件复制到另一个位置

 File.Copy("Original.exe", "Copy.exe");

Now i see that Copy.exe require UAC warning to run under windows 7/Vista. 现在我看到Copy.exe需要在Windows 7 / Vista下运行UAC警告。

How can i compare between Original.exe and Copy.exe to see exactly what happened to the file and change it manually so that it doesn't require UAC anymore. 如何在Original.exe和Copy.exe之间进行比较,以确切了解文件发生了什么并手动更改,以便它不再需要UAC。 Which tool can i use to achieve that ? 我可以使用哪种工具来实现这一目标?

在此输入图像描述

BOTH EXECUTABLE ARE THE SAME FILE : How to know the difference between these two files ? 可执行的是同一个文件 :如何知道这两个文件之间的区别?

Windows Installer Detection Technology is the reason of such behavior. Windows Installer Detection Technology就是这种行为的原因。 There is a set of conditions which force executable file to be considered as requiring administrator privileges: 有一组条件迫使可执行文件被视为需要管理员权限:

  1. 32 bit executables 32位可执行文件
  2. Applications without a requestedExecutionLevel 没有requestedExecutionLevel的应用程序
  3. Interactive processes running as a Standard User with LUA enabled 作为标准用户运行的交互式进程启用了LUA

Before a 32 bit process is created, the following attributes are checked to determine whether it is an installer: 在创建32位进程之前,将检查以下属性以确定它是否为安装程序:

  • Filename includes keywords like "install," "setup," "update," etc. 文件名包括“安装”,“设置”,“更新”等关键字。
  • Keywords in the following Versioning Resource fields: Vendor, Company Name, Product Name, File Description, Original Filename, Internal Name, and Export Name. 以下版本控制资源字段中的关键字:供应商,公司名称,产品名称,文件描述,原始文件名,内部名称和导出名称。
  • Keywords in the side-by-side manifest embedded in the executable. 嵌入在可执行文件中的并排清单中的关键字。
  • Keywords in specific StringTable entries linked in the executable. 可执行文件中链接的特定StringTable条目中的关键字。
  • Key attributes in the RC data linked in the executable. 可执行文件中链接的RC数据中的关键属性。
  • Targeted sequences of bytes within the executable. 可执行文件中的目标字节序列。

Related MSDN article: http://technet.microsoft.com/en-us/library/cc709628%28WS.10%29.aspx 相关MSDN文章: http//technet.microsoft.com/en-us/library/cc709628%28WS.10%29.aspx

Possible solutions: 可能的解决方案:

  • If you are the author of executable, include manifest with specified requestedExecutionLevel 如果您是可执行文件的作者, requestedExecutionLevel使用指定的requestedExecutionLevel包含清单
  • If you don't have access to source code - try to add or modify manifest using appropriate utilities ( mt for example or maybe some generic resource editor) 如果您无权访问源代码 - 尝试使用适当的实用程序添加或修改清单(例如mt或者某些通用资源编辑器)
  • Avoid keywords update , install and setup in executable file name 避免在可执行文件名中updateinstallsetup关键字

Afte copying the file try to set the file's acl like that: 在复制文件后尝试设置文件的acl,如下所示:

var file = new FileInfo("copy.exe")
 var fileSecurity = file.GetAccessControl();
 fileSecurity.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null),
                                                                FileSystemRights.FullControl,
                                                                AccessControlType.Allow));
 file.SetAccessControl(fileSecurity);

You may find that the problem is to do with the location rather than the file. 您可能会发现问题与位置而不是文件有关。 Win 7 is very fussy, especially if you try and change anything under Program Files. Win 7非常繁琐,特别是如果您尝试在Program Files下更改任何内容。

Have you tried putting the original file in the new location to check if that also required UAC approval? 您是否尝试将原始文件放在新位置以检查是否还需要UAC批准?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM