帮忙看看这个函数的作用HeapSetInformation!

O湛狼O 2010-09-26 11:30:39
HeapSetInformation
All applications should use the HeapSetInformation method and specify the HeapEnableTerminationOnCorruption setting to enable the terminate-on-corruption feature. Doing so ensures that heap corruptions do not go unnoticed and therefore do not introduce opportunities for security exploits. Failure codes from this call are ignored because a correct application can proceed successfully even in the unlikely event of failure.

Direct2D samples call the HeapSetInformation from the WinMain function. The following example shows a typical Direct2D WinMain function.

int WINAPI WinMain(
HINSTANCE /*hInstance*/,
HINSTANCE /*hPrevInstance*/,
LPSTR /*lpCmdLine*/,
int /*nCmdShow*/
)
{
// Ignore the return value because we want to run the program even in the
// unlikely event that HeapSetInformation fails.
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
if (SUCCEEDED(CoInitialize(NULL)))
{
{
DemoApp app;

if (SUCCEEDED(app.Initialize()))
{
app.RunMessageLoop();
}
}
CoUninitialize();
}

return 0;
}


这个函数的作用是什么啊?英文水平有限,自己翻译的意思看着很别扭。有没有人能帮忙翻译一下啊。或者直接告诉我这个函数的作用啊。谢谢了。
...全文
591 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Rainqin123 2010-09-27
  • 打赏
  • 举报
回复
就是为了安全,为了使heap corruption noticed(被注意到,能够被发现)
franklinkkk 2010-09-27
  • 打赏
  • 举报
回复
啊,看不懂,看来额是菜鸟也
O湛狼O 2010-09-27
  • 打赏
  • 举报
回复
谢谢了。
pengzhixi 2010-09-26
  • 打赏
  • 举报
回复
应该是降低碎片的吧。
ahao 2010-09-26
  • 打赏
  • 举报
回复
所有程序都应该使用HeapSetInformation这个函数并传递HeapEnableTerminationOnCorruption这个选项,让 terminate-on-corruption 这个功能起作用。
这么做可以确保堆破坏的情况能被注意到,这样就不会造成安全漏洞。这个调用返回的错误码被忽略是因为正确编写的程序能继续正常运行,即使是在这种很少见的失败情况下。
ayw215 2010-09-26
  • 打赏
  • 举报
回复
加上下面的这句话,会让开发人员能够尽早的发现Heap Corruption。

(void)HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL,0);

http://neilwang.blog.163.com/blog/static/1042176200772134840920/

64,643

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧