Year: 2009

Setting a Visual Studio breakpoint on a Win32 API function in user32.dll

I recently had a problem with my Windows application causing the desktop icons to flicker.  I knew that the LockWindowUpdate API could cause that, but I also knew I didn’t use it.  Maybe one of the libraries I use (MFC?) was doing it.

So I wanted to set a Visual Studio breakpoint on that API’s location.  I tried
{,,user32.dll}_LockWindowUpdate@4 but that didn’t work.  I knew that {,,user32.dll}_SendMessageA@16 works for setting a breakpoint on SendMessage (which is also in user32.dll), so why doesn’t the same thing work for LockWindowUpdate?

It turns out that the function is called NtUserLockWindowUpdate as far as the debugger is concerned, so you need to use {,,user32.dll}_NtUserLockWindowUpdate@4

I don’t know which other APIs have that NtUser prefix, but I bet there are some.

Interestingly, the exported symbol as reported by Dependency Walker is called LockWindowUpdate – it’s only in the debug symbols that it’s NtUserLockWindowUpdate.  I used Dependency Walker to find the symbol’s address: my breakpoint for SendMessage was at 7D94B5BA and Dependency Walker told me that its export address was 1b5ba.  LockWindowUpdate was exported at 27d5c, so a quick bit of maths pointed me to 7D957D5C, and hence the real name of the function:

NtUserLockWindowUpdate

(By the way, Raymond Chen’s series of posts on LockWindowUpdate are required reading for anyone thinking of using it: What does LockWindowUpdate do?)

10 comments

Announcing Entrian Source Search 1.2.3

I’m pleased to announce the release of Entrian Source Search 1.2.3, with the following bugfixes and enhancements:

  • Enabling “Match case” no longer breaks mixed case filename / directory / extension filters, eg. someword dir:MyDir.
  • Right-click / ‘Open Windows Explorer’ now opens a full Explorer window with a folder tree down the left, and also selects the file in the files list.
  • Exclusion filters like -ext:csproj now work anywhere in a query, rather than just at the beginning (thanks, Ivan).

Download from the usual place.

Entrian Source Search 1.2.2 is now available

1.2.2 comes with these enhancements:

  • Search results for .rc, .rc2 and .manifest files are now syntax highlighted.
  • Hits in files with very long lines (many thousands of characters) now display properly in the search results.
  • The “Share another solution’s index” menu now puts the solution for which an index was created above those that are sharing it (thanks, Dan).
  • If you have two Visual Studios running when your trial period expires, and you buy a license key and paste the key into one of them, the other will automatically pick up the new key (thanks, Andrew).
  • When an unquoted phrase ends with punctuation then an asterisk, eg. ClassName::*, Source Search no longer searches for a literal asterisk but instead does what you almost certainly meant.  You need to double-quote the phrase to really search for asterisks.  (Thanks, Dan.)
  • Fixed a bug whereby Source Search could crash if another process had an exclusive lock on a directory that Source Search wanted to index (thanks, Sebastian).
  • Fixed a bug when trying to connect to a deleted index (thanks, Dan).
  • Fixed a bug whereby a file could be added to the index twice, and cause a crash when it appeared in the search results (thanks, Dan).
  • Multi-megabyte source files no longer take huge amounts of RAM to index (thanks, Roel).
  • Source Search now copes better if your PC runs out of disk space.

Download from the usual place.

Spell checking entrian.com with Spellr.us

I recently noticed a spelling mistake in one of my blog postings.  Yikes!  For a committed spelling geek like me, that’s really really bad! How did it happen?  I blame GMail.  For a time, GMail was making my Firefox crash.  So I switched to IE for a bit, and IE’s <textarea> doesn’t have a built-in spell checker like Firefox does.  Good grief – for my last few blog postings I’d been un-spell-checked without knowing it.

So I needed an online spell checker, and quick.  Spellr.us came to my rescue.  It’s very easy to use, and does everything I wanted:

  • One-off on-demand checks
  • Regular scheduled checks
  • RSS feed of new spelling errors
  • Custom dictionaries, that you can populate from the list of unknown words on your site
  • The ability to exclude areas from spell checking (eg.  blog comments, though I reserve the right to correct your spelling anyway 🙂 )

And as an unexpected bonus, it will even show you your pages with the spelling errors highlighted – very nice indeed.

Update: At the time of writing, Spellr hadn’t announced their pricing.  They now have.  Their free plan scans 20 pages 5 times a month with no scheduling and no RSS.  Their cheapest monthly plan is $24 and scans 1,000 pages 10 times a month with no RSS.  To get what I’d consider a sensible minimal service, daily scans with RSS, you need to spend $47 a month.

Too rich for my blood.  This might be one of those vanishingly rare cases where a software developer looks at the price of something, says “I could do it cheaper myself”, and is actually right.

Announcing Entrian Source Search 1.2.1

I’m pleased to announce the release of Entrian Source Search 1.2.1, which includes these fixes and enhancements:

  • Files with a .h extension are now syntax highlighted as C++ rather than C.
  • Where you’d excluded a directory via More / Options, files from that directory could still be included in the index if they were changed while Visual Studio was running.  They now stay excluded.
  • The “Entrian Source Search needs a saved solution” dialog that popped up when you created a new solution has gone away.  It was more annoying than useful.

1.2.1 is available from the Download page.

Announcing Entrian Source Search 1.2

I’m pleased to announce Entrian Source Search version 1.2, with the following fixes:

  • Right-clicking on messages like ‘No hits’ no longer causes a crash (thanks, Adam).
  • Versions prior to 1.2 could set up the keyboard shortcuts incorrectly; 1.2 fixes the problem and will also repair broken keyboard shortcuts created by prior versions (thanks, Roel).
  • It no longer optimises the index as often as it used to.
  • For some users, prior versions wouldn’t remember the docking state of the tool window.  Now fixed (thanks, Ivan).

Download from the usual place.