Archive for the programming Category
None of the preset options in HTML Tidy were doing it for me, so I took a few minutes to create my own. They either mangled the code too much, or not enough. So, here is what I ended up with:
[EtdotTidy HTML]
indent: auto
indent-attributes:no
indent-spaces: 2
wrap: 0
wrap-asp:no
wrap-jste:no
wrap-php:no
show-warnings: yes
numeric-entities: yes
quote-marks: yes
quote-nbsp: yes
quote-ampersand: yes
break-before-br: no
uppercase-tags: no
uppercase-attributes: no
char-encoding: latin1
new-inline-tags: cfif, cfelse, math, mroot,
mrow, mi, mn, mo, msqrt, mfrac, msubsup, munderover,
munder, mover, mmultiscripts, msup, msub, mtext,
mprescripts, mtable, mtr, mtd, mth
new-blocklevel-tags: cfoutput, cfquery
new-empty-tags: cfelse
fix-bad-comments:yes
fix-backslash:yes
write-back:yes
Just paste the code above into your TIDYCFG.INI file.
I’m not sure why, but someone has put together animations comparing various sorting algorithms. Edutainment, anyone?
I had trouble building the vmhgfs module (the one that allows shared folders between guest and host computers) when trying to install VMWare Tools in Ubuntu 7.10 running in VMware Workstation 6.0.2 build-59824 on Windows XP. I was getting the following error:
Trying to find a suitable vmhgfs module for your running kernel. None of the pre-built vmhgfs modules for VMware Tools is suitable for your running kernel. Do you want this program to try to build the vmhgfs module for your system (you need to have a C compiler installed on your system)? [yes] Extracting the sources of the vmhgfs module. Building the vmhgfs module. Using 2.6.x kernel build system. make: Entering directory `/tmp/vmware-config0/vmhgfs-only' make -C /lib/modules/2.6.22-15-generic/build/include/.. SUBDIRS=$PWD SRCROOT=$PWD/. modules make[1]: Entering directory `/usr/src/linux-headers-2.6.22-15-generic' CC [M] /tmp/vmware-config0/vmhgfs-only/backdoor.o CC [M] /tmp/vmware-config0/vmhgfs-only/backdoorGcc32.o CC [M] /tmp/vmware-config0/vmhgfs-only/bdhandler.o CC [M] /tmp/vmware-config0/vmhgfs-only/cpName.o CC [M] /tmp/vmware-config0/vmhgfs-only/cpNameLinux.o CC [M] /tmp/vmware-config0/vmhgfs-only/cpNameLite.o CC [M] /tmp/vmware-config0/vmhgfs-only/dbllnklst.o CC [M] /tmp/vmware-config0/vmhgfs-only/dentry.o CC [M] /tmp/vmware-config0/vmhgfs-only/dir.o CC [M] /tmp/vmware-config0/vmhgfs-only/eventManager.o CC [M] /tmp/vmware-config0/vmhgfs-only/file.o CC [M] /tmp/vmware-config0/vmhgfs-only/filesystem.o /tmp/vmware-config0/vmhgfs-only/filesystem.c: In function ‘HgfsInitFileSystem’: /tmp/vmware-config0/vmhgfs-only/filesystem.c:582: error: too few arguments to function ‘kmem_cache_create’ /tmp/vmware-config0/vmhgfs-only/filesystem.c:593: error: too few arguments to function ‘kmem_cache_create’ make[2]: *** [/tmp/vmware-config0/vmhgfs-only/filesystem.o] Error 1 make[1]: *** [_module_/tmp/vmware-config0/vmhgfs-only] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.22-15-generic' make: *** [vmhgfs.ko] Error 2 make: Leaving directory `/tmp/vmware-config0/vmhgfs-only' Unable to build the vmhgfs module. The filesystem driver (vmhgfs module) is used only for the shared folder feature. The rest of the software provided by VMware Tools is designed to work independently of this feature. If you wish to have the shared folders feature, you can install the driver by running vmware-config-tools.pl again after making sure that gcc, binutils, make and the kernel sources for your running kernel are installed on your machine. These packages are available on your distribution's installation CD.
A quick google search turned up this thread which contained the solution to my problem:
sudo aptitude install build-essential linux-headers-$(uname -r) cd /tmp tar -xzvf VMwareTools-6.0.2-59824.tar.gz cd vmware-tools-distrib/lib/modules/source cp vmhgfs.tar vmhgfs.tar.old tar xvf vmhgfs.tar cd vmhgfs-only chmod 644 compat_slab.h vi compat_slab.h
Search-> #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) || defined(VMW_KMEMCR_HAS_DTOR)
Fix-> #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 22) || defined(VMW_KMEMCR_HAS_DTOR)
Save Changes
chmod 444 compat_slab.h cd .. rm vmhgfs.tar tar cvf vmhgfs.tar vmhgfs-only cd /tmp/vmware-tools-distrib sudo ./vmware-install.pl
When debugging a Windows GINA, driver, or service it is sometimes necessary to debug a target computer from a second computer via the serial port. Using the same concept, you can debug a target VMWare computer from the host computer using a named pipe.
For this example, I am using VMWare Workstation 5.5.3 build-34685 with a Windows XP Professional SP 2 virtual machine. On the host computer (also Windows XP Professional SP2) I am using WinDbg 6.7.0005.0.
Part 1: Create a named pipe on the VMWare target machine.
- In VMWare Workstation select VM \ Settings from the menu.
- In the Virtual Machine Settings window select the Hardware tab (if not already selected).

- Click the Add button to launch the Add Hardware Wizard.
- In the Add Hardware Wizard Welcome screen click the Next button.

- In the Add Hardware Wizard Hardware Type screen select Serial Port and click the Next button.

- In the Add Hardware Wizard Serial Port Type screen select Output to named pipe and click the Next button.

- In the Add Hardware Wizard Specify Named Pipe screen do the following:
- Use the default pipe name of:
\\.\pipe\com_1
- Select This end is the server.
- Select The other end is an application.
- Tick the Connect at power on check box.
- Click the Advanced button.
- Use the default pipe name of:
- In the Add hardware Wizard Specify Advanced Options screen tick the Yield CPU on poll check box and click the Finish button.

- In the Virtual Machine Settings window click the OK button.
Part 2: Modify the VMWare target machine boot.ini file.
- Boot the VMWare target machine.
- Remove the read-only permissions from c:\boot.ini if they exist.
- Copy an existing Windows line and append the following to the end of it:
/debugport=com1 /baudrate=115200 /break
- Your boot.ini file should look something like this when you are done:
[boot loader] timeout=30 default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS [operating systems] multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /fastdetect multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional - Debug COM1" /fastdetect /debugport=com1 /baudrate=115200 /break
See “Boot INI Options Reference” for more info.
- Restart the virtual machine and select the new Debug boot option.

Part 3: Run WinDbg
- Launch WinDbg.
- Select File \ Kernel Debug from the menu.
- In the Kernel Debugging window do the following:
- Enter 115200 for the Baud Rate.
- Enter the following for the Port.
\\.\pipe\com_1
- Tick the Pipe check box.
- Remove tick from the Reconnect check box.
- Enter 0 for Resets.
- Click the OK button.
- WinDbg should connect and break.

You are ready to debug.
When remote debugging a Widnows GINA it is handy to stuff in a debug break so that the debugger can be attached and symbols loaded. When you need to replace the GINA dll or view log files stored on the system you must boot to safe mode, remove the WinLogon registry entry, and reboot. With this little code snippet (in C++) you can decide at runtime when you want to hard break by simply holding down the left shift key and eliminate the extra annoying reboots:
if ( (GetAsyncKeyState(VK_LSHIFT) & 0x8000) ) {
_asm int 3; // break if left shift held down
}

