{"id":94586,"date":"2016-10-27T07:00:00","date_gmt":"2016-10-27T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=94586"},"modified":"2019-03-13T10:33:03","modified_gmt":"2019-03-13T17:33:03","slug":"20161027-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20161027-00\/?p=94586","title":{"rendered":"How to electrify your own fence: ProcessStrictHandleCheckPolicy"},"content":{"rendered":"<p>During process termination, if you try to enter a critical section that is owned by another thread that has already been terminated, <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20100122-00\/?p=15193\">the gates are now electrified<\/a>, and the kernel simply terminates your process. <\/p>\n<p>We saw that <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20061211-00\/?p=28763\">an invalid handle error<\/a> and <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20120530-00\/?p=7503\">an object type mismatch error<\/a> both mean that your critical section is corrupted. <\/p>\n<p>And <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20120530-00\/?p=7503#comment-988353\">as noted in a comment on the last linked article<\/a>, there is an option (enabled by default for Store apps) to electrify the fences and raise a exception if an application tries to use an invalid handle or an invalid type of handle (for example, trying to <code>Set&shy;Event<\/code> on a semaphore). Classic Win32 applications can opt into this behavior by calling <code>Set&shy;Process&shy;Mitigation&shy;Policy<\/code> and asking for the <code>Process&shy;Strict&shy;Handle&shy;Check&shy;Policy<\/code> to be turned on. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t touch that; it&#8217;s a live wire.<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25],"class_list":["post-94586","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>Don&#8217;t touch that; it&#8217;s a live wire.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=94586"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/94586\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=94586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=94586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=94586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}