[c#]如何指定/GS,c#应用程序的选项?
如您所知,/GS 是 Visual C++ 编译器或链接器选项。
我可以在 C# 编译器或链接器中指定 /GS 吗?
这些标志在 C# 应用程序中默认启用吗?
[编辑]:更改问题内容:
2a。是否启用了这些功能(通过 Visual C++ 中的这些编译器选项) 在 C# 应用程序中默认情况下?
有没有办法找出 .exe/.dll 文件是否是使用这些标志构建的?
有没有办法
提前致谢。
As you know, /GS are Visual C++ Compiler or Linker Options.
Can i Specify /GS in c# compiler or linker?
Are these flags enabled by default in c# applications?
[Edit]: change the question contents:
2a. Are these features enabled (by these compiler options as in Visual C++)
by default in c# applications?Is there a way to find out wheather a .exe/.dll file is build with these flags?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
C# 中不存在这些选项,因为 C# 生成托管代码,而 C++ 生成本机代码(机器语言代码)。托管代码被称为“可验证”,因为它具有比 C/C++ 更严格的检查,并且以 C++ 和本机代码无法做到的方式强制执行类型安全。 (这些检查与用 C++/CLI 编写的托管代码无关)。
这很大程度上是因为本机代码直接在硬件上运行,而托管代码在 .NET 运行时 (CLR) 内运行。
请允许我一一检查选项
None of those options exist in C# because C# generates managed code and C++ generates native code (machine language code). Managed code is called 'verifiable' because it has much stricter checking than C/C++ and enforces type safety in ways that C++ and native code cannot. (These checks are irrelevant for managed code written in C++/CLI).
Much of this is due to the fact that that native code runs directly on the hardware and managed code runs inside the .NET run time (CLR).
Allow me to go over the options one by one
我猜您尝试进行代码审核/运行静态分析工具以确保 正在遵循安全/SDL 最佳实践。如果您继续阅读...
有一个名为 Binscope 的工具,可用于检查您的本机/C++ 二进制文件是否使用 /GS、/SafeSEH、/NXCOMPAT 和 /DYNAMICBASE 进行编译。这些是 C++ 特定选项,使攻击者更难利用缓冲区溢出。 (Binscope 还检查其他一些内容)
Binscope 在 C#/托管二进制文件中检查的唯一内容是它们是否使用强名称。与 C# 的 binscope 最接近的是 FxCop它将详细说明托管 .Net 代码中的一系列潜在问题。为了安全起见,请修复 FxCop 生成的所有安全警告,然后您就可以开始了。
/analyze 标志使 Visual Studio 对您的本机代码进行一些静态分析,并让您知道它是否发现任何可疑内容。 C#/.Net 的等效项是 FxCop 的安全部分。
I'm guessing your trying to do a code audit/run static analysis tools to ensure that security/SDL best practices are being followed. If you are keep reading...
There is a tool called Binscope that can be used to check that your native/C++ binaries are compiled with the /GS, /SafeSEH, /NXCOMPAT, and /DYNAMICBASE. These are C++ specific options that make it harder for attackers to exploit buffer overruns. (Binscope also checks for a few other things)
The only thing Binscope checks for in C#/managed binaries is if they are using strong names. The closest thing to binscope for C# is FxCop which will detail a bunch of potential issues in your managed .Net code. For security, fix any security warnings that FxCop produces and you are on your way.
The /analyze flag causes Visual Studio to do some static analysis of your native code and lets you know if it finds anything suspicious. The C#/.Net equivalent is the security part of FxCop.