Monthly Archives: November 2007

Creating IMG/IGZ Files for your own Ultimate Boot USB Key

4
Filed under Uncategorized

I’ve been doing a lot of experimenting lately with USB boot devices, Linux system and partition tools, etc.

MFSTools is certainly handy for working with TIVO drives

The Ultimate Boot CD is also quite handy for partitioning etc.

I’ve also been a long time user of SpinRite for testing disks, and it’s still going strong (although writing a pure assembly Windows App just seems like a little slice of hell to me).

In digging around the Ultimate Boot CD, though, I noticed that it uses a dynamic boot loader that essentially allows it to boot up images of boot disks. Most of the utilities included with the package are actually in the form of IGZ image files that the boot loader boots from a stripped down Linux Menu system.

It’s a pretty slick approach and it’s extensible too. You can actually create your own IGZ files, put them in place on the Ultimate Boot CD, add a few lines to the menu cfg files and reburn the CD. Then you can boot to basically any boot disk you want.

If you’re like me, you probably have an “emergency kit” of several CDs and floppies to resort to when things go bad. Many of my floppies are getting a bit long in the tooth, so I thought it might be a good idea to capture them as images, so that in case the floppy does fail, I could simply rewrite a new copy from the image.

But if I can boot directly from the image using the UBCD loader, well, even better. And if I get the UBCD moved to a bootable USB device? System recovery nirvana!

So, how to capture an image of a floppy?

There’s several commercial packages out there that sound like they’d do the job, including:

Of these, AllImage looked the most promising, but I really wasn’t wanting to spend money on something as trivial as this.

That led me to Windows DD.

This is a native Windows version of the Linux DD utility, which can do this job under linux.

To create an img of a floppy in Drive A, just use:

dd if=\\.\a: of=c:\temp\disk1.img bs=1440k

And to write the image back to a floppy:

dd if=c:\temp\disk1.img of=\\.\a: bs=1440k

The bs (block size) option is just a speed thing. You can leave it off and DD will work. It’ll just be a lot slower. If you’re creating an image of bigger disks (say, a CD), you might might use bs=1M (1 megabyte).

Pretty simply stuff. The only downside I’ve noticed so far is that it literally makes an image of the entire source drive, including sectors that don’t really contain data, but that do contain old data that’s been deleted. This has the effect of making the image MUCH bigger than it needs to be, and prevents it from compressing well. I’m not sure how to work around this yet.

For UBCD integration, however, what you really want is an IGZ file.

Turns out, an IGZ is just a GZIPed IMG file.

But Gzip is NOT WinZip. WinZip (and most other ZIP utilities) will read Gzip files, but you have to explicitly create a Gzip format file.

You can grab a copy of GZip for Windows here, or you can use the GUI-licious IZarc to do the heavy lifting. Just be sure to specify the TAR.GZIP format when compressing your image.

image

When it’s finished, rename the file *.IGZ (instead of the *.tar.gz) and you’re golden.

Final word of caution, DD can be a pretty nasty little bugger, as evidenced from the Anti-Examples on the DD Wikipedia page, but then, FORMAT can be nasty as well.

Just watch your typing, and you should be fine. But, if you doubt yourself, spend a few bucks and grab a copy of AllImage or WinImage.

Properly Manipulating the Selection in a Word Document

0
Filed under Uncategorized

The Word object model is an unbelievable rich hierarchy of objects devoted to letting you navigate just about every facet of a particularly complex chunk of data, namely a WYSIWYG document.

Still, there are right ways to use it and wrong. And when you do things wrong with Word, it usually doesn’t just erupt in a massive fireball. Instead, often, something seemingly completely unrelated will fail much farther on down the line, making for some thoroughly enjoyable debugging sessions.</sarcasm>

For instance. I’d been working on a Word Addin that processes the contents of a Word document. It does a pretty thorough job, so it basically hits just about every nook and cranny in the object model.

One technique I’d had to use involved selecting a field, and then pasting text over it, effectively replacing the field with plain text.

The code looked something like this:

fld.Select

Application.Selection.Copy

Application.Selection.PasteSpecial link:=False, DataType:=wdPasteMetafilePicture, Placement:=wdFloatOverText, DisplayAsIcon:=False


Basically, it SELECTed the field, then copied the selection, effectively converting the field to plain text.

And finally, it PASTEd the text back over the selection, wiping out the field with just the plain text content.

It may not be the ideal way to handle this, but other methods failed outright for a variety of reasons, and this technique worked quite nicely and consistently.

That is, until I added code (in a completely unrelated portion of the application), to enumerate all the bookmarks in the document and retrieve information on them.

When I did so, another loaded document  (i.e. not the current document I was working with) would have the contents of the clipboard pasted into its main body.

Needless to say, chasing down these two essentially unrelated pieces of code was no small chore.

But once I knew what was causing the problem, I needed to determine how to fix it.

The main problem was that the Word Document object doesn’t have a Selection property. Only the Application object does, which was global to all loaded documents, and was quite likely the source of the cross contamination.

However, a little digging turned up that the Document object contains an ActiveWindow property returning a Window object.

And the Window object does have a Selection property.

Changing the code to this solved the problem:

fld.Select

CurDoc.ActiveWindow.Selection.Copy

CurDoc.ActiveWindow.Selection.PasteSpecial link:=False, DataType:=wdPasteMetafilePicture, Placement:=wdFloatOverText, DisplayAsIcon:=False

The CurDoc object is the Document object I’m currently working with.

Essentially, instead of using the selection property of the Application object, I’m using the more specific one on the actual document I’m currently working on.

Under normal circumstances, the two approaches are identical, but, at least in this case, they aren’t.

Death of a Blog

2,490
Filed under Blogging, dasBlog

I’ve been offline for a few days. Yeah, it was Thanksgiving, yeah, I lost a drive in the raid of my main workstation. But the real nasty bit was when I went to post a new entry and Windows Live Writer merrily churned away with no errors, but when I went to check the entry on my site, no joy.

Eh?

imageWell, I didn’t have any time till tonight to check into it. A few Googles turned up this handy little label on the Live Writer Help-About screen.

Click it and you get a nice log file (that might be quite long since I don’t believe Live Writer ever trims it).

 

 

Down toward the end, I notice this:

 image

Doh.

I use www.ServerGrid.com for my webspace, so I browsed over to my control panel and it sure looked like I had 302mb used of 1000mb available. Hawuh? That should be plenty. Still, I have a hard time believing dasBlog would lie about an error like that.

Fortunately, ServerGrid has a live chat 24hrs a day. A quick chat with one of their support people, and I discover that just because they upped my space to 1gb, doesn’t mean they automatically up my quota.

Back to the control panel, sure enough, the quota is still set to 300mb.

Change it up and I’m back in business.

When a RAID comes in handy

0
Filed under Uncategorized

image I was having a nice, uneventful Thanksgiving, got up, brewed up a pot of joe, (no, my coffee maker isn’t set up to grind it and brew it all 30 minutes before I wake up like in those commercials, I guess I’m a Luddite that way), and sat down to do a little TIVO HME API research when I get this:

Arghhh.

I crack open the case, and start looking around when I realize:

  1. The hard drives in the system are so hot, I can’t even touch them for more than a second or so
  2. The fan that draws air through the HD rack is stopped, because the cables apparently shifted and are now touching it.

Which leads me to two conclusions (and topics for future blogs, I suppose).

  1. Be sure to cable tie cables together and down so you know that won’t go where they aren’t welcome.
  2. Get some kind of system temp/harddrive temp/fan monitoring alarm program that goes all obnoxious on you if something like this happens

So, I powered off everything, let it all cool down and tried to bring it back up.

No dice. The RAID controller just won’t recognize the one HD that failed.

So I disconnect it from the RAID and hook it up to a spare SATA port (this Intel D975XBX2 mobo has 8 freakin’ SATA ports).

Good news! It’s visible, but of course it’s not readable.

So I fire up SpinRite and let it churn on the drive to validate it. Everything appears OK.

But I load up Partition Magic to repartition and reformat the drive as just one big NTFS volume and I get “Invalid Boot Signature” errors.

Hmm. I tried Partition Commander. It seemed like it worked, but when it finished and I rebooted, the drive hadn’t changed at all. The format didn’t take. Chuck Partition Commander.

Then I tried the free Ranesh Partition Manager (from the Ultimate Boot CD). No joy either. I even tried several boot sector editor/restore utilities, but to no avail.

In the end, I ordered a replacement from Newegg.com for 70$, and I’m still fully operational, even though I quite literally toasted a drive.

I’m still wondering why I only lost one drive. I’m guessing it was a little weak to begin with and this just put it over the edge.

But the real question is, by how much has the life of the other 3 drives been shortened by this little escapade?

With Western Digital now shipping a 1TB drive for ~250$ (yeah, that’s 1 terabyte), I may end up replacing them all in less than a year anyway.

Ah Spam, Wherefore Art Thou Progenitors?

0
Filed under Uncategorized

Grrrr. Today, suddenly, I’m seeing a literal torrent of spam response messages flooding my gmail box.

It’s pretty easy to get the source IP of the original email, and a quick check here can tell you approximately where that IP is.

In this case, the originals seem to be coming from Vienna and Puerto Rico, but they all are using depdarinhigginsgin@darinhiggins.com as a return address, which obviously isn’t an address I’d even use.

Why, oh, why do people setup autoresponders for this nonsense?

After slapping myself to keep me from setting up an autoresponder of my own (“Why the hell are you sending me messages that say I’ve spammed you without bothering to check domains, etc”), I just setup a file 13 for that address. Hint, don’t ever try to send me email using depdarinhigginsgin@darinhiggins.com!

I guess that’s a downside of having your own domains.

Is there any better way to fight email reply-to forgery? This really isn’t fighting it, it’s just more effectively ignoring it<sigh>

Laptops, love’em or leave’em?

1
Filed under Uncategorized

image There’s an article at computerworld.com now about the 10 things we hate about laptops.

It’s a nice read and it just reinforces the feelings I’ve had for laptops ever since, well, since I first lugged one through an airport.

To me, they’re just a huge pain in the ass. Drop the files you need onto a portable HD (or even better, a USB key drive) and go. Seems like a much better solution.

I know, I know, there’s plenty of cases where that’s not practical or even possible, but for typical developers?

Sure, there are days when it’s sunny and 72 outside, and I’d love to be coding via wifi out by the pool. But then, I’m in Texas, so those days number about 5 per year. And writing code at the local Starbucks? Puh-lease. It makes for a good sitcom site gag, but does anybody actually code that way?

Anyone have any thoughts on the subject? Am I missing out on something I just don’t see?

Public Interfaces

0
Filed under Rants, Software Architecture, VB Feng Shui

image I’m guessing that the vast majority of VB apps (VB6, or .NET), have no public interface. After all, VB is the prototyping language, not an actual project development language, right? </sarcasm>

Well, if you do eventually find yourself in need of exposing a public interface from your application, what’s the right way to do it?

First, a definition, though.

By public interface, I’m talking about some manner of exposing functionality within your application to the outside world. What you do with your BAS files, and private CLS files, not to mention FRM’s, or the all-encompassing  VB.NET *.VB file is your own business. But what the world sees, or, more appropriately, has to deal with, is another matter altogether.

There’s a pile o’ ways to expose functionality from an app, especially a VB app.

First, a few old school methods….

  • DDE – Yeah, it’s still alive. Want proof? Just boot up a copy of Vista, load REGEDIT and search for DDEEXEC in the HKCR hive. But seriously, you don’t want to go there.
  • Windows Messages – SendMessage/PostMessage. They’re not just for subclassing and peeping toms. DDE and even COM relies on the Window Messaging subsystem to work. Your apps can leverage it too. But really, that’s a whole lot of pain for not a lot of gain, so why bother?
  • DLL Entry Points – There are several tools out there that make exposing DLL entry points from a VB application relatively easy to do. In some cases, this is how you have to expose functionality (as in when some other app only makes calls to DLL entry points, and you want that app to talk to yours). But using this technique to expose your own functionality to the world just seems so, well, reagan-omic.

And the more common techniques….

  • COM – The classic VB PUBLIC class. All you gotta do is change your class’s interface type to PUBLICNOTCREATABLE, MULTIUSE, or GLOBALMULTIUSE and biff boom pow! Anyone can use your class, right?
  • .NET Assemblies – Same as COM, but shinier

OK, COM (or .NET assemblies) it is (I’m going to consider the two the same for now, what sacrilege!)

So how do you do it?

There’s piles of books on the mechanics of the task, so I’m not going there. Just look at Kurata’s Doing Objects in Visual Basic 2005 or Dan Appleman’s various books on ActiveX techniques for those kinds of details.

What I’m talking about is which interface design is most appropriate.

Kinds of Interfaces

Generally, I’ve seen these designs gather into 3 camps:

  • The massive wad of hierarchically related objects. This is the Outlook, Word or Excel object models.
  • The single public class containing all the functions you could ever want. Not terribly common; I see it most is 3’rd party utility libraries.
  • And finally, the single class with a single (or at most very limited set of) functions that serve as a “command line” of sorts where you might pass in a parameter that is the “operation” and that additional parameters that are the “arguments for the operation”. The GroupWise API is a great example of this.

The Massive Hierarchical Wad

Pros

  • Easiest to program against. Intellisense, separate objects, etc speed working with your model.

Cons

  • Hardest to keep compatible. Even minor changes from one version to the next of your application can render it incompatible with previous versions of your application, causing loads of headaches for your users.

The Single Class

Pros

  • Relatively easy to program against. Intellisense will help. So does consistent naming of all those methods and properties.
  • Works well for relatively minor amounts of exposed functionality.

Cons

  • Generally considered bad practice.
  • Suffers from compatibility headaches much like the Massive Wad.

The Command Line Class

Pros

  • Essentially immune from direct interface compatibility issues, since the lone interface is flexible enough initially to never have to be changed.

Cons

  • More difficult to code against. Intellisense only helps with the command line function itself, not with each of the commands that can be sent.
  • Moves compatibility issues to the user. If new functions are introduced, it’s the users responsibility to test for the version of the application and react appropriately.

So, what’s the final word?

As usual, there’s really no right answer.

Personally, I tend to stay away from the “Single Class”, simply because it has all the difficulties associated with the Massive Wad, and none of the immunity of the Command Line Class; the worst of both worlds.

The Command Line Class is most useful when your exposed function points number in the 10-100’s. Any more than that, and it starts to become unwieldy, though it’s still perfectly workable.

The Massive Wad is the most traditional, most familiar style of public interface to those who’ve likely used public interfaces of other systems. That’s not to say it’s the best option, just that’s it’s the most typical.

How about it? What kinds of public interfaces have you built and put out there? Is there a style I’ve missed. Maybe something better than any of these?

Setting up a Shortcut to Connect to a Server Console Via Remote Administration

6
Filed under Uncategorized

image It’s pretty trivial to setup a shortcut to an RDP file to allow you to connect to a remote desktop session in Vista (or XP for that matter).

But I needed to remotely connect to the console session.

No big deal, I thought, so I started checking out all the various options available when you EDIT an RDP file.

Nothing there to let you connect to the console.

A quick Google turned up a KB article with the command line switches for mstsc, but it looks like it’s not possible to specify the /CONSOLE option inside the rdp file.

Rats.

Then I thought, why not just create a shortcut to mstsc directly, no RDP file at all.

I ended up with a shortcut using this command line

C:\Windows\System32\mstsc.exe /v:myserver /console /w:1024 /h:768

Just make sure your current user (on your desktop) is a member of Remote Desktop users (and possibly administrators, which I know, would be a “bad thing”).

 

 

image  At that point, just double clicking on the shortcut should drop you right on the console of the server (kicking anyone that was on the console off, BTW, which might be a problem in some environments<g>).

In the end, Remote Admin via Terminal Services still isn’t near as good as UltraVNC, but it does seem to work pretty good. If I had to admin a system that was really remote, I’d probably stick with VNC, but since my server is in the closet, about 10 feet away, Remote Admin is good enough.

Favorite FireFox Extensions

1
Filed under Uncategorized

I’ve seen a few “Best tools” lists over the years, but haven’t ever stumbled across a Best Tools for FireFox list.

So, in the grand tradition of probably reinventing the wheel, but not Googling about it first<g>….

Here’s my (quite short, but sweet), list of Favorite FireFox Extensions:

  • Theme: MacfoxIIGraphite 2.1.4
    OK technically not an extension, this theme really makes for a clean, uncluttered FireFox.
  • Tab Mix Pro 0.3.6
    What tabs in FireFox should have included from the start. Forcing popups to open in tabs is something I can’t do without now.
  • DownLoad Them All 0.9.9.10
    Ok, it’s technically not polite to snarf gobs of files from a site all at once. But, well, sometimes, rude is the word, I suppose.
  • IETab 1.3.3.20070528
    Essential if you want to stay away from opening IE but still need it for those nasty IE only sites (Parature, anyone).
  • DOM Inspector 1.8.1.9
    Quite handy for ripping into an existing webpage to see how it ticks.
  • FireBug 1.05
    Another handy little script debugger as well as CSS editor/debugger . I haven’t used it much to this point, but it seems to work quite well. Maybe there’s a better one someone can clue me in on?
  • Web Developer 1.1.4
    More CSS/DOM spelunking goodness

You can find them all by clicking Tools/Addons in FireFox and then click the Get Extensions link at the bottom right of that screen.

So how about it? Anyone with thoughts on any other really useful FireFox Addons?

This Device Cannot be Started (Code 10)

1
Filed under Uncategorized

image

I had opened up my machine to reformat a spare Harddrive last night. When I buttoned everything back up and restarted, I get network errors.

So I opened up My Computer, Device Manager and lo, my network card was “failing to start” with that wonderful code 10.

My machine has an Intel 975XBX2 motherboard, with those cool blue flame heatsinks<g>.

Pretty much best of breed stuff, and a gigabit net card is built in; swapping out cards was a “only if I absolutely have to” option.

Have you ever noticed that for virtually any other problem on a machine, you can just jump on Google, find the answer and be on down the road? But if your network card goes sour, ouch.

I tried all the obvious stuff, uninstalling the drivers, reinstalling them, using the “Update Drivers” option from Device manager, etc.

I’d almost given up, but then I decided to try one more thing.

The internal LAN adapter can be enabled or disabled through the system BIOS, so I rebooted, got into the BIOS, performed a “Load system Defaults”, then restored all those settings that I had to (like the RAID settings, Numlock off on boot, you know, important stuff), and then set the LAN card to disabled (it’s under Advanced/Peripherals).

Rebooted into Vista and sure enough, now it didn’t see the LAN adapter at all. Good sign.

Shutdown, power off, and restart. Back into the BIOS, reenable  the LAN adapter, save settings, and restart.

Boot back into Vista. Lo and behold, back in business.

Now, if only that 120 gb Western Digital Harddrive I picked up as a spare, would recognize properly and not as just 32gb, I’d be done with hardware (for a few days at least).