{"id":104046,"date":"2020-08-05T07:00:00","date_gmt":"2020-08-05T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=104046"},"modified":"2020-08-06T07:34:26","modified_gmt":"2020-08-06T14:34:26","slug":"20200805-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200805-00\/?p=104046","title":{"rendered":"What does it mean when it says that FORMAT_MESSAGE_ALLOCATE_BUFFER can be used in Store apps starting in Windows 10?"},"content":{"rendered":"<p>Tucked away in the documentation for the <code>FormatMessage<\/code> function is this little note:<\/p>\n<blockquote class=\"q\"><p>In previous versions of Windows, this value was not available for use when compiling Windows Store apps. As of Windows 10 this value can be used.<\/p><\/blockquote>\n<p>What does this even mean?<\/p>\n<p>And what happens if I try to use this flag in a Windows Store app that sets its minimum operating system as Windows 8?<\/p>\n<p>Okay, first of all, let&#8217;s set the context. The context is Windows Store apps; that is, apps that are submitted to the Windows Store and which run as a UWP app. These apps must pass a test known as the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/uwp\/debug-test-perf\/windows-app-certification-kit\"> Windows App Certification Kit<\/a> or just WACK for short. Passing this test as a prerequisite for being accepted by the Windows Store is a <i>policy<\/i> issue, not a technical one.<\/p>\n<p>In Windows 8, programs which used the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag were not accepted by WACK. To decrease the possibility of a program accidentally using the flag, only to discover at submission time that it was using a forbidden flag, the Windows header files checked whether they were being include by a program that intended to be a UWP app. If so, then the definition of the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag was <code>#ifdef<\/code>&#8216;d out. That way, if you tried to use the flag, you got an <i>undefined identifier<\/i> error at compile time.\u00b9<\/p>\n<p>What the text is trying to say is that the Windows Store changed their policy so that programs which use the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag will be accepted. This change in policy happened to occur at exactly the same time that Windows 10 was released.<\/p>\n<p>This was not a coincidence.<\/p>\n<p>The Windows 10 SDK came with an updated version of WACK that permitted the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag to be used. Furthermore, the Windows 10 SDK header files removed the <code>#ifdef<\/code> around the definition of the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag, so that the flag became visible.<\/p>\n<p>Can you use that flag in an app that is marked as backward compatible to Windows 8?<\/p>\n<p>Sure.<\/p>\n<p>Will it pass WACK?<\/p>\n<p>It does now.\u00b2<\/p>\n<p>What was so horrible about the <code>FORMAT_<\/code><code>MESSAGE_<\/code><code>ALLOCATE_<\/code><code>BUFFER<\/code> flag that the Windows Store disallowed it for so long? We&#8217;ll look at that <a title=\"What was so horrible about the FORMAT_MESSAGE_ALLOCATE_BUFFER flag that the Windows Store disallowed it for so long?\" href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200806-00\/?p=104048\"> next time<\/a>.<\/p>\n<p>\u00b9 Of course, there&#8217;s nothing stopping you from defining the value yourself and using it. That will get your code to compile, but you would still have to deal with WACK. The reason for removing the definition is to help you find your mistakes early, not to stop you from making mistakes altogether.<\/p>\n<p>\u00b2 The Store does not run an old version of WACK if your program was designed for an older version of Windows. It always runs the latest version of WACK regardless of your target. The Windows SDK contains the version of WACK which was current at the time the SDK was published, and that may have contributed to the confusion, making people think that the Store ran the version of WACK that matched the SDK the program used. It doesn&#8217;t. The Store always runs the latest WACK.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What happens if you use it anyway?<\/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":[2],"class_list":["post-104046","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-history"],"acf":[],"blog_post_summary":"<p>What happens if you use it anyway?<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104046","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=104046"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/104046\/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=104046"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=104046"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=104046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}