Monday, October 12, 2009

vector bounds checking in GCC

Robbed from somewhere on the internet. I can't try this is my application because my libraries are not compiled with GLIBCXX_DEBUG but I believe this option should enable bounds checking on stl vectors etc. Here as a note for future use:

Pedantic debug mode checks not only for errors, but also for usages that rely on GNU extensions and that, while correct, may not be portable to other compilers. In pedantic mode, for example, constructing an std::string with a null pointer will result in an abort, not an exception. Pedantic debug mode is not the default. To enable pedantic debug mode, compile your program with both -D_GLIBCXX_DEBUG and -D_GLIBCXX_DEBUG_PEDANTIC.

Robbed from here:

Sunday, October 4, 2009

Submit a bunch of jobs to SGE using a file as a template

This script takes a filename from the third whitespace separated field of each file of the file "work-to-do" it uses this as the argument of a command (at /home/user/stuff/bin/stuff). The second argument of this command is the directory of the first argument. The third is a name generated from the current date. These commands are generated and then submitted to an SGE queue using qsub (the queue is called myqueueq). As always probably useless to anyone but me.

awk '{print "cd /home/user/stuff;./bin/stuff "$3" `dirname "$3"` auto-`date +%Y-%m-%dT$H-%M-%S`"}' work-to-do > sgecommands

awk '{print "echo \"" $0 "\" > /tmp/regen_run;qsub -q myqueueq /tmp/regen_run"}' sgecommands

Saturday, October 3, 2009

Windows 95/98/Me registry kludging

There is a neat trick that puts Windows 9x back into setup. This lets you resetup all your drivers and can be useful in recovering a dead system (for example one that will not boot into Windows normally). It also keeps all your application settings.
Basicly what you do is merge a registry file called "SYSTEM.1ST" which is stored in the root of the C: drive ontop of your registry. To do this do the following:

Reset the computer, when it says "Starting Windows..." press F5.
You should be presented with a C:\> prompt type:

attrib -h -r -s C:\SYSTEM.1ST
regedit /L:C:\SYSTEM.1ST /E C:\1ST.REG
regedit C:\1ST.REG

next time you boot Windows you will be presented with the setup screen. Your serial number sould already be displayed and you should just be able to click through most of the options.

If your registry is completely corrupt then you may want to just copy C:\SYSTEM.1ST over C:\WINDOWS\SYSTEM.DAT

Misc RM Connect 2.x fixes

Is anybody still stupid enough to use RM Connect? I hope not but in the event that they are here are a random collection of bug fixes:

No packages install


No packages install on any workstations, even clean builds. No error is displayed at all.


Last time I encountered this it was due to the Nimda virus messing up Share permissions on our network. Check that the "Propagate" share on your PDC has the correct permissions. The share should be located at D:\RMVA\Manage\pkgctrl and permissions should be (as for all RM based shares) Everyone/Full Control. File permissions should be "Propagator/Full Control".

If this problems has been caused by Nimda trashing you file permissions you will probably find that many other shares have been distroyed as well. I've written some scripts that will reset the share permissions to there correct values, please contact at: if you would like more information.

Users exceed quota due to large Internet History folders


Users (on a 200/300 station network) come to you on an almost daily basis saying that their file area is full and they can't logon, but when they look in their file area they can't find anything to delete. When you you examine their file area it's AppData is huge, and cookies/History information is using up their quota.


I've written a small program, which you run from the login script of all users, to solve this problem. Basicly it will delete everything in the Internet folder of a user as they login, this should keep the filearea down to a reasonable size.

The fix is available from the link below:


I remove NetBEUI from a client and it continues to work, but I get an error from licence manager when I bootup

You want to get rid of NetBEUI, good idea! NetBEUI produces far too much network traffic, and is not recommended for use on networks larger than 30/40 computers.

The problem you are getting is caused by the fact that RM licence manager is configured by default to use NetBEUI to check for licences. The good news is however that RM licence manager can be configured to use TCP/IP to do this. I've created a package to do this and it can be downloaded from the link below. To install the package on your network simply unzip the folder and copy it to D:\RMVA\manage\packages\32bitWin or the share \\PDCNAME\manage\packages\32bitWin. Then allocate it to all your workstations using application wizard.

Licence Manager doesn't work even on a clean build

Well, it sounds like licence manager is broken on the server. The simplest thing to do is reset it, and add some new licences. Licence manager is really a tool for you to keep track of licencing, so if you are having problems you can add as many licences as you want.

Step 1: Stop the "RM Licence Manager" service on all of your servers.
Step 2: Delete the file called "C:\WINNT\rmlicman.lic" or "C:\WINNT\System32\rmlicman.lic".
Step 3: Start the "RM Licence Manager" service on all of yout servers.
Step 4: Run the "RM Licence Manager" program from Admin Tools on the start menu, it may take some time to startup. Add as many licences as you want to each of your servers.

I'm running Sophos with file Protector, but everytime a user logs in it reinstalls itself, but I've got the correct exculsions setup


(Quick and Dirty tobe updated soon)

Your problem is that File Protector recovers the registry from a backup (taken when a package is allocated or when you "Backup key files") when the system boots up.

The easiest way to solve this is to stop File Protector from replacing the registry at boot. The downside is that any changes that a user makes could stick (which includes, if they know how to do it, disabling File protector).

OK what you need to do is edit a batch file in the "FileProt" package. This is located at: D:\RMVA\Manage\packages\32BitWin\FileProt on your PDC. Or mapped to L:\Packages\32BitWin\FileProt on Admin accounts. You need to edit the file in the STATION\HDS directory called recover.bat load it into notepad. Find the lines under "rem System.Dat" and alter them so they read:

rem System.Dat
rem c:\windows\command\attrib -r -h -s c:\Windows\System.DAT
rem c:\windows\command\attrib -r -h c:\BackUp\System.da0
rem copy c:\BackUp\System.da0 c:\Windows\System.DAT >> %logfile%
rem c:\windows\command\attrib +r +h +s c:\Windows\System.DAT
rem c:\windows\command\attrib +r +h c:\BackUp\System.da0

rem User.Dat
rem c:\windows\command\attrib -r -h -s c:\Windows\User.DAT
rem c:\windows\command\attrib -r -h c:\BackUp\User.da0
rem copy c:\BackUp\User.da0 c:\Windows\User.DAT >> %logfile%
rem c:\windows\command\attrib +r +h +s c:\Windows\User.DAT
rem c:\windows\command\attrib +r +h c:\BackUp\User.da0

Instead of:

rem System.Dat
c:\windows\command\attrib -r -h -s c:\Windows\System.DAT
c:\windows\command\attrib -r -h c:\BackUp\System.da0
copy c:\BackUp\System.da0 c:\Windows\System.DAT >> %logfile%
c:\windows\command\attrib +r +h +s c:\Windows\System.DAT
c:\windows\command\attrib +r +h c:\BackUp\System.da0

rem User.Dat
c:\windows\command\attrib -r -h -s c:\Windows\User.DAT
c:\windows\command\attrib -r -h c:\BackUp\User.da0
copy c:\BackUp\User.da0 c:\Windows\User.DAT >> %logfile%
c:\windows\command\attrib +r +h +s c:\Windows\User.DAT
c:\windows\command\attrib +r +h c:\BackUp\User.da0

The run Application wizard and allocate "FileProt", choose to re-allocate to workstations already setup.

Registry changes should new stick and Sophos should install itself only once.

If you still have problems make sure the follow exclusions are set in file protector:

C:\Program Files\Sophos Sweep

Windows NT/2000 password recovery

I've found two options for cracking Windows 2000 passwords (this probably still works for XP and maybe even Vista).

The first is to buy LockSmith and NTRecover from Wininternal, these cost a hell of a lot (about 200quid I think). They will however almost definitely work as the people who write them really know their stuff.

The second (cheaper option) is to use a free program that's available on the web ( I've saved many systems using this but comes with no guarantees.

The required files are available on the above website, with local copies below. Download them into a directory on your computer and then from the commandline do the following:

CD C:\

When prompted for the disk image source file name enter "bd010114.bin" the target drive will of course be A:. Insert a disc and the program should create you a bootable floppy which is able to reset the Administrator password.

When you boot from this disc on the workstation you are cracking you should be able to accept the defaults for most of the options. You probably won't need to probe for SCSI devices, and you need to answer yes when prompted to write the SAM.

Internet Explorer and Acrobat print incorrectly. But Word and notepad do.


You can print from Microsoft Word and notepad correctly, but when you try printing from Internet explorer you get an error message similar to:

Line: 539
Char: 2
Error: Invalid argument.
Code: 0 URL: res://C:\WINDOWS\SYSTEM\SHDOCLC.DLL/preview.dlg

You may also (or possibly only) find that documents in Adobe Acrobat don't print correctly (words run into each other etc). The printer you're trying to print to is an HP printer.

These errors most commonly occur with HP printers, usually they are down to the PCL 6 driver that is supplied with the printer. Your best option is to download a PCL 5e, or PS driver from the HP website.

Appariently the Internet Explorer problem can also be caused by a faultly DLL (although I haven't come across this), details are available at:

Network configuration for older brother (1260/1660) printers/Emulex configuration

I just rediscovered the internet archive backup of a website I had back in the 2000 odd. Most of the stuff from there is old and no longer relevant but may just be of some use to someone.

Network configuration for older brother (1260/1660) printers/Emulex configuration

Step 0 resets the card, you can probably skip this for a new card.

0. Remove the Emulex NetJet card from the printer.
0.1 Set Jumper JX1 to the 1-2 position (nearest the connector).
0.2 Put the card back in the printer and switch it on for 30 seconds.
0.3 Switch the printer off and remove the card.
0.4 Set JX1 to 2-3 and put the card back in the printer.
0.5 Switch the printer on.
1. Make a note of the MAC address of the printer (writen on the back of the NetJet card).
2. At a cmd prompt on the workstation type:
"arp -s ipaddress mac" for example: "arp -s 00-00-c9-09-22-67". Telnet to the printer
4. Enter the default password which is "access"
5. Type "su", when prompted for a password type "system"
6. You should now have a "Server>>" prompt.
7. Type "define subnet yoursubnet" to set the subnet.
8. Type "define node ip your_ip" to set the ip address. for example "define node ip"
9. Type "logout".
10. You should now be able to ping the printer from any workstation on the network.
11. You'll need to setup an LPR port on the server to connect to the printer, under Windows NT4/2000 use generic LPR.
12. The queue name will be "PASSTHRU", and protocol should be LPR not RAW.

A short script to move files out of the way retaining full path

Find all files named *.fast4 under the current directory. Create replicate the path under ./obsolete and copy the file to the associated location. This script creates the required commands in a file called "moveobsolete" which you can then check over and execute.

find . -name "*.fast4" > obsoletefiles
awk '{print "mkdir -p ./obsolete/`dirname "$1"`; mv " $0 " ./obsolete/" $0}' obsoletefiles > moveobsolete
chmod 777 moveobsolete