{"id":110198,"date":"2024-08-30T07:00:00","date_gmt":"2024-08-30T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=110198"},"modified":"2024-08-30T08:39:20","modified_gmt":"2024-08-30T15:39:20","slug":"20240830-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20240830-00\/?p=110198","title":{"rendered":"In the Windows kernel, what is a LUID, and what makes it loo-ey?"},"content":{"rendered":"<p>In the Windows kernel, you will see a thing called a <code>LUID<\/code>, commonly pronounced \/loo-id\/. <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/api\/ntdef\/ns-ntdef-luid\"> The kernel documentation says<\/a><\/p>\n<blockquote class=\"q\"><p>The <b>LUID<\/b> structure is an opaque structure that specifies an identifier that is guaranteed to be unique on the local machine. For more information, see the reference page for <b>LUID<\/b> in the Microsoft Windows SDK documentation.<\/p><\/blockquote>\n<p>If you go to the Windows SDK documentation, <a href=\"https:\/\/learn.microsoft.com\/windows\/win32\/api\/ntdef\/ns-ntdef-luid\"> you get<\/a><\/p>\n<blockquote class=\"q\">\n<p>Describes a local identifier for an adapter.<\/p>\n<p><b>Remarks<\/b><\/p>\n<p>This structure is used by the ID3D12Device::GetAdapterLuid and GetSharedResourceAdapterLuid methods.<\/p>\n<\/blockquote>\n<p>Somehow, the display driver folks took over the <code>LUID<\/code> documentation and made it be all about display drivers. It&#8217;s as if the file system team had taken over the <code>LARGE_INTEGER<\/code> documentation and made it say &#8220;The <code>LARGE_INTEGER<\/code> structure holds the size of a file in bytes&#8221; because the <code>Get\u00adFile\u00adSize\u00adEx<\/code> function uses the <code>LARGE_INTEGER<\/code> structure for that purpose.<\/p>\n<p>Really, a <code>LUID<\/code> is a structure that holds a 64-bit integer (broken into two 32-bit parts). The 64-bit integer is &#8220;locally unique&#8221;, in the sense that it will not match any other <code>LUID<\/code> generated from the same system until the system is rebooted.<\/p>\n<p>You can ask for a <code>LUID<\/code> to be generated for you by calling <code>Allocate\u00adLocally\u00adUnique\u00adId<\/code>.<\/p>\n<p>Since <code>LUID<\/code>s are only unique to the system, you probably shouldn&#8217;t send them to other systems (since they won&#8217;t be unique there). And since <code>LUID<\/code>s lose uniqueness when the system reboots, you probably shouldn&#8217;t save them anywhere persistent, because they won&#8217;t make sense after a reboot. The purpose of a <code>LUID<\/code> is to let the system identify things whose lifetimes do not extend beyond a reboot.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s a locally-unique ID, for a specific definition of &#8220;local&#8221;.<\/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-110198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>It&#8217;s a locally-unique ID, for a specific definition of &#8220;local&#8221;.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/110198","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=110198"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/110198\/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=110198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=110198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=110198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}