The Old New Thing

Practical development throughout the evolution of Windows.

Latest posts

All the other cool languages have <CODE>try</CODE>…<CODE>finally</CODE>. C++ says “We have <CODE>try</CODE>…<CODE>finally</CODE> at home.”
Dec 22, 2025
Post comments count 3
Post likes count 3

All the other cool languages have <CODE>try</CODE>…<CODE>finally</CODE>. C++ says “We have <CODE>try</CODE>…<CODE>finally</CODE> at home.”

Raymond Chen
Raymond Chen

The destructor serves as the "finally".

A shortcut gives me a weird path for a program shortcut that doesn’t point to the executable, so what is it?
Dec 19, 2025
Post comments count 8
Post likes count 2

A shortcut gives me a weird path for a program shortcut that doesn’t point to the executable, so what is it?

Raymond Chen
Raymond Chen

It's a placeholder because the shortcut is to an MSI application.

Concluding thoughts on our deep dive into Windows clipboard text conversion
Dec 18, 2025
Post comments count 9
Post likes count 3

Concluding thoughts on our deep dive into Windows clipboard text conversion

Raymond Chen
Raymond Chen

Stick to Unicode and you'll be fine.

Deducing the consequences of Windows clipboard text formats on UTF-8
Dec 17, 2025
Post comments count 3
Post likes count 3

Deducing the consequences of Windows clipboard text formats on UTF-8

Raymond Chen
Raymond Chen

Working out the implications.

Why is the Windows clipboard taking the scenic route when converting from <CODE>CF_<WBR>TEXT</CODE> to <CODE>CF_<WBR>OEM­TEXT</CODE>?
Dec 16, 2025
Post comments count 3
Post likes count 1

Why is the Windows clipboard taking the scenic route when converting from <CODE>CF_<WBR>TEXT</CODE> to <CODE>CF_<WBR>OEM­TEXT</CODE>?

Raymond Chen
Raymond Chen

Something is forcing it down an alternate path.

Misunderstanding what the Cricket Celebration Bowl is
Dec 15, 2025
Post comments count 3
Post likes count 1

Misunderstanding what the Cricket Celebration Bowl is

Raymond Chen
Raymond Chen

Apparently, not a bowl of crickets.

The Windows clipboard automatic text conversion algorithm is path-dependent
Dec 15, 2025
Post comments count 1
Post likes count 3

The Windows clipboard automatic text conversion algorithm is path-dependent

Raymond Chen
Raymond Chen

When the journey is not half of the fun.

Resolving an ambiguity in the Windows clipboard automated text conversion table
Dec 12, 2025
Post comments count 8
Post likes count 2

Resolving an ambiguity in the Windows clipboard automated text conversion table

Raymond Chen
Raymond Chen

Who goes first?

Studying the various locale mismatch scenarios in Windows clipboard text format synthesis
Dec 11, 2025
Post comments count 9
Post likes count 2

Studying the various locale mismatch scenarios in Windows clipboard text format synthesis

Raymond Chen
Raymond Chen

If they don't match, then the 8-bit strings are basically broken already.

How does Windows synthesize the <CODE>CF_<WBR>LOCALE</CODE> clipboard format?
Dec 10, 2025
Post comments count 1
Post likes count 1

How does Windows synthesize the <CODE>CF_<WBR>LOCALE</CODE> clipboard format?

Raymond Chen
Raymond Chen

Getting it from a place that might have been obvious in the past, but maybe not today.

How does Windows synthesize <CODE>CF_<WBR>UNICODE­TEXT</CODE> from <CODE>CF_<WBR>TEXT</CODE> and vice versa?
Dec 9, 2025
Post comments count 2
Post likes count 2

How does Windows synthesize <CODE>CF_<WBR>UNICODE­TEXT</CODE> from <CODE>CF_<WBR>TEXT</CODE> and vice versa?

Raymond Chen
Raymond Chen

Let's ask the locale.

How does Windows synthesize <CODE>CF_<WBR>OEM­TEXT</CODE> from <CODE>CF_<WBR>TEXT</CODE> and vice versa?
Dec 8, 2025
Post comments count 11
Post likes count 3

How does Windows synthesize <CODE>CF_<WBR>OEM­TEXT</CODE> from <CODE>CF_<WBR>TEXT</CODE> and vice versa?

Raymond Chen
Raymond Chen

Starting with the easy case, or at least it looks easy.

How can my process read its own standard output?
Dec 5, 2025
Post comments count 11
Post likes count 3

How can my process read its own standard output?

Raymond Chen
Raymond Chen

You'll have to trick yourself before anybody notices, which may not be possible.

How can I read the standard output of an already-running process?
Dec 4, 2025
Post comments count 5
Post likes count 1

How can I read the standard output of an already-running process?

Raymond Chen
Raymond Chen

You can't. You'll have to do it before the process starts.

How do I check whether the user has permission to create files in a directory?
Dec 3, 2025
Post comments count 6
Post likes count 5

How do I check whether the user has permission to create files in a directory?

Raymond Chen
Raymond Chen

Request the directory security attributes that correspond to your proposed operation.

Microspeak: Big rocks
Dec 2, 2025
Post comments count 3
Post likes count 2

Microspeak: Big rocks

Raymond Chen
Raymond Chen

The large obstacles.

How do I get my edit control text to be autoselected when I choose it to be the default focus in my dialog?
Dec 1, 2025
Post comments count 0
Post likes count 2

How do I get my edit control text to be autoselected when I choose it to be the default focus in my dialog?

Raymond Chen
Raymond Chen

Remembering some old APIs.

How can I have a Win32 drop-down combo box with a read-only edit control?
Nov 28, 2025
Post comments count 8
Post likes count 5

How can I have a Win32 drop-down combo box with a read-only edit control?

Raymond Chen
Raymond Chen

You can ask for its handle and mark it read-only.

Message-only windows are for messaging, not as a convenient victim for hosting UI
Nov 27, 2025
Post comments count 3
Post likes count 5

Message-only windows are for messaging, not as a convenient victim for hosting UI

Raymond Chen
Raymond Chen

If you want to host UI, use a real window (possibly hidden).

At what point in the Windows development cycle is it too late to change the text of a translatable string?
Nov 26, 2025
Post comments count 9
Post likes count 2

At what point in the Windows development cycle is it too late to change the text of a translatable string?

Raymond Chen
Raymond Chen

The translation team sets the deadline.

The apocryphal origins of the Hot Dog Stand color scheme
Nov 25, 2025
Post comments count 7
Post likes count 5

The apocryphal origins of the Hot Dog Stand color scheme

Raymond Chen
Raymond Chen

Challenge accepted.

Why does XAML break down when I have an element that is half a billion pixels tall?
Nov 24, 2025
Post comments count 5
Post likes count 4

Why does XAML break down when I have an element that is half a billion pixels tall?

Raymond Chen
Raymond Chen

You've far exceeded the design goals and have even exceeded the expressive ability of a float.

Maybe somebody can explain to me how weak references solve the ODR problem
Nov 21, 2025
Post comments count 6
Post likes count 2

Maybe somebody can explain to me how weak references solve the ODR problem

Raymond Chen
Raymond Chen

I don't see it.

In the commit-on-demand pattern, what happens if an access violation straddles multiple pages?
Nov 20, 2025
Post comments count 11
Post likes count 2

In the commit-on-demand pattern, what happens if an access violation straddles multiple pages?

Raymond Chen
Raymond Chen

The access violation exceptions will continue until commit improves.

Is <CODE>Write­Process­Memory</CODE> faster than shared memory for transferring data between two processes?
Nov 19, 2025
Post comments count 3
Post likes count 8

Is <CODE>Write­Process­Memory</CODE> faster than shared memory for transferring data between two processes?

Raymond Chen
Raymond Chen

Shared memory is the copy-free solution.

Microspeak: Little-r
Nov 18, 2025
Post comments count 1
Post likes count 5

Microspeak: Little-r

Raymond Chen
Raymond Chen

Harkening back to a very old mail program.

How can I detect that Windows is running in S-Mode, redux
Nov 17, 2025
Post comments count 21
Post likes count 3

How can I detect that Windows is running in S-Mode, redux

Raymond Chen
Raymond Chen

Doing it on hard mode.

I can use <CODE>WM_<WBR>COPY<WBR>DATA</CODE> to send a block of data to another window, but how does it send data back?
Nov 14, 2025
Post comments count 9
Post likes count 3

I can use <CODE>WM_<WBR>COPY<WBR>DATA</CODE> to send a block of data to another window, but how does it send data back?

Raymond Chen
Raymond Chen

They can send it back with their own <CODE>WM_<WBR>COPY­DATA</CODE> message, or they can put it in an agreed-upon shared location.

Could we use CTAD to simplify the use of WRL’s Callback function?
Nov 13, 2025
Post comments count 5
Post likes count 2

Could we use CTAD to simplify the use of WRL’s Callback function?

Raymond Chen
Raymond Chen

Not directly, but maybe indirectly.

Non-recursively deleting a binary tree in constant space: Rotating the tree
Nov 12, 2025
Post comments count 5
Post likes count 5

Non-recursively deleting a binary tree in constant space: Rotating the tree

Raymond Chen
Raymond Chen

Preserving in-order while linearizing.

Behind the scenes on how Windows 95 application compatibility patched broken programs
Nov 11, 2025
Post comments count 7
Post likes count 5

Behind the scenes on how Windows 95 application compatibility patched broken programs

Raymond Chen
Raymond Chen

Replacing bytes with the greatest of care.

How did Windows 3.1 distinguish two different programs that happened to share the same executable name?
Nov 10, 2025
Post comments count 0
Post likes count 2

How did Windows 3.1 distinguish two different programs that happened to share the same executable name?

Raymond Chen
Raymond Chen

The trouble with disambiguation.

Non-recursively deleting a binary tree in constant space: Restructuring the tree
Nov 7, 2025
Post comments count 2
Post likes count 1

Non-recursively deleting a binary tree in constant space: Restructuring the tree

Raymond Chen
Raymond Chen

Changing the tree structure to make it easier to delete.

Non-recursively deleting a binary tree in constant space: Synthesizing the parent pointer
Nov 6, 2025
Post comments count 3
Post likes count 1

Non-recursively deleting a binary tree in constant space: Synthesizing the parent pointer

Raymond Chen
Raymond Chen

Making one as you go.

Non-recursively deleting a binary tree in constant space: Traversal with parent pointers
Nov 5, 2025
Post comments count 9
Post likes count 2

Non-recursively deleting a binary tree in constant space: Traversal with parent pointers

Raymond Chen
Raymond Chen

First assume that you have a parent pointer.

The Microsoft SoftCard for the Apple II: Getting two processors to share the same memory
Nov 4, 2025
Post comments count 3
Post likes count 3

The Microsoft SoftCard for the Apple II: Getting two processors to share the same memory

Raymond Chen
Raymond Chen

Reportedly Microsoft's first hardware product.

Why does <CODE>SHFormat­Date­Time</CODE> take an unaligned <CODE>FILETIME</CODE>?
Nov 3, 2025
Post comments count 3
Post likes count 2

Why does <CODE>SHFormat­Date­Time</CODE> take an unaligned <CODE>FILETIME</CODE>?

Raymond Chen
Raymond Chen

Designed for its original use case.

Microspeak: turn into a pumpkin
Oct 31, 2025
Post comments count 4
Post likes count 1

Microspeak: turn into a pumpkin

Raymond Chen
Raymond Chen

To disappear, such as for the year-end holidays.

Trying to build a XAML tree in code throws a “No installed components were detected” exception
Oct 30, 2025
Post comments count 8
Post likes count 3

Trying to build a XAML tree in code throws a “No installed components were detected” exception

Raymond Chen
Raymond Chen

An unfortunate error code collision, but the explanatory text leads the way.

What to do when you have a crash in the runtime control flow guard check
Oct 29, 2025
Post comments count 2
Post likes count 2

What to do when you have a crash in the runtime control flow guard check

Raymond Chen
Raymond Chen

You don't have to understand it, but you should be able to extract data from it.

How did the Windows 95 user interface code get brought to the Windows NT code base?
Oct 28, 2025
Post comments count 17
Post likes count 9

How did the Windows 95 user interface code get brought to the Windows NT code base?

Raymond Chen
Raymond Chen

Ported bit by bit.

Dubious security vulnerability: Denial of service by loading a very large file
Oct 27, 2025
Post comments count 11
Post likes count 5

Dubious security vulnerability: Denial of service by loading a very large file

Raymond Chen
Raymond Chen

I mean, it's what you asked it to do.

The early history of the Windows Runtime PropertyValue and why there is a PropertyType.Inspectable that is never used
Oct 24, 2025
Post comments count 0
Post likes count 2

The early history of the Windows Runtime PropertyValue and why there is a PropertyType.Inspectable that is never used

Raymond Chen
Raymond Chen

It used to be there because PropertyValue started out as the fundamental variant type before shifting focus to being the fundamental boxed type.

Windows Runtime design principle: Properties can be set in any order
Oct 23, 2025
Post comments count 0
Post likes count 3

Windows Runtime design principle: Properties can be set in any order

Raymond Chen
Raymond Chen

If all you're doing is setting properties, you can do it any way you like.

What makes <CODE>cheap_<WBR>steady_<WBR>clock</CODE> faster than <CODE>std::<WBR>chrono::<WBR>high_<WBR>resolution_<WBR>clock</CODE>?
Oct 22, 2025
Post comments count 7
Post likes count 3

What makes <CODE>cheap_<WBR>steady_<WBR>clock</CODE> faster than <CODE>std::<WBR>chrono::<WBR>high_<WBR>resolution_<WBR>clock</CODE>?

Raymond Chen
Raymond Chen

It's quite a bit faster, though maybe you don't care.

Microspeak: The hockey stick on wheels
Oct 21, 2025
Post comments count 1
Post likes count 2

Microspeak: The hockey stick on wheels

Raymond Chen
Raymond Chen

You're always a year away.

What about the icons in pifmgr.dll?
Oct 20, 2025
Post comments count 15
Post likes count 6

What about the icons in pifmgr.dll?

Raymond Chen
Raymond Chen

Just for fun.

Using RAII to remedy a defect where not all code paths performed required exit actions, follow-up
Oct 17, 2025
Post comments count 2
Post likes count 2

Using RAII to remedy a defect where not all code paths performed required exit actions, follow-up

Raymond Chen
Raymond Chen

If the callback requires copyability.

Using RAII to remedy a defect where not all code paths performed required exit actions
Oct 16, 2025
Post comments count 9
Post likes count 5

Using RAII to remedy a defect where not all code paths performed required exit actions

Raymond Chen
Raymond Chen

Passing the obligation onward.

Why can you increment a reference count with relaxed semantics, but you have to decrement with release semantics?
Oct 15, 2025
Post comments count 9
Post likes count 4

Why can you increment a reference count with relaxed semantics, but you have to decrement with release semantics?

Raymond Chen
Raymond Chen

It's more important to clean up when you leave.

I remember taking a screen shot of a video, and when I opened it in Paint, the video was playing in it! What witchcraft is this?
Oct 14, 2025
Post comments count 12
Post likes count 6

I remember taking a screen shot of a video, and when I opened it in Paint, the video was playing in it! What witchcraft is this?

Raymond Chen
Raymond Chen

You copied the green screen.

API design principle: Don’t tempt people to divide by zero
Oct 13, 2025
Post comments count 4
Post likes count 3

API design principle: Don’t tempt people to divide by zero

Raymond Chen
Raymond Chen

Remove it from the equation.

The self-assignment principle for Windows Runtime properties: Don’t change behavior based on whether a property has been written to
Oct 10, 2025
Post comments count 5
Post likes count 2

The self-assignment principle for Windows Runtime properties: Don’t change behavior based on whether a property has been written to

Raymond Chen
Raymond Chen

The fact that a property has been set does not by itself trigger functionality.

The self-assignment principle for Windows Runtime properties applies to default values
Oct 9, 2025
Post comments count 4
Post likes count 2

The self-assignment principle for Windows Runtime properties applies to default values

Raymond Chen
Raymond Chen

The default value must be legal.

Windows Runtime API design principles around read-write properties: Idempotence and self-assignment
Oct 8, 2025
Post comments count 7
Post likes count 2

Windows Runtime API design principles around read-write properties: Idempotence and self-assignment

Raymond Chen
Raymond Chen

Setting it to the value it already has is not a crime.

Remembering the end of support for VRML in Internet Explorer
Oct 7, 2025
Post comments count 6
Post likes count 2

Remembering the end of support for VRML in Internet Explorer

Raymond Chen
Raymond Chen

No one left standing.

Code comments should apply to the state of the system at the point the comment “executes”
Oct 6, 2025
Post comments count 10
Post likes count 3

Code comments should apply to the state of the system at the point the comment “executes”

Raymond Chen
Raymond Chen

Putting them in the flow.

Can we get weak functions for static linking? The Visual C++ compiler says “We have weak functions at home”
Oct 3, 2025
Post comments count 2
Post likes count 2

Can we get weak functions for static linking? The Visual C++ compiler says “We have weak functions at home”

Raymond Chen
Raymond Chen

It's already there, just under a different paradigm.

The problem with inferring from a function call operator is that there may be more than one
Oct 2, 2025
Post comments count 0
Post likes count 1

The problem with inferring from a function call operator is that there may be more than one

Raymond Chen
Raymond Chen

<CODE>auto</CODE> parameters make this easy to write, particularly for lambdas.

How do I convert a <CODE>FILETIME</CODE> to a C++ clock like <CODE>std::system_clock</CODE> or <CODE>winrt::clock</CODE>?
Oct 1, 2025
Post comments count 1
Post likes count 3

How do I convert a <CODE>FILETIME</CODE> to a C++ clock like <CODE>std::system_clock</CODE> or <CODE>winrt::clock</CODE>?

Raymond Chen
Raymond Chen

The <CODE>winrt::clock</CODE> has a conversion for you.

Microspeak: Convicted
Sep 30, 2025
Post comments count 9
Post likes count 1

Microspeak: Convicted

Raymond Chen
Raymond Chen

False backformation.

How can I enumerate the overflow icons in the Notification Area without showing them?
Sep 29, 2025
Post comments count 1
Post likes count 3

How can I enumerate the overflow icons in the Notification Area without showing them?

Raymond Chen
Raymond Chen

If they aren't shown, then they aren't automatable, so there's no requirement that they exist in the UI automation tree.

Why didn’t Windows 95 setup install a miniature Windows 95 so that it could be written as a 32-bit program?
Sep 26, 2025
Post comments count 9
Post likes count 6

Why didn’t Windows 95 setup install a miniature Windows 95 so that it could be written as a 32-bit program?

Raymond Chen
Raymond Chen

Getting to the GUI quickly, and rebooting only once.

Samples note: Use comments to describe what code does, not what you wish the code would do
Sep 25, 2025
Post comments count 8
Post likes count 4

Samples note: Use comments to describe what code does, not what you wish the code would do

Raymond Chen
Raymond Chen

Comments explain the code. They are not substitutes for the code.

Why is Windows still tinkering with critical sections?
Sep 24, 2025
Post comments count 13
Post likes count 8

Why is Windows still tinkering with critical sections?

Raymond Chen
Raymond Chen

The critical section may be an old dog, but it's still learning new tricks.

Another lesson learned from the Windows 98 on-stage USB blue screen
Sep 23, 2025
Post comments count 2
Post likes count 1

Another lesson learned from the Windows 98 on-stage USB blue screen

Raymond Chen
Raymond Chen

Test before using.

Why was Windows 3.0’s WinHelp called an online help system when it ran offline?
Sep 22, 2025
Post comments count 11
Post likes count 4

Why was Windows 3.0’s WinHelp called an online help system when it ran offline?

Raymond Chen
Raymond Chen

It was online in a different sense.

Learning to read C++ compiler errors: Not a legal base class
Sep 19, 2025
Post comments count 1
Post likes count 1

Learning to read C++ compiler errors: Not a legal base class

Raymond Chen
Raymond Chen

What would make it an illegal base class?

Can I close a duplicate handle while I’m waiting on the original?
Sep 18, 2025
Post comments count 6
Post likes count 2

Can I close a duplicate handle while I’m waiting on the original?

Raymond Chen
Raymond Chen

That's fine, since you're not closing the handle that you're waiting on.

How can I get my shell thumbnail extractors to run in the same process?
Sep 17, 2025
Post comments count 1
Post likes count 2

How can I get my shell thumbnail extractors to run in the same process?

Raymond Chen
Raymond Chen

Adding another level of indirection.

Translating the <CODE>STATUS_<WBR>STACK_<WBR>BUFFER_<WBR>OVERRUN</CODE> status code into customer-ready text
Sep 16, 2025
Post comments count 7
Post likes count 3

Translating the <CODE>STATUS_<WBR>STACK_<WBR>BUFFER_<WBR>OVERRUN</CODE> status code into customer-ready text

Raymond Chen
Raymond Chen

Reducing the level of alarm.

Why is the name of the Microsoft Wireless Notebook Presenter Mouse 8000 hard-coded into the Bluetooth drivers?
Sep 15, 2025
Post comments count 14
Post likes count 9

Why is the name of the Microsoft Wireless Notebook Presenter Mouse 8000 hard-coded into the Bluetooth drivers?

Raymond Chen
Raymond Chen

Is it some sort of favoritism?

How can I convert a third party in-process server so it runs in the COM surrogate?
Sep 12, 2025
Post comments count 4
Post likes count 5

How can I convert a third party in-process server so it runs in the COM surrogate?

Raymond Chen
Raymond Chen

You can put your own object in the surrogate first.

Why can’t <CODE>std::apply</CODE> figure out which overload I intend to use? Only one of then will work!
Sep 11, 2025
Post comments count 4
Post likes count 1

Why can’t <CODE>std::apply</CODE> figure out which overload I intend to use? Only one of then will work!

Raymond Chen
Raymond Chen

The overload resolution happens before the compiler knows what it's going to be used for.

The documentation says that CompanyName version information is required, but my program seems to work without it, so how required is it?
Sep 10, 2025
Post comments count 7
Post likes count 3

The documentation says that CompanyName version information is required, but my program seems to work without it, so how required is it?

Raymond Chen
Raymond Chen

It's more of a "Very strongly recommended" than a "Required".

A suggestion to people who assign nicknames to meeting rooms
Sep 9, 2025
Post comments count 11
Post likes count 3

A suggestion to people who assign nicknames to meeting rooms

Raymond Chen
Raymond Chen

Lean into the pattern. Don't try to cross it up.

Why didn’t Windows 95 simply special-case the laptops that locked up when it executed the <CODE>HLT</CODE> instruction?
Sep 8, 2025
Post comments count 15
Post likes count 1

Why didn’t Windows 95 simply special-case the laptops that locked up when it executed the <CODE>HLT</CODE> instruction?

Raymond Chen
Raymond Chen

The catastrophic risk of bricking a computer.

The case of the crash on a null pointer even though we checked it for null
Sep 5, 2025
Post comments count 2
Post likes count 1

The case of the crash on a null pointer even though we checked it for null

Raymond Chen
Raymond Chen

Understanding what you're checking.

How can I write a C++/WinRT <CODE>IAsyncOperation<T></CODE> where <CODE>T</CODE> is not a Windows Runtime type?, part 2
Sep 4, 2025
Post comments count 1
Post likes count 3

How can I write a C++/WinRT <CODE>IAsyncOperation<T></CODE> where <CODE>T</CODE> is not a Windows Runtime type?, part 2

Raymond Chen
Raymond Chen

Safer smuggling.

How can I write a C++/WinRT <CODE>IAsyncOperation<T></CODE> where <CODE>T</CODE> is not a Windows Runtime type?, part 1
Sep 3, 2025
Post comments count 1
Post likes count 3

How can I write a C++/WinRT <CODE>IAsyncOperation<T></CODE> where <CODE>T</CODE> is not a Windows Runtime type?, part 1

Raymond Chen
Raymond Chen

It's not representable in the Windows Runtime, but you can smuggle it.

Dubious security vulnerability: Remembering passwords for recently-opened ZIP files
Sep 2, 2025
Post comments count 7
Post likes count 1

Dubious security vulnerability: Remembering passwords for recently-opened ZIP files

Raymond Chen
Raymond Chen

If it didn't remember them, you wouldn't like it.

Thoughts on creating a tracking pointer class, part 16: Second attempt to use a list
Sep 1, 2025
Post comments count 4
Post likes count 1

Thoughts on creating a tracking pointer class, part 16: Second attempt to use a list

Raymond Chen
Raymond Chen

We can splice nodes to move them between lists.

Thoughts on creating a tracking pointer class, part 15: A custom shared pointer
Aug 29, 2025
Post comments count 2
Post likes count 1

Thoughts on creating a tracking pointer class, part 15: A custom shared pointer

Raymond Chen
Raymond Chen

Simplifying it for out limited use case.

Thoughts on creating a tracking pointer class, part 14: Nonthrowing moves with the shared tracking pointer
Aug 28, 2025
Post comments count 2
Post likes count 1

Thoughts on creating a tracking pointer class, part 14: Nonthrowing moves with the shared tracking pointer

Raymond Chen
Raymond Chen

Moving the exception somewhere else.

Thoughts on creating a tracking pointer class, part 13: Restoring the strong exception guarantee
Aug 27, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 13: Restoring the strong exception guarantee

Raymond Chen
Raymond Chen

Don't commit to anything until you know you can finish the job.

Thoughts on creating a tracking pointer class, part 12: A shared tracking pointer
Aug 26, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 12: A shared tracking pointer

Raymond Chen
Raymond Chen

Sharing a single tracking pointer among all instances.

Thoughts on creating a tracking pointer class, part 11: Repairing assignment
Aug 25, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 11: Repairing assignment

Raymond Chen
Raymond Chen

Restoring things that were automatically deleted.

Thoughts on creating a tracking pointer class, part 10: Proper conversion
Aug 22, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 10: Proper conversion

Raymond Chen
Raymond Chen

Making sure you cannot remove qualifiers.

Thoughts on creating a tracking pointer class, part 9: Conversion
Aug 21, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 9: Conversion

Raymond Chen
Raymond Chen

Making a read-only tracking pointer from a read-write tracking pointer.

Thoughts on creating a tracking pointer class, part 8: Tracking const objects
Aug 20, 2025
Post comments count 1
Post likes count 1

Thoughts on creating a tracking pointer class, part 8: Tracking const objects

Raymond Chen
Raymond Chen

Making tracking pointers to const objects.

Thoughts on creating a tracking pointer class, part 7: Non-modifying trackers, second try
Aug 19, 2025
Post comments count 1
Post likes count 1

Thoughts on creating a tracking pointer class, part 7: Non-modifying trackers, second try

Raymond Chen
Raymond Chen

Another attempt to make tracking pointers to objects that you can't modify.

Thoughts on creating a tracking pointer class, part 6: Non-modifying trackers
Aug 18, 2025
Post comments count 0
Post likes count 1

Thoughts on creating a tracking pointer class, part 6: Non-modifying trackers

Raymond Chen
Raymond Chen

Making tracking pointers to objects that you can't modify.

Thoughts on creating a tracking pointer class, part 5: Copying our tracking pointer
Aug 15, 2025
Post comments count 2
Post likes count 2

Thoughts on creating a tracking pointer class, part 5: Copying our tracking pointer

Raymond Chen
Raymond Chen

How to copy from a const tracking pointer.

Thoughts on creating a tracking pointer class, part 4: Using a circular doubly linked list
Aug 14, 2025
Post comments count 0
Post likes count 2

Thoughts on creating a tracking pointer class, part 4: Using a circular doubly linked list

Raymond Chen
Raymond Chen

Building our own circular doubly-linked list.

Thoughts on creating a tracking pointer class, part 3: Using a <CODE>std::vector</CODE>
Aug 13, 2025
Post comments count 0
Post likes count 2

Thoughts on creating a tracking pointer class, part 3: Using a <CODE>std::vector</CODE>

Raymond Chen
Raymond Chen

Tracking your trackers with a vector.

Thoughts on creating a tracking pointer class, part 2: Using a <CODE>std::list</CODE>
Aug 12, 2025
Post comments count 3
Post likes count 2

Thoughts on creating a tracking pointer class, part 2: Using a <CODE>std::list</CODE>

Raymond Chen
Raymond Chen

Tracking your trackers with a <CODE>std::list</CODE>.

Thoughts on creating a tracking pointer class, part 1: Concept art
Aug 11, 2025
Post comments count 1
Post likes count 3

Thoughts on creating a tracking pointer class, part 1: Concept art

Raymond Chen
Raymond Chen

Following an object as it moves.

Under what conditions could a <CODE>Read­File</CODE> or <CODE>Write­File</CODE> fail to transfer all of the bytes, and how do I detect that?
Aug 8, 2025
Post comments count 7
Post likes count 4

Under what conditions could a <CODE>Read­File</CODE> or <CODE>Write­File</CODE> fail to transfer all of the bytes, and how do I detect that?

Raymond Chen
Raymond Chen

If there is not enough data to read, or not room to write.

How can I detect that Windows is running in S-Mode?
Aug 7, 2025
Post comments count 11
Post likes count 4

How can I detect that Windows is running in S-Mode?

Raymond Chen
Raymond Chen

Check the code integrity policy.

How do I disable pieces of the property sheet for a service in the Services MMC snap-in?
Aug 6, 2025
Post comments count 9
Post likes count 5

How do I disable pieces of the property sheet for a service in the Services MMC snap-in?

Raymond Chen
Raymond Chen

There's no secret setting. It's all based on access control.

Why are Windows semiannual updates named H1 and H2?
Aug 5, 2025
Post comments count 24
Post likes count 5

Why are Windows semiannual updates named H1 and H2?

Raymond Chen
Raymond Chen

To address an unconscious bias.

How can I read more than 4GB of data from a file in a single call to <CODE>Read­File</CODE>?
Aug 4, 2025
Post comments count 23
Post likes count 3

How can I read more than 4GB of data from a file in a single call to <CODE>Read­File</CODE>?

Raymond Chen
Raymond Chen

You can't, but you can try to fake it.

Two related questions about keeping track of PIDs of IPC clients
Aug 1, 2025
Post comments count 2
Post likes count 1

Two related questions about keeping track of PIDs of IPC clients

Raymond Chen
Raymond Chen

Since you're doing IPC, you may as well let IPC do the work for you.

A consequence of the weird <CODE>wReserved</CODE> value at the start of the <CODE>DECIMAL</CODE> structure
Jul 31, 2025
Post comments count 7
Post likes count 1

A consequence of the weird <CODE>wReserved</CODE> value at the start of the <CODE>DECIMAL</CODE> structure

Raymond Chen
Raymond Chen

It overwrites things by accident.

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 0
Jul 30, 2025
Post comments count 2
Post likes count 1

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 0

Raymond Chen
Raymond Chen

If you don't really care about what happens if something goes wrong.

Why is there a window with no name blocking Windows shutdown?
Jul 29, 2025
Post comments count 16
Post likes count 5

Why is there a window with no name blocking Windows shutdown?

Raymond Chen
Raymond Chen

They never expected you to see it.

API design note: Don’t make up multiple names for the same thing
Jul 28, 2025
Post comments count 2
Post likes count 3

API design note: Don’t make up multiple names for the same thing

Raymond Chen
Raymond Chen

It may be obvious to you, but that's because you wrote it.

How can I confirm in the Windows debugger that I’m looking at a COMDAT-folded function?
Jul 25, 2025
Post comments count 0
Post likes count 3

How can I confirm in the Windows debugger that I’m looking at a COMDAT-folded function?

Raymond Chen
Raymond Chen

Ask for all the names for an address.

How can I wait until a named object (say a mutex) is created?
Jul 24, 2025
Post comments count 6
Post likes count 3

How can I wait until a named object (say a mutex) is created?

Raymond Chen
Raymond Chen

You can't, but maybe you can wait for something else.

Exploring possible solutions to the inconsistency in how Windows searches case-insensitively for named resources
Jul 23, 2025
Post comments count 6
Post likes count 1

Exploring possible solutions to the inconsistency in how Windows searches case-insensitively for named resources

Raymond Chen
Raymond Chen

Maintaining compatibility while addressing flaws.

Being more adamant about reporting that C++/WinRT was unable to resume execution on a dispatcher thread
Jul 22, 2025
Post comments count 2
Post likes count 2

Being more adamant about reporting that C++/WinRT was unable to resume execution on a dispatcher thread

Raymond Chen
Raymond Chen

Better versions in a different box.

What happens if C++/WinRT is unable to resume execution on a dispatcher thread?
Jul 21, 2025
Post comments count 1
Post likes count 4

What happens if C++/WinRT is unable to resume execution on a dispatcher thread?

Raymond Chen
Raymond Chen

What you get out of the box.

The case of the invalid instruction exception on an instruction that should never have executed
Jul 18, 2025
Post comments count 20
Post likes count 4

The case of the invalid instruction exception on an instruction that should never have executed

Raymond Chen
Raymond Chen

I don't recall ever asking you to do that.

If the Window Runtime PropertyValue is for boxing non-inspectables, why is there a PropertyValue.CreateInspectable?
Jul 17, 2025
Post comments count 0
Post likes count 3

If the Window Runtime PropertyValue is for boxing non-inspectables, why is there a PropertyValue.CreateInspectable?

Raymond Chen
Raymond Chen

For completeness, but not for functionality.

The Fundamental Failure-Mode Theorem: Systems lie about their proper functioning
Jul 16, 2025
Post comments count 5
Post likes count 5

The Fundamental Failure-Mode Theorem: Systems lie about their proper functioning

Raymond Chen
Raymond Chen

It doesn't say what it does on the tin.

Perhaps not a recommended usage for an emergency power outlet
Jul 15, 2025
Post comments count 0
Post likes count 5

Perhaps not a recommended usage for an emergency power outlet

Raymond Chen
Raymond Chen

Maybe that's not a critical system.

There is a <CODE>std::<WBR>chrono::<WBR>high_<WBR>resolution_<WBR>clock</CODE>, but no <CODE>low_<WBR>resolution_<WBR>clock</CODE>
Jul 14, 2025
Post comments count 5
Post likes count 5

There is a <CODE>std::<WBR>chrono::<WBR>high_<WBR>resolution_<WBR>clock</CODE>, but no <CODE>low_<WBR>resolution_<WBR>clock</CODE>

Raymond Chen
Raymond Chen

For when you care only enough to be roughly on time.

Detecting and reporting all unhandled C++ exceptions as well as all unhandled structured exceptions
Jul 11, 2025
Post comments count 3
Post likes count 4

Detecting and reporting all unhandled C++ exceptions as well as all unhandled structured exceptions

Raymond Chen
Raymond Chen

Closing another exit point.

Our first attempt to detect and report all unhandled C++ exceptions as well as all unhandled structured exceptions
Jul 10, 2025
Post comments count 7
Post likes count 3

Our first attempt to detect and report all unhandled C++ exceptions as well as all unhandled structured exceptions

Raymond Chen
Raymond Chen

Identifying and classifying the exit points.

When I install an unhandled structured exception filter, why doesn’t <CODE>std::<WBR>terminate</CODE> get called?
Jul 9, 2025
Post comments count 4
Post likes count 5

When I install an unhandled structured exception filter, why doesn’t <CODE>std::<WBR>terminate</CODE> get called?

Raymond Chen
Raymond Chen

You're using the same hook that the compiler uses to call <CODE>std::<WBR>terminate</CODE>.

A walkthrough of the original Microsoft Building 3
Jul 8, 2025
Post comments count 9
Post likes count 2

A walkthrough of the original Microsoft Building 3

Raymond Chen
Raymond Chen

Don't get lost on your walk down memory lane.

Dubious security vulnerability: If I perform this complex series of manual steps, I can crash a program I am running
Jul 7, 2025
Post comments count 2
Post likes count 2

Dubious security vulnerability: If I perform this complex series of manual steps, I can crash a program I am running

Raymond Chen
Raymond Chen

What security boundary did you cross?

Why doesn’t <CODE>LVIF_<WBR>INDENT</CODE> work without an image list?
Jul 4, 2025
Post comments count 3
Post likes count 1

Why doesn’t <CODE>LVIF_<WBR>INDENT</CODE> work without an image list?

Raymond Chen
Raymond Chen

Its original client had an image list.

German language cheat sheet: On changing quantities
Jul 3, 2025
Post comments count 13
Post likes count 0

German language cheat sheet: On changing quantities

Raymond Chen
Raymond Chen

How much there is, and how is it changing.

If the <CODE>Format­Message</CODE> function fails, and I requested that it allocate a buffer, do I have to free the buffer?
Jul 3, 2025
Post comments count 0
Post likes count 2

If the <CODE>Format­Message</CODE> function fails, and I requested that it allocate a buffer, do I have to free the buffer?

Raymond Chen
Raymond Chen

There was no buffer returned, so there's nothing to free anyway.

Unintended yet somehow entirely expected consequences of marking a COM interface as local
Jul 2, 2025
Post comments count 1
Post likes count 2

Unintended yet somehow entirely expected consequences of marking a COM interface as local

Raymond Chen
Raymond Chen

If it's local-only, then it can't be remote.

The sizzle reel that says things that nobody understands
Jul 1, 2025
Post comments count 0
Post likes count 1

The sizzle reel that says things that nobody understands

Raymond Chen
Raymond Chen

Failing to understand your audience.

2025 mid-year link clearance
Jun 30, 2025
Post comments count 1
Post likes count 2

2025 mid-year link clearance

Raymond Chen
Raymond Chen

Halfway there.

Embracing the power of the empty set in API design: Requesting zero items
Jun 30, 2025
Post comments count 17
Post likes count 3

Embracing the power of the empty set in API design: Requesting zero items

Raymond Chen
Raymond Chen

It's okay to ask for nothing. You get nothing.

Why do I get errors or warnings about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 3
Jun 27, 2025
Post comments count 8
Post likes count 1

Why do I get errors or warnings about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 3

Raymond Chen
Raymond Chen

Forcing <CODE>main</CODE> to be found in the place we want.

Why do I get errors about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 2
Jun 26, 2025
Post comments count 0
Post likes count 1

Why do I get errors about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 2

Raymond Chen
Raymond Chen

Figuring out why C++/CX makes a difference.

Your information has been permanently deleted, for small values of permanently
Jun 25, 2025
Post comments count 8
Post likes count 4

Your information has been permanently deleted, for small values of permanently

Raymond Chen
Raymond Chen

Is it really gone?

Why do I get errors about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 1
Jun 25, 2025
Post comments count 1
Post likes count 1

Why do I get errors about some weird symbol called ?main@@YAHP$01E$AAV?$Array@PE$AAVString@Platform…, part 1

Raymond Chen
Raymond Chen

Welcome to the world of C++/CX. Is "welcome" the right word?

Abusing copyright strings to trick software into thinking it’s running on your competitor’s PC
Jun 24, 2025
Post comments count 11
Post likes count 5

Abusing copyright strings to trick software into thinking it’s running on your competitor’s PC

Raymond Chen
Raymond Chen

I did technically cross my fingers.

The MIDL compiler still has trouble with double greater-than signs, sadly
Jun 23, 2025
Post comments count 7
Post likes count 6

The MIDL compiler still has trouble with double greater-than signs, sadly

Raymond Chen
Raymond Chen

Many have tried.

The case of the invalid handle error when a handle is closed while a thread is waiting on it
Jun 20, 2025
Post comments count 2
Post likes count 5

The case of the invalid handle error when a handle is closed while a thread is waiting on it

Raymond Chen
Raymond Chen

You are theorizing one race but experiencing another.

Learning to read C++ compiler errors: Ambiguous symbol errors after including a header file
Jun 19, 2025
Post comments count 2
Post likes count 1

Learning to read C++ compiler errors: Ambiguous symbol errors after including a header file

Raymond Chen
Raymond Chen

Finding out why multiple entities with the same name are visible.

You have to tell <CODE>Get-</CODE> and <CODE>Set­Security­Info</CODE> the object type, you can’t make it guess
Jun 18, 2025
Post comments count 0
Post likes count 1

You have to tell <CODE>Get-</CODE> and <CODE>Set­Security­Info</CODE> the object type, you can’t make it guess

Raymond Chen
Raymond Chen

It needs to know which provider to give it to.

Funding the Egghead store shopping spree took a little extra legwork
Jun 17, 2025
Post comments count 0
Post likes count 3

Funding the Egghead store shopping spree took a little extra legwork

Raymond Chen
Raymond Chen

Just ask the boss.

Writing a helper class for generating a particular category of C callback wrappers around C++ methods
Jun 16, 2025
Post comments count 1
Post likes count 5

Writing a helper class for generating a particular category of C callback wrappers around C++ methods

Raymond Chen
Raymond Chen

Another exercise in C++ template programming.

Thread pool threads are like preschool: Leave things the way you found them
Jun 13, 2025
Post comments count 4
Post likes count 3

Thread pool threads are like preschool: Leave things the way you found them

Raymond Chen
Raymond Chen

Your mother always told you to clean up behind yourself.

Why does Windows even have <CODE>Interlocked</CODE> functions when we have <CODE>std::atomic</CODE>?
Jun 12, 2025
Post comments count 7
Post likes count 1

Why does Windows even have <CODE>Interlocked</CODE> functions when we have <CODE>std::atomic</CODE>?

Raymond Chen
Raymond Chen

Well, you have to start somewhere.

Removing the <CODE>MAX_PATH</CODE> restriction on paths applies only to paths
Jun 11, 2025
Post comments count 6
Post likes count 4

Removing the <CODE>MAX_PATH</CODE> restriction on paths applies only to paths

Raymond Chen
Raymond Chen

The individual file names still retain their existing limits.

Application compatibility for Windows 95 crashed a cash register
Jun 10, 2025
Post comments count 6
Post likes count 5

Application compatibility for Windows 95 crashed a cash register

Raymond Chen
Raymond Chen

Exceeding all reasonable maximums.

Dubious security vulnerability: Tricking a program into running non-elevated
Jun 9, 2025
Post comments count 2
Post likes count 2

Dubious security vulnerability: Tricking a program into running non-elevated

Raymond Chen
Raymond Chen

You can do anything, but still within the limits of your authority.

Why does C++ think my class is copy-constructible when it can’t be copy-constructed?
Jun 6, 2025
Post comments count 0
Post likes count 4

Why does C++ think my class is copy-constructible when it can’t be copy-constructed?

Raymond Chen
Raymond Chen

You said that you had a copy constructor, even though it can't be compiled.

Why do some Windows functions fail if I pass an unaligned Unicode string?
Jun 5, 2025
Post comments count 11
Post likes count 2

Why do some Windows functions fail if I pass an unaligned Unicode string?

Raymond Chen
Raymond Chen

Well, if you don't align it, then you've already broken the rules.

Riffing on a typo in the name of the opera <I>Turandot</I>
Jun 4, 2025
Post comments count 2
Post likes count 3

Riffing on a typo in the name of the opera <I>Turandot</I>

Raymond Chen
Raymond Chen

On the dot.

How can I programmatically find the network path by which a folder has been shared?
Jun 4, 2025
Post comments count 0
Post likes count 1

How can I programmatically find the network path by which a folder has been shared?

Raymond Chen
Raymond Chen

There is no direct query. You'll have to infer it.

The symbolism of the magnifying glass is not universal
Jun 3, 2025
Post comments count 8
Post likes count 6

The symbolism of the magnifying glass is not universal

Raymond Chen
Raymond Chen

Just making things bigger?

Stating the obvious about debugging an invalid parameter error when freeing memory
Jun 2, 2025
Post comments count 0
Post likes count 2

Stating the obvious about debugging an invalid parameter error when freeing memory

Raymond Chen
Raymond Chen

Writing it down for posterity.

Using an oracle to see where your code is producing the wrong output
May 30, 2025
Post comments count 5
Post likes count 1

Using an oracle to see where your code is producing the wrong output

Raymond Chen
Raymond Chen

If there is a reference implementation, then use it as a check.

The case of creating new instances when you wanted to use the same one
May 29, 2025
Post comments count 6
Post likes count 7

The case of creating new instances when you wanted to use the same one

Raymond Chen
Raymond Chen

C++ language backward compatibility makes legal what you had hoped wasn't.

How do I convert a WIC bitmap back to a GDI <CODE>HBITMAP</CODE>?
May 28, 2025
Post comments count 1
Post likes count 3

How do I convert a WIC bitmap back to a GDI <CODE>HBITMAP</CODE>?

Raymond Chen
Raymond Chen

You can copy the bits into a DIB section.

What was origin of the code name Redpill for Windows 8 feature lockout?
May 27, 2025
Post comments count 9
Post likes count 4

What was origin of the code name Redpill for Windows 8 feature lockout?

Raymond Chen
Raymond Chen

Pretty obvious, actually.

Why does <CODE>Enum­Process­Modules</CODE> report no modules on a process that was created suspended?
May 26, 2025
Post comments count 2
Post likes count 1

Why does <CODE>Enum­Process­Modules</CODE> report no modules on a process that was created suspended?

Raymond Chen
Raymond Chen

There are no modules yet because you didn't give them a chance to load.

How can I detect if one of my helper processes is launching child processes?
May 23, 2025
Post comments count 6
Post likes count 4

How can I detect if one of my helper processes is launching child processes?

Raymond Chen
Raymond Chen

You can ask a job object to keep track for you.

How can I create a window the size of the screen without it being treated as a fullscreen window?
May 22, 2025
Post comments count 4
Post likes count 3

How can I create a window the size of the screen without it being treated as a fullscreen window?

Raymond Chen
Raymond Chen

You can declare that you aren't rude.

Silly parlor tricks: Promoting a 32-bit value to a 64-bit value when you don’t care about garbage in the upper bits
May 21, 2025
Post comments count 5
Post likes count 3

Silly parlor tricks: Promoting a 32-bit value to a 64-bit value when you don’t care about garbage in the upper bits

Raymond Chen
Raymond Chen

Inline assembly that doesn't do anything.

Why does Windows report my processor speed twice, with slightly different values?
May 20, 2025
Post comments count 7
Post likes count 3

Why does Windows report my processor speed twice, with slightly different values?

Raymond Chen
Raymond Chen

One is calculated. The other is self-promotion.

Secret passages on Microsoft main campus, episode 3
May 19, 2025
Post comments count 1
Post likes count 2

Secret passages on Microsoft main campus, episode 3

Raymond Chen
Raymond Chen

Another covered passage between buildings.

What’s with the weird <CODE>wReserved</CODE> value at the start of the <CODE>DECIMAL</CODE> structure?
May 16, 2025
Post comments count 8
Post likes count 2

What’s with the weird <CODE>wReserved</CODE> value at the start of the <CODE>DECIMAL</CODE> structure?

Raymond Chen
Raymond Chen

It's where the discriminant goes when the <CODE>DECIMAL</CODE> is put "inside" a <CODE>VARIANT</CODE>.

How do I force RunOnce commands to run in a specific order?
May 15, 2025
Post comments count 6
Post likes count 2

How do I force RunOnce commands to run in a specific order?

Raymond Chen
Raymond Chen

Run them in the desired order yourself.

If I mark my thread pool callback as long-running, does it still count toward the thread pool thread limit?
May 14, 2025
Post comments count 0
Post likes count 2

If I mark my thread pool callback as long-running, does it still count toward the thread pool thread limit?

Raymond Chen
Raymond Chen

Yes, because it's still in the thread pool.

What is the developer set-up for developing Windows for multiple processor architectures?
May 13, 2025
Post comments count 9
Post likes count 3

What is the developer set-up for developing Windows for multiple processor architectures?

Raymond Chen
Raymond Chen

You usually just pick one and count on your friends for the others.

Dubious security vulnerability: A program does not run correctly if you run it the wrong way, redux
May 12, 2025
Post comments count 2
Post likes count 2

Dubious security vulnerability: A program does not run correctly if you run it the wrong way, redux

Raymond Chen
Raymond Chen

Trying to make the system run the program automatically.

How can I wait for Clipboard History to recognize a clipboard change before I change it again?
May 9, 2025
Post comments count 12
Post likes count 4

How can I wait for Clipboard History to recognize a clipboard change before I change it again?

Raymond Chen
Raymond Chen

Listen for the change event.

Why doesn’t Clipboard History capture rapid changes to clipboard contents?
May 8, 2025
Post comments count 6
Post likes count 3

Why doesn’t Clipboard History capture rapid changes to clipboard contents?

Raymond Chen
Raymond Chen

Clipboard history operates asynchronously, so you are changing it before it can respond to the changes.

What were the MS-DOS programs that the <TT>moricons.dll</TT> icons were intended for?
May 7, 2025
Post comments count 14
Post likes count 7

What were the MS-DOS programs that the <TT>moricons.dll</TT> icons were intended for?

Raymond Chen
Raymond Chen

Tallying them up.

What were the MS-DOS programs that Windows used the <TT>progman.exe</TT> stock icons for?
May 6, 2025
Post comments count 7
Post likes count 6

What were the MS-DOS programs that Windows used the <TT>progman.exe</TT> stock icons for?

Raymond Chen
Raymond Chen

Mostly generic-looking icons.

What were the intended uses of those icons in <TT>moricons.dll</TT>?
May 5, 2025
Post comments count 9
Post likes count 5

What were the intended uses of those icons in <TT>moricons.dll</TT>?

Raymond Chen
Raymond Chen

Icons for old MS-DOS apps.

Using type aliasing to avoid the ODR problem with conditional compilation, part 2
May 2, 2025
Post comments count 4
Post likes count 3

Using type aliasing to avoid the ODR problem with conditional compilation, part 2

Raymond Chen
Raymond Chen

Ensuring that you pick a side.

Using C++ type aliasing to avoid the ODR problem with conditional compilation, part 1
May 1, 2025
Post comments count 3
Post likes count 2

Using C++ type aliasing to avoid the ODR problem with conditional compilation, part 1

Raymond Chen
Raymond Chen

Still one definition, but two types.

Why does Windows have trouble finding my Win32 resource if it contains an accented character?
Apr 30, 2025
Post comments count 7
Post likes count 4

Why does Windows have trouble finding my Win32 resource if it contains an accented character?

Raymond Chen
Raymond Chen

Disagreements over the fine print.

Protecting Windows users from Janet Jackson’s <I>Rhythm Nation</I>
Apr 29, 2025
Post comments count 9
Post likes count 3

Protecting Windows users from Janet Jackson’s <I>Rhythm Nation</I>

Raymond Chen
Raymond Chen

Granting an exception to a system policy.

Why did Windows 7, for a few months, log on slower if you have a solid color background?
Apr 28, 2025
Post comments count 14
Post likes count 9

Why did Windows 7, for a few months, log on slower if you have a solid color background?

Raymond Chen
Raymond Chen

It's waiting for Godot and eventually gives up.

If we can have <CODE>std::atomic<std::shared_ptr></CODE>, why not <CODE>std::atomic<com_ptr></CODE>?
Apr 25, 2025
Post comments count 11
Post likes count 3

If we can have <CODE>std::atomic<std::shared_ptr></CODE>, why not <CODE>std::atomic<com_ptr></CODE>?

Raymond Chen
Raymond Chen

Controlling the reference count.

When I define a window class with no default cursor, what is the explanation for the cursors that appear in my client area?
Apr 24, 2025
Post comments count 5
Post likes count 3

When I define a window class with no default cursor, what is the explanation for the cursors that appear in my client area?

Raymond Chen
Raymond Chen

You said you'd take care of it, but you didn't.

What resource ID should I give my application’s main icon?
Apr 23, 2025
Post comments count 7
Post likes count 3

What resource ID should I give my application’s main icon?

Raymond Chen
Raymond Chen

Applying what we know about how Explorer finds the "first" icon in a file.

Microspeak: top of mind
Apr 22, 2025
Post comments count 6
Post likes count 1

Microspeak: top of mind

Raymond Chen
Raymond Chen

Things I'm thinking about.

The ongoing story of seconds on the taskbar
Apr 21, 2025
Post comments count 20
Post likes count 1

The ongoing story of seconds on the taskbar

Raymond Chen
Raymond Chen

The cost of ticking.

The case of the feature flag that didn’t stay on long enough, part 2
Apr 18, 2025
Post comments count 2
Post likes count 1

The case of the feature flag that didn’t stay on long enough, part 2

Raymond Chen
Raymond Chen

Leaving everything the way you found it.

The case of the feature flag that didn’t stay on long enough, part 1
Apr 17, 2025
Post comments count 3
Post likes count 2

The case of the feature flag that didn’t stay on long enough, part 1

Raymond Chen
Raymond Chen

Understanding scope and order of destruction.

Using the classical model for linking to provide unit test overrides
Apr 16, 2025
Post comments count 0
Post likes count 1

Using the classical model for linking to provide unit test overrides

Raymond Chen
Raymond Chen

Overriding a LIB with an OBJ for fun and profit.

There was a lot of imagined dropping tablets in swimming pools
Apr 15, 2025
Post comments count 16
Post likes count 2

There was a lot of imagined dropping tablets in swimming pools

Raymond Chen
Raymond Chen

The archetypical example of needing a replacement computer.

Dubious security vulnerability: Once I have tricked the user into running a malicious shortcut, I can install malware
Apr 14, 2025
Post comments count 6
Post likes count 2

Dubious security vulnerability: Once I have tricked the user into running a malicious shortcut, I can install malware

Raymond Chen
Raymond Chen

Yes, that's sort of the point.

The case of the UI thread that hung in a kernel call
Apr 11, 2025
Post comments count 12
Post likes count 5

The case of the UI thread that hung in a kernel call

Raymond Chen
Raymond Chen

I did tell you not to do that.

Function overloading is more flexible (and more convenient) than template function specialization
Apr 10, 2025
Post comments count 0
Post likes count 1

Function overloading is more flexible (and more convenient) than template function specialization

Raymond Chen
Raymond Chen

You can change more things in an overload.

Why can’t I use <CODE>SEC_<WBR>LARGE_<WBR>PAGES</CODE> with a file-based file mapping?
Apr 9, 2025
Post comments count 5
Post likes count 1

Why can’t I use <CODE>SEC_<WBR>LARGE_<WBR>PAGES</CODE> with a file-based file mapping?

Raymond Chen
Raymond Chen

No paging, no crying.

The Goldilocks zone of software stability
Apr 8, 2025
Post comments count 10
Post likes count 2

The Goldilocks zone of software stability

Raymond Chen
Raymond Chen

Not too new, not too old.

On priority inversion in the use of a spinlock to ensure atomic access to a <CODE>shared_ptr</CODE>
Apr 7, 2025
Post comments count 4
Post likes count 3

On priority inversion in the use of a spinlock to ensure atomic access to a <CODE>shared_ptr</CODE>

Raymond Chen
Raymond Chen

Priority inversion may be rare, but correctness doesn't care about rarity.

Adding delays to our task sequencer, part 3
Apr 4, 2025
Post comments count 5
Post likes count 2

Adding delays to our task sequencer, part 3

Raymond Chen
Raymond Chen

Waiting more cheaply.

Adding delays to our task sequencer, part 2
Apr 3, 2025
Post comments count 0
Post likes count 2

Adding delays to our task sequencer, part 2

Raymond Chen
Raymond Chen

Waiting the right amount of time.

Adding delays to our task sequencer, part 1
Apr 2, 2025
Post comments count 0
Post likes count 2

Adding delays to our task sequencer, part 1

Raymond Chen
Raymond Chen

Not so fast there.

The return of Building 7
Apr 1, 2025
Post comments count 1
Post likes count 3

The return of Building 7

Raymond Chen
Raymond Chen

Pranksters lose one of their longtime inside jokes.

If one program blocks shutdown, then <I>all</I> programs block shutdown, revisited
Mar 31, 2025
Post comments count 12
Post likes count 1

If one program blocks shutdown, then <I>all</I> programs block shutdown, revisited

Raymond Chen
Raymond Chen

No take-backs.

The 2025/2026 Seattle Symphony subscription season at a glance
Mar 28, 2025
Post comments count 1
Post likes count 3

The 2025/2026 Seattle Symphony subscription season at a glance

Raymond Chen
Raymond Chen

The pocket reference guide for 2025/2026.

Fixing exception safety in our <CODE>task_<WBR>sequencer</CODE>
Mar 28, 2025
Post comments count 3
Post likes count 2

Fixing exception safety in our <CODE>task_<WBR>sequencer</CODE>

Raymond Chen
Raymond Chen

Exception safety, the forgotten requirement.

On launching a dialog when a specific combo box item is selected
Mar 27, 2025
Post comments count 8
Post likes count 2

On launching a dialog when a specific combo box item is selected

Raymond Chen
Raymond Chen

Changing selections is not a good time to launch a dialog box.

Why does <ODE>INVALID_<WBR>HANDLE_<WBR>VALUE</CODE> cast through a <CODE>LONG_PTR</CODE> first?
Mar 26, 2025
Post comments count 1
Post likes count 4

Why does <ODE>INVALID_<WBR>HANDLE_<WBR>VALUE</CODE> cast through a <CODE>LONG_PTR</CODE> first?

Raymond Chen
Raymond Chen

To ensure that the proper sign extension happens.

We’ll fly you to Atlanta, Texas, and getting to your hotel in Atlanta, Georgia is your problem
Mar 25, 2025
Post comments count 4
Post likes count 1

We’ll fly you to Atlanta, Texas, and getting to your hotel in Atlanta, Georgia is your problem

Raymond Chen
Raymond Chen

Reading the fine print.

A note on the USB-to-PS/2 mouse adapter that came with Microsoft mouse devices
Mar 25, 2025
Post comments count 7
Post likes count 3

A note on the USB-to-PS/2 mouse adapter that came with Microsoft mouse devices

Raymond Chen
Raymond Chen

It's a purely mechanical adapter that relies on smarts in the mouse itself.

On how different Windows ABIs choose how to pass 32-bit values in 64-bit registers
Mar 24, 2025
Post comments count 11
Post likes count 2

On how different Windows ABIs choose how to pass 32-bit values in 64-bit registers

Raymond Chen
Raymond Chen

Surveying the options and looking for commonalities.

The case of the critical section that let multiple threads enter a block of code
Mar 21, 2025
Post comments count 11
Post likes count 4

The case of the critical section that let multiple threads enter a block of code

Raymond Chen
Raymond Chen

It had one job.

What could cause a memory corruption bug to disappear in safe mode?
Mar 20, 2025
Post comments count 4
Post likes count 1

What could cause a memory corruption bug to disappear in safe mode?

Raymond Chen
Raymond Chen

A simplified execution environment means fewer things that you can stumble over.

You can’t simulate keyboard input with PostMessage, revisited
Mar 19, 2025
Post comments count 9
Post likes count 7

You can’t simulate keyboard input with PostMessage, revisited

Raymond Chen
Raymond Chen

If it didn't go through the input system, it only looks like input as much as the app allows itself to be fooled.

Why didn’t Windows 95 setup use a miniature version of Windows 95 as its fallback GUI?
Mar 18, 2025
Post comments count 7
Post likes count 7

Why didn’t Windows 95 setup use a miniature version of Windows 95 as its fallback GUI?

Raymond Chen
Raymond Chen

Avoiding an interim GUI environment.

Dubious security vulnerability: A program does not run correctly if you run it the wrong way
Mar 17, 2025
Post comments count 3
Post likes count 3

Dubious security vulnerability: A program does not run correctly if you run it the wrong way

Raymond Chen
Raymond Chen

So what did you expect?

The case of COM failing to pump messages in a single-threaded COM apartment
Mar 14, 2025
Post comments count 0
Post likes count 2

The case of COM failing to pump messages in a single-threaded COM apartment

Raymond Chen
Raymond Chen

A customer encountered a hang caused by COM not pumping messages while waiting for a cross-thread operation to complete. They were using the class for serializing asynchronous operations on a UI thread they created to handle accessibility callbacks. The hang stack looked like this: We see that we have a UI thread (notice the at the bottom of the stack), yet COM decided to block without pumping messages ( instead of (). Is this a bug in the task sequencer? Let's look at the stack more closely. A message arrived via , and that then queued a task into the task sequencer. The saw that the task sequencer had...

Making sure that a DLL loads only from your application directory
Mar 13, 2025
Post comments count 12
Post likes count 3

Making sure that a DLL loads only from your application directory

Raymond Chen
Raymond Chen

You can ask for it as an option, but think about what you're actually protecting against.

What are the thread safety requirements of <CODE>HSTRING</CODE> and <CODE>BSTR</CODE>?
Mar 12, 2025
Post comments count 2
Post likes count 4

What are the thread safety requirements of <CODE>HSTRING</CODE> and <CODE>BSTR</CODE>?

Raymond Chen
Raymond Chen

They do not have thread affinity.

What an insightful observation, you get to wear “the hat”
Mar 11, 2025
Post comments count 9
Post likes count 3

What an insightful observation, you get to wear “the hat”

Raymond Chen
Raymond Chen

Maybe not so insightful.

How do I destroy an ABI pointer that I extracted from a C++/WinRT object?
Mar 10, 2025
Post comments count 0
Post likes count 4

How do I destroy an ABI pointer that I extracted from a C++/WinRT object?

Raymond Chen
Raymond Chen

You can clean it up the ABI way, whatever that is.

To some people, time zones are just a fancy way of sounding important, episode 2
Mar 7, 2025
Post comments count 21
Post likes count 4

To some people, time zones are just a fancy way of sounding important, episode 2

Raymond Chen
Raymond Chen

Words have meaning.

How can I choose a different C++ constructor at runtime?
Mar 6, 2025
Post comments count 6
Post likes count 6

How can I choose a different C++ constructor at runtime?

Raymond Chen
Raymond Chen

Make somebody else do it, and then use copy elision.

I tried to subscribe to a C++/WinRT event, but my callback was never called
Mar 5, 2025
Post comments count 0
Post likes count 2

I tried to subscribe to a C++/WinRT event, but my callback was never called

Raymond Chen
Raymond Chen

Check how you registered your event handler.

Microspeak: Respin
Mar 4, 2025
Post comments count 2
Post likes count 3

Microspeak: Respin

Raymond Chen
Raymond Chen

Spin it up again, baby.

Lexically scoped functions accessing parent locals: The display
Mar 3, 2025
Post comments count 1
Post likes count 3

Lexically scoped functions accessing parent locals: The display

Raymond Chen
Raymond Chen

Using a well-known location instead of copying frame pointers.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 8
Feb 28, 2025
Post comments count 1
Post likes count 2

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 8

Raymond Chen
Raymond Chen

Comparing the options.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 7
Feb 27, 2025
Post comments count 0
Post likes count 2

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 7

Raymond Chen
Raymond Chen

Inheritance without involving <CODE>winrt::implements</CODE> at all.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 6
Feb 26, 2025
Post comments count 0
Post likes count 1

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 6

Raymond Chen
Raymond Chen

Using CRTP to delegate the method.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 5
Feb 25, 2025
Post comments count 0
Post likes count 1

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 5

Raymond Chen
Raymond Chen

When the base class isn't self-contained.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 4
Feb 24, 2025
Post comments count 0
Post likes count 1

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 4

Raymond Chen
Raymond Chen

Simple inheritance of a self-contained <CODE>implements</CODE>.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 3
Feb 21, 2025
Post comments count 9
Post likes count 1

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 3

Raymond Chen
Raymond Chen

Discovering the legal inheritance structures for <CODE>winrt::<WBR>implements</CODE>.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 2
Feb 20, 2025
Post comments count 0
Post likes count 1

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 2

Raymond Chen
Raymond Chen

Untangling <CODE>unwrap_<WBR>implements_t</CODE>.

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 1
Feb 19, 2025
Post comments count 0
Post likes count 3

C++/WinRT implementation inheritance: Notes on <CODE>winrt::implements</CODE>, part 1

Raymond Chen
Raymond Chen

A closer look at the parameters to the <CODE>implements</CODE> template.

Your statement is now available, just two hidden flyouts and five clicks away
Feb 18, 2025
Post comments count 4
Post likes count 7

Your statement is now available, just two hidden flyouts and five clicks away

Raymond Chen
Raymond Chen

Beware of the leopard.

API design note: Beware of adding an “Other” enum value
Feb 17, 2025
Post comments count 7
Post likes count 7

API design note: Beware of adding an “Other” enum value

Raymond Chen
Raymond Chen

What are you going to do when you add a new kind?

Investigating an argument-dependent lookup issue and working around it
Feb 14, 2025
Post comments count 3
Post likes count 3

Investigating an argument-dependent lookup issue and working around it

Raymond Chen
Raymond Chen

Picking apart the language specification.

A sample implementation of the weak reference pattern for COM callbacks
Feb 13, 2025
Post comments count 1
Post likes count 3

A sample implementation of the weak reference pattern for COM callbacks

Raymond Chen
Raymond Chen

A forwarder through a weak reference.

Async-Async revisited: What about cancellation?
Feb 12, 2025
Post comments count 3
Post likes count 2

Async-Async revisited: What about cancellation?

Raymond Chen
Raymond Chen

Even the cancellation is async.

Did the Windows 95 setup team forget that MS-DOS can do graphics?
Feb 11, 2025
Post comments count 3
Post likes count 9

Did the Windows 95 setup team forget that MS-DOS can do graphics?

Raymond Chen
Raymond Chen

Oh look what you just made there.

How does Explorer find the “first” icon in a file
Feb 10, 2025
Post comments count 4
Post likes count 3

How does Explorer find the “first” icon in a file

Raymond Chen
Raymond Chen

It enumerates them and takes the first one, so this is really a question about enumeration.

Using alternate locales to get more interesting case mapping than the C
Feb 7, 2025
Post comments count 1
Post likes count 3

Using alternate locales to get more interesting case mapping than the C

Raymond Chen
Raymond Chen

Looking for something better.

The default C locale is not a very interesting one
Feb 6, 2025
Post comments count 7
Post likes count 1

The default C locale is not a very interesting one

Raymond Chen
Raymond Chen

It barely understands anything.

On exactly when XAML bindings are evaluated if an element is not yet loaded
Feb 5, 2025
Post comments count 7
Post likes count 0

On exactly when XAML bindings are evaluated if an element is not yet loaded

Raymond Chen
Raymond Chen

It depends on which abstraction you prefer.

The original name for Flexible Single Master Operations in Active Directory
Feb 4, 2025
Post comments count 4
Post likes count 5

The original name for Flexible Single Master Operations in Active Directory

Raymond Chen
Raymond Chen

Not that kind of F-word.

On trying to log an exception as it leaves your scope
Feb 3, 2025
Post comments count 2
Post likes count 2

On trying to log an exception as it leaves your scope

Raymond Chen
Raymond Chen

You can't watch it from an object on the outside.

Creating a generic insertion iterator, part 2
Jan 31, 2025
Post comments count 1
Post likes count 1

Creating a generic insertion iterator, part 2

Raymond Chen
Raymond Chen

Satisfying the iterator requirements, perhaps with a little cheating.

Creating a generic insertion iterator, part 1
Jan 30, 2025
Post comments count 0
Post likes count 1

Creating a generic insertion iterator, part 1

Raymond Chen
Raymond Chen

We provide the boilerplate; you provide the smarts.

How do I create an inserter iterator that does unhinted insertion into an associative container like <CODE>std::map</CODE>?
Jan 29, 2025
Post comments count 6
Post likes count 2

How do I create an inserter iterator that does unhinted insertion into an associative container like <CODE>std::map</CODE>?

Raymond Chen
Raymond Chen

Curiously missing from the standard library.

My electric toothbrush was acting up, so I tried to reboot it
Jan 28, 2025
Post comments count 11
Post likes count 4

My electric toothbrush was acting up, so I tried to reboot it

Raymond Chen
Raymond Chen

It didn't help.

A pattern for obtaining a single value while holding a lock
Jan 27, 2025
Post comments count 9
Post likes count 3

A pattern for obtaining a single value while holding a lock

Raymond Chen
Raymond Chen

The immediately-invoked lambda that returns a value.

A brief and incomplete comparison of memory corruption detection tools
Jan 24, 2025
Post comments count 0
Post likes count 5

A brief and incomplete comparison of memory corruption detection tools

Raymond Chen
Raymond Chen

A short overview, definitely incomplete.

Memory corruption from outside the process looks like space aliens
Jan 23, 2025
Post comments count 0
Post likes count 3

Memory corruption from outside the process looks like space aliens

Raymond Chen
Raymond Chen

The write isn't visible to your process, just the effect of the write.

Be mindful of temporal terms in documents: What is the reference point in time?
Jan 22, 2025
Post comments count 15
Post likes count 4

Be mindful of temporal terms in documents: What is the reference point in time?

Raymond Chen
Raymond Chen

What is your implied point in time for the reference?

Why is there a bulge on my bicycle tire when I inflate it?
Jan 21, 2025
Post comments count 4
Post likes count 1

Why is there a bulge on my bicycle tire when I inflate it?

Raymond Chen
Raymond Chen

Get the order of operations right.

Why doesn’t the Windows blue screen of death prominently identify the company that created the driver that crashed?
Jan 21, 2025
Post comments count 5
Post likes count 3

Why doesn’t the Windows blue screen of death prominently identify the company that created the driver that crashed?

Raymond Chen
Raymond Chen

Because the driver that crashed may not be the one at fault.

Reminder: When a C++ object fails to construct, the destructor does not run
Jan 20, 2025
Post comments count 1
Post likes count 3

Reminder: When a C++ object fails to construct, the destructor does not run

Raymond Chen
Raymond Chen

If you need to run after a failed construction, you have to put it in a base class or member variable.

The case of the crash when trying to erase an element from a <CODE>std::set</CODE>
Jan 17, 2025
Post comments count 6
Post likes count 3

The case of the crash when trying to erase an element from a <CODE>std::set</CODE>

Raymond Chen
Raymond Chen

Another kind of fiasco.

In a C++ class template specialization, how can I call the unspecialized version of a method?
Jan 16, 2025
Post comments count 3
Post likes count 2

In a C++ class template specialization, how can I call the unspecialized version of a method?

Raymond Chen
Raymond Chen

You can't talk about things that might exist, so instead talk about things that do.

How does <CODE>Get­User­Default­Geo­Name</CODE> choose between ISO 3166-1 and UN M.49 codes?
Jan 15, 2025
Post comments count 0
Post likes count 1

How does <CODE>Get­User­Default­Geo­Name</CODE> choose between ISO 3166-1 and UN M.49 codes?

Raymond Chen
Raymond Chen

Clarifying the behavior.

Microspeak: The walk-on topic
Jan 14, 2025
Post comments count 5
Post likes count 2

Microspeak: The walk-on topic

Raymond Chen
Raymond Chen

Just walk on in with your topic.

A simplified overview of ways to add or update elements in a <CODE>std::map</CODE>
Jan 13, 2025
Post comments count 4
Post likes count 3

A simplified overview of ways to add or update elements in a <CODE>std::map</CODE>

Raymond Chen
Raymond Chen

And using it to find missing opportunities.

Why does inadvertently passing a <CODE>std::string</CODE> instead of a <CODE>char const*</CODE> to a variadic function crash on x86-32 but not x86-64?
Jan 10, 2025
Post comments count 2
Post likes count 1

Why does inadvertently passing a <CODE>std::string</CODE> instead of a <CODE>char const*</CODE> to a variadic function crash on x86-32 but not x86-64?

Raymond Chen
Raymond Chen

Looking at the calling convention and the small string optimization.

Inside STL: Waiting for a <CODE>std::atomic<std::shared_ptr<T>></CODE> to change, part 2
Jan 9, 2025
Post comments count 0
Post likes count 4

Inside STL: Waiting for a <CODE>std::atomic<std::shared_ptr<T>></CODE> to change, part 2

Raymond Chen
Raymond Chen

Digging into the libstdc++ implementation.

Inside STL: Waiting for a <CODE>std::atomic<std::shared_ptr<T>></CODE> to change, part 1
Jan 8, 2025
Post comments count 1
Post likes count 2

Inside STL: Waiting for a <CODE>std::atomic<std::shared_ptr<T>></CODE> to change, part 1

Raymond Chen
Raymond Chen

Waiting on a single pointer, but checking for two.

Gesellschaft zur Stärkung der Verben: The German Society for the Irregularization of Verbs
Jan 7, 2025
Post comments count 11
Post likes count 3

Gesellschaft zur Stärkung der Verben: The German Society for the Irregularization of Verbs

Raymond Chen
Raymond Chen

Stand strong and proud.

Emergency power resets on Lenovo, HP, Dell, and Acer laptops
Jan 7, 2025
Post comments count 5
Post likes count 6

Emergency power resets on Lenovo, HP, Dell, and Acer laptops

Raymond Chen
Raymond Chen

Looking for the magic button.

How can I tell whether a change to a control was due to the user or due to my program?
Jan 6, 2025
Post comments count 6
Post likes count 1

How can I tell whether a change to a control was due to the user or due to my program?

Raymond Chen
Raymond Chen

You know when it was done by your program because you did it.

Forcing an <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> error when trying to open <CODE>HKEY_<WBR>CURRENT_<WBR>USER\<WBR>Software</CODE>
Jan 3, 2025
Post comments count 1
Post likes count 1

Forcing an <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> error when trying to open <CODE>HKEY_<WBR>CURRENT_<WBR>USER\<WBR>Software</CODE>

Raymond Chen
Raymond Chen

Just an exercise to show that it can be done, even though it's highly unlikely to occur in practice.

Could I be getting <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> for <CODE>HKEY_<WBR>CURRENT_<WBR>USER\<WBR>Software</CODE> when the user logs off?
Jan 2, 2025
Post comments count 1
Post likes count 1

Could I be getting <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> for <CODE>HKEY_<WBR>CURRENT_<WBR>USER\<WBR>Software</CODE> when the user logs off?

Raymond Chen
Raymond Chen

Probably not, but there are some edge cases.

How is it possible to get <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> when I’m <I>creating</I> a key?
Jan 1, 2025
Post comments count 1
Post likes count 1

How is it possible to get <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> when I’m <I>creating</I> a key?

Raymond Chen
Raymond Chen

The key that got deleted is not the one you are trying to create.

2024 year-end link clearance
Dec 31, 2024
Post comments count 6
Post likes count 3

2024 year-end link clearance

Raymond Chen
Raymond Chen

The cycle completes.

Making sure the Microsoft Visual C++ compiler chooses the right source encoding
Dec 31, 2024
Post comments count 4
Post likes count 4

Making sure the Microsoft Visual C++ compiler chooses the right source encoding

Raymond Chen
Raymond Chen

Making sure the file and settings are set correctly.

How various git diff viewers represent file encoding changes in pull requests
Dec 30, 2024
Post comments count 4
Post likes count 3

How various git diff viewers represent file encoding changes in pull requests

Raymond Chen
Raymond Chen

The invisible UTF-8 BOM, and sometimes invisible encoding changes.

In C++, failure to meet the requirements does not always mean that you fail if you don’t meet the requirements
Dec 27, 2024
Post comments count 4
Post likes count 2

In C++, failure to meet the requirements does not always mean that you fail if you don’t meet the requirements

Raymond Chen
Raymond Chen

Combining SFINAE/requires, standard layout, and overload resolution.

Why are Win32 resources strings bundled at all? And why bundles of 16?
Dec 26, 2024
Post comments count 8
Post likes count 4

Why are Win32 resources strings bundled at all? And why bundles of 16?

Raymond Chen
Raymond Chen

Balancing multiple performance factors.

How can I check if two GUIDs are equal when they are provided as strings?
Dec 25, 2024
Post comments count 0
Post likes count 2

How can I check if two GUIDs are equal when they are provided as strings?

Raymond Chen
Raymond Chen

A customer asked if there was a helper function in the system that accepted two strings and reported whether the s they represent are equal. This is a tricky question, because you first have to decide what "represent" means. There are many ways of representing a as a string. It could be just 32 case-insensitive hexadecimal digits. Or maybe there are internal hyphens to separate the groups. And the whole thing might be enclosed in braces or parentheses. External and interior whitespace might be allowed. Trailing garbage might be accepted (and ignored). And then there's the special format {0x00000000,0x0000,0x00...

A design flaw in the Windows 3D Pipes screen saver pointed out by a customer
Dec 24, 2024
Post comments count 0
Post likes count 3

A design flaw in the Windows 3D Pipes screen saver pointed out by a customer

Raymond Chen
Raymond Chen

Time-wasting.

A common proposed solution to certain categories of IFNDR: Getting the linker to verify identical functions
Dec 23, 2024
Post comments count 5
Post likes count 2

A common proposed solution to certain categories of IFNDR: Getting the linker to verify identical functions

Raymond Chen
Raymond Chen

You could do it, but it could cramp your style.

How do I register a file type for a scripting language so that users get a warning when they run an untrusted script?
Dec 20, 2024
Post comments count 0
Post likes count 2

How do I register a file type for a scripting language so that users get a warning when they run an untrusted script?

Raymond Chen
Raymond Chen

Use the FTA_AlwaysUnsafe edit flag.

Inside STL: The atomic shared_ptr
Dec 19, 2024
Post comments count 7
Post likes count 5

Inside STL: The atomic shared_ptr

Raymond Chen
Raymond Chen

There's a lock hiding inside the pointer.

Is there a way to split the git history of a file or combine the histories of two files without a merge commit?
Dec 18, 2024
Post comments count 2
Post likes count 1

Is there a way to split the git history of a file or combine the histories of two files without a merge commit?

Raymond Chen
Raymond Chen

Studying how git recovers history.

Microspeak terms that didn’t take hold: airspace, synthetics, and AOI
Dec 17, 2024
Post comments count 6
Post likes count 3

Microspeak terms that didn’t take hold: airspace, synthetics, and AOI

Raymond Chen
Raymond Chen

Sometimes they don't stick.

Why do we have header files <CODE><pshpackN.h></CODE> and <CODE><poppack.h></CODE> instead of just issuing the pragma directly?
Dec 16, 2024
Post comments count 0
Post likes count 2

Why do we have header files <CODE><pshpackN.h></CODE> and <CODE><poppack.h></CODE> instead of just issuing the pragma directly?

Raymond Chen
Raymond Chen

Because the pragma may not work everywhere.

Converting to a derived class from the future: How to cast from a base class to an incomplete derived class?
Dec 13, 2024
Post comments count 0
Post likes count 3

Converting to a derived class from the future: How to cast from a base class to an incomplete derived class?

Raymond Chen
Raymond Chen

Deferring the definition until the class is complete.

API naming principles for conditional operations: On, When, and If
Dec 12, 2024
Post comments count 0
Post likes count 3

API naming principles for conditional operations: On, When, and If

Raymond Chen
Raymond Chen

Describing when a condition is tested.

What is the <CODE>CONTINUE_IF_FAILED</CODE> equivalent of <CODE>RETURN_IF_FAILED</CODE>?
Dec 11, 2024
Post comments count 8
Post likes count 3

What is the <CODE>CONTINUE_IF_FAILED</CODE> equivalent of <CODE>RETURN_IF_FAILED</CODE>?

Raymond Chen
Raymond Chen

Be careful how you write it, or better: Don't write it at all.

It rather involved being on the other side of this airtight hatchway: Disabling anti-malware scanning
Dec 10, 2024
Post comments count 3
Post likes count 1

It rather involved being on the other side of this airtight hatchway: Disabling anti-malware scanning

Raymond Chen
Raymond Chen

If you have already infiltrated the process, then you can disable things from the inside.

Learning to read C++ compiler errors: Failing to create a <CODE>shared_ptr</CODE>
Dec 9, 2024
Post comments count 0
Post likes count 2

Learning to read C++ compiler errors: Failing to create a <CODE>shared_ptr</CODE>

Raymond Chen
Raymond Chen

Understanding what you asked the compiler to do, and why it couldn't comply.

Learning to read C++ compiler errors: Nonsensical errors from a function declaration
Dec 6, 2024
Post comments count 4
Post likes count 1

Learning to read C++ compiler errors: Nonsensical errors from a function declaration

Raymond Chen
Raymond Chen

Look closely at what the error message is complaining about.

Won’t waiting for multiple threads one at a time introduce a severe performance issue?
Dec 5, 2024
Post comments count 1
Post likes count 3

Won’t waiting for multiple threads one at a time introduce a severe performance issue?

Raymond Chen
Raymond Chen

It depends on how long you plan on waiting.

Why does my DLL reference count go up by one every time I create and exit a thread?
Dec 4, 2024
Post comments count 0
Post likes count 3

Why does my DLL reference count go up by one every time I create and exit a thread?

Raymond Chen
Raymond Chen

If you use a wrapper, you need to follow the wrapper's rules.

Tricks from product support: We’re not smart enough to debug the problem, can you help us?
Dec 3, 2024
Post comments count 2
Post likes count 3

Tricks from product support: We’re not smart enough to debug the problem, can you help us?

Raymond Chen
Raymond Chen

It's not you, it's me.

News flash: Desire for loud cars correlates with psychopathy and sadism
Dec 2, 2024
Post comments count 1
Post likes count 4

News flash: Desire for loud cars correlates with psychopathy and sadism

Raymond Chen
Raymond Chen

More research into loud vehicles.

An analogy about register preservation rules in calling conventions
Dec 2, 2024
Post comments count 5
Post likes count 1

An analogy about register preservation rules in calling conventions

Raymond Chen
Raymond Chen

And tying it back to unwind codes.

Assessing the attack complexity of a race condition security vulnerability
Nov 29, 2024
Post comments count 1
Post likes count 1

Assessing the attack complexity of a race condition security vulnerability

Raymond Chen
Raymond Chen

It's not just how small the race window is, but how easy it is to hit the window.

Why does my program successfully take foreground only when running under the debugger?
Nov 28, 2024
Post comments count 0
Post likes count 3

Why does my program successfully take foreground only when running under the debugger?

Raymond Chen
Raymond Chen

That's a special exception to the normal foreground rules.

Checking whether a URI refers to a Web site root
Nov 27, 2024
Post comments count 0
Post likes count 1

Checking whether a URI refers to a Web site root

Raymond Chen
Raymond Chen

Let somebody else do the parsing.

Microspeak: Real estate and Airspace
Nov 26, 2024
Post comments count 0
Post likes count 1

Microspeak: Real estate and Airspace

Raymond Chen
Raymond Chen

Space on the screen and negotiating control over it.

How can I know when a window has processed a message that I posted to it?
Nov 25, 2024
Post comments count 0
Post likes count 1

How can I know when a window has processed a message that I posted to it?

Raymond Chen
Raymond Chen

Best would be to have it tell you.

In C++, how can I make a default parameter be the this pointer of the caller?, revisited
Nov 22, 2024
Post comments count 0
Post likes count 2

In C++, how can I make a default parameter be the this pointer of the caller?, revisited

Raymond Chen
Raymond Chen

Expanding on the previous pattern.

How can I detect which menu my item was invoked from?
Nov 21, 2024
Post comments count 1
Post likes count 2

How can I detect which menu my item was invoked from?

Raymond Chen
Raymond Chen

Just give them all different IDs. But this might itself by an XY problem.

How do I determine whether Explorer is showing or hiding file extensions?
Nov 20, 2024
Post comments count 3
Post likes count 4

How do I determine whether Explorer is showing or hiding file extensions?

Raymond Chen
Raymond Chen

You can ask, but maybe you're asking the wrong question.

A wrinkle in how Windows 95 setup bootstrapped its initial GUI step
Nov 19, 2024
Post comments count 4
Post likes count 7

A wrinkle in how Windows 95 setup bootstrapped its initial GUI step

Raymond Chen
Raymond Chen

Getting access to the common controls that don't exist until Windows 95.

The operations for reading and writing single elements for C++ standard library maps
Nov 18, 2024
Post comments count 2
Post likes count 2

The operations for reading and writing single elements for C++ standard library maps

Raymond Chen
Raymond Chen

Breaking down the options.

How do I put a non-copyable, non-movable, non-constructible object into a <CODE>std::optional</CODE>?
Nov 15, 2024
Post comments count 6
Post likes count 4

How do I put a non-copyable, non-movable, non-constructible object into a <CODE>std::optional</CODE>?

Raymond Chen
Raymond Chen

Taking advantage of the conversion operator.

Solving the puzzle of trying to put an object into a <CODE>std::optional</CODE>
Nov 14, 2024
Post comments count 0
Post likes count 3

Solving the puzzle of trying to put an object into a <CODE>std::optional</CODE>

Raymond Chen
Raymond Chen

How do I set a value? Let me count the ways.

The puzzle of trying to put an object into a <CODE>std::optional</CODE>
Nov 13, 2024
Post comments count 14
Post likes count 2

The puzzle of trying to put an object into a <CODE>std::optional</CODE>

Raymond Chen
Raymond Chen

The C++ standard library template type has one of two states. It could be empty (not contain anything), or it could contain a . Suppose you start with an empty . How do you put a into it? One of my colleagues tried to do it in what seemed to be the most natural way: Use the assignment operator. Unfortunately, the assignment failed to compile: I asked for the rest of the error message, because the details will explain what the compiler tried to do (and why it couldn't). It's long, but we'll walk through it. The compiler is showing its work. It's showing you all the possible overloaded assignment opera...

Why did Windows 95 setup use three operating systems?
Nov 12, 2024
Post comments count 6
Post likes count 11

Why did Windows 95 setup use three operating systems?

Raymond Chen
Raymond Chen

Simplifying the problem to an earlier problem.

Debugger breakpoints are usually implemented by patching the in-memory copy of the code
Nov 11, 2024
Post comments count 7
Post likes count 5

Debugger breakpoints are usually implemented by patching the in-memory copy of the code

Raymond Chen
Raymond Chen

The code in memory may not match what the debugger shows you if the debugger is itself is doing the changing.

The case of a program that crashed on its first instruction
Nov 8, 2024
Post comments count 4
Post likes count 13

The case of a program that crashed on its first instruction

Raymond Chen
Raymond Chen

Didn't even make it out of the gate.

Why do I observe reads from a memory-mapped file when writing large blocks?
Nov 7, 2024
Post comments count 6
Post likes count 5

Why do I observe reads from a memory-mapped file when writing large blocks?

Raymond Chen
Raymond Chen

The CPU doesn't see the entire write at once.

How do I declare an operator overload for my Windows Runtime class?
Nov 6, 2024
Post comments count 1
Post likes count 2

How do I declare an operator overload for my Windows Runtime class?

Raymond Chen
Raymond Chen

That's not something expressible in the Windows Runtime.

What’s the difference between Display size and Screen size in the Windows 95 display control panel?
Nov 5, 2024
Post comments count 6
Post likes count 4

What’s the difference between Display size and Screen size in the Windows 95 display control panel?

Raymond Chen
Raymond Chen

No meaningful difference, though others have created a difference.

On the limits of time travel in the face of undefined behavior in C
Nov 4, 2024
Post comments count 4
Post likes count 3

On the limits of time travel in the face of undefined behavior in C

Raymond Chen
Raymond Chen

C imposes some constraints, but the principle is mostly still there.

On locale-aware substring matching, either case-sensitive or case-insensitive
Nov 1, 2024
Post comments count 9
Post likes count 6

On locale-aware substring matching, either case-sensitive or case-insensitive

Raymond Chen
Raymond Chen

It's surprisingly complicated, but fortunately, somebody has done it for you.

What has case distinction but is neither uppercase nor lowercase?
Oct 31, 2024
Post comments count 23
Post likes count 10

What has case distinction but is neither uppercase nor lowercase?

Raymond Chen
Raymond Chen

It has one foot in each world but belongs to neither.

I have enabled “take ownership” permission, but I still cannot obtain write access
Oct 30, 2024
Post comments count 0
Post likes count 3

I have enabled “take ownership” permission, but I still cannot obtain write access

Raymond Chen
Raymond Chen

Taking ownership is only one part of gaining write access.

Reverse-engineering what a “short” section is
Oct 29, 2024
Post comments count 0
Post likes count 2

Reverse-engineering what a “short” section is

Raymond Chen
Raymond Chen

The long and short of it all.

How useful is the hint passed to the <CODE>std::<WBR>unordered_…</CODE> collections?
Oct 28, 2024
Post comments count 1
Post likes count 2

How useful is the hint passed to the <CODE>std::<WBR>unordered_…</CODE> collections?

Raymond Chen
Raymond Chen

Only a little, or sometimes not at all.

How can I explicitly specialize a templated C++ constructor, follow-up notes
Oct 25, 2024
Post comments count 0
Post likes count 2

How can I explicitly specialize a templated C++ constructor, follow-up notes

Raymond Chen
Raymond Chen

You can use a maker function, but that doesn't let you escape the problem.

It rather involved being on the other side of the airtight hatchway: Defeating ASLR after you’ve gained RCE via ROP
Oct 24, 2024
Post comments count 1
Post likes count 1

It rather involved being on the other side of the airtight hatchway: Defeating ASLR after you’ve gained RCE via ROP

Raymond Chen
Raymond Chen

If you defeat ASLR, then you can defeat ASLR.

How do I create a Windows Runtime <CODE>IRandom­Access­Stream</CODE> around a bunch of bytes or a classic COM <CODE>IStream</CODE>?
Oct 23, 2024
Post comments count 2
Post likes count 2

How do I create a Windows Runtime <CODE>IRandom­Access­Stream</CODE> around a bunch of bytes or a classic COM <CODE>IStream</CODE>?

Raymond Chen
Raymond Chen

Another wrapper function.

Did Windows 95 shrink the default font size of windowed MS-DOS apps?
Oct 22, 2024
Post comments count 3
Post likes count 5

Did Windows 95 shrink the default font size of windowed MS-DOS apps?

Raymond Chen
Raymond Chen

The effect was that it shrunk, but only sometimes.

Why does adding <CODE>WS_<WBR>MINIMIZE­BOX</CODE> change how my window behaves when the user presses <KBD>Win</KBD>+<KBD>D</KBD>?
Oct 21, 2024
Post comments count 10
Post likes count 2

Why does adding <CODE>WS_<WBR>MINIMIZE­BOX</CODE> change how my window behaves when the user presses <KBD>Win</KBD>+<KBD>D</KBD>?

Raymond Chen
Raymond Chen

It minimizes your window if it can.

Evaluating tail call elimination in the face of return address protection, part 2
Oct 18, 2024
Post comments count 2
Post likes count 1

Evaluating tail call elimination in the face of return address protection, part 2

Raymond Chen
Raymond Chen

Rewriting the activation frame.

Evaluating tail call elimination in the face of return address protection, part 1
Oct 17, 2024
Post comments count 2
Post likes count 1

Evaluating tail call elimination in the face of return address protection, part 1

Raymond Chen
Raymond Chen

Reusing the activation frame.

Effects of classic return address tricks on hardware-assisted return address protection
Oct 16, 2024
Post comments count 4
Post likes count 3

Effects of classic return address tricks on hardware-assisted return address protection

Raymond Chen
Raymond Chen

Return address manipulations that are possibly even more impermissible than they already were.

A quick introduction to return address protection technologies
Oct 15, 2024
Post comments count 4
Post likes count 2

A quick introduction to return address protection technologies

Raymond Chen
Raymond Chen

Detecting attempts to manipulate the return address.

On naming things: The tension between naming something for what it is, what it does, or how it is used
Oct 14, 2024
Post comments count 13
Post likes count 3

On naming things: The tension between naming something for what it is, what it does, or how it is used

Raymond Chen
Raymond Chen

You are guaranteed to make someone upset.

How can I explicitly specialize a templated C++ constructor?
Oct 11, 2024
Post comments count 1
Post likes count 3

How can I explicitly specialize a templated C++ constructor?

Raymond Chen
Raymond Chen

Looking for a C++ tag type for representing another type.

A correction to the awaitable lock for C++ PPL tasks
Oct 10, 2024
Post comments count 2
Post likes count 3

A correction to the awaitable lock for C++ PPL tasks

Raymond Chen
Raymond Chen

Over-scoped lock.

If threads are created without a message queue, why can I post to them immediately upon creation?
Oct 9, 2024
Post comments count 3
Post likes count 3

If threads are created without a message queue, why can I post to them immediately upon creation?

Raymond Chen
Raymond Chen

Check who is doing the posting.

Microspeak: Run to ground
Oct 8, 2024
Post comments count 1
Post likes count 2

Microspeak: Run to ground

Raymond Chen
Raymond Chen

Come to a resolution.

A popular but wrong way to convert a string to uppercase or lowercase
Oct 7, 2024
Post comments count 14
Post likes count 8

A popular but wrong way to convert a string to uppercase or lowercase

Raymond Chen
Raymond Chen

Converting character by character isn't good enough any more.

How does the linker decide whether to call <CODE>WinMain</CODE> or <CODE>wWinMain</CODE>?
Oct 4, 2024
Post comments count 0
Post likes count 3

How does the linker decide whether to call <CODE>WinMain</CODE> or <CODE>wWinMain</CODE>?

Raymond Chen
Raymond Chen

If you don't tell it, it will try to figure it out.

How can I detect whether the user is running as an elevated administrator (as opposed to a natural administrator)?
Oct 3, 2024
Post comments count 8
Post likes count 6

How can I detect whether the user is running as an elevated administrator (as opposed to a natural administrator)?

Raymond Chen
Raymond Chen

You can ask for the elevation type.

A function for creating an absolute security descriptor from a self-relative one
Oct 2, 2024
Post comments count 0
Post likes count 3

A function for creating an absolute security descriptor from a self-relative one

Raymond Chen
Raymond Chen

Just wrap it up.

Misunderstanding the “Prevent access to registry editing tools” policy
Oct 1, 2024
Post comments count 5
Post likes count 5

Misunderstanding the “Prevent access to registry editing tools” policy

Raymond Chen
Raymond Chen

It prevents access to the tools, but not to the registry itself.

Pulling a single item from a C++ parameter pack by its index, remarks
Sep 30, 2024
Post comments count 3
Post likes count 1

Pulling a single item from a C++ parameter pack by its index, remarks

Raymond Chen
Raymond Chen

Why such a complicated way to pull the type from the pack?

The case of the crash when destructing a <CODE>std::map</CODE>
Sep 27, 2024
Post comments count 3
Post likes count 5

The case of the crash when destructing a <CODE>std::map</CODE>

Raymond Chen
Raymond Chen

Who is corrupting the map?

If you’re going to specify the <CODE>LVS_SORTASCENDING</CODE> or <CODE>LVS_SORTDESCENDING</CODE> style, you had better be telling the truth
Sep 26, 2024
Post comments count 3
Post likes count 3

If you’re going to specify the <CODE>LVS_SORTASCENDING</CODE> or <CODE>LVS_SORTDESCENDING</CODE> style, you had better be telling the truth

Raymond Chen
Raymond Chen

Because the listview control uses it to optimize searching.

Another example of the Windows Runtime interop pattern: Using the UserConsentVerifier from a Win32 program
Sep 25, 2024
Post comments count 1
Post likes count 3

Another example of the Windows Runtime interop pattern: Using the UserConsentVerifier from a Win32 program

Raymond Chen
Raymond Chen

Following the standard pattern.

The UserConsentVerifier confirms that the user is there, but it doesn’t protect any data
Sep 24, 2024
Post comments count 3
Post likes count 2

The UserConsentVerifier confirms that the user is there, but it doesn’t protect any data

Raymond Chen
Raymond Chen

Is that really you?

Going beyond the empty set: Embracing the power of other empty things
Sep 23, 2024
Post comments count 6
Post likes count 2

Going beyond the empty set: Embracing the power of other empty things

Raymond Chen
Raymond Chen

Just because there's nothing in it doesn't mean it's not valid.

How can I check that all the changes in a git branch have been cherry-picked or rebased into its upstream branch?
Sep 20, 2024
Post comments count 5
Post likes count 3

How can I check that all the changes in a git branch have been cherry-picked or rebased into its upstream branch?

Raymond Chen
Raymond Chen

You can pretend to merge it and see if anything happens.

My window has the <CODE>WS_<WBR>EX_<WBR>NOACTIVATE</CODE> extended style, but it got activated anyway
Sep 19, 2024
Post comments count 0
Post likes count 5

My window has the <CODE>WS_<WBR>EX_<WBR>NOACTIVATE</CODE> extended style, but it got activated anyway

Raymond Chen
Raymond Chen

Well, at least it wasn't activated by a click.

More on the mysterious <CODE>[default_interface]</CODE> attribute in Windows Runtime classes
Sep 18, 2024
Post comments count 6
Post likes count 3

More on the mysterious <CODE>[default_interface]</CODE> attribute in Windows Runtime classes

Raymond Chen
Raymond Chen

Forcing you to make a choice.

It rather involved being on the other side of this airtight hatchway: Posting completions to somebody else’s I/O completion port
Sep 17, 2024
Post comments count 1
Post likes count 3

It rather involved being on the other side of this airtight hatchway: Posting completions to somebody else’s I/O completion port

Raymond Chen
Raymond Chen

If you have gained access to it, then that was the problem.

Some notes on Win32 carets
Sep 16, 2024
Post comments count 5
Post likes count 6

Some notes on Win32 carets

Raymond Chen
Raymond Chen

Assorted notes and musings.

The case of the fail-fast crashes coming from the power management system
Sep 13, 2024
Post comments count 3
Post likes count 4

The case of the fail-fast crashes coming from the power management system

Raymond Chen
Raymond Chen

Understanding why it decided to fail fast.

How can I tell whether two programs will share drive letter mappings?
Sep 12, 2024
Post comments count 0
Post likes count 3

How can I tell whether two programs will share drive letter mappings?

Raymond Chen
Raymond Chen

You can compare the authentication IDs.

The case of the string being copied from a mysterious pointer to invalid memory, revisited
Sep 11, 2024
Post comments count 2
Post likes count 1

The case of the string being copied from a mysterious pointer to invalid memory, revisited

Raymond Chen
Raymond Chen

Reflections on an older topic.

Does the Resource Compiler have a separate preprocessor or doesn’t it?
Sep 10, 2024
Post comments count 1
Post likes count 2

Does the Resource Compiler have a separate preprocessor or doesn’t it?

Raymond Chen
Raymond Chen

It did, but now it doesn't.

GitHub trick to find the commit that deleted a file
Sep 9, 2024
Post comments count 6
Post likes count 4

GitHub trick to find the commit that deleted a file

Raymond Chen
Raymond Chen

Ask for the history of the file.

The case of the image that came out horribly slanted: Negative stride
Sep 6, 2024
Post comments count 0
Post likes count 3

The case of the image that came out horribly slanted: Negative stride

Raymond Chen
Raymond Chen

It's all topsy-turvy.

The case of the image that came out horribly slanted: Taking the pitch into account
Sep 5, 2024
Post comments count 6
Post likes count 2

The case of the image that came out horribly slanted: Taking the pitch into account

Raymond Chen
Raymond Chen

Getting the pieces to line up.

The case of the image that came out horribly slanted: Diagnosis
Sep 4, 2024
Post comments count 4
Post likes count 3

The case of the image that came out horribly slanted: Diagnosis

Raymond Chen
Raymond Chen

Imperfect pitch.

Why did Windows 95 use blue screen error messages instead of hard error messages?
Sep 3, 2024
Post comments count 0
Post likes count 6

Why did Windows 95 use blue screen error messages instead of hard error messages?

Raymond Chen
Raymond Chen

You may not able to get there from here.

The <CODE>Co­Initialize­Security</CODE> function demands an absolute security descriptor
Sep 2, 2024
Post comments count 10
Post likes count 3

The <CODE>Co­Initialize­Security</CODE> function demands an absolute security descriptor

Raymond Chen
Raymond Chen

Even though you usually have a self-relative one in hand.

In the Windows kernel, what is a LUID, and what makes it loo-ey?
Aug 30, 2024
Post comments count 12
Post likes count 4

In the Windows kernel, what is a LUID, and what makes it loo-ey?

Raymond Chen
Raymond Chen

It's a locally-unique ID, for a specific definition of "local".

How is the Windows.Foundation.Uri.Domain property different from Host?
Aug 29, 2024
Post comments count 7
Post likes count 3

How is the Windows.Foundation.Uri.Domain property different from Host?

Raymond Chen
Raymond Chen

It's an educated guess.

On the strange status of <CODE>wchar_t</CODE> in classic MIDL
Aug 28, 2024
Post comments count 0
Post likes count 2

On the strange status of <CODE>wchar_t</CODE> in classic MIDL

Raymond Chen
Raymond Chen

From the era before <CODE>wchar_t</CODE> was a standard type.

The Microsoft/IBM joint development was built on mutual respect, wait, is respect the right word?
Aug 27, 2024
Post comments count 3
Post likes count 3

The Microsoft/IBM joint development was built on mutual respect, wait, is respect the right word?

Raymond Chen
Raymond Chen

Maybe it's some other word.

Thoughts on finding the essential elements of a set
Aug 26, 2024
Post comments count 9
Post likes count 3

Thoughts on finding the essential elements of a set

Raymond Chen
Raymond Chen

Another binary search, but searching a different way.

What if I need to wait for more than <CODE>MAXIMUM_<WBR>WAIT_<WBR>OBJECTS</CODE> threads?
Aug 23, 2024
Post comments count 7
Post likes count 5

What if I need to wait for more than <CODE>MAXIMUM_<WBR>WAIT_<WBR>OBJECTS</CODE> threads?

Raymond Chen
Raymond Chen

Studying your options, and the consequences of breaking things up.

The role of the activation factory in the Windows Runtime
Aug 22, 2024
Post comments count 3
Post likes count 1

The role of the activation factory in the Windows Runtime

Raymond Chen
Raymond Chen

The activation factory represents the class itself.

What does <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> mean?
Aug 21, 2024
Post comments count 1
Post likes count 4

What does <CODE>ERROR_<WBR>KEY_<WBR>DELETED</CODE> mean?

Raymond Chen
Raymond Chen

You now have a handle to a key that doesn't exist, and there's nothing you can do with it.

Another tribute to Microsoft history hiding in Building 41
Aug 20, 2024
Post comments count 1
Post likes count 4

Another tribute to Microsoft history hiding in Building 41

Raymond Chen
Raymond Chen

Logo touches.

Constructing nodes of a hand-made linked list, how hard can it be?
Aug 19, 2024
Post comments count 11
Post likes count 1

Constructing nodes of a hand-made linked list, how hard can it be?

Raymond Chen
Raymond Chen

Trying to force copy elision.

The case of the missing ordinal 380
Aug 16, 2024
Post comments count 4
Post likes count 1

The case of the missing ordinal 380

Raymond Chen
Raymond Chen

Untangling the error message and developing a theory.

Instead of putting a hash in the Portable Executable timestamp field, why not create a separate field for the hash?
Aug 15, 2024
Post comments count 9
Post likes count 4

Instead of putting a hash in the Portable Executable timestamp field, why not create a separate field for the hash?

Raymond Chen
Raymond Chen

That would defeat the purpose.

Temporarily dropping a lock: The anti-lock pattern
Aug 14, 2024
Post comments count 13
Post likes count 3

Temporarily dropping a lock: The anti-lock pattern

Raymond Chen
Raymond Chen

It's not to prevent locking, but rather to counteract a lock.

A look back at one of the (many) projects code-named Highlander
Aug 13, 2024
Post comments count 0
Post likes count 1

A look back at one of the (many) projects code-named Highlander

Raymond Chen
Raymond Chen

The showdown that almost repeated.

Embracing the power of the empty set in API design (and applying this principle to selectors and filters)
Aug 12, 2024
Post comments count 14
Post likes count 6

Embracing the power of the empty set in API design (and applying this principle to selectors and filters)

Raymond Chen
Raymond Chen

You got plenty of nothing.

What does it even mean to Close a Windows Runtime asynchronous operation or action?
Aug 9, 2024
Post comments count 2
Post likes count 2

What does it even mean to Close a Windows Runtime asynchronous operation or action?

Raymond Chen
Raymond Chen

That's the end of the road.

Why do I get <CODE>E_<WBR>ACCESS­DENIED</CODE> when trying to access my brokered Windows Runtime object?COM is double-checking the trust level.
Aug 8, 2024
Post comments count 0
Post likes count 3

Why do I get <CODE>E_<WBR>ACCESS­DENIED</CODE> when trying to access my brokered Windows Runtime object?COM is double-checking the trust level.

Raymond Chen
Raymond Chen

COM is double-checking the trust level.

How do I know when the user has finished interacting with the <CODE>Accounts­Settings­Pane</CODE>?
Aug 7, 2024
Post comments count 1
Post likes count 1

How do I know when the user has finished interacting with the <CODE>Accounts­Settings­Pane</CODE>?

Raymond Chen
Raymond Chen

You can use the version that runs an asynchronous operation.

It rather involved being on the other side of the airtight hatchway: Disabling a security feature as an administrator
Aug 6, 2024
Post comments count 9
Post likes count 3

It rather involved being on the other side of the airtight hatchway: Disabling a security feature as an administrator

Raymond Chen
Raymond Chen

At least they don't beat around the bush.

What are the dire consequences of registering a RunOnce command from my RunOnce command?
Aug 5, 2024
Post comments count 9
Post likes count 1

What are the dire consequences of registering a RunOnce command from my RunOnce command?

Raymond Chen
Raymond Chen

The circle of life, or a perpetual motion machine.

The difference between undefined behavior and ill-formed C++ programs
Aug 2, 2024
Post comments count 3
Post likes count 3

The difference between undefined behavior and ill-formed C++ programs

Raymond Chen
Raymond Chen

They are two kinds of undefined-ness, one for runtime and one for compile-time.

What’s the difference between <CODE>Data­Package­View.<WBR>Get­Uri­Async</CODE> and <CODE>Data­Package­View.<WBR>Get­Web­Link­Async</CODE>?
Aug 1, 2024
Post comments count 2
Post likes count 1

What’s the difference between <CODE>Data­Package­View.<WBR>Get­Uri­Async</CODE> and <CODE>Data­Package­View.<WBR>Get­Web­Link­Async</CODE>?

Raymond Chen
Raymond Chen

Just improving on an ambiguous name.

How to compress out interior padding in a <CODE>std::pair</CODE> and why you don’t want to
Jul 31, 2024
Post comments count 1
Post likes count 3

How to compress out interior padding in a <CODE>std::pair</CODE> and why you don’t want to

Raymond Chen
Raymond Chen

Context-sensitive layout means you get a different structure each time you use it.

There is no mystery over who wrote the Blue Screen of Death, despite what some may want you to believe
Jul 30, 2024
Post comments count 8
Post likes count 4

There is no mystery over who wrote the Blue Screen of Death, despite what some may want you to believe

Raymond Chen
Raymond Chen

No real contradictions in anybody's story.

Why don’t Windows Imaging Component pixel format GUIDs continue their nice pattern?
Jul 29, 2024
Post comments count 1
Post likes count 1

Why don’t Windows Imaging Component pixel format GUIDs continue their nice pattern?

Raymond Chen
Raymond Chen

Patterns are predictable, which is not always a good thing.

What can I do if IMlangConvertCharset is unable to convert from code page 28591 directly to UTF-8?
Jul 26, 2024
Post comments count 2
Post likes count 2

What can I do if IMlangConvertCharset is unable to convert from code page 28591 directly to UTF-8?

Raymond Chen
Raymond Chen

You can do the conversion in two steps using things you already have.

In my Visual Studio project, I set my Conformance mode to permissive, but it’s still not permissive
Jul 25, 2024
Post comments count 0
Post likes count 2

In my Visual Studio project, I set my Conformance mode to permissive, but it’s still not permissive

Raymond Chen
Raymond Chen

Digging into what the compiler sees.

API naming principle: If there is no direct object, then the direct object is the source object
Jul 24, 2024
Post comments count 7
Post likes count 1

API naming principle: If there is no direct object, then the direct object is the source object

Raymond Chen
Raymond Chen

If you don't know what it operates on or produces, then it operates on or produces itself.

Unquoted service paths: The new frontier in script kiddie security vulnerability reports
Jul 23, 2024
Post comments count 11
Post likes count 3

Unquoted service paths: The new frontier in script kiddie security vulnerability reports

Raymond Chen
Raymond Chen

Usually not exploitable, but the script kiddies don't know that.

Organizing the five creation dispositions of the <CODE>Create­File</CODE> function
Jul 22, 2024
Post comments count 9
Post likes count 5

Organizing the five creation dispositions of the <CODE>Create­File</CODE> function

Raymond Chen
Raymond Chen

Six possibilities, but only five useful ones.

Creating an already-completed asynchronous activity in C++/WinRT, part 9
Jul 19, 2024
Post comments count 0
Post likes count 1

Creating an already-completed asynchronous activity in C++/WinRT, part 9

Raymond Chen
Raymond Chen

Cheating the delegates.

Creating an already-completed asynchronous activity in C++/WinRT, part 8
Jul 18, 2024
Post comments count 1
Post likes count 1

Creating an already-completed asynchronous activity in C++/WinRT, part 8

Raymond Chen
Raymond Chen

Generalizing the pattern.

Creating an already-completed asynchronous activity in C++/WinRT, part 7
Jul 17, 2024
Post comments count 2
Post likes count 1

Creating an already-completed asynchronous activity in C++/WinRT, part 7

Raymond Chen
Raymond Chen

Implementing the contract directly.

Creating an already-completed asynchronous activity in C++/WinRT, part 6
Jul 16, 2024
Post comments count 0
Post likes count 1

Creating an already-completed asynchronous activity in C++/WinRT, part 6

Raymond Chen
Raymond Chen

Let the conversion do the talking.

Creating an already-completed asynchronous activity in C++/WinRT, part 5
Jul 15, 2024
Post comments count 0
Post likes count 1

Creating an already-completed asynchronous activity in C++/WinRT, part 5

Raymond Chen
Raymond Chen

Trying to fail more correctly.

Creating an already-completed asynchronous activity in C++/WinRT, part 4
Jul 12, 2024
Post comments count 2
Post likes count 3

Creating an already-completed asynchronous activity in C++/WinRT, part 4

Raymond Chen
Raymond Chen

Failing is easy. Failing correctly is hard.

Creating an already-completed asynchronous activity in C++/WinRT, part 3
Jul 11, 2024
Post comments count 0
Post likes count 2

Creating an already-completed asynchronous activity in C++/WinRT, part 3

Raymond Chen
Raymond Chen

Generalizing to the four kinds of Windows Runtime asynchronous activities.

Creating an already-completed asynchronous activity in C++/WinRT, part 2
Jul 10, 2024
Post comments count 2
Post likes count 3

Creating an already-completed asynchronous activity in C++/WinRT, part 2

Raymond Chen
Raymond Chen

Making our function a coroutine.

Creating an already-completed asynchonous activity in C++/WinRT, part 1
Jul 9, 2024
Post comments count 2
Post likes count 2

Creating an already-completed asynchonous activity in C++/WinRT, part 1

Raymond Chen
Raymond Chen

The simplest version.

What’s the point of <CODE>std::<WBR>monostate</CODE>? You can’t do anything with it!
Jul 8, 2024
Post comments count 5
Post likes count 3

What’s the point of <CODE>std::<WBR>monostate</CODE>? You can’t do anything with it!

Raymond Chen
Raymond Chen

Not doing anything with it is exactly the point.

How do I produce a Windows Runtime asynchronous activity from C++/WinRT?
Jul 5, 2024
Post comments count 0
Post likes count 2

How do I produce a Windows Runtime asynchronous activity from C++/WinRT?

Raymond Chen
Raymond Chen

Somebody that deals with them natively.

How do I produce a Windows Runtime asynchronous activity from C#?
Jul 4, 2024
Post comments count 2
Post likes count 3

How do I produce a Windows Runtime asynchronous activity from C#?

Raymond Chen
Raymond Chen

The AsyncInfo helper class converts Tasks to Windows Runtime asynchronous activities.

How do I produce a Windows Runtime asynchronous activity from C++/CX?
Jul 3, 2024
Post comments count 1
Post likes count 1

How do I produce a Windows Runtime asynchronous activity from C++/CX?

Raymond Chen
Raymond Chen

The Parallel Patterns Library has special support for C++/CX.

The history of <KBD>Alt</KBD>+number sequences, and why <KBD>Alt</KBD>+<KBD>9731</KBD> sometimes gives you a heart and sometimes a snowman
Jul 2, 2024
Post comments count 22
Post likes count 5

The history of <KBD>Alt</KBD>+number sequences, and why <KBD>Alt</KBD>+<KBD>9731</KBD> sometimes gives you a heart and sometimes a snowman

Raymond Chen
Raymond Chen

Code pages and custom keyboard handling.

If I register the same shell extension as both a context menu extension and a drag/drop extension, how do I know which one the system is using?
Jul 1, 2024
Post comments count 5
Post likes count 3

If I register the same shell extension as both a context menu extension and a drag/drop extension, how do I know which one the system is using?

Raymond Chen
Raymond Chen

Who forced you to register the same shell extension for both?

2024 mid-year link clearance
Jun 28, 2024
Post comments count 11
Post likes count 3

2024 mid-year link clearance

Raymond Chen
Raymond Chen

Emptying out the junk drawer.

Writing a <CODE>remove_all_pointers</CODE> type trait, part 2
Jun 28, 2024
Post comments count 2
Post likes count 3

Writing a <CODE>remove_all_pointers</CODE> type trait, part 2

Raymond Chen
Raymond Chen

Factoring out the type resolution to after the dangerous part.

Writing a <CODE>remove_all_pointers</CODE> type trait, part 1
Jun 27, 2024
Post comments count 3
Post likes count 3

Writing a <CODE>remove_all_pointers</CODE> type trait, part 1

Raymond Chen
Raymond Chen

Delaying the expansion to avoid infinite recursion.

Is there a built-in way in C++/WinRT to get the string name for a Windows Runtime enum?
Jun 26, 2024
Post comments count 2
Post likes count 1

Is there a built-in way in C++/WinRT to get the string name for a Windows Runtime enum?

Raymond Chen
Raymond Chen

No, and maybe you don't want to.

Microspeak: Fun fork
Jun 25, 2024
Post comments count 0
Post likes count 1

Microspeak: Fun fork

Raymond Chen
Raymond Chen

A place to party.

Finding a specific value in a sequence of integers that changes by at most 1
Jun 24, 2024
Post comments count 7
Post likes count 1

Finding a specific value in a sequence of integers that changes by at most 1

Raymond Chen
Raymond Chen

It's basically a discrete version of the intermediate value theorem.

The Windows Runtime <CODE>winrt::<WBR>hstring</CODE> and the C++ <CODE>std::<WBR>wstring</CODE> are inter-assignable
Jun 21, 2024
Post comments count 1
Post likes count 1

The Windows Runtime <CODE>winrt::<WBR>hstring</CODE> and the C++ <CODE>std::<WBR>wstring</CODE> are inter-assignable

Raymond Chen
Raymond Chen

Just assign them over, no cermony necessary.

How to convert between different types of counted-string string types
Jun 20, 2024
Post comments count 0
Post likes count 3

How to convert between different types of counted-string string types

Raymond Chen
Raymond Chen

Looking for constructors that take a character count.

On the sadness of treating counted strings as null-terminated strings
Jun 19, 2024
Post comments count 12
Post likes count 2

On the sadness of treating counted strings as null-terminated strings

Raymond Chen
Raymond Chen

You're throwing away perfectly good data, there.

The time smart quotes prevented the entire Office division from committing code
Jun 18, 2024
Post comments count 9
Post likes count 1

The time smart quotes prevented the entire Office division from committing code

Raymond Chen
Raymond Chen

Breaking your tools with your tools.

How can I view the list of symbols available in a library?
Jun 17, 2024
Post comments count 5
Post likes count 4

How can I view the list of symbols available in a library?

Raymond Chen
Raymond Chen

A tool hiding inside another tool.

Lock-free reference-counting a TLS slot using atomics, part 3
Jun 14, 2024
Post comments count 3
Post likes count 1

Lock-free reference-counting a TLS slot using atomics, part 3

Raymond Chen
Raymond Chen

Keeping track of two things at once.

Lock-free reference-counting a TLS slot using atomics, part 2
Jun 13, 2024
Post comments count 2
Post likes count 2

Lock-free reference-counting a TLS slot using atomics, part 2

Raymond Chen
Raymond Chen

Getting it is easy. Getting rid of it is hard.

Lock-free reference-counting a TLS slot using atomics, part 1
Jun 12, 2024
Post comments count 6
Post likes count 1

Lock-free reference-counting a TLS slot using atomics, part 1

Raymond Chen
Raymond Chen

First, we do it with locks.

The origin story of the Windows 3D Pipes screen saver
Jun 11, 2024
Post comments count 19
Post likes count 7

The origin story of the Windows 3D Pipes screen saver

Raymond Chen
Raymond Chen

Looking for a place to show off.

How do I get the name of a SID, and what does it mean when the conversion fails?
Jun 10, 2024
Post comments count 15
Post likes count 1

How do I get the name of a SID, and what does it mean when the conversion fails?

Raymond Chen
Raymond Chen

Most places will do it for you, or at least try.

What’s the deal with <CODE>std::type_identity</CODE>?
Jun 7, 2024
Post comments count 4
Post likes count 2

What’s the deal with <CODE>std::type_identity</CODE>?

Raymond Chen
Raymond Chen

When you want to use a type without participating in type deduction.

Can INI files be Unicode? Yes, they can, but it has to be your idea
Jun 6, 2024
Post comments count 8
Post likes count 3

Can INI files be Unicode? Yes, they can, but it has to be your idea

Raymond Chen
Raymond Chen

It'll only be Unicode if it's already Unicode.

How 16-bit Windows cached INI files for performance
Jun 5, 2024
Post comments count 0
Post likes count 3

How 16-bit Windows cached INI files for performance

Raymond Chen
Raymond Chen

Taking advantage of co-operative multitasking.

Why does <CODE>Global­Lock</CODE> max out at 255 locks?
Jun 4, 2024
Post comments count 3
Post likes count 1

Why does <CODE>Global­Lock</CODE> max out at 255 locks?

Raymond Chen
Raymond Chen

Because that's how many bits were available for reporting the lock count.

More on harmful overuse of <CODE>std::<WBR>move</CODE>
Jun 3, 2024
Post comments count 9
Post likes count 1

More on harmful overuse of <CODE>std::<WBR>move</CODE>

Raymond Chen
Raymond Chen

Could we expand copy elision to cover the harmful cases?

A graphical depiction of the steps in building a C++ executable, with XAML and packaging
May 31, 2024
Post comments count 4
Post likes count 5

A graphical depiction of the steps in building a C++ executable, with XAML and packaging

Raymond Chen
Raymond Chen

Fleshing out the diagram.

A graphical depiction of the steps in building a C++ executable, enhanced for classic Win32
May 30, 2024
Post comments count 1
Post likes count 1

A graphical depiction of the steps in building a C++ executable, enhanced for classic Win32

Raymond Chen
Raymond Chen

Adding in Microsoft-specific tools.

A graphical depiction of the steps in building a C++ executable, basics
May 29, 2024
Post comments count 5
Post likes count 2

A graphical depiction of the steps in building a C++ executable, basics

Raymond Chen
Raymond Chen

A high-level overview.

How can I force a DLL to register itself if it won’t respond to <CODE>regsvr32</CODE>?
May 28, 2024
Post comments count 6
Post likes count 4

How can I force a DLL to register itself if it won’t respond to <CODE>regsvr32</CODE>?

Raymond Chen
Raymond Chen

You can't force something that isn't there.

Is there any difference between <CODE>String­From­IID</CODE> and <CODE>String­From­CLSID</CODE>?
May 27, 2024
Post comments count 3
Post likes count 3

Is there any difference between <CODE>String­From­IID</CODE> and <CODE>String­From­CLSID</CODE>?

Raymond Chen
Raymond Chen

Not really.

Setting the contents of a Windows Runtime Vector from C++/WinRT in one call
May 24, 2024
Post comments count 0
Post likes count 1

Setting the contents of a Windows Runtime Vector from C++/WinRT in one call

Raymond Chen
Raymond Chen

The one-stop shop for updating a Windows Runtime Vector.

Creating a prepopulated Windows Runtime Vector from C++/WinRT without going through an explicit <CODE>std::<WBR>vector</CODE>
May 23, 2024
Post comments count 0
Post likes count 1

Creating a prepopulated Windows Runtime Vector from C++/WinRT without going through an explicit <CODE>std::<WBR>vector</CODE>

Raymond Chen
Raymond Chen

Creating the vector inline.

If you have to create a Windows Runtime Vector from C++/WinRT, do it as late as possible
May 22, 2024
Post comments count 3
Post likes count 1

If you have to create a Windows Runtime Vector from C++/WinRT, do it as late as possible

Raymond Chen
Raymond Chen

Stay with the <CODE>std::vector</CODE> until you really need the Window Runtime Vector.

A blurry photo of the legendary USB Cart of Death
May 21, 2024
Post comments count 6
Post likes count 6

A blurry photo of the legendary USB Cart of Death

Raymond Chen
Raymond Chen

And some details about that infamous on-stage bluescreen.

If you know what interface you want, just pass it directly to CoCreateInstance
May 20, 2024
Post comments count 5
Post likes count 1

If you know what interface you want, just pass it directly to CoCreateInstance

Raymond Chen
Raymond Chen

Avoiding a second round trip.

Why can’t I find the injected name of a templated class’s templated base class?
May 17, 2024
Post comments count 0
Post likes count 1

Why can’t I find the injected name of a templated class’s templated base class?

Raymond Chen
Raymond Chen

The compiler needs help finding it because it's not findable at the time the template is parsed.

Pulling a single item from a C++ parameter pack by its index
May 16, 2024
Post comments count 1
Post likes count 2

Pulling a single item from a C++ parameter pack by its index

Raymond Chen
Raymond Chen

Combining a few tools to make a new tool.

Building the most efficient device selector query that selects no devices
May 15, 2024
Post comments count 9
Post likes count 2

Building the most efficient device selector query that selects no devices

Raymond Chen
Raymond Chen

Looking for the most efficient way of rejecting everything.

The confidential coffee maker was not the only source of shenanigans at the IBM Boca office
May 14, 2024
Post comments count 1
Post likes count 5

The confidential coffee maker was not the only source of shenanigans at the IBM Boca office

Raymond Chen
Raymond Chen

The culture (and weather) clash continues.

Before you try to change something, make sure you can change nothing
May 13, 2024
Post comments count 2
Post likes count 5

Before you try to change something, make sure you can change nothing

Raymond Chen
Raymond Chen

Nobody touch anything.

An informal comparison of the three major implementations of <CODE>std::string</CODE>
May 10, 2024
Post comments count 4
Post likes count 7

An informal comparison of the three major implementations of <CODE>std::string</CODE>

Raymond Chen
Raymond Chen

Pros and cons.

Asking for a DispatcherQueue from a GUI thread you created
May 9, 2024
Post comments count 0
Post likes count 1

Asking for a DispatcherQueue from a GUI thread you created

Raymond Chen
Raymond Chen

Grafting a DispatcherQueue onto an existing thread.

Awaiting a set of handles with a timeout, part 7: Just doing it one at a time
May 8, 2024
Post comments count 3
Post likes count 1

Awaiting a set of handles with a timeout, part 7: Just doing it one at a time

Raymond Chen
Raymond Chen

A simpler version with its own quirks.

Awaiting a set of handles with a timeout, part 6: Capturing the handles efficiently
May 7, 2024
Post comments count 7
Post likes count 1

Awaiting a set of handles with a timeout, part 6: Capturing the handles efficiently

Raymond Chen
Raymond Chen

SFINAE'ing the case of a random-access(ish) iterator.

Awaiting a set of handles with a timeout, part 5: Generalizing the awaiter
May 6, 2024
Post comments count 0
Post likes count 1

Awaiting a set of handles with a timeout, part 5: Generalizing the awaiter

Raymond Chen
Raymond Chen

Fitting into existing patterns.

Awaiting a set of handles with a timeout, part 4: Building our own awaiter
May 3, 2024
Post comments count 1
Post likes count 1

Awaiting a set of handles with a timeout, part 4: Building our own awaiter

Raymond Chen
Raymond Chen

To stop relying on unspecified behavior.

Awaiting a set of handles with a timeout, part 3: Going beyond two
May 2, 2024
Post comments count 2
Post likes count 1

Awaiting a set of handles with a timeout, part 3: Going beyond two

Raymond Chen
Raymond Chen

Generalizing what we learned last time.

Awaiting a set of handles with a timeout, part 2: Continuing with two
May 1, 2024
Post comments count 4
Post likes count 1

Awaiting a set of handles with a timeout, part 2: Continuing with two

Raymond Chen
Raymond Chen

Giving it another try.

Awaiting a set of handles with a timeout, part 1: Starting with two
Apr 30, 2024
Post comments count 3
Post likes count 1

Awaiting a set of handles with a timeout, part 1: Starting with two

Raymond Chen
Raymond Chen

Let's see by seeing if we can do it with just two.

Awaiting a set of handles in C++/WinRT
Apr 29, 2024
Post comments count 0
Post likes count 2

Awaiting a set of handles in C++/WinRT

Raymond Chen
Raymond Chen

It's easier thank you think.

Adding state to the update notification pattern, part 8
Apr 26, 2024
Post comments count 0
Post likes count 1

Adding state to the update notification pattern, part 8

Raymond Chen
Raymond Chen

Comparing the two algorithms.

Adding state to the update notification pattern, part 7
Apr 25, 2024
Post comments count 5
Post likes count 1

Adding state to the update notification pattern, part 7

Raymond Chen
Raymond Chen

Going free-threaded.

Adding state to the update notification pattern, part 6
Apr 24, 2024
Post comments count 0
Post likes count 2

Adding state to the update notification pattern, part 6

Raymond Chen
Raymond Chen

Using a change counter with coalescing.

Adding state to the update notification pattern, part 5
Apr 23, 2024
Post comments count 1
Post likes count 1

Adding state to the update notification pattern, part 5

Raymond Chen
Raymond Chen

Using a change counter.

Adding state to the update notification pattern, part 4
Apr 22, 2024
Post comments count 0
Post likes count 1

Adding state to the update notification pattern, part 4

Raymond Chen
Raymond Chen

What if the UI thread isn't there to save you?

Adding state to the update notification pattern, part 3
Apr 19, 2024
Post comments count 2
Post likes count 1

Adding state to the update notification pattern, part 3

Raymond Chen
Raymond Chen

Abandoning the background work if we know that it is pointless.

Adding state to the update notification pattern, part 2
Apr 18, 2024
Post comments count 2
Post likes count 1

Adding state to the update notification pattern, part 2

Raymond Chen
Raymond Chen

First attempt to try to fix the race condition.

Adding state to the update notification pattern, part 1
Apr 17, 2024
Post comments count 0
Post likes count 3

Adding state to the update notification pattern, part 1

Raymond Chen
Raymond Chen

Where each notification depends on some state information.

In search of the Ballmer Peak, and other results from SIGBOVIK 2024
Apr 16, 2024
Post comments count 4
Post likes count 0

In search of the Ballmer Peak, and other results from SIGBOVIK 2024

Raymond Chen
Raymond Chen

Continuing studies in silliness.

Dubious security vulnerability: Program allows its output to be exfiltrated
Apr 16, 2024
Post comments count 2
Post likes count 2

Dubious security vulnerability: Program allows its output to be exfiltrated

Raymond Chen
Raymond Chen

Once the output is generated, the program can't control where it goes.

What were the tax consequences of letting Windows 95 team members keep a piece of software as long as they tested it?
Apr 15, 2024
Post comments count 4
Post likes count 2

What were the tax consequences of letting Windows 95 team members keep a piece of software as long as they tested it?

Raymond Chen
Raymond Chen

It basically falls under the <I>de minimis</I> rule.

The case of the string being copied from a mysterious pointer to invalid memory
Apr 12, 2024
Post comments count 8
Post likes count 7

The case of the string being copied from a mysterious pointer to invalid memory

Raymond Chen
Raymond Chen

Using AppVerifier to deduce the heap allocation history.

Why do <CODE>STANDARD_<WBR>RIGHTS_<WBR>READ</CODE>, <CODE>STANDARD_<WBR>RIGHTS_<WBR>WRITE</CODE>, and <CODE>STANDARD_<WBR>RIGHTS_<WBR>EXECUTE</CODE> have the same values?
How can I find out which process has locked me out of the clipboard?
Apr 10, 2024
Post comments count 1
Post likes count 1

How can I find out which process has locked me out of the clipboard?

Raymond Chen
Raymond Chen

You can ask for the clipboard opener.

If I enumerate all the processes and add up all the <CODE>Get­Gui­Resources</CODE>, why doesn’t it match the <CODE>GR_<WBR>GLOBAL</CODE> value?
Apr 9, 2024
Post comments count 0
Post likes count 1

If I enumerate all the processes and add up all the <CODE>Get­Gui­Resources</CODE>, why doesn’t it match the <CODE>GR_<WBR>GLOBAL</CODE> value?

Raymond Chen
Raymond Chen

There are some things that aren't charged to processes.

How does the classic Win32 ListView handle incremental searching?
Apr 8, 2024
Post comments count 18
Post likes count 4

How does the classic Win32 ListView handle incremental searching?

Raymond Chen
Raymond Chen

Combining prefix search with repeated search, to accommodate multiple styles.

The case of the exception that a <CODE>catch (…)</CODE> didn’t catch
Apr 5, 2024
Post comments count 0
Post likes count 2

The case of the exception that a <CODE>catch (…)</CODE> didn’t catch

Raymond Chen
Raymond Chen

Reconstructing a false history.

It rather involved being on the other side of this airtight hatchway: System corruption caused by an administrator
Apr 4, 2024
Post comments count 16
Post likes count 4

It rather involved being on the other side of this airtight hatchway: System corruption caused by an administrator

Raymond Chen
Raymond Chen

If your goal was to corrupt the system, you sure are doing it the hard way.

Windows debugger trick: Breaking when a specific debugger message is printed
Apr 3, 2024
Post comments count 2
Post likes count 5

Windows debugger trick: Breaking when a specific debugger message is printed

Raymond Chen
Raymond Chen

A different kind of conditional breakpoint.

The history of computing, as told by the hallways of Microsoft Building 41
Apr 2, 2024
Post comments count 4
Post likes count 6

The history of computing, as told by the hallways of Microsoft Building 41

Raymond Chen
Raymond Chen

A walk through history, in the form of wall textures.

Subroutine calls in the ancient world, before computers had stacks or heaps
Apr 1, 2024
Post comments count 19
Post likes count 9

Subroutine calls in the ancient world, before computers had stacks or heaps

Raymond Chen
Raymond Chen

A lot of computing got done even before we had stacks and heaps.

How can I tell C++ that I want to discard a nodiscard value?
Mar 29, 2024
Post comments count 10
Post likes count 5

How can I tell C++ that I want to discard a nodiscard value?

Raymond Chen
Raymond Chen

A variety of tricks, with different degrees of readability and legality.

I called <CODE>Create­Environment­Block</CODE> with a process’s token, but I didn’t get that process’s environment
Mar 28, 2024
Post comments count 8
Post likes count 3

I called <CODE>Create­Environment­Block</CODE> with a process’s token, but I didn’t get that process’s environment

Raymond Chen
Raymond Chen

That's not what the <CODE>Create­Environment­Block</CODE> function does.

Some choices for encrypting data so that it can be decrypted only by the same user or computer
Mar 27, 2024
Post comments count 9
Post likes count 5

Some choices for encrypting data so that it can be decrypted only by the same user or computer

Raymond Chen
Raymond Chen

There's your classic, and there's some newfangled stuff.

Dubious security vulnerability: Manual operations can cause a program to hang
Mar 26, 2024
Post comments count 2
Post likes count 4

Dubious security vulnerability: Manual operations can cause a program to hang

Raymond Chen
Raymond Chen

You did this to yourself.

Why isn’t C++ using my default parameter to deduce a template type?
Mar 25, 2024
Post comments count 0
Post likes count 4

Why isn’t C++ using my default parameter to deduce a template type?

Raymond Chen
Raymond Chen

Trying to have it both ways.

Why does my thread get a broken string as its initial parameter?
Mar 22, 2024
Post comments count 7
Post likes count 2

Why does my thread get a broken string as its initial parameter?

Raymond Chen
Raymond Chen

It got converted too late.

Using the <CODE>Display­Information</CODE> class from a desktop Win32 application, part 2
Mar 21, 2024
Post comments count 13
Post likes count 1

Using the <CODE>Display­Information</CODE> class from a desktop Win32 application, part 2

Raymond Chen
Raymond Chen

Completing the prerequisites.

Using the <CODE>Display­Information</CODE> class from a desktop Win32 application, part 1
Mar 20, 2024
Post comments count 3
Post likes count 2

Using the <CODE>Display­Information</CODE> class from a desktop Win32 application, part 1

Raymond Chen
Raymond Chen

A little interop music.

How well does C++/WinRT <CODE>com_ptr</CODE> support class template argument deduction (CTAD)?
Mar 19, 2024
Post comments count 0
Post likes count 1

How well does C++/WinRT <CODE>com_ptr</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

It doesn't even try, and probably doesn't want you to do it.

How well does wil <CODE>com_ptr</CODE> support class template argument deduction (CTAD)?
Mar 18, 2024
Post comments count 0
Post likes count 1

How well does wil <CODE>com_ptr</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

Falling into a hole in the C++ language, not filled in until C++20.

How well does WRL <CODE>ComPtr</CODE> support class template argument deduction (CTAD)?
Mar 15, 2024
Post comments count 4
Post likes count 1

How well does WRL <CODE>ComPtr</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

It tries too hard and accidentally breaks CTAD.

How well does ATL <CODE>CComPtr</CODE> support class template argument deduction (CTAD)?
Mar 14, 2024
Post comments count 1
Post likes count 1

How well does ATL <CODE>CComPtr</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

It actually works right out of the box.

How well does MFC <CODE>IPTR</CODE>/<CODE>CIP</CODE> support class template argument deduction (CTAD)?
Mar 13, 2024
Post comments count 1
Post likes count 1

How well does MFC <CODE>IPTR</CODE>/<CODE>CIP</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

Not very well, thanks to requiring the interface ID to be specified explicitly.

How well does <CODE>_com_ptr_t</CODE> support class template argument deduction (CTAD)?
Mar 12, 2024
Post comments count 0
Post likes count 2

How well does <CODE>_com_ptr_t</CODE> support class template argument deduction (CTAD)?

Raymond Chen
Raymond Chen

Not very well, thanks to storing the pointer and IID pair in a helper type.

Class template argument deduction (CTAD) and C++ COM wrappers: Initial explorations
Mar 11, 2024
Post comments count 3
Post likes count 3

Class template argument deduction (CTAD) and C++ COM wrappers: Initial explorations

Raymond Chen
Raymond Chen

How well do these libraries support a feature that likely didn't exist at the time they were written?

The 2024/2025 Seattle Symphony subscription season at a glance
Mar 8, 2024
Post comments count 0
Post likes count 0

The 2024/2025 Seattle Symphony subscription season at a glance

Raymond Chen
Raymond Chen

The pocket reference guide for 2024/2025.

How can I force a copy of a C++ value?
Mar 8, 2024
Post comments count 5
Post likes count 1

How can I force a copy of a C++ value?

Raymond Chen
Raymond Chen

Forcing a copy with a minimum of typing.

In C++/WinRT, you shouldn’t destroy an object while you’re <CODE>co_await</CODE>ing it
Mar 7, 2024
Post comments count 4
Post likes count 1

In C++/WinRT, you shouldn’t destroy an object while you’re <CODE>co_await</CODE>ing it

Raymond Chen
Raymond Chen

A generalization of the ground rules of programming.

How do I make an expression non-movable? What’s the opposite of <CODE>std::move</CODE>?
Mar 6, 2024
Post comments count 5
Post likes count 1

How do I make an expression non-movable? What’s the opposite of <CODE>std::move</CODE>?

Raymond Chen
Raymond Chen

You can turn it into a const thing so it's no longer movable, in a conventional sense.

In domain\user syntax, you can often use the period as an abbreviation for “this computer”
Mar 5, 2024
Post comments count 4
Post likes count 2

In domain\user syntax, you can often use the period as an abbreviation for “this computer”

Raymond Chen
Raymond Chen

A bit of a typing saver, particularly with complex machine names.

Is shadowing a member variable from a base class a bad thing? Maybe, but maybe not.
Mar 4, 2024
Post comments count 1
Post likes count 4

Is shadowing a member variable from a base class a bad thing? Maybe, but maybe not.

Raymond Chen
Raymond Chen

It depends on the order in which things occurred.

C++/WinRT performance trap: Switching to Windows Runtime too soon
Mar 1, 2024
Post comments count 14
Post likes count 4

C++/WinRT performance trap: Switching to Windows Runtime too soon

Raymond Chen
Raymond Chen

Stay in the devirtualized world until you are forced to leave.

If a parameter isn’t used, what should I pass?
Feb 29, 2024
Post comments count 7
Post likes count 5

If a parameter isn’t used, what should I pass?

Raymond Chen
Raymond Chen

It doesn't matter what you pass, but if you have to ask, then just pass zero.

On the whole idea of giving away a reference to yourself at destruction
Feb 28, 2024
Post comments count 16
Post likes count 2

On the whole idea of giving away a reference to yourself at destruction

Raymond Chen
Raymond Chen

Hey, at least it's possible.

Mitigating attacks based on knowing the length of a Windows Hello PIN
Feb 27, 2024
Post comments count 15
Post likes count 2

Mitigating attacks based on knowing the length of a Windows Hello PIN

Raymond Chen
Raymond Chen

Balancing convenience against security, and how you can tune the knobs toward more security.

A C# LINQ one-liner to check if exactly one of a set of conditions is met
Feb 26, 2024
Post comments count 21
Post likes count 1

A C# LINQ one-liner to check if exactly one of a set of conditions is met

Raymond Chen
Raymond Chen

Maybe not the most efficient, but it's easy to write.

Gotcha: Be careful how you shut down your dispatcher queues
Feb 23, 2024
Post comments count 4
Post likes count 4

Gotcha: Be careful how you shut down your dispatcher queues

Raymond Chen
Raymond Chen

The dispatcher queue thread isn't useful after it has shut down, so don't try anything.

Gotcha: Don’t forget to shut down your dispatcher queues
Feb 22, 2024
Post comments count 1
Post likes count 1

Gotcha: Don’t forget to shut down your dispatcher queues

Raymond Chen
Raymond Chen

Keep that dispatcher queue controller around, or you'll never be able to clean up.

Once your object reaches <CODE>final_release</CODE>, you are committed to destructing it (eventually)
Feb 21, 2024
Post comments count 1
Post likes count 1

Once your object reaches <CODE>final_release</CODE>, you are committed to destructing it (eventually)

Raymond Chen
Raymond Chen

Don't try to resurrect it.

Microspeak: Closing out, duping out
Feb 20, 2024
Post comments count 3
Post likes count 1

Microspeak: Closing out, duping out

Raymond Chen
Raymond Chen

Making work items no longer appear on a query.

Why can’t I trigger a manual blue screen crash by injecting the magic key sequence?
Feb 19, 2024
Post comments count 9
Post likes count 5

Why can’t I trigger a manual blue screen crash by injecting the magic key sequence?

Raymond Chen
Raymond Chen

It has to come from the physical keyboard, because that's the code that detects the magic key sequence.

If you’re just going to sit there doing nothing, at least do nothing correctly
Feb 16, 2024
Post comments count 17
Post likes count 8

If you’re just going to sit there doing nothing, at least do nothing correctly

Raymond Chen
Raymond Chen

How to be inert.

Registered command lines are just command lines, not a programming language
Feb 15, 2024
Post comments count 3
Post likes count 8

Registered command lines are just command lines, not a programming language

Raymond Chen
Raymond Chen

If you want a programming language, you know where to find one.

Functions that return the size of a required buffer generally return upper bounds, not tight bounds
Feb 14, 2024
Post comments count 6
Post likes count 4

Functions that return the size of a required buffer generally return upper bounds, not tight bounds

Raymond Chen
Raymond Chen

An over-estimate is better than an under-estimate.

It rather involved being on the other side of this airtight hatchway: Attacking a domain administrator from the local administrator
Feb 13, 2024
Post comments count 3
Post likes count 3

It rather involved being on the other side of this airtight hatchway: Attacking a domain administrator from the local administrator

Raymond Chen
Raymond Chen

If you pwn the machine, then you pwn everyone on the machine.

How can I get the Windows Runtime HttpClient to display a basic authentication prompt?
Feb 12, 2024
Post comments count 1
Post likes count 2

How can I get the Windows Runtime HttpClient to display a basic authentication prompt?

Raymond Chen
Raymond Chen

You need to give it some help finding the right window.

On the virtues of the trailing comma
Feb 9, 2024
Post comments count 25
Post likes count 11

On the virtues of the trailing comma

Raymond Chen
Raymond Chen

A more uniform appearance comes with its own benefits beyond aesthetics.

How do I suppress the error box that appears when a <CODE>LoadLibrary</CODE> fails?
Feb 8, 2024
Post comments count 3
Post likes count 3

How do I suppress the error box that appears when a <CODE>LoadLibrary</CODE> fails?

Raymond Chen
Raymond Chen

They don't appear often, but they do appear occasionally.

Why doesn’t my program get fancy drag/drop effects in high contrast mode with <CODE>CLSID_<WBR>Drag­Drop­Helper</CODE>?
Feb 7, 2024
Post comments count 4
Post likes count 2

Why doesn’t my program get fancy drag/drop effects in high contrast mode with <CODE>CLSID_<WBR>Drag­Drop­Helper</CODE>?

Raymond Chen
Raymond Chen

You have to upgrade your manifest.

On using milliseconds as a measure of network latency
Feb 6, 2024
Post comments count 11
Post likes count 3

On using milliseconds as a measure of network latency

Raymond Chen
Raymond Chen

There's a limit to how much technology can improve.

How can I close a thread pool and cancel all work that had been queued to it?
Feb 5, 2024
Post comments count 1
Post likes count 4

How can I close a thread pool and cancel all work that had been queued to it?

Raymond Chen
Raymond Chen

You can put them in a group.

The case of the invalid parameter error from <CODE>Measure­Override</CODE>
Feb 2, 2024
Post comments count 4
Post likes count 1

The case of the invalid parameter error from <CODE>Measure­Override</CODE>

Raymond Chen
Raymond Chen

Chasing it back to its origin.

Using virtual memory placeholders to allocate contiguous address space for multiple purposes
Feb 1, 2024
Post comments count 7
Post likes count 2

Using virtual memory placeholders to allocate contiguous address space for multiple purposes

Raymond Chen
Raymond Chen

Can you hold this for a second?

How can I add an environment variable to a process launched via <CODE>Shell­Execute­Ex</CODE> or <CODE>IContext­Menu</CODE>?
Jan 31, 2024
Post comments count 10
Post likes count 2

How can I add an environment variable to a process launched via <CODE>Shell­Execute­Ex</CODE> or <CODE>IContext­Menu</CODE>?

Raymond Chen
Raymond Chen

Hooking into the way the Windows shell launches processes.

Smoothing over the differences (and defects) in the various implementations of <CODE>IMemory­Buffer</CODE>
Jan 30, 2024
Post comments count 1
Post likes count 1

Smoothing over the differences (and defects) in the various implementations of <CODE>IMemory­Buffer</CODE>

Raymond Chen
Raymond Chen

Stick to the part that nobody messes up.

A comparison of various implementations of the Windows Runtime <CODE>IMemory­Buffer</CODE>
Jan 29, 2024
Post comments count 0
Post likes count 2

A comparison of various implementations of the Windows Runtime <CODE>IMemory­Buffer</CODE>

Raymond Chen
Raymond Chen

Every unhappy class is unhappy in its own way.

How can I expose a pre-existing block of memory as a Windows Runtime object without copying the data?
Jan 26, 2024
Post comments count 0
Post likes count 2

How can I expose a pre-existing block of memory as a Windows Runtime object without copying the data?

Raymond Chen
Raymond Chen

Assembling all the pieces.

How can I give away a COM reference just before my object destructs?
Jan 25, 2024
Post comments count 8
Post likes count 1

How can I give away a COM reference just before my object destructs?

Raymond Chen
Raymond Chen

You have to do it before committing to destruction.

The dangerous implementations of the <CODE>IMemory­Buffer­Reference.Closed</CODE> event
Jan 24, 2024
Post comments count 2
Post likes count 2

The dangerous implementations of the <CODE>IMemory­Buffer­Reference.Closed</CODE> event

Raymond Chen
Raymond Chen

Mistakenly handing out COM references that don't work.

The useless <CODE>IMemory­Buffer­Reference.Closed</CODE> event
Jan 23, 2024
Post comments count 1
Post likes count 2

The useless <CODE>IMemory­Buffer­Reference.Closed</CODE> event

Raymond Chen
Raymond Chen

It tells you that you have already lost.

Accessing a block of memory represented by a Windows Runtime IMemoryBuffer
Jan 22, 2024
Post comments count 0
Post likes count 3

Accessing a block of memory represented by a Windows Runtime IMemoryBuffer

Raymond Chen
Raymond Chen

Through the currency known as an IMemoryBufferReference.

The case of the fail-fast trying to log a caught exception
Jan 19, 2024
Post comments count 2
Post likes count 1

The case of the fail-fast trying to log a caught exception

Raymond Chen
Raymond Chen

What is being thrown and why can't we log it?

Implementing two-phase initialization with ATL
Jan 18, 2024
Post comments count 0
Post likes count 2

Implementing two-phase initialization with ATL

Raymond Chen
Raymond Chen

ATL looks like it supports two-phase initialization, but it doesn't.

Getting a strong reference from the <CODE>this</CODE> pointer too soon
Jan 17, 2024
Post comments count 1
Post likes count 2

Getting a strong reference from the <CODE>this</CODE> pointer too soon

Raymond Chen
Raymond Chen

Giving out strong references to an object before you can guarantee that it will work.

What is a hard error, and what makes it harder than an easy error?
Jan 16, 2024
Post comments count 4
Post likes count 9

What is a hard error, and what makes it harder than an easy error?

Raymond Chen
Raymond Chen

A throwback to the early days of 16-bit Windows.

C++/WinRT gotcha: Not all exceptions derive from <CODE>hresult_error</CODE>
Jan 15, 2024
Post comments count 5
Post likes count 2

C++/WinRT gotcha: Not all exceptions derive from <CODE>hresult_error</CODE>

Raymond Chen
Raymond Chen

There are also C++ standard exceptions, particularly <CODE>std::bad_alloc</CODE>.

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 3
Jan 12, 2024
Post comments count 1
Post likes count 2

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 3

Raymond Chen
Raymond Chen

Dealing with awaitables that return <CODE>void</CODE>, and questioning our life choices.

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 2
Jan 11, 2024
Post comments count 0
Post likes count 3

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 2

Raymond Chen
Raymond Chen

Wrapping the results and returning them in a tuple.

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 1
Jan 10, 2024
Post comments count 0
Post likes count 2

In C++/WinRT, how can I await multiple coroutines and capture the results?, part 1

Raymond Chen
Raymond Chen

Using a custom awaiter to suppress the <CODE>GetResults()</CODE>.

After I accidentally denied access to everyone, how do I get access back?
Jan 9, 2024
Post comments count 10
Post likes count 2

After I accidentally denied access to everyone, how do I get access back?

Raymond Chen
Raymond Chen

Congratulations, you locked your keys in the car.

How do I prevent my C++/WinRT implementation class from participating in COM aggregation?
Jan 8, 2024
Post comments count 0
Post likes count 2

How do I prevent my C++/WinRT implementation class from participating in COM aggregation?

Raymond Chen
Raymond Chen

Looking for a clue.

The case of the vector with an impossibly large size
Jan 5, 2024
Post comments count 4
Post likes count 3

The case of the vector with an impossibly large size

Raymond Chen
Raymond Chen

Play threading games, win threading prizes.

How can I specify icons for my app to use on the Start menu in high contrast mode?
Jan 4, 2024
Post comments count 9
Post likes count 4

How can I specify icons for my app to use on the Start menu in high contrast mode?

Raymond Chen
Raymond Chen

Put them in your manifest.

Why doesn’t my code compile when I change a <CODE>shared_ptr<T>(p)</CODE> to an equivalent <CODE>make_shared<T>(p)</CODE>?
Jan 3, 2024
Post comments count 1
Post likes count 2

Why doesn’t my code compile when I change a <CODE>shared_ptr<T>(p)</CODE> to an equivalent <CODE>make_shared<T>(p)</CODE>?

Raymond Chen
Raymond Chen

It depends on who is doing the parameter conversion.

It rather involved being on the other side of this airtight hatchway: Attacking another program by modifying its memory
Jan 2, 2024
Post comments count 7
Post likes count 4

It rather involved being on the other side of this airtight hatchway: Attacking another program by modifying its memory

Raymond Chen
Raymond Chen

If you assume the existence of a vulnerability, you can use that vulnerability to attack something.

How do I prevent my ATL class from participating in COM aggregation? <CODE>DECLARE_<WBR>NOT_<WBR>AGGREGATABLE</CODE> didn’t work
Jan 1, 2024
Post comments count 0
Post likes count 2

How do I prevent my ATL class from participating in COM aggregation? <CODE>DECLARE_<WBR>NOT_<WBR>AGGREGATABLE</CODE> didn’t work

Raymond Chen
Raymond Chen

That marker applies only to creation via the class factory.

2023 year-end link clearance
Dec 29, 2023
Post comments count 8
Post likes count 4

2023 year-end link clearance

Raymond Chen
Raymond Chen

Ringing out another year.

How to allocate address space with a custom alignment or in a custom address region
Dec 29, 2023
Post comments count 2
Post likes count 4

How to allocate address space with a custom alignment or in a custom address region

Raymond Chen
Raymond Chen

Some new powers to guide the allocation.

On calling <CODE>Afx­Connection­Advise</CODE> with <CODE>bAddRef</CODE> set to <CODE>FALSE</CODE>
Dec 28, 2023
Post comments count 1
Post likes count 4

On calling <CODE>Afx­Connection­Advise</CODE> with <CODE>bAddRef</CODE> set to <CODE>FALSE</CODE>

Raymond Chen
Raymond Chen

Playing fast and loose, and eventually you get burnt.

What does it mean when the compiler says that it can’t convert something to itself?
Dec 27, 2023
Post comments count 1
Post likes count 4

What does it mean when the compiler says that it can’t convert something to itself?

Raymond Chen
Raymond Chen

Why is it even thinking about a conversion?

Don’t keep state in your XAML item templates; put the state in the items
Dec 26, 2023
Post comments count 1
Post likes count 8

Don’t keep state in your XAML item templates; put the state in the items

Raymond Chen
Raymond Chen

Beware of temporary alliances.

That time the Word team sent presents to the children of WordPerfect’s executive vice president
Dec 25, 2023
Post comments count 3
Post likes count 6

That time the Word team sent presents to the children of WordPerfect’s executive vice president

Raymond Chen
Raymond Chen

No, it wasn't creepy.

If I don’t have any items, what error should my <CODE>IFolderView::Items</CODE> method return?
Dec 22, 2023
Post comments count 11
Post likes count 2

If I don’t have any items, what error should my <CODE>IFolderView::Items</CODE> method return?

Raymond Chen
Raymond Chen

It shouldn't return an error at all.

How do I get access to the <CODE>wParam</CODE> and <CODE>lParam</CODE> of the <CODE>WM_<WBR>QUERY­END­SESSION</CODE> method from my MFC message handler?
Dec 21, 2023
Post comments count 2
Post likes count 3

How do I get access to the <CODE>wParam</CODE> and <CODE>lParam</CODE> of the <CODE>WM_<WBR>QUERY­END­SESSION</CODE> method from my MFC message handler?

Raymond Chen
Raymond Chen

Don't be afraid to see how the macros are built.

It rather involved being on the other side of this airtight hatchway: Spoofing another program
Dec 20, 2023
Post comments count 1
Post likes count 1

It rather involved being on the other side of this airtight hatchway: Spoofing another program

Raymond Chen
Raymond Chen

You already had the power to do it yourself.

Microspeak: Locked and loaded
Dec 19, 2023
Post comments count 1
Post likes count 1

Microspeak: Locked and loaded

Raymond Chen
Raymond Chen

Armed and ready, with the suggestion that no further changes will be needed (or accepted).

In 2023, the Gävle Goat faces a new threat to its survival
Dec 18, 2023
Post comments count 1
Post likes count 0

In 2023, the Gävle Goat faces a new threat to its survival

Raymond Chen
Raymond Chen

It's bock.

If the RegisterClass function takes ownership of the custom background brush, why is it leaking?
Dec 18, 2023
Post comments count 3
Post likes count 1

If the RegisterClass function takes ownership of the custom background brush, why is it leaking?

Raymond Chen
Raymond Chen

It takes ownership only on success.

How do I specify an optional string parameter to a Windows Runtime method?
Dec 15, 2023
Post comments count 2
Post likes count 1

How do I specify an optional string parameter to a Windows Runtime method?

Raymond Chen
Raymond Chen

Strings are sort of reference but sort of values.

How do I specify an optional parameter to a Windows Runtime method?
Dec 14, 2023
Post comments count 1
Post likes count 1

How do I specify an optional parameter to a Windows Runtime method?

Raymond Chen
Raymond Chen

There is no way to express explicit optionality, but there are implicit ways.

How can I work around the absence of default parameters in the Windows Runtime?
Dec 13, 2023
Post comments count 0
Post likes count 2

How can I work around the absence of default parameters in the Windows Runtime?

Raymond Chen
Raymond Chen

You can fake it with overloads.

What happens if I define one environment variable in terms of the value of another environment variable?
Dec 12, 2023
Post comments count 4
Post likes count 4

What happens if I define one environment variable in terms of the value of another environment variable?

Raymond Chen
Raymond Chen

Only certain types of dependencies are supported.

The mysterious second parameter to the x86 <CODE>ENTER</CODE> instruction
Dec 11, 2023
Post comments count 12
Post likes count 6

The mysterious second parameter to the x86 <CODE>ENTER</CODE> instruction

Raymond Chen
Raymond Chen

For an ABI that probably nobody uses.

A simpler version of the task sequencer that doesn’t promise fairness
Dec 8, 2023
Post comments count 6
Post likes count 3

A simpler version of the task sequencer that doesn’t promise fairness

Raymond Chen
Raymond Chen

Just let a kernel object control the access.

In C++, how can I make a default parameter be the <CODE>this</CODE> pointer of the caller?
Dec 7, 2023
Post comments count 1
Post likes count 2

In C++, how can I make a default parameter be the <CODE>this</CODE> pointer of the caller?

Raymond Chen
Raymond Chen

Again, you can't, but you can fake it.

In C++, how can I make a member function default parameter depend on <CODE>this</CODE>?
Dec 6, 2023
Post comments count 2
Post likes count 4

In C++, how can I make a member function default parameter depend on <CODE>this</CODE>?

Raymond Chen
Raymond Chen

You can't, but you can fake it.

What was the code name for 64-bit Windows?
Dec 5, 2023
Post comments count 6
Post likes count 8

What was the code name for 64-bit Windows?

Raymond Chen
Raymond Chen

Sundown, which was a hidden jab at the competition.

What is a static chain pointer in the context of calling convention ABI?
Dec 4, 2023
Post comments count 5
Post likes count 4

What is a static chain pointer in the context of calling convention ABI?

Raymond Chen
Raymond Chen

Buried in the System V Application Binary Interface.

Why does the Windows Portable Executable (PE) format have both an import section and input directory?
Dec 1, 2023
Post comments count 6
Post likes count 3

Why does the Windows Portable Executable (PE) format have both an import section and input directory?

Raymond Chen
Raymond Chen

They seem to be the same thing. Do we need both?

Why does the Windows Portable Executable (PE) format have separate tables for import names and import addresses?, part 2
Nov 30, 2023
Post comments count 2
Post likes count 5

Why does the Windows Portable Executable (PE) format have separate tables for import names and import addresses?, part 2

Raymond Chen
Raymond Chen

Keeping read-only data separate from read-write data.

Why does the Windows Portable Executable (PE) format have separate tables for import names and import addresses?, part 1
Nov 29, 2023
Post comments count 6
Post likes count 4

Why does the Windows Portable Executable (PE) format have separate tables for import names and import addresses?, part 1

Raymond Chen
Raymond Chen

Even though their lifetimes don't overlap, you sometimes need to go back in time.

A reported vulnerability about getting paid apps for free is really about paying for free apps
Nov 28, 2023
Post comments count 8
Post likes count 3

A reported vulnerability about getting paid apps for free is really about paying for free apps

Raymond Chen
Raymond Chen

Try shopping around.

In Windows 3.1 and Windows 95, what is a “grabber”?
Nov 27, 2023
Post comments count 3
Post likes count 5

In Windows 3.1 and Windows 95, what is a “grabber”?

Raymond Chen
Raymond Chen

It grabbed your MS-DOS screen and put it into a window.

On harmful overuse of <CODE>std::move</CODE>
Nov 24, 2023
Post comments count 10
Post likes count 11

On harmful overuse of <CODE>std::move</CODE>

Raymond Chen
Raymond Chen

Initial excitement leads to overuse.

On the need to keep most event sources alive if you want them to raise events
Nov 23, 2023
Post comments count 0
Post likes count 2

On the need to keep most event sources alive if you want them to raise events

Raymond Chen
Raymond Chen

You can't receive a notification from something that doesn't exist.

How can I convert a Windows Runtime <CODE>Software­Bitmap</CODE> to a WIC bitmap?
Nov 22, 2023
Post comments count 1
Post likes count 5

How can I convert a Windows Runtime <CODE>Software­Bitmap</CODE> to a WIC bitmap?

Raymond Chen
Raymond Chen

The reverse of <CODE>ISoftware­Bitmap­Native­Factory::<WBR>Create­From­WIC­Bitmap</CODE>.

Microspeak revisited: Line of sight
Nov 21, 2023
Post comments count 5
Post likes count 8

Microspeak revisited: Line of sight

Raymond Chen
Raymond Chen

A fancy way of saying unimpeded network connectivity.

If you’re going to crash on an unhandled exception, you may as well do it sooner rather than later
Nov 20, 2023
Post comments count 0
Post likes count 3

If you’re going to crash on an unhandled exception, you may as well do it sooner rather than later

Raymond Chen
Raymond Chen

Avoiding the problem discovered by the case of the invalid argument exception from a method that takes no arguments.

The theory behind the IHttpFilter interface
Nov 17, 2023
Post comments count 0
Post likes count 3

The theory behind the IHttpFilter interface

Raymond Chen
Raymond Chen

Layering features on top of each other.

What happened to the custom exception description I threw from a C++/WinRT IAsyncAction?
Nov 16, 2023
Post comments count 0
Post likes count 2

What happened to the custom exception description I threw from a C++/WinRT IAsyncAction?

Raymond Chen
Raymond Chen

The description is just a courtesy and is not part of the API contract.

Why does calling a coroutine allocate a lot of stack space even though the coroutine frame is on the heap?
Nov 15, 2023
Post comments count 2
Post likes count 2

Why does calling a coroutine allocate a lot of stack space even though the coroutine frame is on the heap?

Raymond Chen
Raymond Chen

Heap elision optimization kicks in, and doesn't kick out.

Starting on the other side of this airtight hatchway: Running a program that leaks memory
Nov 14, 2023
Post comments count 5
Post likes count 3

Starting on the other side of this airtight hatchway: Running a program that leaks memory

Raymond Chen
Raymond Chen

There are a lot of things you can do to consume memory.

What is the difference between UuidToString, StringFromCLSID, StringFromIID, and StringFromGUID2?
Nov 13, 2023
Post comments count 2
Post likes count 4

What is the difference between UuidToString, StringFromCLSID, StringFromIID, and StringFromGUID2?

Raymond Chen
Raymond Chen

Different ways of stringizing a GUID.

The case of the invalid argument exception from a method that takes no arguments
Nov 10, 2023
Post comments count 2
Post likes count 2

The case of the invalid argument exception from a method that takes no arguments

Raymond Chen
Raymond Chen

Where did the invalid argument come from?

A clarification on the multithreading constraints of the <CODE>Encrypt­Message</CODE> function
Nov 9, 2023
Post comments count 0
Post likes count 1

A clarification on the multithreading constraints of the <CODE>Encrypt­Message</CODE> function

Raymond Chen
Raymond Chen

Reading a sentence in the context of the whole paragraph.

How can I get information about media playing on the system, and optionally control their playback?
Nov 8, 2023
Post comments count 0
Post likes count 1

How can I get information about media playing on the system, and optionally control their playback?

Raymond Chen
Raymond Chen

Going to the global system media transport controls world.

“Stop sharing this folder” is not the same as “Never share this folder”
Nov 7, 2023
Post comments count 3
Post likes count 5

“Stop sharing this folder” is not the same as “Never share this folder”

Raymond Chen
Raymond Chen

It stops sharing the folder, but that doesn't prevent you from starting it again.

Why doesn’t reduction by modulo work for floating point values?
Nov 6, 2023
Post comments count 3
Post likes count 4

Why doesn’t reduction by modulo work for floating point values?

Raymond Chen
Raymond Chen

Working out why it works for integers and seeing what goes wrong.

Why does unsafe multithreaded use of an <CODE>std::<WBR>unordered_<WBR>map</CODE> crash more often than unsafe multithreaded use of a <CODE>std::<WBR>map</CODE>?
How come my custom exception message is lost when it is thrown from a <CODE>IAsyncAction^</CODE>?
Nov 2, 2023
Post comments count 0
Post likes count 1

How come my custom exception message is lost when it is thrown from a <CODE>IAsyncAction^</CODE>?

Raymond Chen
Raymond Chen

Things that survive in the C++ world and things that are lost when you cross the ABI.

More notes on use of the <CODE>DS_<WBR>CONTROL</CODE> style
Nov 1, 2023
Post comments count 2
Post likes count 2

More notes on use of the <CODE>DS_<WBR>CONTROL</CODE> style

Raymond Chen
Raymond Chen

Styles that have to go in, and styles that have to come out. (And styles that you can choose.)

What is the thread reaper?
Oct 31, 2023
Post comments count 9
Post likes count 3

What is the thread reaper?

Raymond Chen
Raymond Chen

Should you fear the thread reaper?

What are the dire consequences of not removing all the properties that were set via <CODE>SetProp</CODE>?
Oct 30, 2023
Post comments count 5
Post likes count 3

What are the dire consequences of not removing all the properties that were set via <CODE>SetProp</CODE>?

Raymond Chen
Raymond Chen

Not so much any more, but it could be a sign that you forgot something.

How to support a COM interface conditionally in WRL
Oct 27, 2023
Post comments count 1
Post likes count 2

How to support a COM interface conditionally in WRL

Raymond Chen
Raymond Chen

Customizing the QueryInterface and GetIids methods.

How to support a COM interface conditionally in C++/WinRT
Oct 26, 2023
Post comments count 0
Post likes count 3

How to support a COM interface conditionally in C++/WinRT

Raymond Chen
Raymond Chen

Prevent <CODE>winrt::implements</CODE> from responding to it or reporting it.

The format of icon resources, revisited
Oct 25, 2023
Post comments count 5
Post likes count 6

The format of icon resources, revisited

Raymond Chen
Raymond Chen

Filling in some gaps.

Why is there a hash of a weak password in the Windows cryptographic libraries?
Oct 24, 2023
Post comments count 2
Post likes count 4

Why is there a hash of a weak password in the Windows cryptographic libraries?

Raymond Chen
Raymond Chen

They're part of an internal self-test.

How do I add a non-copyable, non-movable object to a <CODE>std::map</CODE> or <CODE>std::unordered_map</CODE>?
Oct 23, 2023
Post comments count 2
Post likes count 4

How do I add a non-copyable, non-movable object to a <CODE>std::map</CODE> or <CODE>std::unordered_map</CODE>?

Raymond Chen
Raymond Chen

Fancy emplacement.

On the failed unrealized promise of <CODE>Reg­Override­Predef­Key</CODE>
Oct 20, 2023
Post comments count 0
Post likes count 1

On the failed unrealized promise of <CODE>Reg­Override­Predef­Key</CODE>

Raymond Chen
Raymond Chen

An early attempt to sandbox the registry for a process.

What’s the difference between setting a page’s protection to <CODE>PAGE_NOACCESS</CODE> and freeing it?
Oct 19, 2023
Post comments count 3
Post likes count 2

What’s the difference between setting a page’s protection to <CODE>PAGE_NOACCESS</CODE> and freeing it?

Raymond Chen
Raymond Chen

Nobody can access it, but it's still there.

How can I check if I’m on a DispatcherQueue’s thread if I can’t call HasThreadAccess?
Oct 18, 2023
Post comments count 3
Post likes count 3

How can I check if I’m on a DispatcherQueue’s thread if I can’t call HasThreadAccess?

Raymond Chen
Raymond Chen

Looking at the tools you have available.

Microspeak: The As-Appropriate (AA) interviewer
Oct 17, 2023
Post comments count 5
Post likes count 2

Microspeak: The As-Appropriate (AA) interviewer

Raymond Chen
Raymond Chen

So, how are things going so far?

API design principle: Reading a property or adding an event handler should not alter observable behavior
Oct 16, 2023
Post comments count 9
Post likes count 3

API design principle: Reading a property or adding an event handler should not alter observable behavior

Raymond Chen
Raymond Chen

Don't punish people for looking.

On detecting improper use of <CODE>std::<WBR>enable_<WBR>shared_<WBR>from_<WBR>this</CODE>
Oct 13, 2023
Post comments count 0
Post likes count 2

On detecting improper use of <CODE>std::<WBR>enable_<WBR>shared_<WBR>from_<WBR>this</CODE>

Raymond Chen
Raymond Chen

Playing around with the standard library.

I created an overloaded operator for my C++/WinRT class, but it’s not working
Oct 12, 2023
Post comments count 0
Post likes count 1

I created an overloaded operator for my C++/WinRT class, but it’s not working

Raymond Chen
Raymond Chen

Take a closer look at what you are overloading.

Why does <CODE>IFileDialog</CODE> still show non-filesystem folders when I pass <CODE>FOS_<WBR>FORCE­FILE­SYSTEM</CODE>?
Oct 11, 2023
Post comments count 13
Post likes count 3

Why does <CODE>IFileDialog</CODE> still show non-filesystem folders when I pass <CODE>FOS_<WBR>FORCE­FILE­SYSTEM</CODE>?

Raymond Chen
Raymond Chen

Because you need to pass through them to get there.

It rather required being on the other side of this airtight hatchway: Knowing the domain administrator password
Oct 10, 2023
Post comments count 5
Post likes count 2

It rather required being on the other side of this airtight hatchway: Knowing the domain administrator password

Raymond Chen
Raymond Chen

If you give away the password, well, that's sort of on you.

Is there any performance advantage to marking a page read-only if I had no intention of writing to it anyway?
Oct 9, 2023
Post comments count 2
Post likes count 2

Is there any performance advantage to marking a page read-only if I had no intention of writing to it anyway?

Raymond Chen
Raymond Chen

The CPU already figured it out.

A very belated improvement to the filtering of the Browse for Folder dialog so it shows only drive letters
Oct 6, 2023
Post comments count 2
Post likes count 1

A very belated improvement to the filtering of the Browse for Folder dialog so it shows only drive letters

Raymond Chen
Raymond Chen

The case of the very short UNC.

How can I get WideCharToMultiByte to convert strings encoded in UTF-16BE?
Oct 5, 2023
Post comments count 2
Post likes count 1

How can I get WideCharToMultiByte to convert strings encoded in UTF-16BE?

Raymond Chen
Raymond Chen

You first have to get it into a format the WideCharToMultiByte accepts.

On the confusing names for the Windows service SID types
Oct 4, 2023
Post comments count 3
Post likes count 2

On the confusing names for the Windows service SID types

Raymond Chen
Raymond Chen

Too much abbreviation.

A complaint about Links the Cat, the Office assistant
Oct 3, 2023
Post comments count 1
Post likes count 6

A complaint about Links the Cat, the Office assistant

Raymond Chen
Raymond Chen

Do all cats do that?

How do I manually update a remote tracking branch, say, to undo a fetch?
Oct 2, 2023
Post comments count 0
Post likes count 1

How do I manually update a remote tracking branch, say, to undo a fetch?

Raymond Chen
Raymond Chen

Updating refs to point to whatever you like.

Template meta-programming: Avoiding saying a type before it is complete
Sep 29, 2023
Post comments count 0
Post likes count 1

Template meta-programming: Avoiding saying a type before it is complete

Raymond Chen
Raymond Chen

Deferring use until after the class is defined.

C++/WinRT gotcha: <CODE>get_strong()</CODE> will produce a broken strong reference if destruction has already begun
Sep 28, 2023
Post comments count 2
Post likes count 2

C++/WinRT gotcha: <CODE>get_strong()</CODE> will produce a broken strong reference if destruction has already begun

Raymond Chen
Raymond Chen

A strong reference to nothing.

The dangers of releasing the last strong reference from within its own callback
Sep 27, 2023
Post comments count 4
Post likes count 3

The dangers of releasing the last strong reference from within its own callback

Raymond Chen
Raymond Chen

Deadlocking with yourself.

Why is kernel32.dll running in user mode and not kernel mode, like its name implies?
Sep 26, 2023
Post comments count 8
Post likes count 6

Why is kernel32.dll running in user mode and not kernel mode, like its name implies?

Raymond Chen
Raymond Chen

It's just a name, and it comes from the days before user-mode/kernel-mode separation.

GetQueueStatus and the queue state
Sep 25, 2023
Post comments count 1
Post likes count 3

GetQueueStatus and the queue state

Raymond Chen
Raymond Chen

There's stuff going on that's hiding behind the innocuous-looking name.

When I try to call an exported function, the target crashes when it tries to call any Windows function
Sep 22, 2023
Post comments count 3
Post likes count 6

When I try to call an exported function, the target crashes when it tries to call any Windows function

Raymond Chen
Raymond Chen

Using what you know about how functions are imported to construct a theory that matches the evidence.

How does Explorer calculate the “Date” of a file?
Sep 21, 2023
Post comments count 9
Post likes count 8

How does Explorer calculate the “Date” of a file?

Raymond Chen
Raymond Chen

Mapping the generic concept to specific file types.

Why does my C++/WinRT project get unresolved externals for constructors?
Sep 20, 2023
Post comments count 1
Post likes count 1

Why does my C++/WinRT project get unresolved externals for constructors?

Raymond Chen
Raymond Chen

You forgot to include the namespace header file, didn't you.

Why did the 16-bit _lopen and _lcreat function return -1 on failure instead of 0?
Sep 19, 2023
Post comments count 3
Post likes count 3

Why did the 16-bit _lopen and _lcreat function return -1 on failure instead of 0?

Raymond Chen
Raymond Chen

Trying to look like somebody else.

When looking to free up disk space, don’t forget your symbol file caches
Sep 18, 2023
Post comments count 3
Post likes count 5

When looking to free up disk space, don’t forget your symbol file caches

Raymond Chen
Raymond Chen

They go all over the place.

How can I prevent myself from using a parameter after I’ve extracted all value from it?
Sep 15, 2023
Post comments count 6
Post likes count 2

How can I prevent myself from using a parameter after I’ve extracted all value from it?

Raymond Chen
Raymond Chen

You can shadow it with something useless.

I accidentally performed an operation on <CODE>INVALID_<WBR>HANDLE_<WBR>VALUE</CODE>, and it worked: What just happened?
Sep 14, 2023
Post comments count 7
Post likes count 3

I accidentally performed an operation on <CODE>INVALID_<WBR>HANDLE_<WBR>VALUE</CODE>, and it worked: What just happened?

Raymond Chen
Raymond Chen

Coincidentally valid, but not what you think.

How do I perform a case-insensitive comparison of two strings in the Deseret script?
Sep 13, 2023
Post comments count 1
Post likes count 2

How do I perform a case-insensitive comparison of two strings in the Deseret script?

Raymond Chen
Raymond Chen

It sort of depends on why you're comparing them.

The odd cadence of narrative engineering design documents
Sep 12, 2023
Post comments count 4
Post likes count 3

The odd cadence of narrative engineering design documents

Raymond Chen
Raymond Chen

Following the rubric off a cliff.

Any sufficiently advanced uninstaller is indistinguishable from malware
Sep 11, 2023
Post comments count 27
Post likes count 8

Any sufficiently advanced uninstaller is indistinguishable from malware

Raymond Chen
Raymond Chen

The common pattern of trying to delete yourself.

On transferring or copying ABI pointers between smart pointers
Sep 8, 2023
Post comments count 3
Post likes count 4

On transferring or copying ABI pointers between smart pointers

Raymond Chen
Raymond Chen

Keep track of who owns the reference.

A freestanding JavaScript function that uses <CODE>this</CODE> is easily mistaken for a constructor
Sep 7, 2023
Post comments count 1
Post likes count 1

A freestanding JavaScript function that uses <CODE>this</CODE> is easily mistaken for a constructor

Raymond Chen
Raymond Chen

Because that's what constructors look like.

Detecting whether a tree-like data structure contains a cycle
Sep 6, 2023
Post comments count 2
Post likes count 2

Detecting whether a tree-like data structure contains a cycle

Raymond Chen
Raymond Chen

Combining two things we already know.

When documentation cautions that something may not happen, that suggests that it normally does happen
Sep 5, 2023
Post comments count 2
Post likes count 1

When documentation cautions that something may not happen, that suggests that it normally does happen

Raymond Chen
Raymond Chen

Reading between the lines.

Just for fun: What happens when you shift a register by more than the register size?
Sep 4, 2023
Post comments count 9
Post likes count 3

Just for fun: What happens when you shift a register by more than the register size?

Raymond Chen
Raymond Chen

A comparative study of processor architectures.

How do I find out more about the fail-fast exception that occurs when an exception in a PPL task goes unobserved?
Sep 1, 2023
Post comments count 0
Post likes count 1

How do I find out more about the fail-fast exception that occurs when an exception in a PPL task goes unobserved?

Raymond Chen
Raymond Chen

Digging into the internals.

Diagnosing a crash when trying to call <CODE>ReadFile</CODE> via language interop
Aug 31, 2023
Post comments count 0
Post likes count 3

Diagnosing a crash when trying to call <CODE>ReadFile</CODE> via language interop

Raymond Chen
Raymond Chen

Checking the signatures and inferring what could have gone wrong.

How can I programmatically obtain the value of the “Make text bigger” slider?
Aug 30, 2023
Post comments count 2
Post likes count 5

How can I programmatically obtain the value of the “Make text bigger” slider?

Raymond Chen
Raymond Chen

The text scale factor property.

The popularity of DOS/4GW made Windows 95 game compatibility a little easier, but with higher stakes
Aug 29, 2023
Post comments count 10
Post likes count 3

The popularity of DOS/4GW made Windows 95 game compatibility a little easier, but with higher stakes

Raymond Chen
Raymond Chen

A popular path to protected mode.

Just for fun: Which processors prefer sign-extended loads, and which prefer zero-extended loads?
Aug 28, 2023
Post comments count 4
Post likes count 3

Just for fun: Which processors prefer sign-extended loads, and which prefer zero-extended loads?

Raymond Chen
Raymond Chen

Another pointless chart.

On writing loops in continuation-passing style, part 4
Aug 25, 2023
Post comments count 3
Post likes count 2

On writing loops in continuation-passing style, part 4

Raymond Chen
Raymond Chen

Equivalents in C# and JavaScript.

On writing loops in PPL and continuation-passing style, part 3
Aug 24, 2023
Post comments count 0
Post likes count 2

On writing loops in PPL and continuation-passing style, part 3

Raymond Chen
Raymond Chen

Explicit shared state.

On writing loops in PPL and continuation-passing style, part 2
Aug 23, 2023
Post comments count 0
Post likes count 2

On writing loops in PPL and continuation-passing style, part 2

Raymond Chen
Raymond Chen

Recursion comes back.

On writing loops in PPL and continuation-passing style, part 1
Aug 22, 2023
Post comments count 0
Post likes count 2

On writing loops in PPL and continuation-passing style, part 1

Raymond Chen
Raymond Chen

Keeping track of what to do next.

Inside STL: The different types of shared pointer control blocks
Aug 21, 2023
Post comments count 7
Post likes count 3

Inside STL: The different types of shared pointer control blocks

Raymond Chen
Raymond Chen

Well, some of them, at least.

Phantom and indulgent shared pointers
Aug 18, 2023
Post comments count 1
Post likes count 2

Phantom and indulgent shared pointers

Raymond Chen
Raymond Chen

The phantom controls something yet holds nothing. The indulgent holds something but controls nothing.

What it means when you convert between different <CODE>shared_ptr</CODE>s
Aug 17, 2023
Post comments count 1
Post likes count 2

What it means when you convert between different <CODE>shared_ptr</CODE>s

Raymond Chen
Raymond Chen

Changing the pointer while controlling the same object.

Inside STL: The <CODE>shared_ptr</CODE> constructor and <CODE>enable_shared_from_this</CODE>
Aug 16, 2023
Post comments count 1
Post likes count 4

Inside STL: The <CODE>shared_ptr</CODE> constructor and <CODE>enable_shared_from_this</CODE>

Raymond Chen
Raymond Chen

Working together through a secret signal.

Inside STL: The <CODE>shared_ptr</CODE> constructor vs <CODE>make_shared</CODE>
Aug 15, 2023
Post comments count 7
Post likes count 2

Inside STL: The <CODE>shared_ptr</CODE> constructor vs <CODE>make_shared</CODE>

Raymond Chen
Raymond Chen

Where to hide the control block.

Inside STL: Smart pointers
Aug 14, 2023
Post comments count 4
Post likes count 6

Inside STL: Smart pointers

Raymond Chen
Raymond Chen

Simple pointers or more complicated pointers.

Inside STL: The array
Aug 11, 2023
Post comments count 0
Post likes count 5

Inside STL: The array

Raymond Chen
Raymond Chen

It's just an array.

Inside STL: The deque, implementation
Aug 10, 2023
Post comments count 3
Post likes count 5

Inside STL: The deque, implementation

Raymond Chen
Raymond Chen

An array of (pointers to) arrays.

Inside STL: The deque, design
Aug 9, 2023
Post comments count 2
Post likes count 7

Inside STL: The deque, design

Raymond Chen
Raymond Chen

An array of (pointers to) arrays.

Inside STL: The unordered_map, unordered_set, unordered_multimap, and unordered_multiset
Aug 8, 2023
Post comments count 1
Post likes count 8

Inside STL: The unordered_map, unordered_set, unordered_multimap, and unordered_multiset

Raymond Chen
Raymond Chen

A hash table.

Inside STL: The map, set, multimap, and multiset
Aug 7, 2023
Post comments count 6
Post likes count 5

Inside STL: The map, set, multimap, and multiset

Raymond Chen
Raymond Chen

A red-black tree.

Inside STL: The lists
Aug 4, 2023
Post comments count 3
Post likes count 7

Inside STL: The lists

Raymond Chen
Raymond Chen

Your traditional singly- or doubly-linked list.

Inside STL: The string
Aug 3, 2023
Post comments count 6
Post likes count 9

Inside STL: The string

Raymond Chen
Raymond Chen

An allocation, with a twist.

Inside STL: The vector
Aug 2, 2023
Post comments count 6
Post likes count 7

Inside STL: The vector

Raymond Chen
Raymond Chen

A contiguous memory block, reallocated as necessary.

Inside STL: The pair and the compressed pair
Aug 1, 2023
Post comments count 7
Post likes count 8

Inside STL: The pair and the compressed pair

Raymond Chen
Raymond Chen

Two fields in one object, how hard can it be?

Misinterpreting the misleadingly-named <CODE>STATUS_<WBR>STACK_<WBR>BUFFER_<WBR>OVERRUN</CODE>
Jul 31, 2023
Post comments count 4
Post likes count 4

Misinterpreting the misleadingly-named <CODE>STATUS_<WBR>STACK_<WBR>BUFFER_<WBR>OVERRUN</CODE>

Raymond Chen
Raymond Chen

The subcode tells you why we stopped executing, and it's rarely because of a stack buffer overflow.

How to split off an older copy of a file while preserving git line history
Jul 28, 2023
Post comments count 1
Post likes count 1

How to split off an older copy of a file while preserving git line history

Raymond Chen
Raymond Chen

Variation on a theme.

Perfect forwarding forwards objects, not braced things that are trying to become objects
Jul 27, 2023
Post comments count 0
Post likes count 1

Perfect forwarding forwards objects, not braced things that are trying to become objects

Raymond Chen
Raymond Chen

Before you can forward something, it needs to be a something.

On the various ways of creating Windows Runtime delegates in C++/WinRT and C++/CX
Jul 26, 2023
Post comments count 0
Post likes count 2

On the various ways of creating Windows Runtime delegates in C++/WinRT and C++/CX

Raymond Chen
Raymond Chen

Comparing and contrasting.

Before you try to do something, make sure you can do nothing
Jul 25, 2023
Post comments count 7
Post likes count 33

Before you try to do something, make sure you can do nothing

Raymond Chen
Raymond Chen

If you can't do nothing, then don't expect to be able to do something.

Why does <CODE>IAsyncAction</CODE> or <CODE>IAsyncOperation.<WBR>GetResults()</CODE> produce a <CODE>E_<WBR>ILLEGAL_<WBR>METHOD_<WBR>CALL</CODE> exception?
How to clone a Windows Runtime map in the face of possible concurrent modification, part 3
Jul 21, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime map in the face of possible concurrent modification, part 3

Raymond Chen
Raymond Chen

Doing it one more time, for C++/CX.

How to clone a Windows Runtime map in the face of possible concurrent modification, part 2
Jul 20, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime map in the face of possible concurrent modification, part 2

Raymond Chen
Raymond Chen

Applying what we learned about vectors.

How to clone a Windows Runtime map in the face of possible concurrent modification, part 1
Jul 19, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime map in the face of possible concurrent modification, part 1

Raymond Chen
Raymond Chen

Applying what we learned about vectors.

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 4
Jul 18, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 4

Raymond Chen
Raymond Chen

Translating to C++/CX and dealing with some quirks of that language.

Cloning a Windows Runtime vector in the face of possible concurrent modification, denial of service?
Jul 17, 2023
Post comments count 0
Post likes count 1

Cloning a Windows Runtime vector in the face of possible concurrent modification, denial of service?

Raymond Chen
Raymond Chen

Can you get sent into an infinite loop?

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 3
Jul 14, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 3

Raymond Chen
Raymond Chen

Dealing with the pesky <CODE>std::vector<bool></CODE>.

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 2
Jul 13, 2023
Post comments count 0
Post likes count 1

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 2

Raymond Chen
Raymond Chen

Trying to make a generic solution.

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 1
Jul 12, 2023
Post comments count 2
Post likes count 1

How to clone a Windows Runtime vector in the face of possible concurrent modification, part 1

Raymond Chen
Raymond Chen

Backing off and retrying, but the detection is the tricky part.

Why does the compiler complain about a missing constructor when I’m just resizing my <CODE>std::vector</CODE> to a smaller size?
Jul 11, 2023
Post comments count 0
Post likes count 2

Why does the compiler complain about a missing constructor when I’m just resizing my <CODE>std::vector</CODE> to a smaller size?

Raymond Chen
Raymond Chen

The compiler doesn't know that you're shrinking.

How to wait for multiple C++ coroutines to complete before propagating failure, concluding remarks
Jul 10, 2023
Post comments count 1
Post likes count 2

How to wait for multiple C++ coroutines to complete before propagating failure, concluding remarks

Raymond Chen
Raymond Chen

The things that could go wrong before you even start.

How to wait for multiple C++ coroutines to complete before propagating failure, finding the awaiter
Jul 7, 2023
Post comments count 1
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, finding the awaiter

Raymond Chen
Raymond Chen

Making sure to wrap the right thing.

How to wait for multiple C++ coroutines to complete before propagating failure, wrapping the awaitable
Jul 6, 2023
Post comments count 0
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, wrapping the awaitable

Raymond Chen
Raymond Chen

Intercepting the exception on the front side.

How to wait for multiple C++ coroutines to complete before propagating failure, preallocating the coroutine frame
Jul 5, 2023
Post comments count 2
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, preallocating the coroutine frame

Raymond Chen
Raymond Chen

Avoiding dynamic memory allocation.

How to wait for multiple C++ coroutines to complete before propagating failure, memory allocation failure
Jul 4, 2023
Post comments count 2
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, memory allocation failure

Raymond Chen
Raymond Chen

There's no good way to report the failure, so we just have to give up.

How to wait for multiple C++ coroutines to complete before propagating failure, symmetric transfer
Jul 3, 2023
Post comments count 0
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, symmetric transfer

Raymond Chen
Raymond Chen

Avoiding stack build-up.

2023 mid-year link clearance
Jun 30, 2023
Post comments count 3
Post likes count 3

2023 mid-year link clearance

Raymond Chen
Raymond Chen

The tradition continues.

How to wait for multiple C++ coroutines to complete before propagating failure, custom promise
Jun 30, 2023
Post comments count 1
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, custom promise

Raymond Chen
Raymond Chen

Taking things into our own hands.

How to wait for multiple C++ coroutines to complete before propagating failure, peeling away at a tuple
Jun 29, 2023
Post comments count 0
Post likes count 2

How to wait for multiple C++ coroutines to complete before propagating failure, peeling away at a tuple

Raymond Chen
Raymond Chen

Iterating over a tuple recursively.

How to wait for multiple C++ coroutines to complete before propagating failure, false hope
Jun 28, 2023
Post comments count 1
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, false hope

Raymond Chen
Raymond Chen

Trying to iterate over a pack.

How to wait for multiple C++ coroutines to complete before propagating failure, unhelpful lambda
Jun 27, 2023
Post comments count 0
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, unhelpful lambda

Raymond Chen
Raymond Chen

The usual trick doesn't work.

How to wait for multiple C++ coroutines to complete before propagating failure, initial plunge
Jun 26, 2023
Post comments count 5
Post likes count 1

How to wait for multiple C++ coroutines to complete before propagating failure, initial plunge

Raymond Chen
Raymond Chen

Remembering the exception while finishing the other work.

What can go wrong if you release an SRWLock from a thread different from the one that acquired it?
Jun 23, 2023
Post comments count 5
Post likes count 4

What can go wrong if you release an SRWLock from a thread different from the one that acquired it?

Raymond Chen
Raymond Chen

It's not a supported scenario, so anything can happen.

How can I find out the last time a user logged on from C++?
Jun 22, 2023
Post comments count 1
Post likes count 1

How can I find out the last time a user logged on from C++?

Raymond Chen
Raymond Chen

The information is in the historically-named LANMAN APIs.

The case of the <CODE>make_shared</CODE> on a C++/WinRT type
Jun 21, 2023
Post comments count 0
Post likes count 3

The case of the <CODE>make_shared</CODE> on a C++/WinRT type

Raymond Chen
Raymond Chen

Now you can't tell who's in charge.

Why is Windows using only even-numbered processors?
Jun 20, 2023
Post comments count 2
Post likes count 2

Why is Windows using only even-numbered processors?

Raymond Chen
Raymond Chen

Spreading out the load over cores.

Why am I being told about a signed/unsigned comparison, and why only sometimes, and how can I fix it?
Jun 19, 2023
Post comments count 6
Post likes count 2

Why am I being told about a signed/unsigned comparison, and why only sometimes, and how can I fix it?

Raymond Chen
Raymond Chen

How the compiler back-end can influence warnings.

The case of the invalid handle despite being managed by an RAII type, part 2
Jun 16, 2023
Post comments count 0
Post likes count 2

The case of the invalid handle despite being managed by an RAII type, part 2

Raymond Chen
Raymond Chen

Avoiding using an object after is has destructed, and maybe using a less-well-known corner of the C++ language.

The case of the invalid handle despite being managed by an RAII type
Jun 15, 2023
Post comments count 0
Post likes count 2

The case of the invalid handle despite being managed by an RAII type

Raymond Chen
Raymond Chen

The handle remains valid for the object's lifetime, but what is the object's lifetime?

How expensive is it to create a Windows performance counter?
Jun 14, 2023
Post comments count 3
Post likes count 1

How expensive is it to create a Windows performance counter?

Raymond Chen
Raymond Chen

The cost depends on the performance counter.

SIDs are really just another a fancy way of creating unique IDs in a decentralized way
Jun 13, 2023
Post comments count 2
Post likes count 2

SIDs are really just another a fancy way of creating unique IDs in a decentralized way

Raymond Chen
Raymond Chen

Keeping them from colliding with each other.

The move constructor that you have to declare, even though you don’t want anyone to actually call it
Jun 12, 2023
Post comments count 4
Post likes count 2

The move constructor that you have to declare, even though you don’t want anyone to actually call it

Raymond Chen
Raymond Chen

Forcing named return value optimization.

Reordering C++ template type parameters for usability purposes, and type deduction from the future
Jun 9, 2023
Post comments count 4
Post likes count 2

Reordering C++ template type parameters for usability purposes, and type deduction from the future

Raymond Chen
Raymond Chen

You want them to go first, but you also want to deduce them.

How can I register a program to auto-relaunch if it crashes or is terminated?, redux
Jun 8, 2023
Post comments count 8
Post likes count 2

How can I register a program to auto-relaunch if it crashes or is terminated?, redux

Raymond Chen
Raymond Chen

You can get a little bit of the way there.

Pulling sleight of hand tricks in a security vulnerability report, episode 2
Jun 7, 2023
Post comments count 11
Post likes count 1

Pulling sleight of hand tricks in a security vulnerability report, episode 2

Raymond Chen
Raymond Chen

I see what you did there.

How can I make WiFi passwords per-user rather than per-system?
Jun 6, 2023
Post comments count 4
Post likes count 1

How can I make WiFi passwords per-user rather than per-system?

Raymond Chen
Raymond Chen

A little-known system configuration setting.

It’s great that you provide operator overloads, but it’s also nice to have names
Jun 5, 2023
Post comments count 8
Post likes count 1

It’s great that you provide operator overloads, but it’s also nice to have names

Raymond Chen
Raymond Chen

Avoiding the need to invoke the operator explicitly as a specialized template, among other things.

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 3
Jun 2, 2023
Post comments count 0
Post likes count 1

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 3

Raymond Chen
Raymond Chen

Extending to <CODE>std::weak_ptr</CODE>.

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 2
Jun 1, 2023
Post comments count 0
Post likes count 1

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 2

Raymond Chen
Raymond Chen

Working out the boilerplate.

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 1
May 31, 2023
Post comments count 0
Post likes count 2

C++/WinRT event handlers that are lambdas with weak pointers to the parent class, part 1

Raymond Chen
Raymond Chen

Assessing the state of affairs.

How do I change the directory Windows uses for user profiles? revisited
May 30, 2023
Post comments count 10
Post likes count 1

How do I change the directory Windows uses for user profiles? revisited

Raymond Chen
Raymond Chen

You can still do it, but it's not really supported.

On writing functions that accept any specialization of a C++ template type
May 29, 2023
Post comments count 5
Post likes count 1

On writing functions that accept any specialization of a C++ template type

Raymond Chen
Raymond Chen

There are the obvious arguments, the non-obvious arguments, and the invisible arguments.

Getting a strong reference from the <CODE>this</CODE> pointer too late
May 26, 2023
Post comments count 3
Post likes count 1

Getting a strong reference from the <CODE>this</CODE> pointer too late

Raymond Chen
Raymond Chen

Once destruction begins, strong references mean nothing.

How can I trigger a recalc of the mouse cursor after I changed some of my internal application state?, follow-up
May 25, 2023
Post comments count 0
Post likes count 4

How can I trigger a recalc of the mouse cursor after I changed some of my internal application state?, follow-up

Raymond Chen
Raymond Chen

You still need to filter to your window, so you don't mess up another window on the same thread.

Don’t name your header file <CODE>security.h</CODE> either
May 24, 2023
Post comments count 4
Post likes count 4

Don’t name your header file <CODE>security.h</CODE> either

Raymond Chen
Raymond Chen

You may be overriding an SDK header by mistake.

On creating (and using) a transforming iterator
May 23, 2023
Post comments count 4
Post likes count 4

On creating (and using) a transforming iterator

Raymond Chen
Raymond Chen

It lets you change the thing being iterated over, on the fly.

Speeding up the insertion of a sorted (or mostly-sorted) key list into a <CODE>std::map</CODE> or other ordered associative container
May 22, 2023
Post comments count 1
Post likes count 4

Speeding up the insertion of a sorted (or mostly-sorted) key list into a <CODE>std::map</CODE> or other ordered associative container

Raymond Chen
Raymond Chen

Provide a hint for the location of the next item.

On catching exceptions in PPL tasks
May 19, 2023
Post comments count 0
Post likes count 1

On catching exceptions in PPL tasks

Raymond Chen
Raymond Chen

You also have to catch the exception when it comes out the end of the task chain.

What is the opposite of <CODE>LVM_SORTITEMS</CODE>?
May 18, 2023
Post comments count 3
Post likes count 2

What is the opposite of <CODE>LVM_SORTITEMS</CODE>?

Raymond Chen
Raymond Chen

How can you unring the bell?

How do I free the pointers returned by functions like <CODE>Get­Token­Information</CODE>?
May 17, 2023
Post comments count 2
Post likes count 2

How do I free the pointers returned by functions like <CODE>Get­Token­Information</CODE>?

Raymond Chen
Raymond Chen

They are all pointers back into the main memory block.

It appears that I’ve never made a complete visit to the Pacific Northwest
May 16, 2023
Post comments count 6
Post likes count 1

It appears that I’ve never made a complete visit to the Pacific Northwest

Raymond Chen
Raymond Chen

If the marketing department is to be believed.

Summary of the duck-typing requirements of C++ COM wrappers
May 16, 2023
Post comments count 3
Post likes count 4

Summary of the duck-typing requirements of C++ COM wrappers

Raymond Chen
Raymond Chen

Wrapping up and comparing.

What are the duck-typing requirements of C++/WinRT <CODE>com_ptr</CODE>?
May 15, 2023
Post comments count 1
Post likes count 2

What are the duck-typing requirements of C++/WinRT <CODE>com_ptr</CODE>?

Raymond Chen
Raymond Chen

The experiments conclude.

What are the duck-typing requirements of wil <CODE>com_ptr</CODE>?
May 12, 2023
Post comments count 0
Post likes count 2

What are the duck-typing requirements of wil <CODE>com_ptr</CODE>?

Raymond Chen
Raymond Chen

The experiments continue.

What are the duck-typing requirements of WRL <CODE>ComPtr</CODE>?
May 11, 2023
Post comments count 0
Post likes count 2

What are the duck-typing requirements of WRL <CODE>ComPtr</CODE>?

Raymond Chen
Raymond Chen

Another round of experimentation.

What are the duck-typing requirements of ATL <CODE>CComPtr</CODE>?
May 10, 2023
Post comments count 1
Post likes count 1

What are the duck-typing requirements of ATL <CODE>CComPtr</CODE>?

Raymond Chen
Raymond Chen

Looking for the minimum requirements.

What are the duck-typing requirements of MFC <CODE>IPTR</CODE>?
May 9, 2023
Post comments count 0
Post likes count 1

What are the duck-typing requirements of MFC <CODE>IPTR</CODE>?

Raymond Chen
Raymond Chen

Seeing what goes wrong and trying to fix it.

What are the duck-typing requirements of <CODE>_com_ptr_t</CODE>?
May 8, 2023
Post comments count 1
Post likes count 2

What are the duck-typing requirements of <CODE>_com_ptr_t</CODE>?

Raymond Chen
Raymond Chen

As long as you fulfill the contract, based on method names.

The case of the crash in a C++/WinRT coroutine: Unpeeling the onion
May 5, 2023
Post comments count 3
Post likes count 1

The case of the crash in a C++/WinRT coroutine: Unpeeling the onion

Raymond Chen
Raymond Chen

Digging deeper and deeper.

Why does XAML complain that none of the overloads of <CODE>winrt::to_hstring</CODE> could be used?
May 4, 2023
Post comments count 0
Post likes count 1

Why does XAML complain that none of the overloads of <CODE>winrt::to_hstring</CODE> could be used?

Raymond Chen
Raymond Chen

Look at what you are converting from and converting to.

What can I do if I don’t want my file version number to be a sequence of four integers?
May 3, 2023
Post comments count 7
Post likes count 3

What can I do if I don’t want my file version number to be a sequence of four integers?

Raymond Chen
Raymond Chen

The format is enforced by the Windows file format, but you can present the information in a custom way.

Why does Task Manager disappear briefly when you switch it into or out of <I>Always on top</I>?
May 2, 2023
Post comments count 21
Post likes count 3

Why does Task Manager disappear briefly when you switch it into or out of <I>Always on top</I>?

Raymond Chen
Raymond Chen

Ascending to another plane of existence.

How is it even possible to cheat on a musical performance practical exam?
May 1, 2023
Post comments count 3
Post likes count 3

How is it even possible to cheat on a musical performance practical exam?

Raymond Chen
Raymond Chen

Nature finds a way.

A quick note about WRL’s <CODE>Chain­Interfaces</CODE> template class
May 1, 2023
Post comments count 2
Post likes count 2

A quick note about WRL’s <CODE>Chain­Interfaces</CODE> template class

Raymond Chen
Raymond Chen

For interfaces which extend each other.

On the finer points of cancelling timers and wait objects in Windows thread pool
Apr 28, 2023
Post comments count 0
Post likes count 3

On the finer points of cancelling timers and wait objects in Windows thread pool

Raymond Chen
Raymond Chen

Assorted little details.

What’s up with this new <CODE>memory_<WBR>order_<WBR>consume</CODE> memory order?
Apr 27, 2023
Post comments count 2
Post likes count 3

What’s up with this new <CODE>memory_<WBR>order_<WBR>consume</CODE> memory order?

Raymond Chen
Raymond Chen

A weaker variation of acquire.

One way to defer work when a re-entrant call is detected
Apr 26, 2023
Post comments count 1
Post likes count 2

One way to defer work when a re-entrant call is detected

Raymond Chen
Raymond Chen

Tying a string on your finger, as a reminder to yourself.

A code comment noting the steps to take when a 256th enum field is added
Apr 25, 2023
Post comments count 7
Post likes count 2

A code comment noting the steps to take when a 256th enum field is added

Raymond Chen
Raymond Chen

A note for my future self.

Why is <CODE>std::hardware_destructive_interference_size</CODE> a compile-time constant instead of a run-time value?
Apr 24, 2023
Post comments count 2
Post likes count 3

Why is <CODE>std::hardware_destructive_interference_size</CODE> a compile-time constant instead of a run-time value?

Raymond Chen
Raymond Chen

The compiler is already making compile-time assumptions about the processor; you just don't realize it.

Protecting a broker from a failing delegate
Apr 21, 2023
Post comments count 1
Post likes count 1

Protecting a broker from a failing delegate

Raymond Chen
Raymond Chen

Catching them in a different way.

Protecting a broker from a failing event handler
Apr 20, 2023
Post comments count 0
Post likes count 2

Protecting a broker from a failing event handler

Raymond Chen
Raymond Chen

Gotta catch them all.

The case of the unhandled exception in a brokered Windows Runtime component
Apr 19, 2023
Post comments count 2
Post likes count 1

The case of the unhandled exception in a brokered Windows Runtime component

Raymond Chen
Raymond Chen

Digging into the event dispatch code.

No, it is not a security vulnerability that there is no certificate of appreciation for reporting a bug
Apr 18, 2023
Post comments count 14
Post likes count 2

No, it is not a security vulnerability that there is no certificate of appreciation for reporting a bug

Raymond Chen
Raymond Chen

It wasn't even a bug report.

How can I find the invalid class when C++/WinRT tells me that the class may not be final?
Apr 17, 2023
Post comments count 3
Post likes count 2

How can I find the invalid class when C++/WinRT tells me that the class may not be final?

Raymond Chen
Raymond Chen

It's in the error details.

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 4: Handing it over
Apr 14, 2023
Post comments count 4
Post likes count 2

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 4: Handing it over

Raymond Chen
Raymond Chen

Just take the whole thing.

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 3: Filling the SoftwareBitmap directly
Apr 13, 2023
Post comments count 1
Post likes count 1

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 3: Filling the SoftwareBitmap directly

Raymond Chen
Raymond Chen

Avoiding the intermediate buffer.

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 2: Via a buffer
Apr 12, 2023
Post comments count 0
Post likes count 1

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 2: Via a buffer

Raymond Chen
Raymond Chen

Passing raw pixels across.

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 1: Via an encoded stream
Apr 11, 2023
Post comments count 0
Post likes count 1

How can I convert a WIC bitmap to a Windows Runtime SoftwareBitmap? part 1: Via an encoded stream

Raymond Chen
Raymond Chen

We'll start with the hard way, but it gets easier.

Why is there a large gap between some of the Windows system metrics indices?
Apr 10, 2023
Post comments count 1
Post likes count 2

Why is there a large gap between some of the Windows system metrics indices?

Raymond Chen
Raymond Chen

An artifact of the internal implementation.

The case of the PasswordVault.Add call that the customer thinks was hung
Apr 7, 2023
Post comments count 1
Post likes count 3

The case of the PasswordVault.Add call that the customer thinks was hung

Raymond Chen
Raymond Chen

But was it really hung? Or did it just look that way.

An ignored exception can be misinterpreted as a hang, particularly in coroutines
Apr 6, 2023
Post comments count 0
Post likes count 2

An ignored exception can be misinterpreted as a hang, particularly in coroutines

Raymond Chen
Raymond Chen

I mean, execution seems to have stopped.

How do I modify the contents of a boxed Windows Runtime value?
Apr 5, 2023
Post comments count 9
Post likes count 1

How do I modify the contents of a boxed Windows Runtime value?

Raymond Chen
Raymond Chen

Once it's in the box, you can't change it.

What is the maximum size of a process environment block?
Apr 4, 2023
Post comments count 4
Post likes count 2

What is the maximum size of a process environment block?

Raymond Chen
Raymond Chen

There's no hard-coded limit in Windows, but maybe somebody else has a limit.

C++17 creates a practical use of the backward array index operator
Apr 3, 2023
Post comments count 3
Post likes count 6

C++17 creates a practical use of the backward array index operator

Raymond Chen
Raymond Chen

Possibly more than just a curiosity.

What is this <CODE>[uuid(…)]</CODE> in front of my C++ class declaration?
Mar 31, 2023
Post comments count 4
Post likes count 3

What is this <CODE>[uuid(…)]</CODE> in front of my C++ class declaration?

Raymond Chen
Raymond Chen

It's an old nonstandard syntax that you should try to move away from.

If you want to watch games on your tractor, please use your own iPad
Mar 30, 2023
Post comments count 6
Post likes count 2

If you want to watch games on your tractor, please use your own iPad

Raymond Chen
Raymond Chen

Not an approved use of the embedded system.

How can I box a <CODE>std::optional</CODE> into a C++/WinRT <CODE>IInspectable</CODE>?
Mar 30, 2023
Post comments count 0
Post likes count 2

How can I box a <CODE>std::optional</CODE> into a C++/WinRT <CODE>IInspectable</CODE>?

Raymond Chen
Raymond Chen

There's a handy conversion for that, but you have to know where to look.

The <CODE>WM_GETDLGCODE</CODE> message is a query message and should not modify state
Mar 29, 2023
Post comments count 2
Post likes count 3

The <CODE>WM_GETDLGCODE</CODE> message is a query message and should not modify state

Raymond Chen
Raymond Chen

Wait until you actually get the message.

How can I try to escape the disease-ridden hot-tubs known as the TEMP and Downloads directories?
Mar 28, 2023
Post comments count 16
Post likes count 4

How can I try to escape the disease-ridden hot-tubs known as the TEMP and Downloads directories?

Raymond Chen
Raymond Chen

You can ask that dependent DLLs be loaded from the System32 directory.

Using the contents of a file to define an MSBuild property
Mar 27, 2023
Post comments count 2
Post likes count 2

Using the contents of a file to define an MSBuild property

Raymond Chen
Raymond Chen

A little trick that maybe should be better known.

Adventures in application compatibility: The case of the jump into the middle of an instruction from nowhere
Mar 24, 2023
Post comments count 25
Post likes count 8

Adventures in application compatibility: The case of the jump into the middle of an instruction from nowhere

Raymond Chen
Raymond Chen

Another rogue patcher.

How unique must the <CODE>uIdSubclass</CODE> parameter be when I call <CODE>Set­Window­Subclass</CODE>?
Mar 23, 2023
Post comments count 0
Post likes count 3

How unique must the <CODE>uIdSubclass</CODE> parameter be when I call <CODE>Set­Window­Subclass</CODE>?

Raymond Chen
Raymond Chen

Each one identifies an instance of the subclass for the window.

Why am I getting a weird error about <CODE>promise_type</CODE> when I try to write a coroutine? part 2
Mar 22, 2023
Post comments count 0
Post likes count 1

Why am I getting a weird error about <CODE>promise_type</CODE> when I try to write a coroutine? part 2

Raymond Chen
Raymond Chen

Are you even writing a coroutine?

Why does the usage of the initial registers of a Win32 process depend on whether it is a 32-bit or 64-bit process?
Mar 21, 2023
Post comments count 5
Post likes count 2

Why does the usage of the initial registers of a Win32 process depend on whether it is a 32-bit or 64-bit process?

Raymond Chen
Raymond Chen

Well, I mean, it's a different processor.

On the proper care and feeding of the enigmatic <CODE>Get­Distance­Of­Closest­Language­In­List</CODE> function
Mar 20, 2023
Post comments count 0
Post likes count 2

On the proper care and feeding of the enigmatic <CODE>Get­Distance­Of­Closest­Language­In­List</CODE> function

Raymond Chen
Raymond Chen

Thinking about how this could be used.

Exploiting C++/WinRT CRTP: Property and event declarations
Mar 17, 2023
Post comments count 2
Post likes count 3

Exploiting C++/WinRT CRTP: Property and event declarations

Raymond Chen
Raymond Chen

They don't have to be methods; they just have to look like methods.

Mind your C++/WinRT namespaces
Mar 16, 2023
Post comments count 0
Post likes count 2

Mind your C++/WinRT namespaces

Raymond Chen
Raymond Chen

What you say changes meaning depending on where you are.

How can I create a git feature branch that can merge into multiple other branches?
Mar 15, 2023
Post comments count 0
Post likes count 2

How can I create a git feature branch that can merge into multiple other branches?

Raymond Chen
Raymond Chen

Just work in your patch branch.

Did Vienna ever exist or was it just misinformation?
Mar 14, 2023
Post comments count 4
Post likes count 2

Did Vienna ever exist or was it just misinformation?

Raymond Chen
Raymond Chen

It could be neither.

The 2023/2024 Seattle Symphony subscription season at a glance
Mar 13, 2023
Post comments count 1
Post likes count 2

The 2023/2024 Seattle Symphony subscription season at a glance

Raymond Chen
Raymond Chen

The pocket reference guide for 2023/2024.

What is the expression language used by the Resource Compiler for non-preprocessor expressions?
Mar 13, 2023
Post comments count 3
Post likes count 2

What is the expression language used by the Resource Compiler for non-preprocessor expressions?

Raymond Chen
Raymond Chen

Oddly different for a different audience.

When should I use <CODE>CS_GLOBALCLASS</CODE>?
Mar 10, 2023
Post comments count 7
Post likes count 2

When should I use <CODE>CS_GLOBALCLASS</CODE>?

Raymond Chen
Raymond Chen

When you want to be summoned from anywhere.

From a Windows app, how can I check whether there is an app installed that implements a particular URI scheme?, part 2
Mar 9, 2023
Post comments count 5
Post likes count 3

From a Windows app, how can I check whether there is an app installed that implements a particular URI scheme?, part 2

Raymond Chen
Raymond Chen

Alternatives that work for unpackaged apps.

From a Windows app, how can I check whether there is an app installed that implements a particular URI scheme?
Mar 8, 2023
Post comments count 1
Post likes count 3

From a Windows app, how can I check whether there is an app installed that implements a particular URI scheme?

Raymond Chen
Raymond Chen

Additional function to let you see what is available.

Microspeak: Baseball card
Mar 7, 2023
Post comments count 0
Post likes count 1

Microspeak: Baseball card

Raymond Chen
Raymond Chen

A one-page summary, and this time we mean it.

I can create a read-only page, but why not a write-only page?
Mar 6, 2023
Post comments count 12
Post likes count 2

I can create a read-only page, but why not a write-only page?

Raymond Chen
Raymond Chen

At the end of the day, it comes down to processor support.

Enumerating Windows clipboard history in PowerShell
Mar 3, 2023
Post comments count 10
Post likes count 6

Enumerating Windows clipboard history in PowerShell

Raymond Chen
Raymond Chen

Doing Windows Runtime things from PowerShell.

Enumerating Windows clipboard history in C++/WinRT and C#
Mar 2, 2023
Post comments count 2
Post likes count 2

Enumerating Windows clipboard history in C++/WinRT and C#

Raymond Chen
Raymond Chen

Exploring the clipboard history API.

If you want to sort a Windows Runtime collection, you may first want to capture it into something a bit easier to manipulate
Mar 1, 2023
Post comments count 1
Post likes count 2

If you want to sort a Windows Runtime collection, you may first want to capture it into something a bit easier to manipulate

Raymond Chen
Raymond Chen

Moving everything into the same universe.

Once you give away the farm, you can’t take it back: Recovering from a rogue administrator
Feb 28, 2023
Post comments count 5
Post likes count 2

Once you give away the farm, you can’t take it back: Recovering from a rogue administrator

Raymond Chen
Raymond Chen

Who knows what happened to it while you weren't looking.

The unintentionally-expanding scope of the <CODE>SEM_NOGPFAULTERRORBOX</CODE> flag
Feb 27, 2023
Post comments count 4
Post likes count 1

The unintentionally-expanding scope of the <CODE>SEM_NOGPFAULTERRORBOX</CODE> flag

Raymond Chen
Raymond Chen

Other suppressions caught in its net.

Understanding a mysterious <CODE>RPC_<WBR>E_<WBR>WRONG­THREAD</CODE> exception when we’re on the right thread
Feb 24, 2023
Post comments count 2
Post likes count 2

Understanding a mysterious <CODE>RPC_<WBR>E_<WBR>WRONG­THREAD</CODE> exception when we’re on the right thread

Raymond Chen
Raymond Chen

Things can go wrong in ways you may not have realized.

Why am I getting an unhandled exception from my C++ function that catches all exceptions?
Feb 23, 2023
Post comments count 0
Post likes count 3

Why am I getting an unhandled exception from my C++ function that catches all exceptions?

Raymond Chen
Raymond Chen

Yes, you caught an exception. But that's not the one that went unhandled.

Avoiding the redundancy of adding the object files to both the primary project and its unit test
Feb 22, 2023
Post comments count 9
Post likes count 4

Avoiding the redundancy of adding the object files to both the primary project and its unit test

Raymond Chen
Raymond Chen

Adding another level of indirection.

Microspeak: Light reading (ironic)
Feb 21, 2023
Post comments count 2
Post likes count 3

Microspeak: Light reading (ironic)

Raymond Chen
Raymond Chen

Just a fun diversion.

The case of the mysterious "out of bounds" error from <CODE>CreateUri</CODE> and <CODE>memmove</CODE>
Feb 20, 2023
Post comments count 9
Post likes count 5

The case of the mysterious "out of bounds" error from <CODE>CreateUri</CODE> and <CODE>memmove</CODE>

Raymond Chen
Raymond Chen

Unfolding some COMDATs.

What happens if you co_await a std::future, and why is it a bad idea?
Feb 17, 2023
Post comments count 2
Post likes count 2

What happens if you co_await a std::future, and why is it a bad idea?

Raymond Chen
Raymond Chen

Just waiting for something to finish.

What does it mean when my cross-thread COM call fails with <CODE>RPC_<WBR>E_<WBR>SYS_<WBR>CALL_<WBR>FAILED</CODE>?
Feb 16, 2023
Post comments count 0
Post likes count 2

What does it mean when my cross-thread COM call fails with <CODE>RPC_<WBR>E_<WBR>SYS_<WBR>CALL_<WBR>FAILED</CODE>?

Raymond Chen
Raymond Chen

Look for an unresponsive recipient.

What are the potentially-erroneous results if you don’t pass NULL as the lpNumberOfBytesRead when issuing overlapped I/O?
Feb 15, 2023
Post comments count 7
Post likes count 2

What are the potentially-erroneous results if you don’t pass NULL as the lpNumberOfBytesRead when issuing overlapped I/O?

Raymond Chen
Raymond Chen

It's to avoid a self-inflicted race condition.

Why are the Windows chassis hardware button hotkeys so strange?
Feb 14, 2023
Post comments count 4
Post likes count 2

Why are the Windows chassis hardware button hotkeys so strange?

Raymond Chen
Raymond Chen

Operating within the constraints of the system.

Adventures in application compatibility: The case of the display control panel crash on exit
Feb 13, 2023
Post comments count 15
Post likes count 6

Adventures in application compatibility: The case of the display control panel crash on exit

Raymond Chen
Raymond Chen

When you get a 64-bit pointer, you probably should remember all 64 of the bits.

The case of the <CODE>RPC_<WBR>E_<WBR>DISCONNECTED</CODE> error thrown from <CODE>await_<WBR>resume</CODE>
Feb 10, 2023
Post comments count 4
Post likes count 4

The case of the <CODE>RPC_<WBR>E_<WBR>DISCONNECTED</CODE> error thrown from <CODE>await_<WBR>resume</CODE>

Raymond Chen
Raymond Chen

You can keep trying, but the result won't change.

A more direct and mistake-free way of creating a process in a job object
Feb 9, 2023
Post comments count 5
Post likes count 1

A more direct and mistake-free way of creating a process in a job object

Raymond Chen
Raymond Chen

A new attribute for creating a process directly in a job object.

How can I get the original target of a shortcut without applying any 32-bit adjustments?
Feb 8, 2023
Post comments count 0
Post likes count 2

How can I get the original target of a shortcut without applying any 32-bit adjustments?

Raymond Chen
Raymond Chen

Disable the fancy tracking.

The frustration of finding a suitable time to hold a meeting when the participants are evenly spaced around the globe
Feb 7, 2023
Post comments count 3
Post likes count 1

The frustration of finding a suitable time to hold a meeting when the participants are evenly spaced around the globe

Raymond Chen
Raymond Chen

Somebody has to suffer, but we try to make sure it's not the same person each time.

It rather involved being on the other side of this airtight hatchway: Reading the user’s saved passwords
Feb 6, 2023
Post comments count 9
Post likes count 2

It rather involved being on the other side of this airtight hatchway: Reading the user’s saved passwords

Raymond Chen
Raymond Chen

Only the user can read their own saved passwords, so you must already have gained total control over the user.

Inside C++/WinRT: Coroutine completions: Cancellation propagation
Feb 3, 2023
Post comments count 0
Post likes count 2

Inside C++/WinRT: Coroutine completions: Cancellation propagation

Raymond Chen
Raymond Chen

Giving up.

Hyperlinking to Hutchison Whampoa Limited is still forbidden
Feb 2, 2023
Post comments count 6
Post likes count 1

Hyperlinking to Hutchison Whampoa Limited is still forbidden

Raymond Chen
Raymond Chen

Didn't make you look.

Inside C++/WinRT: Coroutine completions: Avoiding reentrant completion
Feb 2, 2023
Post comments count 0
Post likes count 1

Inside C++/WinRT: Coroutine completions: Avoiding reentrant completion

Raymond Chen
Raymond Chen

Resuming the coroutine directly, rather than consuming yet more stack.

Inside C++/WinRT: Coroutine completion handlers: Disconnection
Feb 1, 2023
Post comments count 0
Post likes count 1

Inside C++/WinRT: Coroutine completion handlers: Disconnection

Raymond Chen
Raymond Chen

When the other end hangs up without even saying good-bye.

Inside C++/WinRT: Apartment switching: Error reporting
Jan 31, 2023
Post comments count 0
Post likes count 2

Inside C++/WinRT: Apartment switching: Error reporting

Raymond Chen
Raymond Chen

If you can't get back to where you started, who you gonna call?

Inside C++/WinRT: Apartment switching: COM without COM
Jan 30, 2023
Post comments count 0
Post likes count 2

Inside C++/WinRT: Apartment switching: COM without COM

Raymond Chen
Raymond Chen

Also known as Nano-COM.

Inside C++/WinRT: Apartment switching: Unwinding the stack
Jan 27, 2023
Post comments count 0
Post likes count 1

Inside C++/WinRT: Apartment switching: Unwinding the stack

Raymond Chen
Raymond Chen

Reducing stack usage.

Inside C++/WinRT: Apartment switching: Bypassing the context callback
Jan 26, 2023
Post comments count 0
Post likes count 2

Inside C++/WinRT: Apartment switching: Bypassing the context callback

Raymond Chen
Raymond Chen

Reducing stack usage.

Inside C++/WinRT: Apartment switching: Unblocking the outgoing thread
Jan 25, 2023
Post comments count 1
Post likes count 2

Inside C++/WinRT: Apartment switching: Unblocking the outgoing thread

Raymond Chen
Raymond Chen

Avoiding the problem of the synchronous apartment-changing callback: Let the outgoing thread do whatever it wants to do next.

Inside C++/WinRT: Apartment switching: The basic idea
Jan 24, 2023
Post comments count 0
Post likes count 2

Inside C++/WinRT: Apartment switching: The basic idea

Raymond Chen
Raymond Chen

Getting back to where you started.

Inside C++/WinRT: Coroutine completions: The oversimplified version
Jan 23, 2023
Post comments count 3
Post likes count 3

Inside C++/WinRT: Coroutine completions: The oversimplified version

Raymond Chen
Raymond Chen

Resuming the coroutine when the asynchronous work completes.

How can I call a method on a derived class from a base class, say, to get a strong reference to the containing object?
Jan 20, 2023
Post comments count 0
Post likes count 1

How can I call a method on a derived class from a base class, say, to get a strong reference to the containing object?

Raymond Chen
Raymond Chen

A variety of patterns are available.

Windows Runtime asynchronous operations can fail in two different ways, so make sure you get them both
Jan 19, 2023
Post comments count 0
Post likes count 2

Windows Runtime asynchronous operations can fail in two different ways, so make sure you get them both

Raymond Chen
Raymond Chen

Fail me now or fail me later.

It rather involved being on the other side of this airtight hatchway: Attacking a user by modifying that user’s files
Jan 18, 2023
Post comments count 4
Post likes count 2

It rather involved being on the other side of this airtight hatchway: Attacking a user by modifying that user’s files

Raymond Chen
Raymond Chen

You're just attacking yourself.

A trio of dubious denial-of-service security vulnerability reports which are just style points piled on top of nothing
Jan 17, 2023
Post comments count 8
Post likes count 1

A trio of dubious denial-of-service security vulnerability reports which are just style points piled on top of nothing

Raymond Chen
Raymond Chen

You could have accomplished the same thing with a garbage file.

Making C++ primitive types meaningfully movable when they have sentinel values
Jan 16, 2023
Post comments count 0
Post likes count 1

Making C++ primitive types meaningfully movable when they have sentinel values

Raymond Chen
Raymond Chen

The value actually moves now.

Adventures in application compatibility: Querying for an internal interface
Jan 13, 2023
Post comments count 18
Post likes count 4

Adventures in application compatibility: Querying for an internal interface

Raymond Chen
Raymond Chen

Reaching in and fiddling the internal knobs.

How should I interpret the various values of <CODE>NLM_CONNECTIVITY</CODE>?
Jan 12, 2023
Post comments count 5
Post likes count 2

How should I interpret the various values of <CODE>NLM_CONNECTIVITY</CODE>?

Raymond Chen
Raymond Chen

Different levels of connectedness.

What does it mean when I get a mismatch from MSVC for <CODE>_COROUTINE_ABI</CODE>?
Jan 11, 2023
Post comments count 0
Post likes count 3

What does it mean when I get a mismatch from MSVC for <CODE>_COROUTINE_ABI</CODE>?

Raymond Chen
Raymond Chen

The two different kinds of coroutine interfaces shouldn't be mixed and matched.

It rather involved being on the other side of this airtight hatchway: Administrator attacking a domain account on the local system
Jan 10, 2023
Post comments count 10
Post likes count 1

It rather involved being on the other side of this airtight hatchway: Administrator attacking a domain account on the local system

Raymond Chen
Raymond Chen

You don't gain control over any other systems.

On leading underscores and names reserved by the C and C++ languages
Jan 9, 2023
Post comments count 14
Post likes count 6

On leading underscores and names reserved by the C and C++ languages

Raymond Chen
Raymond Chen

The rules laid out.

Dubious security vulnerability: Granting access to SIDs that don’t exist yet
Jan 6, 2023
Post comments count 1
Post likes count 1

Dubious security vulnerability: Granting access to SIDs that don’t exist yet

Raymond Chen
Raymond Chen

You can put anyone you like on your guest list, even if they don't exist.

How can I force a user to have a specific SID prefix, so that they go into a particular group?
Jan 5, 2023
Post comments count 0
Post likes count 1

How can I force a user to have a specific SID prefix, so that they go into a particular group?

Raymond Chen
Raymond Chen

The prefix doesn't define group membership.

Using perfect (and imperfect) forwarding to simplify C++ wrapper classes
Jan 4, 2023
Post comments count 11
Post likes count 3

Using perfect (and imperfect) forwarding to simplify C++ wrapper classes

Raymond Chen
Raymond Chen

Just call that other thing the same way you called this thing.

It rather involved being on the other side of this airtight hatchway: Gaining code execution from a Trojan horse
Jan 3, 2023
Post comments count 4
Post likes count 1

It rather involved being on the other side of this airtight hatchway: Gaining code execution from a Trojan horse

Raymond Chen
Raymond Chen

You already have code execution, so it's not surprising that you can gain code execution.

Opinionated notes on the Windows.Data.Json namespace
Jan 2, 2023
Post comments count 8
Post likes count 3

Opinionated notes on the Windows.Data.Json namespace

Raymond Chen
Raymond Chen

It's available if you need it, but there are some tricks and pitfalls, and you may very well have better options.

2022 year-end link clearance
Dec 30, 2022
Post comments count 1
Post likes count 4

2022 year-end link clearance

Raymond Chen
Raymond Chen

Closing the book on another year.

When I create a waitable timer with a callback, do I have to wait alertably on that specific timer before the callback will run?
Dec 30, 2022
Post comments count 3
Post likes count 1

When I create a waitable timer with a callback, do I have to wait alertably on that specific timer before the callback will run?

Raymond Chen
Raymond Chen

Any alertable wait will do.

How can I detect programmatically whether Windows is an N or KN version?
Dec 29, 2022
Post comments count 2
Post likes count 2

How can I detect programmatically whether Windows is an N or KN version?

Raymond Chen
Raymond Chen

Don't check the version, just check the feature.

After importing a TLB, how do I convert from one type of <CODE>_com_ptr_t</CODE> to another?
Dec 28, 2022
Post comments count 3
Post likes count 2

After importing a TLB, how do I convert from one type of <CODE>_com_ptr_t</CODE> to another?

Raymond Chen
Raymond Chen

Digging into the source code.

Why can’t I print when I boot Windows into audit mode?
Dec 27, 2022
Post comments count 4
Post likes count 1

Why can’t I print when I boot Windows into audit mode?

Raymond Chen
Raymond Chen

It's not all there.

The worst-selling Microsoft software product of all time: OS/2 for the Mach 20
Dec 26, 2022
Post comments count 10
Post likes count 5

The worst-selling Microsoft software product of all time: OS/2 for the Mach 20

Raymond Chen
Raymond Chen

Count 'em on one hand.

The case of the recursively hung <CODE>WM_DRAW­CLIPBOARD</CODE> message
Dec 23, 2022
Post comments count 4
Post likes count 2

The case of the recursively hung <CODE>WM_DRAW­CLIPBOARD</CODE> message

Raymond Chen
Raymond Chen

Understanding why it's happening and how you can avoid it.

Is there a fixed virtual address that the system promises never to use for anything, so I can use it?
Dec 22, 2022
Post comments count 7
Post likes count 3

Is there a fixed virtual address that the system promises never to use for anything, so I can use it?

Raymond Chen
Raymond Chen

Everything is up for grabs.

Running some UI code on a timer at a higher priority than your usual timer messages, or without coalescing
Dec 21, 2022
Post comments count 3
Post likes count 2

Running some UI code on a timer at a higher priority than your usual timer messages, or without coalescing

Raymond Chen
Raymond Chen

You can build your own timer system.

Why doesn’t the BitLocker wizard let me save the BitLocker key on an encrypted drive?
Dec 20, 2022
Post comments count 9
Post likes count 5

Why doesn’t the BitLocker wizard let me save the BitLocker key on an encrypted drive?

Raymond Chen
Raymond Chen

Don't lock your keys in the car.

On the large number of ways of expressing Microsoft Visual C++ compiler versions
Dec 19, 2022
Post comments count 6
Post likes count 4

On the large number of ways of expressing Microsoft Visual C++ compiler versions

Raymond Chen
Raymond Chen

So many version numbers.

Why doesn’t Windows use the 64-bit virtual address space below <CODE>0x00000000`7ffe0000</CODE>?
Dec 16, 2022
Post comments count 7
Post likes count 6

Why doesn’t Windows use the 64-bit virtual address space below <CODE>0x00000000`7ffe0000</CODE>?

Raymond Chen
Raymond Chen

It does use it, although it doesn't look like it.

Inside C++/WinRT: <CODE>IReference<T></CODE>
Dec 15, 2022
Post comments count 1
Post likes count 1

Inside C++/WinRT: <CODE>IReference<T></CODE>

Raymond Chen
Raymond Chen

Reverse-engineering the usages from the code.

In C++/WinRT, how do I create or consume an <CODE>IReference<T></CODE> that wraps a particular value?
Dec 14, 2022
Post comments count 0
Post likes count 1

In C++/WinRT, how do I create or consume an <CODE>IReference<T></CODE> that wraps a particular value?

Raymond Chen
Raymond Chen

Conversions to and from <CODE>IReference</CODE>.

Thank you for conference announcement, but it would help if you told me what your conference was about
Dec 13, 2022
Post comments count 5
Post likes count 3

Thank you for conference announcement, but it would help if you told me what your conference was about

Raymond Chen
Raymond Chen

There was an announcement of an all-day Microsoft-internal conference featuring a project I will call Project Enzyme. The announcement went like this: The Project Enzyme Forum is our flagship community conference that brings together engineers, project managers, data scientists, and designers from around the company to learn about Project Enzyme and get a first look at some of the exciting new improvements in the platform. Senior leaders will share their vision for Project Enyzme and how we can use it to create the next wave of cutting-edge products and experiences. Other senior leaders will participate in a ...

What does it mean when the compiler tells me that <CODE>promise_type</CODE>: is not a member of <CODE>coroutine_traits<void></CODE>?
Dec 12, 2022
Post comments count 0
Post likes count 1

What does it mean when the compiler tells me that <CODE>promise_type</CODE>: is not a member of <CODE>coroutine_traits<void></CODE>?

Raymond Chen
Raymond Chen

Applying your understanding of the coroutine transformation.

How can I do the opposite of <CODE>compare_exchange</CODE> and exchange if the value is <I>different</I>?
Dec 9, 2022
Post comments count 0
Post likes count 2

How can I do the opposite of <CODE>compare_exchange</CODE> and exchange if the value is <I>different</I>?

Raymond Chen
Raymond Chen

An exchange with itself has no effect on the value.

If you’re going to wrap a Windows Runtime event, you may as well let the wrapped event source manage the token
Dec 8, 2022
Post comments count 1
Post likes count 1

If you’re going to wrap a Windows Runtime event, you may as well let the wrapped event source manage the token

Raymond Chen
Raymond Chen

It keeps the original object in control.

Reminder: If you intend to use a C++/WinRT namespace, you must include that namespace’s header file
Dec 7, 2022
Post comments count 1
Post likes count 1

Reminder: If you intend to use a C++/WinRT namespace, you must include that namespace’s header file

Raymond Chen
Raymond Chen

Various errors that can be traced back to breaking that one rule.

Trouble connecting to Web sites and services because of certificate errors? Check if you’re being held captive
Dec 6, 2022
Post comments count 6
Post likes count 1

Trouble connecting to Web sites and services because of certificate errors? Check if you’re being held captive

Raymond Chen
Raymond Chen

There's a man in the middle.

Instead of a C++ template parlor trick, why not just add support based on whether the header file has already been included?
Dec 5, 2022
Post comments count 2
Post likes count 1

Instead of a C++ template parlor trick, why not just add support based on whether the header file has already been included?

Raymond Chen
Raymond Chen

Header file inclusion order dependencies.

C++ template parlor tricks: Using a type before it is defined
Dec 2, 2022
Post comments count 10
Post likes count 3

C++ template parlor tricks: Using a type before it is defined

Raymond Chen
Raymond Chen

You can talk about hypothetical things, hoping that a real thing shows up later.

Not even trying to cross an airtight hatchway: Calling a function in your own process by synthesizing a function pointer
Dec 1, 2022
Post comments count 4
Post likes count 1

Not even trying to cross an airtight hatchway: Calling a function in your own process by synthesizing a function pointer

Raymond Chen
Raymond Chen

You can already attack yourself in far more interesting ways.

I used <CODE>FILE_FLAG_SEQUENTIAL_SCAN</CODE> but it didn’t seem to speed up my sequential scanning
Nov 30, 2022
Post comments count 1
Post likes count 3

I used <CODE>FILE_FLAG_SEQUENTIAL_SCAN</CODE> but it didn’t seem to speed up my sequential scanning

Raymond Chen
Raymond Chen

It triggers prefetching, but your usage pattern may mean that prefetch doesn't mean much.

Dubious security vulnerability: Reading the files in the WindowsApps folder
Nov 29, 2022
Post comments count 2
Post likes count 1

Dubious security vulnerability: Reading the files in the WindowsApps folder

Raymond Chen
Raymond Chen

You already had access to those files, by virtue of the fact that they ran in the first place.

What kind of caller diagnostic information can I get from exceptions thrown by C++/WinRT and wil?, C++20 edition
Nov 28, 2022
Post comments count 0
Post likes count 1

What kind of caller diagnostic information can I get from exceptions thrown by C++/WinRT and wil?, C++20 edition

Raymond Chen
Raymond Chen

The state of the art has moved forward slightly.

The case of the application that used thread local storage it never allocated
Nov 28, 2022
Post comments count 8
Post likes count 3

The case of the application that used thread local storage it never allocated

Raymond Chen
Raymond Chen

Of course it's there, isn't it? I mean, it's always been there.

How do I pass a raw pointer to a Windows Runtime function?
Nov 25, 2022
Post comments count 2
Post likes count 2

How do I pass a raw pointer to a Windows Runtime function?

Raymond Chen
Raymond Chen

Raw pointers don't exist in the Windows Runtime, so you'll have to re-express it in terms of something that does.

How does JavaScript represent output parameters in the Windows Runtime?
Nov 24, 2022
Post comments count 12
Post likes count 1

How does JavaScript represent output parameters in the Windows Runtime?

Raymond Chen
Raymond Chen

It has to fake it.

Sometimes perfect forwarding can be too perfect: Lazy conversion is lazy
Nov 23, 2022
Post comments count 4
Post likes count 1

Sometimes perfect forwarding can be too perfect: Lazy conversion is lazy

Raymond Chen
Raymond Chen

Lazy conversion is too lazy.

Microspeak: Breaking into jail
Nov 22, 2022
Post comments count 2
Post likes count 1

Microspeak: Breaking into jail

Raymond Chen
Raymond Chen

Just asking for trouble.

What kind of caller diagnostic information can I get from exceptions thrown by C++/WinRT and wil?
Nov 21, 2022
Post comments count 0
Post likes count 2

What kind of caller diagnostic information can I get from exceptions thrown by C++/WinRT and wil?

Raymond Chen
Raymond Chen

A survey of the current state of the art.

On Windows Runtime asynchronous operations with critical progress reports
Nov 18, 2022
Post comments count 0
Post likes count 2

On Windows Runtime asynchronous operations with critical progress reports

Raymond Chen
Raymond Chen

Make the caller provide the progress handler up front.

How soon is too soon to report progress from a C++/WinRT coroutine that implements a Windows Runtime asynchronous operation with progress?
Nov 17, 2022
Post comments count 1
Post likes count 1

How soon is too soon to report progress from a C++/WinRT coroutine that implements a Windows Runtime asynchronous operation with progress?

Raymond Chen
Raymond Chen

If a progress is sent to a forest but there's no one there to hear it.

Why won’t C++/WinRT let me <CODE>co_await</CODE> a <CODE>CoreDispatcher</CODE> or <CODE>DispatcherQueue</CODE>?
Nov 16, 2022
Post comments count 0
Post likes count 1

Why won’t C++/WinRT let me <CODE>co_await</CODE> a <CODE>CoreDispatcher</CODE> or <CODE>DispatcherQueue</CODE>?

Raymond Chen
Raymond Chen

Making sure you meet the usual prerequisites.

It’s important to get the most difficult part out of the way by putting it in the title
Nov 15, 2022
Post comments count 1
Post likes count 1

It’s important to get the most difficult part out of the way by putting it in the title

Raymond Chen
Raymond Chen

It does much less harm there than in the body.

How does Windows decide whether your computer has limited or full Internet access?
Nov 15, 2022
Post comments count 11
Post likes count 6

How does Windows decide whether your computer has limited or full Internet access?

Raymond Chen
Raymond Chen

Looking for special servers.

C++ constexpr parlor tricks: How can I obtain the length of a string at compile time?
Nov 14, 2022
Post comments count 7
Post likes count 5

C++ constexpr parlor tricks: How can I obtain the length of a string at compile time?

Raymond Chen
Raymond Chen

The <CODE>constexpr</CODE>'ification of <CODE>strlen</CODE>.

If I issue multiple overlapped I/O requests against the same region of a file, will they execute in the order I issued them?
Nov 11, 2022
Post comments count 4
Post likes count 6

If I issue multiple overlapped I/O requests against the same region of a file, will they execute in the order I issued them?

Raymond Chen
Raymond Chen

Overlapped I/O refers to temporal overlap, and that includes completion out of order.

On the dangers of giving a product feature the name “new”
Nov 10, 2022
Post comments count 24
Post likes count 3

On the dangers of giving a product feature the name “new”

Raymond Chen
Raymond Chen

It may be new today, but it won't be new tomorrow.

Why don’t Windows functions begin with a pointless MOV EDI,EDI instruction on x86-64?
Nov 9, 2022
Post comments count 6
Post likes count 6

Why don’t Windows functions begin with a pointless MOV EDI,EDI instruction on x86-64?

Raymond Chen
Raymond Chen

Applying the hot-patch in a different way.

Why is there a system sound called Asterisk? What sound does an Asterisk make anyway?
Nov 8, 2022
Post comments count 3
Post likes count 4

Why is there a system sound called Asterisk? What sound does an Asterisk make anyway?

Raymond Chen
Raymond Chen

It's to accompany the asterisk, back when we had an asterisk.

My niece is just here for the food
Nov 7, 2022
Post comments count 1
Post likes count 1

My niece is just here for the food

Raymond Chen
Raymond Chen

The important part of the trip.

In the debugger, how can I get from a projected type back to the C++/WinRT implementation?
Nov 7, 2022
Post comments count 2
Post likes count 3

In the debugger, how can I get from a projected type back to the C++/WinRT implementation?

Raymond Chen
Raymond Chen

Look behind you.

Why am I getting a <CODE>RPC_E_WRONG_THREAD</CODE> exception when I’m on the right thread?
Nov 4, 2022
Post comments count 1
Post likes count 2

Why am I getting a <CODE>RPC_E_WRONG_THREAD</CODE> exception when I’m on the right thread?

Raymond Chen
Raymond Chen

It's the wrong thread from XAML's point of view.

How does the dialog manager calculate the average width of a character?
Nov 3, 2022
Post comments count 2
Post likes count 5

How does the dialog manager calculate the average width of a character?

Raymond Chen
Raymond Chen

It's a simple formula, perhaps too simple.

A history of the <CODE>fd_set</CODE>, <CODE>FD_SETSIZE</CODE>, and how it relates to WinSock
Nov 2, 2022
Post comments count 5
Post likes count 6

A history of the <CODE>fd_set</CODE>, <CODE>FD_SETSIZE</CODE>, and how it relates to WinSock

Raymond Chen
Raymond Chen

The <CODE>fd_set</CODE> started out as just a bitmap.

What is a “Select Administrator”? Is that some special elite kind of administrator?
Nov 1, 2022
Post comments count 10
Post likes count 3

What is a “Select Administrator”? Is that some special elite kind of administrator?

Raymond Chen
Raymond Chen

It's two different messages that combine in an interesting way.

How can I test my geolocation code on a system without a GPS?
Oct 31, 2022
Post comments count 0
Post likes count 3

How can I test my geolocation code on a system without a GPS?

Raymond Chen
Raymond Chen

You can use the Windows Device Portal to create a synthetic GPS.

Setting properties in C++/WinRT is done by a function call, but you need to call the function the right way
Oct 28, 2022
Post comments count 4
Post likes count 4

Setting properties in C++/WinRT is done by a function call, but you need to call the function the right way

Raymond Chen
Raymond Chen

The new value is the function parameter.

Why am I seeing two WRITE requests at the same offset from a single call to WriteFile?
Oct 27, 2022
Post comments count 3
Post likes count 4

Why am I seeing two WRITE requests at the same offset from a single call to WriteFile?

Raymond Chen
Raymond Chen

It started as one write, but turned into a lot of other things.

What can or should I do with the cursor handle returned by <CODE>SetCursor</CODE>?
Oct 26, 2022
Post comments count 3
Post likes count 3

What can or should I do with the cursor handle returned by <CODE>SetCursor</CODE>?

Raymond Chen
Raymond Chen

You can put it back, but sometimes you need to make sure you do it before anybody else can see the change.

Why are many Windows user interface elements positioned at multiples of 4 or 8 pixels?
Oct 25, 2022
Post comments count 8
Post likes count 5

Why are many Windows user interface elements positioned at multiples of 4 or 8 pixels?

Raymond Chen
Raymond Chen

It depends on whose pixels you're talking about.

Why can’t I programmatically inspect the check boxes in the Security property sheet any more?
Oct 24, 2022
Post comments count 0
Post likes count 2

Why can’t I programmatically inspect the check boxes in the Security property sheet any more?

Raymond Chen
Raymond Chen

Abusing the <CODE>ISecurity­Information::<WBR>Property­Sheet­Page­Callback</CODE> method.

What happens if my C++ exception handler itself raises an exception?
Oct 21, 2022
Post comments count 1
Post likes count 3

What happens if my C++ exception handler itself raises an exception?

Raymond Chen
Raymond Chen

And comparing to the handling of structured exceptions.

Is it true that raising a structured exception from a structured exception handler terminates the process?
Oct 20, 2022
Post comments count 1
Post likes count 4

Is it true that raising a structured exception from a structured exception handler terminates the process?

Raymond Chen
Raymond Chen

Untangling the myth.

Why is there a <CODE>make_unique</CODE>? Why not just overload the <CODE>unique_ptr</CODE> constructor?
Oct 19, 2022
Post comments count 1
Post likes count 4

Why is there a <CODE>make_unique</CODE>? Why not just overload the <CODE>unique_ptr</CODE> constructor?

Raymond Chen
Raymond Chen

You'll have to resolve the ambiguity, so you're still typing a lot.

Why is there a <CODE>passwords.txt</CODE> file on my system that’s filled with somebody else’s passwords?
Oct 18, 2022
Post comments count 10
Post likes count 7

Why is there a <CODE>passwords.txt</CODE> file on my system that’s filled with somebody else’s passwords?

Raymond Chen
Raymond Chen

It's part of an open-source password strength package.

How can I check the integrity level of my process?
Oct 17, 2022
Post comments count 11
Post likes count 3

How can I check the integrity level of my process?

Raymond Chen
Raymond Chen

A series of range checks.

The case of the memory corruption from a coroutine that already finished
Oct 14, 2022
Post comments count 3
Post likes count 1

The case of the memory corruption from a coroutine that already finished

Raymond Chen
Raymond Chen

The zombie coroutine.

How can I check whether the user’s network connection is roaming or metered?
Oct 13, 2022
Post comments count 1
Post likes count 4

How can I check whether the user’s network connection is roaming or metered?

Raymond Chen
Raymond Chen

The classic way and the Windows Runtime way.

One possible reason why your program crashes when submitted to the Microsoft Store, but it runs fine on your machine
Oct 12, 2022
Post comments count 0
Post likes count 1

One possible reason why your program crashes when submitted to the Microsoft Store, but it runs fine on your machine

Raymond Chen
Raymond Chen

Check your minimum requirements.

Clicking past the warning that you are about to cross the airtight hatchway: Vulnerable file type that you are warned about
Oct 11, 2022
Post comments count 7
Post likes count 1

Clicking past the warning that you are about to cross the airtight hatchway: Vulnerable file type that you are warned about

Raymond Chen
Raymond Chen

Acknowledging the danger but complaining about it anyway.

On the overloading of the address-of operator <CODE>&</CODE> in smart pointer classes
Oct 10, 2022
Post comments count 5
Post likes count 2

On the overloading of the address-of operator <CODE>&</CODE> in smart pointer classes

Raymond Chen
Raymond Chen

Different patterns, which means you're never sure what you're going to get.

How can I perform a CopyFile, but also flush the file buffers before the destination handle is closed?
Oct 7, 2022
Post comments count 7
Post likes count 6

How can I perform a CopyFile, but also flush the file buffers before the destination handle is closed?

Raymond Chen
Raymond Chen

Your callback function can do things with the handle, even extend their lifetime.

The Import Address Table is now write-protected, and what that means for rogue patching
Oct 6, 2022
Post comments count 9
Post likes count 4

The Import Address Table is now write-protected, and what that means for rogue patching

Raymond Chen
Raymond Chen

Making a potential attack vector less attractive.

The gotcha of the C++ temporaries that don’t destruct as eagerly as you thought
Oct 5, 2022
Post comments count 7
Post likes count 5

The gotcha of the C++ temporaries that don’t destruct as eagerly as you thought

Raymond Chen
Raymond Chen

You have to look for the end of the full expression.

Starting on the other side of this airtight hatchway: Overwhelming the system
Oct 4, 2022
Post comments count 1
Post likes count 1

Starting on the other side of this airtight hatchway: Overwhelming the system

Raymond Chen
Raymond Chen

It'll take time for things to drain out.

Feel free to stop using IMultiLanguage2::DetectInputCodepage
Oct 3, 2022
Post comments count 0
Post likes count 1

Feel free to stop using IMultiLanguage2::DetectInputCodepage

Raymond Chen
Raymond Chen

You should have been keeping your eye on the code page all along.

Debugging coroutine handles: Looking for the source of a one-byte memory corruption
Sep 30, 2022
Post comments count 1
Post likes count 1

Debugging coroutine handles: Looking for the source of a one-byte memory corruption

Raymond Chen
Raymond Chen

Applying what we know about coroutines.

I did that merge-as-cherry-pick thing, but my change still didn’t merge correctly
Sep 29, 2022
Post comments count 1
Post likes count 1

I did that merge-as-cherry-pick thing, but my change still didn’t merge correctly

Raymond Chen
Raymond Chen

A case study of what goes wrong.

Why does COM express GUIDs in a mix of big-endian and little-endian? Why can’t it just pick a side and stick with it?
Sep 28, 2022
Post comments count 2
Post likes count 6

Why does COM express GUIDs in a mix of big-endian and little-endian? Why can’t it just pick a side and stick with it?

Raymond Chen
Raymond Chen

Oh, it does pick a side. It's just that some dashes are missing.

Microspeak: Break glass
Sep 27, 2022
Post comments count 1
Post likes count 2

Microspeak: Break glass

Raymond Chen
Raymond Chen

Metaphorically breaking the glass in case of emergency.

What does the C++ error “A pointer to a bound function may only be used to call the function” mean?
Sep 26, 2022
Post comments count 3
Post likes count 1

What does the C++ error “A pointer to a bound function may only be used to call the function” mean?

Raymond Chen
Raymond Chen

You got all set to call a function but forgot to call it.

Why am I receiving <CODE>SHCNE_<WBR>UPDATE­DIR</CODE> notifications that my code never generates?
Sep 23, 2022
Post comments count 1
Post likes count 1

Why am I receiving <CODE>SHCNE_<WBR>UPDATE­DIR</CODE> notifications that my code never generates?

Raymond Chen
Raymond Chen

You did generate them, indirectly.

How can I get WRL to link my object into its activation factory?
Sep 22, 2022
Post comments count 0
Post likes count 1

How can I get WRL to link my object into its activation factory?

Raymond Chen
Raymond Chen

More magic macros.

How can I trigger a recalc of the mouse cursor after I changed some of my internal application state?
Sep 21, 2022
Post comments count 3
Post likes count 5

How can I trigger a recalc of the mouse cursor after I changed some of my internal application state?

Raymond Chen
Raymond Chen

Go through the standard process one more time.

Janet Jackson had the power to crash laptop computers, follow-up
Sep 20, 2022
Post comments count 8
Post likes count 2

Janet Jackson had the power to crash laptop computers, follow-up

Raymond Chen
Raymond Chen

Deeper speculation by others.

Why load fs:[0x18] into a register and then dereference that, instead of just going for fs:[n] directly?
Sep 19, 2022
Post comments count 11
Post likes count 3

Why load fs:[0x18] into a register and then dereference that, instead of just going for fs:[n] directly?

Raymond Chen
Raymond Chen

Simplifying the compiler.

Serializing asynchronous operations in C++/WinRT, gotchas and final assembly
Sep 16, 2022
Post comments count 0
Post likes count 4

Serializing asynchronous operations in C++/WinRT, gotchas and final assembly

Raymond Chen
Raymond Chen

Cancellation and abandonment.

Serializing asynchronous operations in C++/WinRT
Sep 15, 2022
Post comments count 0
Post likes count 4

Serializing asynchronous operations in C++/WinRT

Raymond Chen
Raymond Chen

Making them run one after the other.

Creating a lazy-start C++/WinRT coroutine from an eager-start one, part 2
Sep 14, 2022
Post comments count 0
Post likes count 3

Creating a lazy-start C++/WinRT coroutine from an eager-start one, part 2

Raymond Chen
Raymond Chen

Keeping a turkey in suspense.

Creating a manual-start C++/WinRT coroutine from an eager-start one, part 1
Sep 13, 2022
Post comments count 0
Post likes count 3

Creating a manual-start C++/WinRT coroutine from an eager-start one, part 1

Raymond Chen
Raymond Chen

Ready, wait for it.

Serializing asynchronous operations in C#
Sep 12, 2022
Post comments count 5
Post likes count 0

Serializing asynchronous operations in C#

Raymond Chen
Raymond Chen

Making them run one after the other.

The case of the APC that never arrives
Sep 9, 2022
Post comments count 18
Post likes count 3

The case of the APC that never arrives

Raymond Chen
Raymond Chen

Or maybe it did?

How do I consume raw COM interfaces from a Windows Runtime metadata file?
Sep 8, 2022
Post comments count 7
Post likes count 3

How do I consume raw COM interfaces from a Windows Runtime metadata file?

Raymond Chen
Raymond Chen

There's a handy tool for generating raw COM interfaces.

It rather involved being on the other side of this airtight hatchway: Replacing a service binary
Sep 7, 2022
Post comments count 2
Post likes count 1

It rather involved being on the other side of this airtight hatchway: Replacing a service binary

Raymond Chen
Raymond Chen

Looking for misconfigured services.

Commonly-supported Windows shortcuts for pasting without formatting
Sep 6, 2022
Post comments count 21
Post likes count 7

Commonly-supported Windows shortcuts for pasting without formatting

Raymond Chen
Raymond Chen

Variations on a paste theme.

Is there any meaningful way to compare two Time Travel Debugging positions?
Sep 5, 2022
Post comments count 1
Post likes count 1

Is there any meaningful way to compare two Time Travel Debugging positions?

Raymond Chen
Raymond Chen

They are basically in chronological order, subject to the uncertainty of multiprocessing.

The case of the recursively-acquired non-recursive lock, and how to avoid the unintentional reentrancy
Sep 2, 2022
Post comments count 7
Post likes count 4

The case of the recursively-acquired non-recursive lock, and how to avoid the unintentional reentrancy

Raymond Chen
Raymond Chen

Watch what you do when you hold a lock.

Why am I getting a null pointer crash when trying to call a method on my C++/WinRT object?
Sep 1, 2022
Post comments count 2
Post likes count 2

Why am I getting a null pointer crash when trying to call a method on my C++/WinRT object?

Raymond Chen
Raymond Chen

Requirements weren't met.

The x86-64 processor (aka amd64, x64): Whirlwind tour
Aug 31, 2022
Post comments count 27
Post likes count 3

The x86-64 processor (aka amd64, x64): Whirlwind tour

Raymond Chen
Raymond Chen

Pretty much a 64-bit-ification of the i386.

The AArch64 processor (aka arm64), part 25: The ARM64EC ABI
Aug 30, 2022
Post comments count 0
Post likes count 2

The AArch64 processor (aka arm64), part 25: The ARM64EC ABI

Raymond Chen
Raymond Chen

Aligning with the x86-64 calling convention.

The AArch64 processor (aka arm64), part 24: Code walkthrough
Aug 29, 2022
Post comments count 1
Post likes count 0

The AArch64 processor (aka arm64), part 24: Code walkthrough

Raymond Chen
Raymond Chen

Putting theory into practice.

The AArch64 processor (aka arm64), part 23: Common patterns
Aug 26, 2022
Post comments count 1
Post likes count 0

The AArch64 processor (aka arm64), part 23: Common patterns

Raymond Chen
Raymond Chen

Learning to recognize various code generation patterns.

The AArch64 processor (aka arm64), part 22: Other kinds of classic prologues and epilogues
Aug 25, 2022
Post comments count 0
Post likes count 0

The AArch64 processor (aka arm64), part 22: Other kinds of classic prologues and epilogues

Raymond Chen
Raymond Chen

Taking shortcuts, or maybe adding steps.

The AArch64 processor (aka arm64), part 21: Classic function prologues and epilogues
Aug 24, 2022
Post comments count 3
Post likes count 1

The AArch64 processor (aka arm64), part 21: Classic function prologues and epilogues

Raymond Chen
Raymond Chen

Implementing the ABI.

The AArch64 processor (aka arm64), part 20: The classic calling convention
Aug 23, 2022
Post comments count 2
Post likes count 1

The AArch64 processor (aka arm64), part 20: The classic calling convention

Raymond Chen
Raymond Chen

How parameters are passed.

The AArch64 processor (aka arm64), part 19: Miscellaneous instructions
Aug 22, 2022
Post comments count 4
Post likes count 2

The AArch64 processor (aka arm64), part 19: Miscellaneous instructions

Raymond Chen
Raymond Chen

Sweeping up the crumbs.

The AArch64 processor (aka arm64), part 18: Return address protection
Aug 19, 2022
Post comments count 3
Post likes count 3

The AArch64 processor (aka arm64), part 18: Return address protection

Raymond Chen
Raymond Chen

Making it even harder to smash the return address.

The AArch64 processor (aka arm64), part 17: Manipulating flags
Aug 18, 2022
Post comments count 0
Post likes count 2

The AArch64 processor (aka arm64), part 17: Manipulating flags

Raymond Chen
Raymond Chen

Trying to twiddle the knobs directly.

The AArch64 processor (aka arm64), part 16: Conditional execution
Aug 17, 2022
Post comments count 2
Post likes count 2

The AArch64 processor (aka arm64), part 16: Conditional execution

Raymond Chen
Raymond Chen

Making decisions.

Janet Jackson had the power to crash laptop computers
Aug 16, 2022
Post comments count 24
Post likes count 30

Janet Jackson had the power to crash laptop computers

Raymond Chen
Raymond Chen

Not an artistic judgement. Just a technical one.

The AArch64 processor (aka arm64), part 15: Control transfer
Aug 15, 2022
Post comments count 0
Post likes count 4

The AArch64 processor (aka arm64), part 15: Control transfer

Raymond Chen
Raymond Chen

We're going places.

The AArch64 processor (aka arm64), part 14: Barriers
Aug 12, 2022
Post comments count 0
Post likes count 5

The AArch64 processor (aka arm64), part 14: Barriers

Raymond Chen
Raymond Chen

Keeping things in the right order.

The AArch64 processor (aka arm64), part 13: Atomic access
Aug 11, 2022
Post comments count 3
Post likes count 1

The AArch64 processor (aka arm64), part 13: Atomic access

Raymond Chen
Raymond Chen

Don't let someone else get a word in edgewise.

The AArch64 processor (aka arm64), part 12: Memory access and alignment
Aug 10, 2022
Post comments count 0
Post likes count 2

The AArch64 processor (aka arm64), part 12: Memory access and alignment

Raymond Chen
Raymond Chen

The load and store part of the load/store architecture.

The AArch64 processor (aka arm64), part 11: Loading addresses
Aug 9, 2022
Post comments count 0
Post likes count 1

The AArch64 processor (aka arm64), part 11: Loading addresses

Raymond Chen
Raymond Chen

Finding a needle in the haystack of the 64-bit address space.

The AArch64 processor (aka arm64), part 10: Loading constants
Aug 8, 2022
Post comments count 0
Post likes count 2

The AArch64 processor (aka arm64), part 10: Loading constants

Raymond Chen
Raymond Chen

Getting them into a register.

The AArch64 processor (aka arm64), part 9: Sign and zero extension
Aug 5, 2022
Post comments count 0
Post likes count 1

The AArch64 processor (aka arm64), part 9: Sign and zero extension

Raymond Chen
Raymond Chen

Nothing new here, but old things being used in clever ways.

The AArch64 processor (aka arm64), part 8: Bit shifting and rotation
Aug 4, 2022
Post comments count 4
Post likes count 3

The AArch64 processor (aka arm64), part 8: Bit shifting and rotation

Raymond Chen
Raymond Chen

Sliding around.

The AArch64 processor (aka arm64), part 7: Bitfield manipulation
Aug 3, 2022
Post comments count 0
Post likes count 3

The AArch64 processor (aka arm64), part 7: Bitfield manipulation

Raymond Chen
Raymond Chen

Peeking inside the words.

The AArch64 processor (aka arm64), part 6: Bitwise operations
Aug 2, 2022
Post comments count 0
Post likes count 1

The AArch64 processor (aka arm64), part 6: Bitwise operations

Raymond Chen
Raymond Chen

And their very strange immediates.

The AArch64 processor (aka arm64), part 5: Multiplication and division
Aug 1, 2022
Post comments count 1
Post likes count 1

The AArch64 processor (aka arm64), part 5: Multiplication and division

Raymond Chen
Raymond Chen

Arithmetic gets harder.

The AArch64 processor (aka arm64), part 4: Addition and subtraction
Jul 29, 2022
Post comments count 0
Post likes count 1

The AArch64 processor (aka arm64), part 4: Addition and subtraction

Raymond Chen
Raymond Chen

Starting with the basic arithmetic.

The AArch64 processor (aka arm64), part 3: Addressing modes
Jul 28, 2022
Post comments count 0
Post likes count 4

The AArch64 processor (aka arm64), part 3: Addressing modes

Raymond Chen
Raymond Chen

The ways of accessing memory.

The AArch64 processor (aka arm64), part 2: Extended register operations
Jul 27, 2022
Post comments count 3
Post likes count 2

The AArch64 processor (aka arm64), part 2: Extended register operations

Raymond Chen
Raymond Chen

The weird ways of transforming the value in a register.

The AArch64 processor (aka arm64), part 1: Introduction
Jul 26, 2022
Post comments count 4
Post likes count 9

The AArch64 processor (aka arm64), part 1: Introduction

Raymond Chen
Raymond Chen

Make it a double.

Yes, the 8086 wanted to be mechanically translatable from the 8080, but why not add the ability to indirect through AX, CX and DX?
Jul 25, 2022
Post comments count 6
Post likes count 3

Yes, the 8086 wanted to be mechanically translatable from the 8080, but why not add the ability to indirect through AX, CX and DX?

Raymond Chen
Raymond Chen

So many addressing modes, so little space.

Using C++/WinRT’s <CODE>final_release</CODE> to control which thread destructs your object
Jul 22, 2022
Post comments count 2
Post likes count 2

Using C++/WinRT’s <CODE>final_release</CODE> to control which thread destructs your object

Raymond Chen
Raymond Chen

Once it's yours, you can take it wherever you like.

Making sure that people use <CODE>make_unique</CODE> and <CODE>make_shared</CODE> to make your object
Jul 21, 2022
Post comments count 3
Post likes count 3

Making sure that people use <CODE>make_unique</CODE> and <CODE>make_shared</CODE> to make your object

Raymond Chen
Raymond Chen

Using a secret signal in what is required to be a public constructor.

My class derives from <CODE>std::enable_<WBR>shared_<WBR>from_<WBR>this</CODE>, but <CODE>shared_<WBR>from_<WBR>this()</CODE> doesn’t work
Jul 20, 2022
Post comments count 0
Post likes count 2

My class derives from <CODE>std::enable_<WBR>shared_<WBR>from_<WBR>this</CODE>, but <CODE>shared_<WBR>from_<WBR>this()</CODE> doesn’t work

Raymond Chen
Raymond Chen

Various cases where your enabled <CODE>shared_<WBR>from_<WBR>this</cODE> doesn't work.

Microspeak: The one-pager
Jul 19, 2022
Post comments count 4
Post likes count 2

Microspeak: The one-pager

Raymond Chen
Raymond Chen

Rarely ever one page long.

C++ coroutine gotcha: Falling off the end of a function-level catch
Jul 18, 2022
Post comments count 1
Post likes count 1

C++ coroutine gotcha: Falling off the end of a function-level catch

Raymond Chen
Raymond Chen

You still have to return something, but today's compilers don't warn you.

Processing a ValueSet or PropertySet even in the face of possible mutation, part 4
Jul 15, 2022
Post comments count 0
Post likes count 0

Processing a ValueSet or PropertySet even in the face of possible mutation, part 4

Raymond Chen
Raymond Chen

Processing the result differently.

Processing a ValueSet or PropertySet even in the face of possible mutation, part 3
Jul 14, 2022
Post comments count 0
Post likes count 1

Processing a ValueSet or PropertySet even in the face of possible mutation, part 3

Raymond Chen
Raymond Chen

Applying and adapting the pattern.

Processing a ValueSet or PropertySet even in the face of possible mutation, part 2
Jul 13, 2022
Post comments count 0
Post likes count 0

Processing a ValueSet or PropertySet even in the face of possible mutation, part 2

Raymond Chen
Raymond Chen

The first one there has to stay there until the work is done.

Processing a ValueSet or PropertySet even in the face of possible mutation, part 1
Jul 12, 2022
Post comments count 0
Post likes count 0

Processing a ValueSet or PropertySet even in the face of possible mutation, part 1

Raymond Chen
Raymond Chen

Watching out for iterator invalidation.

How can I provide a Windows Runtime ValueSet or PropertySet while non-intrusively monitoring changes to it?
Jul 11, 2022
Post comments count 0
Post likes count 0

How can I provide a Windows Runtime ValueSet or PropertySet while non-intrusively monitoring changes to it?

Raymond Chen
Raymond Chen

Use the right kind of observer.

Windows Runtime observable collections don’t mix well with multithreading
Jul 8, 2022
Post comments count 2
Post likes count 1

Windows Runtime observable collections don’t mix well with multithreading

Raymond Chen
Raymond Chen

Concurrent observation and mutation is a bit of a mess.

How can I write a coroutine that produces a result but keeps on running?
Jul 7, 2022
Post comments count 5
Post likes count 1

How can I write a coroutine that produces a result but keeps on running?

Raymond Chen
Raymond Chen

Returning without returning.

The empty Windows Runtime string is not just a pretty face
Jul 6, 2022
Post comments count 8
Post likes count 1

The empty Windows Runtime string is not just a pretty face

Raymond Chen
Raymond Chen

It really is an empty string.

How to write like Raymond: Intentional typographical errors, part 2
Jul 5, 2022
Post comments count 0
Post likes count 1

How to write like Raymond: Intentional typographical errors, part 2

Raymond Chen
Raymond Chen

I can take you there, but you'll have to fix one tiny typo. Let's see if you can do that.

The case of the constructor that was being ignored
Jul 4, 2022
Post comments count 0
Post likes count 1

The case of the constructor that was being ignored

Raymond Chen
Raymond Chen

Retracing the compiler's steps.

Under what conditions can I modify the memory that I received in the form a <CODE>STGMEDIUM</CODE>?
Jul 1, 2022
Post comments count 1
Post likes count 1

Under what conditions can I modify the memory that I received in the form a <CODE>STGMEDIUM</CODE>?

Raymond Chen
Raymond Chen

If you own it, then it's yours to do with as you wish.

2022 mid-year link clearance
Jun 30, 2022
Post comments count 5
Post likes count 1

2022 mid-year link clearance

Raymond Chen
Raymond Chen

Another accumulation of stuff.

How can I build a URL query string in the Windows Runtime?
Jun 30, 2022
Post comments count 1
Post likes count 1

How can I build a URL query string in the Windows Runtime?

Raymond Chen
Raymond Chen

Pretend you're submitting a form.

How can I parse URL query string in the Windows Runtime?
Jun 29, 2022
Post comments count 2
Post likes count 1

How can I parse URL query string in the Windows Runtime?

Raymond Chen
Raymond Chen

There's a query parser built in, but it's a little cantankerous.

Microspeak: Inside baseball
Jun 28, 2022
Post comments count 7
Post likes count 1

Microspeak: Inside baseball

Raymond Chen
Raymond Chen

Specialized jargon comprehensible only to a select few.

Starting on the other side of the airtight hatchway: Attacking the batch file parser
Jun 27, 2022
Post comments count 0
Post likes count 1

Starting on the other side of the airtight hatchway: Attacking the batch file parser

Raymond Chen
Raymond Chen

Why stop at denial of service when you have remote code execution?

The case of the mysterious over-release from deep inside the marshaling infrastructure
Jun 24, 2022
Post comments count 0
Post likes count 0

The case of the mysterious over-release from deep inside the marshaling infrastructure

Raymond Chen
Raymond Chen

The tedium of monitoring reference counts.

Writing a marshal-by-value marshaler, part 2
Jun 23, 2022
Post comments count 0
Post likes count 0

Writing a marshal-by-value marshaler, part 2

Raymond Chen
Raymond Chen

Maybe you don't need a copy on the other side.

Understanding the marshaling flags: The free-threaded marshaler
Jun 22, 2022
Post comments count 5
Post likes count 0

Understanding the marshaling flags: The free-threaded marshaler

Raymond Chen
Raymond Chen

Keeping your eye on the reference count.

Writing a compound marshaler
Jun 21, 2022
Post comments count 1
Post likes count 0

Writing a compound marshaler

Raymond Chen
Raymond Chen

On the nature of streams.

On the importance of managing the stream pointer when manipulating marshal data
Jun 20, 2022
Post comments count 0
Post likes count 0

On the importance of managing the stream pointer when manipulating marshal data

Raymond Chen
Raymond Chen

Making sure things are ready for the person who comes after you.

Writing a marshal-by-value marshaler, part 1
Jun 17, 2022
Post comments count 1
Post likes count 0

Writing a marshal-by-value marshaler, part 1

Raymond Chen
Raymond Chen

Creating an identical object on the other side.

The skeleton marshaler that does default marshaling
Jun 16, 2022
Post comments count 1
Post likes count 0

The skeleton marshaler that does default marshaling

Raymond Chen
Raymond Chen

Starting with a marshaler that has no special features.

An initial look at the mechanics of how COM marshaling is performed
Jun 15, 2022
Post comments count 4
Post likes count 0

An initial look at the mechanics of how COM marshaling is performed

Raymond Chen
Raymond Chen

Pretend you're an oracle.

What are the various usage patterns for manually-marshaled interfaces?
Jun 14, 2022
Post comments count 4
Post likes count 1

What are the various usage patterns for manually-marshaled interfaces?

Raymond Chen
Raymond Chen

The outermost simple layer, and the more complex inner layer.

Adventures in application compatibility: The case of the PC-relative indirect jump that reads from nowhere
Jun 13, 2022
Post comments count 10
Post likes count 2

Adventures in application compatibility: The case of the PC-relative indirect jump that reads from nowhere

Raymond Chen
Raymond Chen

A little too much copy/pasta.

How do I retrieve an extremely large range of cells from Excel if the clipboard functions all time out?
Jun 10, 2022
Post comments count 10
Post likes count 1

How do I retrieve an extremely large range of cells from Excel if the clipboard functions all time out?

Raymond Chen
Raymond Chen

Maybe you shouldn't be using the clipboard.

How can I wait more than 30 seconds for a delay-rendered clipboard format to become rendered?
Jun 9, 2022
Post comments count 6
Post likes count 1

How can I wait more than 30 seconds for a delay-rendered clipboard format to become rendered?

Raymond Chen
Raymond Chen

Provide your own delay.

Is there a maximum size for Windows clipboard data? Because I’m getting null for something I know should be there
Jun 8, 2022
Post comments count 7
Post likes count 4

Is there a maximum size for Windows clipboard data? Because I’m getting null for something I know should be there

Raymond Chen
Raymond Chen

There is no pre-set maximum size, but that null might be coming from somewhere else.

How to write like Raymond: Contacting another team for the first time
Jun 7, 2022
Post comments count 9
Post likes count 2

How to write like Raymond: Contacting another team for the first time

Raymond Chen
Raymond Chen

Flattery will get you in the door.

An opinionated comparison of C++ frameworks for consuming and implementing Windows Runtime types
Jun 6, 2022
Post comments count 11
Post likes count 1

An opinionated comparison of C++ frameworks for consuming and implementing Windows Runtime types

Raymond Chen
Raymond Chen

The three leading contenders.

Assessing a read-after free for security implications: The string comparison
Jun 3, 2022
Post comments count 11
Post likes count 1

Assessing a read-after free for security implications: The string comparison

Raymond Chen
Raymond Chen

Can you get elevation? What are you disclosing?