Thursday, March 27, 2014

Inflating a bicycle tire with a potato

The inimitable Raymond Chen of Old New Thing fame once wrote a blog post about using inappropriate tools for the job. It came to my mind the other day when I needed to do a timestamp-based conditional in a batch file. The underlying cause was rather vanilla - file H is generated from file X, so if file X was modified later than H was, the batch needs to rebuild H.

Wednesday, March 26, 2014

SEH for fun and profit

PREAMBLE: this technique is no longer necessary. As of Visual Studio 2015 Update 2, one can mix C++ exceptions with SEH.

The built-in crash reporting of Windows Phone 8 sucks. It doesn't report registers, stack, what modules were loaded at crash time... Definitely not something you can debug from.

Friday, June 4, 2010

Not a real boy

Of all mobile software platforms, I have extensive development experience with three: Windows Mobile, BlackBerry and iPhone. For all three, there's a simulator for ease of debugging. And here's my expert opinion: the Microsoft Device Emulator is the best. The BB simulator does not support multiple debugging sessions in a row - if you change and recompile, you have to restart the simulator, and that takes a nontrivial amount of time. The iPhone simulator is not that bad, but it has considerable differences with the real device. Also, you cannot run arbitrary software on it - the simulator does not actually simulate the ARM CPU of a real iPhone, it runs compiled Intel code.

Microsoft Device Emulator, on the other hand, emulates ARM instruction set to a tee, supports debugger reconnection, and on top of that, approximates real device performance reasonably well. Hats off to MSFT. Apple Computer and RIM - you officially suck.

Monday, March 29, 2010

Bug-o-rama, encore...

Another day, another beautiful C++ bug. My program is a shareware Windows Mobile application. And it uses a unique device ID for the purposes of licensing and user identification.

Monday, November 23, 2009

Commentary

More from the exotic C++ bugs department:
Under GCC, the \ character at the end of a single-line comment extends the comment to the next line.

A similar behavior is well-known and oft-used for the preprocessor directives (#define etc.), but for the comments? No such behavior under MSVC; the code in question was ported from Windows, where it worked like a charm. And the worst part is, the IDE (Apple Xcode in my case) did not know about that either - the second, commented out line was not colored as one.

You learn something new every day.

Wednesday, January 14, 2009

Web-based...

Poor man's SSL:
Get yourself a JavaScript hash library and a JavaScript RSA library. Both exist.

For the logon page, use a hash-based challenge-response. Server generates the unique challenge, the page accepts the password in a form, on submission clears the password field, instead populates a hidden field with a hash of challenge and password (you can throw in a username and some client-based randomness, if you feel like it). The server calculates a hash with the same algorithm using the true password, matches the two hashes.

All fine and dandy, but the password has to get to the server somehow in the first place, right? That's where RSA comes in. For your user registration page, let the server generate a RSA key, cache the private key on the server, send the public key to the client. On submission, the page script would use the public key to encrypt the password, place the cyphertext into a hidden and clear the password field. The server code would retrieve the private key and decrypt.