{"id":95856,"date":"2017-03-30T07:00:00","date_gmt":"2017-03-30T21:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/?p=95856"},"modified":"2019-03-13T01:08:55","modified_gmt":"2019-03-13T08:08:55","slug":"20170330-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20170330-00\/?p=95856","title":{"rendered":"The gradual erosion of the SEM_NOOPENFILEERRORBOX error mode"},"content":{"rendered":"<p>The <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag has a long history. <\/p>\n<p>It goes back to 16-bit Windows and <a HREF=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/\">the way modules were loaded from floppy disks<\/a>. If the loader could not find the file it needed, it prompted you to insert the disk and gave you the option to retry or cancel. The <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag lets you disable the prompt and force the system to act as if you had selected <i>Cancel<\/i>. <\/p>\n<p>The 16-bit kernel also exported a function called <code>Open&shy;File<\/code> that lets you access the routine in the module loader that tries to open a file and prompts for retries if the file isn&#8217;t found. Therefore, the <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag controlled the <code>Open&shy;File<\/code> function, too. <\/p>\n<p>Forward to 32-bit Windows NT. The Windows NT module loader doesn&#8217;t work anything at all like the 16-bit module loader. Memory management is page-based rather than segment based. Images are memory-mapped and operate on page faults rather than being manually loaded from the disk and operating on segment faults (or worse, <a HREF=\"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/20120622-00\/?p=7303\">segment reload thunks<\/a>). <\/p>\n<p>This means that the old model of prompting the user to reinsert the floppy disk makes no sense. There is never any prompting for failed module loads. The <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag has no effect for modules, which means that you won&#8217;t see any error boxes from <code>Load&shy;Library<\/code> on Windows NT. (On Windows 95, if the DLL you were trying to load had a chain of dependencies that led to a missing 16-bit DLL, then you still got the error box from the 16-bit loader.) <\/p>\n<p>This means that today, the <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag has no effect. <\/p>\n<p>Well, almost. <\/p>\n<p>Remember that <code>Open&shy;File<\/code> function? The one that let you open a file using the same retry logic as the 16-bit module loader? The function was ported to 32-bit Windows, but of course it doesn&#8217;t actually use the 16-bit module loader. It just replicates the behavior of the 16-bit module loader. <\/p>\n<p>Including the error prompt if the file cannot be found. <\/p>\n<p>So that&#8217;s where we are today. The <code>SEM_NO&shy;OPEN&shy;FILE&shy;ERROR&shy;BOX<\/code> flag has been eroded away. The only place that still respects the flag is the old <code>Open&shy;File<\/code> function, a function you probably didn&#8217;t even realize existed, and which exists only for backward compatibility with 16-bit programs. <\/p>\n<p><b>Bonus chatter<\/b>: I submitted a documentation change request to MSDN to clarify this. We&#8217;ll see which happens first: This article gets posted or the MSDN change request gets processed. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It does less and less, until it basically does nothing.<\/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,2],"class_list":["post-95856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code","tag-history"],"acf":[],"blog_post_summary":"<p>It does less and less, until it basically does nothing.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/95856","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=95856"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/95856\/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=95856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=95856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=95856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}