reinstalling sshd service in windows

This one was a bit painful as I didn’t want to mess with the pre-existing configuration of the key files. Installation required a small modification to the standard installation options.

cygrunsrv --install sshd --path '/usr/sbin/sshd' --env 'PATH=/bin;/sbin' --env 'CYGWIN=ntsec tty' -a -D

You need to use the cygwin –path item, otherwise the service won’t start correctly (sshd needs to be executed with an absolute path). The env flags are there to allow the service to start, otherwise you end up with an annoying: cygcrypt-0.dll cannot be found error. The CYGWIN environment was there because otherwise it doesn’t work correctly. the -D is for daemon mode.

[Listening to: Butterfly Caught – Massive Attack – 100th Window (7:34)]

What’s on your desktop

It happens – the brother in law peers over my shoulder to verify that I’m not playing a game while I should be programming – like he could really tell the difference based on a lot of the games I play these days. In response, I decided to list what’s on my desktop, and the reasons for them being there.

  • My Computer, My Network Places, My Documents – ease of navigation
  • My Bluetooth Places – bluetooth makes me so happy
  • Firefox, Explorer, Thunderbird – web, and email
  • Skype – cheap calls
  • w.bloggar – web logging
  • PE Resource Explorer – occasionally my projects don’t compile so good
  • Acrobat Professional – Lot of PDFs
  • Nullsoft Install System – for making those all important installers (still learning this)
  • Nunit GUI. One of these days I’ll actually write those tests I’ve been promising myself
  • IDA. The intelligent disassembler. Really good disassembler. This one is old, but I can’t afford a new version (~€320 + vat at last check)
  • Code-Work, my projects folder. Practically everything lives here. It’s not on my desktop, it’s a folder-link
  • Visual FoxPro 8 – upsizing some code to SQL server. The venerable Fox needs to die, as it has not kept up with the times.
  • Visual Studio.NET – I write a few bits and bobs in Microsoft C, C++, C#
  • Delphi 2005 – Best Delphi yet, sadly it’s got the nastiest price tag also. God be with the days when pascal cost $60
  • Netbeans 4.1 – the gui designer alone is worth the download
  • Palm OS Developer Suite – I caved, cscope just didn’t cut the mustard – pocketcity
  • Simcity 3000, UK Edition – reference for pocketcity
  • Copernic Desktop Search – partial word search; ’nuff said
  • El Bin of Recycling

Making virtual folders. When you create a shortcut to a folder the start menu do not expand them on hover. This is remedied by creating a real folder, then making a desktop.ini file containing the following:

[.ShellClassInfo]
CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}
Flags=2

Follow this with a shortcut called target, which points to the real directory. You can place this folder anywhere. When it’s on the start menu you have the right pointing triangle, which indicates that it’s a real folder

Bad syntax

Came across this one in a piece of C code.

(conditionflag & STATUSBIT) ?
(KdPrint(xxxx)) : 0;

Edited [ 2005-08-04, 19:42 Pete ] There was no code making use of the result of the ?: operation.
This piece of code is terrible from both a readability and functionality perspective. If the return type of the function is changed to a void, then there won’t be a valid left hand side for the evaluation to function correctly, from a readability perspective the developer split the code over two lines, which made it ripe for the more legible form of:

if (conditionflag & STATUSBIT)
(KdPrint(xxxx));

Ah well, you can’t boss everyone around all of the time I suppose.

Desktop search and code

It’s slightly frustrating when you are trying to find out what piece of code created what variable. Desktop search only goes so far, showing you all the references of the name of a variable. I need something along the lines of cscope, but over all my code – C, C++, Delphi, Java, FoxPro.
Does anyone know of something like this, or am I going to have to make one myself?

Keeping in shape

Just seeing if I was still capable of breaking the typical registration check in a program. Today’s exercise was Konfabulator, a prettification program for Windows and the Mac. Long and the short of it. Find out where the registration code is stored. It was in the registry. Find out what the registration key is (Registration). Found two functions referencing the registry key as two separate strings (Bad optimization on the compiler). One of them looked like it was trying to check the registration code, the other made internet check calls (part of the registration process – it’s over the internet). Went to the call that wasn’t over the internet and backtracked it – it was a very short, stubby routine with an setnz immediately following the call to the check. Replaced this with an setz, and the program executed flawlessly.
I was attempting to produce a keygen, but the one byte change was easier. I’m not planning on using the software anyhow, this was just me trying something out.
On other details, I have a chunk of encrypted data that I need to decode. I’ve deduced the structure size based on repeating patterns, now I need to find out the encryption scheme for the data – that way we can upsize it to the windows systems. There’s encryption on the data. The key for encrypting the data is in the application. The only reasonable conclusion I can come to about the encryption is that it is intended to prevent people from porting their data from the old system to a new one.
Of course I went to the Konfabulator web site to find out that it’s all free gratis and for nothing now – they’ve been acquired by Yahoo.

The joy of C

This one is one of my favourites – Comparing strings. The logic is simple: the function returns 0 if the strings are equal. The problem is that people code it like: if (!strcmp(x,y)), so a casual read can completely misinterpret the intent.
Explicit comparisons please people! This is one of those things that I’m glad does not happen in the more B&D languages.

Microsoft’s spot the bug

Microsoft have this ‘spot the bug’ blog entry. And while the code size is trivial, people have been finding more than one bug! Of course if you want some more fun spot-the-bug items you could try the Secure programming @blogspot, or even the linux kernel. Ok, anyone who thinks I’m being smart by this one can just bite me. You could also try the Open Solaris code also. So there’s plenty of things to keep you occupied with in your bug finding tasks.
Of course, you could try to find the bugs in your own code 🙂

The Underhanded C Contest

This one is a doozy. It’s the underhanded C contest. It’s purpose is to have people write seemingly innocent code that actually performs some sort of nefarious activity. If anyone remembers the linux exploit that was attempted around about January 2005, where some code was introduced which had the subtle side effect of granting people root permission. It was noticed and killed off… but what if people have been doing this for a long time already?

Timely information

Here I am, at about 2 in the morning thinking about timely information. Take for example accessing a file’s Version Information (Windows applications). The API is piss easy, it’s jut a bit noxious. I wrote myself up a small class to extract this for my applications. The problem is that this code is to all intents obsolete – there is a class in .NET that covers it.
This is the two forked problem with the internet. When you have a problem, by the time you’ve either (a) solved it or (b) found the solution, the world has gone and passed you by. Almost depressing, I might add.

Undocumented methods

It’s not unusual to encounter undocumented methods in a programming language, it’s just the nature of the beast. Take for example Delphi 2005. It has a new Queue method, for allowing a programmer to queue a call to the main user thread, rather than serially invoke it (it’s not quite serial, there’s a WaitForSingleObject in there).
This interestingly brings up another item. There are two models generally associated with timed events. The first model is the Invoke, leaving at least an interval gap between the invocations, the second model is the invoke, and even if it’s not finished invoke it again when the interval elapses. The first model can be emulated using the standard Synchronize call, the second can be emulated using the Queue call. Because they both are operating from the one task queue, either method would be safe to use on mt-unsafe code. The advantage of the Queue method is that you can interlock the thread and the GUI in a looser manner, as the thread does not wait for the GUI to do it’s stuff before continuing. This means that, for example you could be informing a gui component to repaint itself when the underlying dataset changes.