Showing archive results for 2014

Sep 5, 2014
Post comments count0
Post likes count1

You can use a file as a synchronization object, too

Raymond Chen

A customer was looking for a synchronization object that had the following properties: Can be placed in a memory-mapped file. Can be used by multiple processes simultaneously. Bonus if it can even be used by different machines simultaneously. Does not leak resources if the file is deleted. It turns out there is already a synchronization ob...

Code
Sep 4, 2014
Post comments count0
Post likes count1

Aha, I have found a flaw in the logic to detect whether my program is running on 64-bit Windows

Raymond Chen

Some time ago, I described how to detect programmatically whether you are running on 64-bit Windows, and one of the steps of the algorithm was "If you are a 64-bit program, then you are running on 64-bit Windows, because 32-bit Windows cannot run 64-bit programs." Every so often, somebody will claim that they found a flaw in this logic: "This alg...

Code
Sep 3, 2014
Post comments count0
Post likes count1

Why does the timestamp of a file increase by up to 2 seconds when I copy it to a USB thumb drive?

Raymond Chen

We saw some time ago that the FAT file system records timestamps in local time to only two-second resolution. This means that copying a file to a FAT-formatted device (typically a floppy drive or a USB thumb drive) can increase the timestamp by up two seconds. And even after the file is copied, the timestamp is not stable. The timestamp changes ...

Tips/Support
Aug 29, 2014
Post comments count0
Post likes count2

How can I detect that a user's SID has changed and recover their old data?

Raymond Chen

A customer maintained a database which recorded information per user. The information in the database is keyed by the user's SID. This works out great most of the time, but there are cases in which a user's SID can change. "Wait, I thought SIDs don't change." While it's true that SIDs don't change, it is also true that the SID associated with a u...

Code
Aug 28, 2014
Post comments count0
Post likes count2

Taking advantage of the fact that the handle returned when you create a kernel synchronization object has full access regardless of the actual ACL

Raymond Chen

A customer wanted some help deciding what security attributes to place on an event object intended to be used by multiple security contexts. We have two processes, call them A and B, running in different security contexts. I have an event that process A creates and shares with process B. The only thing process A does with the event is signal it,...

Code
Aug 27, 2014
Post comments count0
Post likes count1

Where does the Installed Updates control panel get the install date from?

Raymond Chen

A corporate customer wanted to know where the Installed Updates control panel gets the Installed On information from, because they found that the values were always set to the current date regardless of when the update was actually installed. The algorithm goes roughly like this: First, ask MSI what date the update was installed by calling and a...

Tips/Support
Aug 26, 2014
Post comments count0
Post likes count1

It's time we face reality, my friends: We're not rocket scientists

Raymond Chen

During the development of Windows 95, it was common for team members to pay visits to other teams to touch base and let them know what's been happening on the Windows 95 side of the project. It was during one of these informal visits that the one of my colleagues reported that he saw that one of the members of the partner team had a Ga...

History
Aug 25, 2014
Post comments count0
Post likes count1

How do I read the "Double-click to open an item (single-click to select)" setting in Folder Options?

Raymond Chen

Today's Little Program reports whether the Double-click to open an item (single-click to select) option is selected in the Folder Options dialog. A customer wanted to know how to do this, presumably so that their program would respect the setting and adjust its user interface to match. The flag and member name is kind of weird. The ability to s...

Code