我编写了一个包含 requireAdministrator list 的程序。在启用了 UAC 的 Windows 7 系统上,Windows 会弹出一个对话框,询问权限,这是应该的。效果很好。
如果用户通过右键单击我的程序并选择“以管理员身份运行”来启动我的程序,那么 Windows 7 也会弹出一个对话框询问权限。但是,在我的程序的一些更深奥的部分中,我的程序的运行方式略有不同。
那么“以管理员身份运行”和带有 requireAdministrator 的 list 之间有什么区别?任何指向描述差异的文档的链接都将不胜感激。
编辑:这是启用了 UAC。
编辑:如下所 promise 的是对我所看到的差异的完整解释。
我正在使用 EasyHook library将 DLL 注入(inject)另一个进程。当我的应用程序以“以管理员身份运行”运行时,注入(inject)的进程崩溃并且 EasyHook 返回错误“注入(inject)的汇编代码中出现未知错误”。我的 DLL 中的代码都没有机会执行;崩溃发生在此之前。 (此外,即使我将 DLL 剥离为空,也会发生崩溃)
如果我正常运行我的程序(即通过 requireAdministrator 提升),一切正常。
我的应用程序由几个不同的可执行文件组成。用户启动的进程与执行注入(inject)的进程不同。
最佳答案
根据给定的信息,两个进程之间的权限没有差异。
如果您通过应用程序 list 请求“requireAdministrator”的执行级别,您的应用程序将使用管理员的完全访问 token 启动,或者如果用户拒绝同意则根本不会启动(参见 Create and Embed an Application Manifest (UAC) 了解更多信息)。
当用户选择以管理员身份运行时,也会发生同样的情况。
唯一的区别是流程的启动方式。当您从 shell 启动可执行文件时,例如通过在资源管理器中双击或从上下文菜单中选择以管理员身份运行,shell 将调用ShellExecute 以实际开始进程执行。提升的整个过程都隐藏在这个函数里面。 Kenny Kerr 在 Windows Vista for Developers – Part 4 – User Account Control 中更详细地描述了这个过程:
ShellExecute first calls CreateProcess to attempt to create the new process. CreateProcess does all the work of checking application compatibility settings, application manifests, runtime loaders, etc. If it determines that the application requires elevation but the calling process is not elevated then CreateProcess fails with ERROR_ELEVATION_REQUIRED. ShellExecute then calls the Application Information service to handle the elevation prompt and creation of the elevated process since the calling process obviously doesn’t have the necessary permissions to perform such a task. The Application Information service ultimately calls CreateProcessAsUser with an unrestricted administrator token.
If on the other hand you want to create an elevated process regardless of what application information is available then you can specify the little-known “runas” verb with ShellExecute. This has the effect of requesting elevation regardless of what an application’s manifest and compatibility information might prescribe. The runas verb is not actually new to Windows Vista. It was available on Windows XP and Windows 2003 and was often used to create a restricted token directly from the shell. This behavior has however changed. Here is a simple example:
::ShellExecute(0, // owner window L"runas", L"C:\\Windows\\Notepad.exe", 0, // params 0, // directory SW_SHOWNORMAL);
所以本质上使用以管理员身份运行选项启动可执行文件意味着ShellExecute绕过兼容性设置、应用程序 list 等检查并直接请求提升。
Kenny Kerr 的文章还提供了使用 OpenProcessToken 函数查询当前进程 token 以获得其权限的示例代码。也许您可以使用该示例来确定您的流程提升方式没有差异。
我非常想知道您观察到哪些差异,因为我强烈怀疑它们与海拔高度有关。
最后一件事:您能否仔细检查您是否真的请求了 requireAdministrator 级别,而不是错误地只请求了 highestAvailable 级别?
关于windows - "Run as administrator"和带有 requireAdministrator 的 list 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3224804/
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我有一个模型:classItem项目有一个属性“商店”基于存储的值,我希望Item对象对特定方法具有不同的行为。Rails中是否有针对此的通用设计模式?如果方法中没有大的if-else语句,这是如何干净利落地完成的? 最佳答案 通常通过Single-TableInheritance. 关于ruby-on-rails-Rails-子类化模型的设计模式是什么?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我主要使用Ruby来执行此操作,但到目前为止我的攻击计划如下:使用gemsrdf、rdf-rdfa和rdf-microdata或mida来解析给定任何URI的数据。我认为最好映射到像schema.org这样的统一模式,例如使用这个yaml文件,它试图描述数据词汇表和opengraph到schema.org之间的转换:#SchemaXtoschema.orgconversion#data-vocabularyDV:name:namestreet-address:streetAddressregion:addressRegionlocality:addressLocalityphoto:i
为什么4.1%2返回0.0999999999999996?但是4.2%2==0.2。 最佳答案 参见此处:WhatEveryProgrammerShouldKnowAboutFloating-PointArithmetic实数是无限的。计算机使用的位数有限(今天是32位、64位)。因此计算机进行的浮点运算不能代表所有的实数。0.1是这些数字之一。请注意,这不是与Ruby相关的问题,而是与所有编程语言相关的问题,因为它来自计算机表示实数的方式。 关于ruby-为什么4.1%2使用Ruby返
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
它不等于主线程的binding,这个toplevel作用域是什么?此作用域与主线程中的binding有何不同?>ruby-e'putsTOPLEVEL_BINDING===binding'false 最佳答案 事实是,TOPLEVEL_BINDING始终引用Binding的预定义全局实例,而Kernel#binding创建的新实例>Binding每次封装当前执行上下文。在顶层,它们都包含相同的绑定(bind),但它们不是同一个对象,您无法使用==或===测试它们的绑定(bind)相等性。putsTOPLEVEL_BINDINGput