Category Archives: Win32

Reading Monitor Physical Dimensions, or: Getting the EDID, the Right Way

  Edit: an improvement is published in a separate post We recently needed to know the physical size of monitors on customer machines. Getting it right was a surprisingly tedious research – and definitely something that deserves more web presence … Continue reading

Posted in Win32 | 44 Comments

Breaking on Data Read

Edit: As of windows 10 the details and code below do not work. A working alternative is detailed at a newer post.   You’re probably familiar with Data Breakpoints, and rightfully so: It’s extremely useful to know where a value changes. … Continue reading

Posted in Debugging, VC++, Win32 | 6 Comments

g_dwLastErrorToBreakOn: Watching Errors on VS Revisited

Raymond Chen posted about SetLastError recently, and an interesting discussion ensued. One comment in particular caught my eye: The easiest way to catch a specific last error value in debugger is to set ntdll!g_dwLastErrorToBreakOn to that value. A good while … Continue reading

Posted in Debugging, Win32 | 3 Comments

AfxIsValidAddress (and Others) Don’t Work as Advertised

MFC exposes a some memory debugging facilities such as AfxIsValidAddress, which (for debug builds) supposedly – Tests any memory address to ensure that it is contained entirely within the program’s memory space. Or does it?   AfxIsValidAddress only delegates the call … Continue reading

Posted in MFC, Win32 | Leave a comment

Deleting Folders

RemoveDirectory requires the input folder to be empty. That typically requires repeatedly FileFind’ing the folder contents (either with the MFC wrapper or directly with the Win32 API) and DeleteFile‘ing. Things soon get interesting when you discover you need more code … Continue reading

Posted in Win32 | 4 Comments

Duplicate Volume Serial Numbers

We recently released a product version, with yearly licenses attached to the machine’s Volume Serial Number.  Now it is called a ‘serial number’, and it seems as meaningless and as random as a UID (mine is 34EE-10A0), so it must … Continue reading

Posted in Win32 | Leave a comment

Memory Fragmentation Trouble

We recently had some weird issues that turned out to emanate from a failure to allocate a large consecutive chunk of heap memory.  (It was an exceptional pain to nail the cause there – maybe more on that in a … Continue reading

Posted in Win32 | Leave a comment

EnumDisplayMonitors Troubles – NvCpl solutions.

Recently I had EnumDisplayMonitors presenting some strange behaviour, exposing 2 monitors when in fact only one was connected. The nVidia Control panel API eventually came to the rescue – it exposes the entire functionality available via the nVidia control panel, … Continue reading

Posted in Win32 | Leave a comment