附加受保护文件时出现问题 [英] Problem in appending a protected file

查看:43
本文介绍了附加受保护文件时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主席先生,即使我尝试以管理员身份运行,我也会在添加受保护文件时出现问题。它只是寻找NULL值。

Sir,I have a problem in appending a protected file even when I tried to run as an administrator.It simply goes for the NULL value.

#include<errno.h>
FILE  *appender;
appender = fopen("anySystemFile","a");
if(appender==NULL)
{
     int errorNumber;
     errorNumber = errno;
     fprintf(stderr, "Error number: %d\n", errno);
}
else
{
   fprintf(appender,"Suceeded...");
}
fclose(appender);



受保护的文件只是一个没有任何扩展名的文件,可以通过此代码读取和追加。但是,当我尝试使用时,程序运行正常附加一个非系统文件。我错过了什么或者我该怎么做才能让我的程序附加系统文件。



这是我的清单文件代码:


The protected file is just a file without any extension which can be read and appended by this code.But, the program works fine when I have tried to append a non system file.Have I missed anything or what should I do in order to make my program to append the system file.

Here is my manifest file code:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity version="1.0.0.0"

     processorArchitecture="X86"

     name="appender"

     type="console"/> 
  <description>Description of your application</description> 
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel

          level="requireAdministrator"

          uiAccess="false"/>
        </requestedPrivileges>
       </security>
  </trustInfo>



我还有什么遗漏?

输出:

错误编号:13
请帮助我这个先生。


Still have I missed anything?
output:
Error number: 13
Kindly help me with this Sir.

推荐答案

主机文件不像任何随机文件。

Windows保护它免受修改,你需要以管理员身份运行你的程序才能改变事物。

你的AV也在积极保护文件所以你也必须关闭你的AV写在这个文件。



如果您的程序没有其他文件主机,你可以利弊这是好的。

主机是恶意软件攻击的目标,所以它也受到操作系统和AV的特殊保护,细节因版本而异。
Hosts file is not like any random file.
Windows protects it against modification, you need to run your program as supervisor in order to change things.
Your AV is also actively protecting the file so your also have to shutdown you AV to write in this file.

If your program is OK with another files than Hosts, you can consider it is OK.
Hosts is the target of attack by malwares, so it have also special protection by OS and AV, details varying with versions.


您是否以管理员身份运行Visual Studio?你应该是。



您是否在项目中添加了清单?你应该。谷歌的清单管理员权限,以找出要放入其中的内容。



如果您的代码在写入文件时抛出异常,则意味着您的代码不是使用管理员权限运行。
Are you running Visual Studio as Administrator? You should be.

Did you add a manifest to your project? You should. Google for "manifest administrator privileges" to find out what to put in it.

If your code is throwing an exception on writing to the file it means your code is not running with administrator privs.


您通常无权在该位置写入;请参阅 https://msdn.microsoft.com/en-us/library/bb727008.aspx [ ^ ]。
You do not normally have permission to write in that location; see https://msdn.microsoft.com/en-us/library/bb727008.aspx[^].


这篇关于附加受保护文件时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆