February 2007

MapPoint and the Dreaded Incorrect Parameter

I’m working on an application to map data in Microsoft MapPoint and ran into a very generic COM subsystem error message of “The parameter is incorrect”. This beautifully nondescript error message seems to be a big thorn in the side of MapPoint developers everywhere, including myself. The function I was trying to use was DisplayDataMap, which is the only API call that MapPoint exposes to map imported data. I was calling this function from within a C++ application, and no matter what I tried, I always seemed to get the error message when mapping data using the geoDataMapTypeMultipleSymbol map type. This error message doesn’t indicate which parameter is incorrect, which made troubleshooting it that much more frustrating, since the function has 13 (ironic?) different parameters.

I’ve been working with Eric Frost of mp2kmag fame over the last few weeks, and he was able to supply me with a C# snippit of code that worked. I trimmed it down to the bare essentials and figured out the main parameter that I was having problems with was ArrayOfCustomValues. This seemed to be rather straight forward in that I just needed to pass in an array of numbers. But Eric’s code was a bit different.

object[] customValues = { 1, 2, 3, 4, 5 };

The array was defined as an object array, not an int or long array as I would have expected. Sure enough, changing the declaration to the following caused MapPoint to throw the error.

long[] customValues = { 1, 2, 3, 4, 5 };

So now that I knew what caused the error message I was seeing, I went about figuring out how to fix it in the Visual C++ world. Variants and variant arrays (safearrays) are a crude beast to get your mind around, and there are quite a few code samples scattered across the internet that deal with them. When it came right down to it, the difference between these two code segments lies in how the .Net framework packages up the values to pass as a variant parameter. The long array is packaged up as a variant safearray containing type VT_I4, whereas the object array is packaged up as a variant safearray of variants, with each variant set to a type VT_I4. This additional level of indirection makes all the difference in the world.

I changed my code to create the array of type VT_VARIANT instead of VT_I4, then added variant records containing the values to the array, and MapPoint happily plotted the data as expected.

Technology

Comments (0)

Permalink

Getting Stepped on By DRM

I’m not a DRM fan. I never have been. I’m all for artists getting paid for what they do, but enough is enough. I’ve never purchased music online, and will not until I can buy DRM-free versions. I haven’t even bought a music CD in over 5 years because of the DRM on newer CD’s. Yes Sony, I’m talking to you. I’m boycotting the purchase of music because of DRM.

A couple of years ago I wanted to buy the definitive MAPI reference guide, InsideMAPI. As it was out of print at the time, the book and examples were conveniently available in electronic form from www.insidemapi.com. After about 3 or 4 weeks with nary a response to my order and credit card charge, I sent the author an email, and got a response a couple of days later stating that it had shipped about the time I sent my email. No problem, he missed the order, and got it shipped out to me when he realized the mistake. I’m cool with that.

A week or so later and I received a CD. Great!

The CD contained an installer, and running it installed a bunch of files to my hard drive (samples mostly), and a copy of Adobe Acrobat Reader 4.0. Huh? Yes, that’s right. Acrobat Reader 4.0. I already had Acrobat Reader 7.0 installed, so I figured I’d just deinstall 4.0 later.

Sadly, things went downhill from there. The PDF book is an encrypted PDF (which I expected) but it used a third party plugin to Adobe Acrobat 4.0 for the decryption. This little plugin is called IMPlugin.api. This great little security feature doesn’t work in Acrobat 7.0 at all. Opening the PDF in Acrobat 7.0 causes a message to appear that Acrobat isn’t installed correctly or is missing some features (the plugin) and I should reinstall.

It didn’t occur to me until yesterday that Acrobat Reader 8.0 is out now and I still need to use a version of Acrobat with a version number half the current version to read a damn book. Welcome to the wonderful world of DRM. The people who come up with DRM assume that I have no moral values, and should be treated like a criminal. I spent a whole three days with a debugger attached to Acrobat Reader 4.0 figuring out exactly what the plugin does and how it works. It also scans every drive on the system looking for the original CD, so I can’t even read the book on my laptop that doesn’t have a CD drive. I spent the better part of 4 hours yesterday being a criminal. I disassembled the plugin. I dumped the Acrobat 4.0 process memory. I tried printing to a new PDF. I hex-edited the PDF. I won.

I now have a PDF that is just slightly smaller than the original PDF, but has absolutely zero DRM attached to it. It works in Acrobat Reader 7.0. It works in Acrobat Reader 8.0. I’m sure it will work in many future versions to come. The only thing I lost were the original bookmarks, but since the PDF is searchable, I just don’t care.

To the DMCA lawyers, I’m sorry I had to break the law to read a book I paid for it legitimately. When you figure out a way to verify my licenses for content without restricting how I use that content, I’ll be ready with my credit card.

Technology

Comments (0)

Permalink

Machine Learning and Meta-Meta-Data

I read a recent post on slashdot talking about machine learning and some new ideas coming out of MIT and it got me thinking. Since I’m a programmer, I’ve always been fascinated by how well my children learn by experience, training, categorization, and classification of all of their available input to produce (mostly) sensible output. I have two wonderful children and watching them grow is the ultimate first-hand experience for a programmer to see the baby bootstrap.

Here’s a simple example: One night my daughter woke up crying. I asked her what the problem was and she couldn’t really give me an answer. Just some babbling and more crying. Since it was 2 in the morning and my programmer brain was just nodding off, I figured that A) she had some kind of dream and her brain didn’t really know what to do with it and B) she couldn’t focus on what I was asking her because of A. All it took to fix the problem was a simple processor interrupt. I just carried her into the bathroom, sat her on the toilet and said “go potty”. Since that was something we had practiced many times, it was very easy for her to focus on that instead of the problem at hand, and the crying instantly stopped. (Parents take note, beatings and yelling only get you so far…) As a programmer, I found that little trick worked perfectly well.

So back to the learning thing… The brain doesn’t come pre-wired. It doesn’t come with a blueprint, and it sure doesn’t come with a users-manual. So how in the world does it come up with a superb sensory storage system that doesn’t cook itself given all of the input we experience on a daily basis? A common buzzword in this synergy-infected business world is “thinking outside the box”. Typically this means taking a step back and re-evaluating the problem. In the database world, we had data, we stepped back and came up with metadata to fit the data into. It worked, and worked surprisingly well. All of the techniques that I’ve seen from MIT and Caltech and every other AI research group out there are focused on how to categorize the data. They start with some data, then they find these wonderfully sophisticated algorithms to pour through hundreds of thousands of samples and produce some very good output, but the framework is very rigid.

Brain cells die. New brain cells are created. The brain re-wires itself constantly. You just can’t cram that rigid square-peg-algorithm into a dynamic round-hole-environment. It won’t work. We need to take another step backwards. Call it a meta-meta-data if you’d like. Call it dynamic metadata. I don’t care what you call it, just call it something.

Instead of toiling over algorithms and data structures, come up with a simple genetic sequence of virtual parallel computer instructions. The Cell processor from IBM is a good starting point. Each SPE has a fixed instruction set. Use that. Now write some code that randomly scrambles and reassembles generations of genetic code and run it through fitness trials (i.e. real life situations), but don’t train the model based on example input and yes/no output – train the model on example input and “classification methodologies”. We train our children how to organize by color, size, shape, feel, etc. Train the genetic model that a picture of a car can be a “red car”, a “big car”, a “race car”, whatever. Let the model decide how to store that data. Let the model decide where to store that data.

Then give the model a toddler to learn with. They might just be able to teach each other something.

Technology

Comments (0)

Permalink

Unlocking my Blackberry Pearl

I decided to see how hard it would be to get T-Mobile to unlock my shiny new Blackberry Pearl. I figured since I might need to travel outside the country, popping a cheap long-distance SIM card into the phone would be a nice feature to have. I called the tech support department at 611 from my phone. I got to a tech within just a minute or two, and they had me enter *#06# and read them my SIM (IMEI) number. He asked if it would be ok to send the unlock instructions to my email address, which I agreed to.

The next day, I had an email from an “ARSystem Notify” with a 16 digit unlock code and the following instructions:

  1. Press the Menu key
  2. Scroll to Options and press the trackball
  3. Scroll to Advanced Options and press the trackball
  4. Scroll to SIM Card and press the trackball
  5. Type MEPPD
  6. Press the Alt key and type MEPP2
  7. Enter the unlock code
  8. Press the Enter Key

I followed these instructions to the letter and the phone was unlocked shortly thereafter. No fuss, no problems, nothing.

T-Mobile, you guys rock. I had been a Cingular customer for years and their customer service was mediocre at best. Ever since I switched in November, I’ve had nothing but excellent customer service from your Blackberry support people.

Technology

Comments (3)

Permalink