No, I haven’t been hacked :) I’m just kicking it large with my current passion-du-jour, Playgate. I’m not going to post screenshots because it’s some of the worst coder art I’ve ever produced, but I’ve been fighting a running battle between two – what I am coming to realize are not quite compos mentis – installs of Visual Studio.
What works on my Vista and XP boxes at home arrives at the office with phantom menu bars and graphical displacements – but only on some dialogs. Bizzare experimentation began showing that elements of the corruption would transfer if I copied and pasted the content into a different file, or if I renumbered some of the IDs, etc, etc. I copied the dialog definitions from the resource file into a blank project only to find the order and particulars of the anomalies altered.
And before you suspect anything – up to this point there was no functionality or cleverness or funky stuff in the projects to leak memory, clobber stacks or anything.
No, that fun came later when I start using _stprintf_s without realizing that you have to remember to divide sizeof(foo) by sizeof(foo); and in Debug builds, Visual Studio helpfully shows you when you are exposing your stack to clobberation and curropterment by taking the destination buffer size and overwriting it with 0xEFs. If you gave it the wrong buffer size, you’ll see bad things happen even if your tests are just printing “Hello World” into a 256kb buffer.
So if you’re passing sizeof() to something that’s expecting an element count, you’ll discover it early. In theory. Instead what happens is insane behavior. During one phase, my application would block at a mutex and Windows would come crawling to a halt. I tracked this down to a mutex block inside a Window-message handler just at the right point in the process to block all Window-signaling.
And what brings all this on?
One of the Microsoft security changes is to prevent applications from writing to files in the “Program Files” folder — that prevents stuff from tinkering with your copy of WoW. But they also reorganized numerous other folders and not just the folders but the methods for querying the folders. Now, if you want to write files to disk from your application, the right place to do it us under the user’s Documents folder. Easy enough to ask Windows where that is from inside an application, but lets say you have an older installer application for installing your app: It has a pre-Vista set of variables and path concepts. Oh, that’s so not going to be good.
I’ve been trying to Vistify Playgate; Playgate was written in 1999 in raw Win32 because, at the time, Microsoft’s Foundation Classes (MFC) were still help in scepticism by many (C++ was looked at the way folks were more recently looking at C#: Poorly performing and tending towards a lot of proprietary interfaces).
So for the last couple of weeks I have been tortuously bashing my brains out against the Playgate code. The underlying application code isn’t so bad, but the interface code would draw tears of pity from Frankenstein’s monster. Playgate was supposed to be a lot more. It’s all that more that’s been the problem. In the last two weeks I’ve removed nearly 18,000 lines of code from Playgate down to it’s basic functionality — authenticate, patch and launch.
You’ve seen my .NET mockups, but unfortunately the call was for a non .NET version. Which mean’t falling back to MFC. In the quest to be able to write to a folder, I’ve had to turn to the technology Microsoft has just spent the last 3 years trying to phase out. It’s a sign of just how little love is lost over the passing of MFC that useful information on common problems has evaporated. You can spend hours searching Google for something as simple as “How do I load a bitmap from a file into a static control?”
Still, I’ve managed to Unicode it, integrate it into the game project (not into the game itself, its still a separate executable), make the interface user-friendly and left the door open for a proper art treatment, and the use of an embedded web browser will allow us to fall on HTML content for much of the app.
And that’s where I’m stuck at the moment: For some reason the embedded CExplorer2 browser keeps dissapearing. I guess one of my sprintf_s’s is still clobbering something. But, after pulling an all-nighter last night, I’ll be getting some rest this weekend, trying to get a little time in our game again, and cleaning my carpets with my new H2O mop.