API, Junkies and every thing in between…

API Junkie is moving to APIJunkie.com

API junkie is moving to a new home.

From now on you can find me at http://blog.ApiJunkie.com or at http://www.apijunkie.com/

I hope to see you there…

November 6, 2007 Posted by apijunkie | Uncategorized | , | No Comments Yet

How to use an external USB drive with a DVD player or breaking the FAT32-32GB limit.

Starting with Windows 2000 you can’t format FAT32 partitions larger then 32GB.

The problem does not stem from a limitation of the FAT32 design or implementation(FAT32 partitions can reach 2TB in size and each single file can reach 4GB in size) instead it stems from Microsoft’s high handed patriarchal decision to limit partitions to a 32GB maximum size.

The original idea was probably to encourage users to move to the more robust and secure NTFS file system.

Alas Microsoft failed to appreciate how successful their file system turned out to be. Today most devices and operating systems support the FAT file system. This is not necessarily true for FAT’s younger sister NTFS.

So what’s the big deal?

The big deal is that if you want to use a new USB disk, which is likely to be much bigger then 32GB and you are the proud owner of a Windows OS produced in the past 10 years and you want to copy your “home movies” and play them on your new DVD player, Microsoft says: No, No, No…

Yes I’ve been bad but…

The official solution is to boot from a Windows 98 floppy and format the drive. But that’s just opening a whole new can of worms.

Fortunately, thanks to other API junkies out there we have much better solutions.

This is the one I used:

http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm

Follow the steps in the above link and you should be good to go.

Just do me a favor and remember to format the right drive J

   

September 7, 2007 Posted by apijunkie | Uncategorized | | No Comments Yet

A fix for .Net 2.0 security update (KB922770) – error code: 0×669

In case any one else out there has the same problem with KB922770 error 0×669.

If you go to the Microsoft KB page at: http://support.microsoft.com/kb/922770
You can only find a solution to error 0×643.

I couldn’t find any good info on the web on a solution to this bug.

Most places suggest removing the .Net frame work, reinstalling it and then applying the KB922770 patch.

After some thought I decided to try the obvious, which no one seemed to suggest.

Why not just uninstall the patch and try to reinstall it?

Surprisingly it worked for me and saved me the headache of a complete .Net reinstall and restart of the server machine.

So you might want to head on to “Start/Settings/Control Panel/Add/Remove Programs”, scroll down to KB922770 and choose “Change/Remove”.

After you do that go to “Start/Microsoft update” and run the update check.

It should detect you are missing the KB922770 and ask you to install it.

Walla…

July 2, 2007 Posted by apijunkie | Uncategorized | | No Comments Yet

Debugging a .NET application on a production server using WinDbg

I recently experienced a weird problem on a .Net application deployed to our production server.

 

The problem only occurred on the production server.

 

I was looking for a way to debug the process live on the server.

 

A quick Google search led me to Troubleshooting ASP.NET using WinDbg and the SOS extension (http://support.microsoft.com/kb/892277) and Debugging ASP.NET with the CLR Debugger (http://support.microsoft.com/kb/893657)

 

The latter solution seems very user friendly but also requires you to install the .NET Framework SDK. Hmm…Interesting solution but downloading and installing a 106.2 MB (.Net Version 1.1.) or 354.0 MB (.Net Version 2.0) package on the production Server just so I can use a debugger? I don’t think so. At least not today (I hope some one at Microsoft realizes the problem here and make a stand alone reasonably sized debugger install).

 

Ok so were left with the former solution….

 

Not bad only 15.8MB for WinDbg. The installation is very easy, takes very little time and does not require a restart, in short my favorite type of install.

 

I followed the instructions in the article and they are pretty straight forward. However, there are a couple of caveats that are worth mentioning and hopefully might save you some time and agony:

  • When running the command line “cscript adplus.vbs -crash -pn aspnet_wp.exe -o c:\crashdumpyou might see a message regarding a missing environment variable _NT_SYMBOL_PATH.

To solve the problem you can add an environment variable and set it to the debugger symbol path (e.g.: C:\Symbols). You can add an environment variable by pressing the right button on my computer and choosing properties and then advanced/environment variables… 

  • To debug the asp.net process you will probably have to connect to your server remotely. If your server is running Windows 2000 and you are using a terminal services remote session, you can not debug a native process from another session. You can read Windows 2000 does not support cross-session debugging using a terminal server for more info. To solve this problem use the following trick. Although you can not debug the running process directly you can still make a snap shot of it and debug/examine the debug dump. The following command will take a snapshot of the asp net process:

        cscript adplus.vbs -hang -pn aspnet_wp.exe -o c:\crashdump

        Note the command line uses the –hang command line switch instead of the –crash.

  • The article refers to using SOS extensions for debugging managed code. If you are running .Net 2.0 the following command “.load clr10\sos” will not work. Any command you try will give you the following descriptive message “Doesn’t work with 2.x”. To solve this problem use the “.loadby sos mscorwks” command instead. You can find more info about it here.   

 

 

June 19, 2007 Posted by apijunkie | Uncategorized | | 1 Comment

Mailslots Bug or Documentation Error?

I had to use some form of IPC (Inter Process Communications) on a recent project I was working on. Normally I am what you may call a sock-sexual (i.e. biased towards sockets) but this time for various reasons like security and service discovery. We had to use some other form of IPC. After some deliberation we decided to go with Mail slots. Mail slots are easy to use and provide a simple unreliable mechanism for message passing in a domain.

After a few hours of work we had the mechanism in place and started testing it. At first every thing seemed to work smooth and for a minute there I thought I would actually finish work early for a change. But unfortunately it turns out there is an interesting mail slot bug or documentation error on MSDN. The error is related to mail slot names.

When using a mail slot client to connect to a mail slot on the local machine the documentation says: “…To write to a mailslot on the local computer, a process can use a mailslot name that has the same form used for creating a mailslot…” The form they are referring to when it comes to a local computer is: \\.\mailslot\[path\]nameWhere the “.” denotes the local computer.

Well as it turns out (the hard way) the “.” Does not work when creating a client side connection on a mailslot using createfile API while the client is running inside a Terminal Services session. That is at the very least true on Windows 2003 server. We did not test it on Windows 2000 Server yet. 

BTW, the solution to this problem is to query the local computer name and use its name instead of the “.” In the mail slot name for the client side of the mail slot.

February 1, 2007 Posted by apijunkie | Uncategorized | | No Comments Yet

Hello world!

My name is Bacon…James Bacon.

I am an API wars veteran I was wounded by x86 assembly, recovered and moved on to C. I am currently stuck in C++ and sniffing .NET.

I am mainly here to ramble about coding, various API’s, Junkies(me especially) and everything else that happens between coders and their significant other.

January 31, 2007 Posted by apijunkie | Uncategorized | | No Comments Yet