Tuesday, 1 November 2005

How media companies root your system

…and why you shouldn’t insert an audio CD into your computer if you’re running as an administrator: what Mark Russinovich found on one of his systems.

(If you’re not running as an administrator you, or software running on your behalf, cannot install a driver).

Tuesday, 11 October 2005

MetaBlog: CAPTCHA enabled

Over the last week or so, comment spammers have found this blog. I’ve therefore turned on Blogger’s only security feature, word-recognition (sometimes known as CAPTCHA). It’s probably not enough to fool a determined comment spammer but I hope it will reduce it a bit.

I’ve also enabled ‘backlinks’ which I hope are just a Blogger name for referrers or some such.

Saturday, 1 October 2005

Project Gotham Racing 3 videos

Some shakycam footage of a presentation of Project Gotham Racing 3.

Xbox360 News has six videos. They link to another which is still downloading as I write this.

I have to admit that graphically, it’s very, very good. There’s no substitute for actually playing it though. Looking at these videos does make me think that the game may well actually be ready for launch day – for an idea of software manufacturing schedules, note that Visual Studio 2005 is due to RTM on 14 October with physical product supposedly available on 7 November. In both cases the manuals and boxes can be pre-prepared, with only the DVD duplication required. Bizarre Creations still have probably a month to fine-tune the game.

There’s something worrying me. In the first video (actually the fifth link, named ‘pgr3gp1.wmv’) the menu has ‘Buy A New Car’ and ‘Sell Car’. I’ve played many games where you have to earn money to buy new cars and they’re universally a pain – you can never, ever afford a decent car, and the sale price is a small fraction of what you paid to buy it. It doesn’t look like PGR3 will have ‘repair’ requirements though, where you have to pay to repair your car. This was one of the many, many things that made Sega GT (a freebie with my Xbox) completely annoying and unplayable (on the other hand, the other freebie game, Jet Set Radio Future, is one of my all-time favourites and one of the major reasons I bought the console).

I recall that PGR2 has ‘Kudos Tokens’ which you earn by gaining a level, which you do simply by earning Kudos (basically by racing well or doing tricks like sliding the back end out or doing donuts, although I hope that’s easier on the new game). You unlock cars by exchanging Kudos Tokens, and in PGR2 you can’t sell a pony that you’ve bought. Having said that in PGR2 it’s rare that you’ll buy a complete dud because the car stats are pretty accurate (indicating that the Porsche Cayenne Turbo is by far the best SUV for example). As long as you’re not penalised too heavily for making a bad car choice, I’m happy. PGR2 also had a test drive feature but I’ll confess I never used it! PGR3 is meant to have much more level car sets, so there isn’t one ‘right’ car to use for a section of the game.

Here’s hoping they skip the American Muscle section this time. Last time out you’d got used to the nice-handling-but-a-little-slow cars in the early stages of the game, only to suddenly encounter cars which accelerate fast but lurch all over the place, and have no brakes to speak of. These cars were uniformly awful, there was no good one in the bunch. Making it through this section was a tedious slog, and it was a definite relief when I finished that section and could move onto some cars which, you know, handled.

Sunday, 4 September 2005

What does the (VB.NET) ComClass attribute do?

A former colleague emailed me this week to ask about registering C# assemblies for COM Interop. He was convinced that you needed to do something special to advertise a COM object from C#, since we’d used the ComClass attribute in VB.NET. Also, Rockford Lhotka wrote (in July 2004):

“There are several COM interop features in VB that require much more work in C#. VB has the ComClass attribute and the CreateObject method for instance.”

I was able to assure him that for his scenario – late-bound use of an object – all you need to do is use regasm to register the assembly. That registers every public class in the assembly, except any that are marked [ComVisible(false)]. (A quick aside here – the registration time is longer the more public classes you have, so you should only make the classes you actually want to expose to COM public.)

But if regasm registers all public classes in an assembly, what is the ComClass attribute for? The documentation suggests it’s required but as we’ve just seen it isn’t, at least not for this scenario.

It’s a signal to the VB.NET compiler to do three things:

  • Emit an interface definition automatically generated from the methods and properties in the class – a so-called Class Interface.
  • Add this interface to the Implements list for the class (so the class appears to implement this interface).
  • Emit a <ClassInterface(ClassInterfaceType.None)> attribute to suppress auto-generation of a class interface.

That last one is interesting. The .NET Framework supports automatic generation of class interfaces at registration time using the ClassInterfaceAttribute attribute. That generated interface is either a dispatch-only or a dual interface depending on the type selected. So what’s the difference?

Let’s take a simple test:

Imports System.Runtime.InteropServices
<ComClass()> _
Public Class WithComClassAttribute
    Sub Test()
    End Sub
End Class
Public Class WithNoAttribute
    Sub Test()
    End Sub
End Class
<ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class WithClassInterfaceAttribute
    Sub Test()
    End Sub
End Class

First, let’s look at the generated code with the help of Reflector (in C# mode):

namespace VbComTlbTest
{
      [ClassInterface(2)]
      public class WithClassInterfaceAttribute
      {
            // Methods
            public WithClassInterfaceAttribute();
            public void Test();
      }
      [ClassInterface(0), ComClass]
      public class WithComClassAttribute : _WithComClassAttribute
      {
            // Methods
            public WithComClassAttribute();
            public void Test();
            // Nested Types
            public interface _WithComClassAttribute
            {
                  // Methods
                  [DispId(1)]
                  void Test();
            }
      }
      public class WithNoAttribute
      {
            // Methods
            public WithNoAttribute();
            public void Test();
      }
}

Notice that VB has generated the automatic class interface as a nested type, inside the class it belongs to.

To see the difference from a COM perspective, we need to look at the type library. Export it using tlbexp, then use OLE View from the Platform SDK (also supplied with VS.NET) to load the type library (File/View TypeLib).

I’m not going to post the entire type library IDL shown by OLE View, but note that not setting an attribute generates an empty class interface definition (equivalent to setting ClassInterfaceType.AutoDispatch), and that setting AutoDual generates a class interface containing all inherited methods, including ToString, Equals, GetHashCode and GetType from System.Object.

So to duplicate VB.NET’s behaviour with the ComClass attribute in C# – if you need to, bearing in mind that this really only applies to early-binding scenarios – you need to define an interface then implement that interface, and use ClassInterfaceType.None. This (declaring interfaces) is, of course, what you have to do in traditional C++.

Monday, 29 August 2005

Answering the mail - anatomy of a solution

I’m a bit slow in answering questions from the contact box. A couple of months ago, a commenter asked how the MC3000 application for New Look was implemented. Since we’re using this system as a case study it’s probably fair to post details if I don’t go into too much detail.

Actually I’m not sure where New Look’s name came up. I don’t think I’ve mentioned it here. It must have been some other forum.

As far as the MC3000 software goes, the main application is just Meteor Client. Meteor is our application server product which allows text-mode applications to be written using Windows-based desktop/server development tools – typically more rapidly than the equivalent handheld application. On this occasion, the four applications (Price Check, Stock Availability and the ancillary Menu and Head Office applications) were developed with Visual Basic .NET using a SQL Server 2000 data source. The total number of handhelds deployed is over 1200 I believe.

Meteor Client was originally written for Symbol’s Series 3000 DOS handhelds and the original/common code is written in C targetting a Symbol library called ADL and Symbol’s BiosXxx routines (wrappers around both the standard IBM PC BIOS interrupts and Symbol’s own BIOS features). It was ported to a Windows console application which is mainly used for development and testing although it has been used in deployment occasionally. It was also ported to PalmOS for the Symbol SPT 1700 and Monarch’s Pathfinder Ultra DOS device, although those ports are not currently maintained.

Meteor Client on Windows CE was originally targetted at Pocket PC-based devices such as the PPT 2700. I started the porting work about three years ago. Pocket PC devices don’t have console support and even if they did, the console would still – I think – have ended up with a certain amount of ‘furniture’ we didn’t want. Meteor Client is meant to be a locked-down application, no other applications can be used.

Without this console support, I had to provide all on-screen rendering. The only monospaced font I could rely on was Courier New, which I detest – it would be illegible at the screen sizes we need – and we needed the potential for custom font capabilities anyway. Therefore we use bitmapped fonts using bitmaps I drew, designed to use the maximum space available on the Pocket PC screen and others at two sizes, 8 rows by 20 columns (matching the PDT 3100) and 16 rows by 21 columns (matching the PDT 6800). Further fonts have been drawn to offer better displays on devices with different screen sizes – the MC3000 has a 320x320 screen which can all be used – and there are now 8 sizes ranging from a 9x9 pixel character cell up to a 15x39 pixel character.

The Windows CE port uses C++ for the Windows CE-specific code, and uses ATL for windowing support and a small amount of additional data structure support. MFC is overkill and I’d originally intended to do without it, but when it came to integrating barcode support I remembered that the code I’d written up to that point used bits of MFC since the new CE apps we were writing at that point were all written with MFC (the .NET Compact Framework wasn’t released until 2003). As part of the process to turn the port code into a separate library for porting DOS applications, I’ve eliminated this dependency.

Actually, the core of the porting library is really the keyboard buffer. Windows’ keyboard system requires that a window accept keyboard input messages. There’s a bit of a mismatch between the DOS behaviour, which made both scan code and character code available at the same time, and Windows, which generates a WM_CHAR message with the character code after the WM_KEYDOWN message with the virtual key code, but this wasn’t too hard to work around. Originally all the screen and keyboard code ran on the same thread as the application code, which meant that the screen didn’t update until you called either a keyboard wait function or a delay function, but I’ve recently – as part of the porting library effort – moved all the screen functions, and hence the keyboard functions, to their own thread. Cue some fairly complicated synchronisation code.

For barcode scanning I originally used a chunk of code that was, although slightly enhanced and made into a static library, some of the first code I wrote after graduating. Its main problem was that it only supported Symbol’s scanning APIs – it would run on a non-Symbol device but barcode scanning would be disabled. Over December to February 2002 we came up with a more abstract API that we call the Scanner Hardware Abstraction Layer, or ScanHAL for short. We now support Intermec and HHP’s APIs as well as Symbol’s, and have a package that can detect what device it’s running on and therefore install the right ScanHAL (there’s a null stub for devices with no scanner). This code is all C++ and, due to an error that was overlooked when building the first few versions, is tricky to use from C as all the entry point names are type-decorated (i.e. using the C++ linkage naming convention – we forgot to use ‘extern “C”’). We use this library, enhancing it as new features are required, in all our .NET Compact Framework applications too (if scanning is required). A colleague wrote the API and the initial version of the Symbol and Intermec HALs; I’ve enhanced both and wrote the HHP HAL, while Ian’s extended all the HALs at least once.

The New Look handheld software doesn’t just consist of Meteor Client though. There are a few other things too. Primary among them is support for firmware updates over-the-air (i.e. over the network). Symbol’s AirBEAM supports over-the-air upgrade but it doesn’t support scheduling an upgrade and for obvious reasons we didn’t want to push a firmware upgrade – which since they’re using the colour terminal is over 30MB – during work hours. Symbol do have a tool intended for making an update image on an SD card which we’ve adapted. Meteor Server pushes a notification of a new version to Meteor Client, which schedules the upgrade to occur at a random time within an administrator-specified time window. When that time occurs the updater program I wrote downloads the required files over HTTP (using the WinInet library), checks that the files downloaded correctly using the CRC32 algorithm, then runs our unpacker for Meteor Client and the other software, then Symbol’s updater. When the updater finishes successfully it cold boots the device which causes the new software to install. The install-after-cold-boot mechanism is another tool that’s evolved over my four years with the company – primarily my work.

To ensure that the update happens when the administrator wants it to, the device’s clock must be fairly accurate. Windows CE does supply a Simple Network Time Protocol client, but Symbol didn’t include that component in the MC3000 platform. We’d had trouble with its reliability on another device previously. I therefore wrote one myself, which took a couple of days – it’s less than 750 lines of C++ code (including blanks and comments) which includes converting from UTC to the local time zone since this part of Windows CE is often unreliable – it will tend not to take daylight saving into account, or do it twice. We therefore turn off the AutoDST setting in the registry – we update the clock every few hours anyway so being slightly wrong at the start and end of daylight saving doesn’t matter. It’s somewhat simplified code – the time is only computed to an accuracy of one second, which means no fixed point maths, and no roundtrip delay calculation is done. This provides plenty of accuracy for our purposes though.

The final part is the keyboard map. We do two things here: first, we map the two keys at the top of the MC3000’s keyboard which have, respectively, a green and a red surround so that they get key codes. The default keyboard map leaves them unmapped. These keys, being directly below the screen, are used as soft keys in the applications. Secondly, we found that since there’s no indicator light near the Alpha key, users could not tell when Alpha mode was active – we had a few support calls in the trial deployment asking why the handheld was simply beeping when any key was pressed, which was simply because Alpha was on. New Look use the 28–key keyboard. Style codes, colour codes and SKUs are all numeric, so there’s little need for alphabetic input, but the customer wanted to keep access to alphabetic characters for future applications. We therefore remap Alpha to a function key code and, in Meteor Client, toggle the on-screen keyboard when that key code is received.

That’s just the client side. This project, being the first to use multiple co-operating Meteor Servers to provide scale-out and failover capability, required some extensive work on the server side too.

Sunday, 14 August 2005

Aaarrgh!

In my last post I said Microsoft would be releasing some official information on a topic that had caused plenty of FUD on forums. They haven’t yet done so. This is kind of annoying. The guy I was talking to hasn’t responded to my query about where the statement would appear. So the world – or at least, that part of the world that discusses these things on forums – carries on consuming and spreading FUD.

Some parts of the Windows team reacted very quickly to the suggestion that Monad could allow the spread of viruses. This team needs a boot up the backside, IMO. Scoble, are you listening?

OK, enough beating about the bush – I asked about OpenGL, and specifically this topic. Now I come to re-read the topic, it’s clear – if the app asks for accelerated pixel formats, and there is an Installable Client Driver available, Windows Vista will switch off the desktop compositor while the ICD is in use. What effect this will actually have I don’t know – presumably it will temporarily revert to using software desktop rendering, i.e. directing each window to draw in turn, clipping the parts that are obscured, as Windows has done for about 18 years (Windows 1.0 only allowed tiled, not overlapping windows). And of course you’ll only notice this if you’re using a windowed OpenGL app – full-screen apps (like games) will no doubt want the desktop compositor turned off!

The stuff about taking a 50% performance hit is simply FUD, IMO. The presumption is that translating OpenGL calls to Direct3D calls is expensive, but I don’t really see that. Numerous sites have had posters claiming that OpenGL is a more performant API than D3D, but without a program released for both APIs with as much time spent on both implementations, benchmarked on a range of hardware to eliminate driver variability, there really is no way to tell. I think the basis for this is essentially iD fanboys – since iD use OpenGL for their Quake, Return to Castle Wolfenstein and Doom 3 engines, it must obviously be better, right? I honestly don’t know, except to say that the games I’ve played have always seemed ‘fast enough’ if my system’s been within recommended spec, whatever API was used.

Wednesday, 10 August 2005

If you want to know something, ask

Conspiracy theorists: if you want to know why Microsoft are doing something, try asking them.

I recently saw some information on forums that seemed wrong, so I did a bit of research and found a presentation that seemed to apply. Microsoft presenters normally put their email addresses on the cover, and this was no exception, so I emailed the presenter asking him to clarify a few points. I got a nice reply back which covered what I was after.

Yes, I know that’s very wooly. I asked if I could blog the conversation and he said no. However, there should be some official information appearing later today. When it does, I’ll update (if I remember).

When in doubt, ask. If they can’t say, they’ll normally say so.

Thursday, 4 August 2005

Where's the damn SDK?

As I’m sure you’ve already seen, Windows Vista beta 1 was released about a week ago. This means I’m thinking about resurrecting my Changes to Win32 API in Longhorn series. Except, I can’t yet – because the SDK hasn’t been released yet!

Some kind of developer preview this is…

(Yeah, OK, the WinFX SDK has been released. But I’m still something of an unreconstructed Win32 guy.)

Loving the new monitor

I finally decided I needed more desktop space: both computer desktop, and the real desktop my monitor sits on – and this computer sits under. So I decided it was time to replace my old faithful Iiyama VisionMaster Pro 400 17” CRT with a flat panel. I looked at a number of sites and picked the ViewSonic VP191b 19” panel. So I can now use 1280x1024 comfortably.

It took a little while to adjust it to how I like it – colours seemed a little washed out – and it’s very bright. For tips on adjusting your monitor, see Charles Poynton’s article on ‘Brightness’ and ‘Contrast’ controls.

It cost a lot – nearly £400 after VAT and delivery – but I reckon it’ll last. It’s got something to live up to – the Iiyama lasted seven years with me, and is still going strong.

Thursday, 14 July 2005

The Little Button That Could

Good story today on The Daily WTF.

The reason I posted this, though, was this fantastic comment: “It's like he tried to reinvent the wheel and some how came up with a Platypus or something.”

Tuesday, 21 June 2005

No2ID Flair

Following Ian's example, I've added the No2ID PledgeBank petition flair to this site. It looks like this:

Click here to sign the no2id pledge

The counter updates with the number of people who have signed up. Meta: I need to think about moving off Blogger. Republishing the whole site (e.g. when changing the template) takes an age.

Tuesday, 14 June 2005

Check your signatures and use precautions

I’ve had 24 copies of the I-Worm/Mytob.HI worm since 1am today. Either they’re sending to spam lists or there’s a lot of infections out there.

This one’s being sent with faked ‘From’ addresses, info@<domain>, admin@<domain>, service@<domain>, etc. Mostly the message is about account suspensions, password updates, etc. Don’t be fooled. Don’t open the attachments. 

Sunday, 12 June 2005

Mac & PC - will the performance comparisons end?

From Paul Thurrott: a link to Java Rants, “Will partnering with Intel give Apple a Mac faster than a PC?”

No.

Let me expand. The theory goes that the processor is laden down with years of backwards compatibility that costs performance – starting afresh with a special customised ‘x86’ with fewer instructions, without this backward compatibility, could improve performance. Apple’s ‘special’ x86s could then beat ‘regular’ x86s.

The trouble with this argument is that it’s bullshit.

The Pentium 4 does feature compatibility right back to the 8086. If the platform support is right, you can, it is believed, boot the original MS-DOS 1.0. But that doesn’t slow it down.

It’s correct that the core of the P4 is RISC-like, but only in the sense that the aim of RISC was to have very simple instructions that could be decoded by simple logic circuits which would execute on the core in one cycle. Modern ‘RISC’ processors are the same, effectively, as the core of the P4 – there are multiple execution units that can execute operations concurrently, in the same cycle. On the P4 there are two Arithmetic-Logic Units [ALUs] which can actually perform two operations per cycle – one on the first half of the cycle, the other on the second. The key is in how the instructions are decoded.

Simple x86 instructions are decoded pretty much as a true RISC processor would – using logic to directly decode an x86 instruction into a core-compatible micro-operation [µop]. The resulting trace goes in the trace cache – the P4 attempts to only decode a stream of instructions once, performing loops directly from translated instructions. Anything more difficult than this – say, indexed indirect memory loads with autoincrement – goes to a microcode ROM which contains a ‘program’ of µops to implement that x86 instruction. If the microcode program is greater than 4 µops in size, the execution core has to execute directly from the microcode ROM rather than the trace cache. I think that pretty much all of the clever out-of-order stuff is suppressed when this occurs. Hit a large instruction from ROM and the processor slows to a crawl.

Anyway, after that brief technical interlude, let me explain why removing backwards compatibility won’t speed up the processor. Because most of it’s implemented in the microcode ROM. I don’t know if you recall when the P4 first came out. A lot of commentators, running their tests on Windows 98, suggested that the P4 was actually slower clock-for-clock than the PIII. Guess why? Partly that code was optimised for the PIII which had different characteristics from the P4 – but also that Windows 98 still contained a lot of 16–bit code, which hit the microcode ROM.

If you don’t use the expensive instructions, you don’t incur any cost, particularly, for them being there. Presumably there’s a little more complexity in the decoder logic to determine that the instructions are in microcode.

People often make the same mistake with respect to Windows XP. They think that the existence of the DOS and Win16–compatible subsystems slows it down. Nope. That code lives in NTVDM.EXE and WOWEXEC.EXE, which aren’t even loaded unless they’re being used. I also need to be clear that the console window is not DOS. cmd.exe, the Command Prompt, is a 32–bit Windows application that uses the console subsystem. The difference between a console app and a Windows app is that a console app has a console created for it if its parent was not running in a console. What is a console? It’s a window which is created and updated by the CSRSS process. There’s some code in there to handle back-compat graphics but again this almost certainly isn’t loaded unless it’s being used. A lot of this has been ditched for Windows x64, but that’s because the processor doesn’t support virtual-8086 mode, necessary for this support, in so-called Long Mode (64–bit mode).

cmd.exe supports (I believe) all of the DOS command interpreter, command.com’s feature set, and extends it greatly. This, plus the command-line environment, leads a lot of people to be confused. Particularly when some of the system utilities, like more, exist as files named more.com. If you look with dumpbin or depends, you’ll see that more.com is in fact a Win32 console executable.

Speaking of x64, I note that Apple aren’t going straight for x64. Their Universal Binary Programming Guidelines [PDF, 1.5MB] talk about the 32–bit register set, not the 64–bit extended set. I expect that this decision is because the Pentium M with EM64T – codename ‘Merom’ – isn’t due out until late 2006.

This whole argument presupposes that Intel will make Mac-specific processors. I think that’s highly unlikely. Apple haven’t told us their motivations, leading to a lot of speculation. My view is that they are trying to both save money, by using a more commodity processor, and enable quicker access to newer technologies, by using more commodity chipsets (oh, and save money). It took them years to get AGP in Mac hardware, and it looked like taking even more years to get PCI Express. I don’t therefore expect Intel to produce ‘special’ processors for Apple – it’ll be stock parts or nothing.

Another reason for using stock parts is so that stock software tools can be used. Apple can mostly wave goodbye to maintaining their own compiler. It’s no accident that their guidelines state they’re using the System V i386 Application Binary Interface [PDF, 1.0MB], with only minor modifications. Of course, that means that to begin with, Apple will be using the very compiler – GCC – which they used to ‘prove’ that PowerPC G5s outperformed P4s, in that contentious set of benchmarks. Unless they’ve improved the optimiser, or learned how to use it properly, ‘PCs’ may well still outperform Macs.

One tiny area in which Macs may have a temporary advantage is in exception handling. Today, on 32–bit Windows, each use of an exception handler pushes a handler frame onto the stack, a cost incurred whether or not an exception actually occurs. I believe GCC uses a table-based scheme, which in general incurs that cost only when an exception occurs. However, Windows on x64 – indeed on every architecture other than 32–bit x86 – also uses a table-based scheme.

Saturday, 11 June 2005

Passing the word

Want to keep your right, as a UK citizen[*], to privacy? Sign up for the No2ID pledge here.

Via Ian.

[*]Not a subject, dammit. I do not recognise the Queen as my ruler. Rulers are things you draw straight lines with – she’s a bit bumpy for that.

Saturday, 28 May 2005

Watermark rendering bug in ListView

Or at least, in the ‘My Pictures’ folder in Windows XP Explorer. Try it yourself – ensure the watermark is enabled. Then right click and select ‘New Text Document’. Click to remove the rename highlight. Then select it again and press Shift+Del. Hit Yes.

If this reproduces on your computer, you’ll see something like this:

I guess the ListView code simply calls ScrollWindowEx to move any remaining lines up, but doesn’t take account of the watermark.

New technology plug: since Avalon is a stored graph system, it should handle this kind of thing for you. That is, you tell it what components make up your rendering – it renders the appropriate parts as required.

More Mobile Developer Shafting: Compact Framework 2.0 won't run on CE 4.x

I downloaded the Compact Framework 2.0 Redistributable yesterday as well, planning to do a little testing with one of our CF 1.0 apps. (I need to discover how to force using 2.0 if both are installed). In doing so I discovered that CF 2.0 only supports Pocket PC 2003 and Smartphone 2003, Windows CE 5.0 custom platforms, and Windows Mobile 5.0 (for Pocket PC and Smartphone).

That means that new devices, introduced this year, like Symbol’s MC3000 which runs a custom CE 4.2 platform, are not supported. Why aren’t Symbol using CE 5.0? Who knows. Maybe they didn’t want to revalidate all their components on the new OS yet.

Yesterday I was at the London Eye. They appear to use PPT 2800s with the optional trigger handle to scan the barcoded tickets. This device runs Pocket PC 2002.

Customers often want upgrades and/or new applications to run on existing hardware. We’d like to be able to use the newer tools to implement those upgrades or new applications. But we can’t, because those tools won’t run on the old hardware.

The full framework is compatible back to Windows 98. We can’t get three years’ worth of backwards compatibility in the mobile world.

.NET Framework 2.0 Compatibility

Brad Abrams: Take the .NET Framework 2.0 Compatibility Challenge.

I was at a slightly loose end yesterday afternoon, so I took advantage of that time to check that Meteor Server, and the price checking/stock availability application we wrote for a large deployment at a UK retailer, still work correctly under .NET Framework 2.0 Beta 2.

Meteor Server itself is mostly VB6 components – a server executable, an application-host component executable (ActiveX EXE in VB6 terminology), a few application-interface components which have strict binary-compatibility requirements – with a few bits of C++ where the VB6 environment really ran out of steam (TCP/IP printing, since TCP is a pain with the Winsock control, and a ‘callback’ component which replaces the use of minimum-delay timers). Applications are written as COM components. Recently – in the last couple of years – we’ve been writing new applications in VB.NET or C#. We’ve generally found that more productive than VB6. To do this we’ve built Primary Interop Assemblies [PIAs] for the application-interface components.

Meteor Server isn’t really .NET-aware. We do ship configuration files for the server and application-host executables, to force the latest version of the PIAs to be used. This allows older applications to run on a newer version of the server, without having to distribute the PIAs with each app, or all versions that have ever existed with Meteor itself. Remember that .NET binds to a specific version of an assembly, not to the most recently installed. We did try using Publisher Policy but had problems with it – sometimes the Framework would fail to load an application object, often crashing with an Access Violation in fusion.dll. Due to a misunderstanding in version numbers we had to ship multiple policy DLLs when using that scheme – one for every major.minor version of the PIAs we’d released.

Using explicit configuration reduces the frequency of this problem, but not to zero – we still occasionally see this in deployment, with Framework 1.1 SP1. It’s something of a heisenbug – it never happens when you’re looking for it. And a particular nightmare when dealing with VB6 code, because the VB6 debugger does not run your code as it will be run in deployment. Instead it hosts it in-process in the VB6 environment. You’re not even running the compiled code, I believe it translates the code to p-code and interprets that. While you can turn on PDB generation and debug with VS.NET or another native code debugger such as WinDbg, the generated PDBs are poor quality and don’t, for example, often include your local variables or globals properly.

Since it’s not really .NET-aware, the default behaviour of the Framework when loading into an unmanaged host applies – the most recent version of the Framework is loaded. We support loading alternate applications under application control in the newest versions of Meteor (I think the version currently available on our website is very out-of-date). The aforementioned price-checking application is actually implemented as four applications: a menu application which loads the others, the price-check application, the stock-availability application, and a head-office application which has testing features. This does mean that all applications will need to support the latest version of Framework, or the admin will need to tweak the config files to force all applications to bind to the older runtime.

Anyway, I’m pleased to report that there were no obvious problems using Framework 2.0 with any of these applications.

Thursday, 19 May 2005

StarCraft: Ghost

How long have we been waiting for Blizzard’s StarCraft: Ghost? I can’t recall – I think they first announced it in 2001.

This week at E3 Blizzard have published new trailers and gameplay movies. I can’t help thinking it might be too little too late. What blew us away three or four years ago now looks a bit, well, ordinary. Halo 2 seriously raised the bar.

What’s been taking so long? I don’t know, but it looks like Blizzard have ditched their original partner Nihilistic Software, bought up a console developer, and brought the game back in-house.

The question for Blizzard: can they release this game before the next generation of hardware arrives and they look completely stupid?

Tuesday, 17 May 2005

Xbox Backwards Compatibility

Xbox Backwards Compatibility

Now that it's been announced at E3, I can finally reveal that the Xbox 360 feature I work on is... Xbox backwards compatibility!

Yes, it's real. It's been fun to watch all the wild speculation over the past year or so as to whether the Xbox 360 would or wouldn't be backwards compatible. And all the wild ideas about how hard or easy it would be. It's clear that a lot of people have very little understanding of how these things work.

Were I forced to speculate, I’d expect some kind of JIT-compiler like the x86–on-Itanium IA32EL or the x86–on-Alpha FX!32 is involved. I can’t remember the old rule-of-thumb for emulation – was it that you should have a processor ten times as powerful as the emulated processor to reach parity? Of course that was for state-machine-based emulators, where essentially each instruction was executed in turn by emulating instruction fetch, decode, execute, retire.

Whether a particular Xbox game runs on Xbox 360 will depend on just how closely the assumed-JIT and its library emulate the original processor and, of course, GPU. Hopefully the fact that Jet Set Radio Future was a launch title and was bundled with some consoles (e.g. mine!) will be taken into consideration!

Monday, 16 May 2005

Dammit, more incompatibilities

From Windows Mobile Platform Migration FAQ for Developers:

Starting with Windows Mobile 5.0, only one instance of the installer (wceload.exe) can be running at a time on Pocket PC devices. This restriction has always been in place on Smartphone. As a result, CAB files that start other CAB files from a custom setup DLL may not work on Windows Mobile 5.0. The workaround for this is to have a small executable in the CAB that a custom setup.dll starts in its Install_Exit entry point. This executable can get a handle to the running wceload.exe process, wait for wceload.exe to exit, and then restart wceload.exe on the additional CABs.

We have a pretty clever (says he who wrote it) technique of packing multiple CABs into one wrapper CAB file, which enables us to install Compact Framework, SQL CE, our barcode scanner hardware abstraction layer (ScanHAL), our simple large-key input method, and the application itself, all in one go. Looks like I’ll need to rewrite it slightly at the install-to-RAM stage.