Quantcast
Channel: The Old New Thing

C++ coroutines: The problem of the DispatcherQueue task that runs too soon,...

Last time, we made another attempt to fix a race condition in C++/WinRT’s resume_foreground(Dispatcher­Queue) function when it tries to resume execution on a dispatcher queue. We did this by having...

View Article


Controversial extension methods: CastTo and As

You’ve probably had to do this in C#. You get an object, you need to cast it to some type T and then fetch a property that is returned as an object, so you have to cast that to some other type U, so...

View Article


How do I make a clone of a Windows Runtime vector in C++/CX?

There are still some people maintaining code bases written in C++/CX, even though C++/WinRT is the new hotness. Suppose you have a reference to a Windows Runtime vector in C++/CX, either an...

View Article

2019 year-end link clearance: The different kinds of DLL planting

This time, the link clearance is just one link: Triaging a DLL planting vulnerability. That link summarizes various causes of alleged DLL planting vulnerabilities and how the Microsoft Security...

View Article

Nasty gotcha: Positioning your window beneath a topmost window makes it topmost

There’s a nasty gotcha with the Defer­Window­Pos function, and therefore any functions built on top of it, such as Set­Window­Pos: If you specify a hwndInsertAfter, and the insert-after window is...

View Article


Why doesn’t RegSetKeySecurity propagate inheritable ACEs, but SetSecurityInfo...

A customer was updating some code that manipulated registry key security. The old code used the Set­Security­Info function to update the security, and they observed that the function propagates...

View Article

Anybody who writes #pragma pack(1) may as well just wear a sign on their...

When you use #pragma pack(1), this changes the default structure packing to byte packing, removing all padding bytes normally inserted to preserve alignment. Consider these two structures: // no...

View Article

Image may be NSFW.
Clik here to view.

Tree-walking algorithms: Incrementally enumerating leaf nodes of an N-ary tree

Suppose you have an N-ary tree, in which the node operations are Get first child. Get next sibling. Get parent. For example, this type of tree structure may represent a window hierarchy. You also see...

View Article


Image may be NSFW.
Clik here to view.

Tree-walking algorithms: Incrementally performing a preorder walk of an N-ary...

We continue our exploration of algorithms for walking incrementally through an N-ary tree by perform a preorder walk through the tree. Recall that our goal is to follow the red arrows through the tree,...

View Article


Image may be NSFW.
Clik here to view.

Tree-walking algorithms: Incrementally performing a postorder walk of an...

We continue our exploration of algorithms for walking incrementally through an N-ary tree by perform a postorder walk through the tree. Recall that our goal is to follow the red arrows through the...

View Article


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>