{"id":103740,"date":"2020-05-11T07:00:00","date_gmt":"2020-05-11T14:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/oldnewthing\/?p=103740"},"modified":"2020-05-11T06:46:03","modified_gmt":"2020-05-11T13:46:03","slug":"20200511-00","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200511-00\/?p=103740","title":{"rendered":"Peeking inside WRL weak references"},"content":{"rendered":"<p>The Windows Runtime C++ Template Library (WRL) also provides a standard implementation of the <code>IWeakReference<\/code> interface. Here&#8217;s what it looks like:<\/p>\n<pre>0:000&gt; $ 64-bit version\r\n0:000&gt; dt Microsoft::WRL::Details::WeakReferenceImpl\r\n   +0x000 __VFN_table : Ptr64\r\n   +0x00c refcount_        : Int4B\r\n   +0x010 strongRefCount_  : Int4B\r\n   +0x018 unknown_         : Ptr64 IUnknown\r\n\r\n0:000&gt; $ 32-bit version\r\n0:000&gt; dt Microsoft::WRL::Details::WeakReferenceImpl\r\n   +0x000 __VFN_table : Ptr32\r\n   +0x008 refcount_        : Int4B\r\n   +0x00c strongRefCount_  : Int4B\r\n   +0x010 unknown_         : Ptr32 IUnknown\r\n<\/pre>\n<p>The offsets are different, but the basic idea should look familiar: It&#8217;s basically the same as <a href=\"https:\/\/devblogs.microsoft.com\/oldnewthing\/20200504-00\/?p=103725\"> C++\/CX weak references<\/a>. The offsets are different because the WRL control block is made up out of multiple base classes, so you end up with alignment padding.<\/p>\n<p>The members serve the same purpose as they did in C++\/CX, so I will defer to earlier discussion.<\/p>\n<p>You can find the implementation of WRL weak references in <code>wrl\/implements.h<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you ever have to debug one of these things.<\/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-103740","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-code"],"acf":[],"blog_post_summary":"<p>If you ever have to debug one of these things.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103740","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=103740"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/103740\/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=103740"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=103740"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=103740"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}