Posts filed under 'Win32'

Never perfect

Do we not just enjoy the incompatibilities, the quirks and the complications of the assemble-it-yourself-things? No we don’t, but developers and hardware assemblers get a real kick out of it.

I decided to buy a bare clean HP Proliant ML110 5G tower, and I connected some extra RAM, an extra 1Gbps card and 2 extra 250gb harddisks. So far, so good.

I forgot the Sata cables, so I didn’t connect the disks yet, and tried out Ubuntu Server and installed KVM + Virtual Manager – for ‘virtualisation’. Unfortunately it doesn’t work exactly like a charm, the speed was ok for the most part, but at some points at the installation of Windows 2003 Server, it stalled up to a point where I just fell asleep. So I let it rest, got the sata cables, installed the harddisks.

Since I wanted to use the extra disks to store large backups, and because I wanted to try out Sata Raid, I decided to enable and configure a raid array. And since I wanted to backup files across servers in a swift fassion, I decided to do a clean install of the Ubuntu Server edition again.

Ubuntu shows a nice surprise; no raid. Just 2 seperate disks. When I insert the HP smart-setup CD-rom that came with the Proliant, it seems HP doesn’t support its own products either. I guess it’s my own fault for buying a cheap pc.

So out of frustration I disabled raid again, and I popped in the Windows Server 2003 cdrom I got along with my VS2008 Pro/MSDN Pro subscription. A nice clean install, but naturally half of the hardware drivers weren’t available, so I had to download it – with the Internet explorer that blocks just about every website there is out of security reasons. After a few reboots I wanted to see what happened if I enabled raid again: bluescreen reboots. So it’s just 3 seperate harddisks from now on.

Since I didn’t dare to download Virtual Server from MSDN, I wanted to get back to the familiar VMWare Server. Upon installing however, several MSI Installer and security issues arise which had to be patched, but only after about 2 hours of searching the web. Installed and well, the installation of Windows XP Pro went like a charm on VMWare.

And then I wanted to be bold and reckless, and reached for an old OpenSolaris cdrom. But alas, the graphics are beyond legible and I couldn’t install. So a new version perhaps? Solaris Express? Same graphics issues, and more – it couldn’t read the dvd, but I didn’t know what the error meant. Once I pointed the VM configuration to the ISO itself instead of the physical cdrom drive, it finally worked.

Now I’m waiting for the text based installation to finish and I will pray for some proper graphics once it’s installed, because even the text based graphics are just beyond normal.

Not to mention that working on the actual Windows 2003 installation is faster via Remote Desktop than a physical screen, keyboard and mouse for some reason. I suspect that drivers are fighting eachother off on the same IO or Memory addresses as always.

Come to think of it, I had similar issues with text based installation on Windows 2003. I suppose the VMWare beta has issues supporting the 80×40 lines resolution as opposed to the 80×25.

“unknown console login:” … that sounds promising.

Ah, and the graphical login screen looks horrible.

Example of what I’m dealing with here:

Solution

Add comment July 11, 2008

Compatibility

I don’t really get why so many people are into remaining compatible with the Microsoft Windows API. While the operating system itself is very mature and well tested after so many years remaining compatible to predecessors, the basic concepts of the Windows API are not of this age anymore. I know this isn’t entirely Microsoft’s fault, Posix compatibility brought plenty of misery to the OS the same as the other OS’es.

Isn’t it time we started a new OS with an API that is Not compatible with Posix and Windows? Haven’t we had enough of all the workarounds we had to make up? For the future’s sake, someone has to be bold and be shouted at for their non-posix compatibility, I’m absolutely sure it will have potential (if properly documented of course).

Oh well. For the time being we’re stuck with the mess of the past, and we’ll have to keep writing our fancy wrappers…

Or better yet; Microsoft to remove all legacy, deprecated, inefficient, inconsistent and insecure API functions so we stop using them.

Add comment July 1, 2008

IPv6 readyness

Supporting IPv6 can be a little tricky for the average developer. I have stumbled on so many issues, mainly because I was hooked to IPv4 and I have little means to test IPv6. My Internet Router that’s attached to my ISP’s modem doesn’t support IPv6, even though the store where I bought my Cisco 851 said it did. So the only way to get in touch with the Internet cloud with IPv6 is to set up a 6to4 tunnel from within my network and connect to a fancy external provider.

I could still do that, but luckily I found a way to set up a mini-network between my main-development-pc and a server. First I had to assign v6 IP’s to the machines, and since I didn’t want to bother with DHCPv6 yet, I had to use static ones. I found a website where I just nicked the sample IP address from (since my router doesn’t support IPv6 anyway, it shouldn’t be a problem).

So I punched into my ssh-console; /sbin/ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64
And on Vista I entered 2001:0db8:0:f101::2 mask 64 into the IPv6 protocol configuration screen.

And magically the pinging now works.

Next step was to add an AAAA record to the local DNS server I’m using, which wasn’t that hard.

Now, the first thing you’ll notice is that the posix function gethostbyname() doesn’t give you any results when you try to lookup your AAAA-record. At least, under Vista it doesn’t, I haven’t tested it anywhere else yet. You have to use the getaddrinfo() function (also posix).

The second problem, which is highly annoying, is about the ip-structure to ip-string conversion and vice-versa. Normally with IPv4 you can use the handy function inet_ntoa(), but ofcourse it doesn’t support IPv6. You have to start using inet_pton() / inet_ntop(). But it’s there where posix compliancy ended with Microsoft. You have to improvise the functions using getnameinfo() and getaddrinfo() using special flags.

Looking back at all the struggles concerning these functions, I don’t really get why I didn’t make a custom implementation. All it should be able to do is to translate an ascii patterned string to a structure with all the numbers mixed up. (seriously, the person who made up that network-byte-order-mechanism was insane)

Microsoft obviously got the message in a very late stage, and added a new Vista+ only function baked into ntdll.dll, named RtlIpv6StringToAddress(). I don’t get why no one else thought of that earlier.

Add comment June 23, 2008

Triplatform GUI chaos

For the last few months (no not 24/7) I’ve been working on a multiplatform library in C++. Now, the first thing you might expect as a pro-open-source-and-lunix-person, that GUI development on Linux is going to be awesome. Unfortunately, this isn’t very close to reality.

The first thing in the world of Linux that you’ll come across, is that there are no default toolkits. The X-windows system is basically just a remote pixelbuffer with support for keyboard and mouse events. Now, how wonderful it may be to develop your own fancy toolkit and to draw buttons and gadgets, it will take you literally months to develop a well-tested and feature-rich toolkit like that. So you look at the available options of libraries to use, and you’ll browse the websites of the 2 major players around. The first one being the basis of KDE, named QT, and the other one of GNOME, called GTK+.

I have worked with QT before, on both Windows and Linux, and it feels generally ok. All the necessary components are there, decent callback (signals) mechanics, object oriented. The set of features in QT is quite extensive, but then you’ll come across the itchy area. It’s dual licensed, with a price tag on the commercial one that is not exactly forgiving, or you’ll have to go and make your applications open source. I’m convinced that the price is justified and that they deserve to get paid for it, but I wasn’t so sure I could take such a gamble at the time.

The next major player is GTK+, which is available for windows and linux as well. It’s used in things like GIMP, and pretty much the whole of the GNOME desktop application base. It’s based on LGPL, so you can pretty much do whatever you want when statically linking to it. So you start investigating it, make some hello worlds and try to make them compile. The linking process under Windows is just too horrible to endure, but when you fall you learn and write it down, it becomes manageable. Linking under Linux won’t be so hard, as you’ll just use some default pkg-config lines in your makefile – which can be done under Windows as well, but is a tad more complicated.

The thing that will eventually make you hit a large wall of nastyness, is the fact that it promises amazing MVC qualities and it doesn’t deliver quite so amazingly. I don’t really know how to explain it. It just doesn’t feel right. I recognize the hard work they put into the project, using a C-only base with a really inventive way of creating custom types and inheritance with it, but then using an overexcited amount of runtime type checking and using several other libraries for the dirty work. Little things in the gui-area of the library actually feel like you expect it to work.

There are a lot of other toolkits out there for linux, like WxWidgets or FLTK, and if you like to be old-school, you can go for Xaw – but I went for GTK, and I’ll have to stick to that decision. Speaking of WxWidgets, as wonderful it may seem on the cover, the actual performance of even the simplest Mac OSX examples is very poor somehow.

So here you are, after weeks of surfing around, investigating and testing, while your native Microsoft Windows API support was done in half the time. I’ve really grown back towards the Windows API. I generally know out of experience what to expect and what workarounds I should use, and it’s documented on MSDN up-to the weirdest behaviour you’ll come across. The best thing about the Windows API is that you can pretty much do anything you want, yes it will be very complicated with fancy window messages and special functions, but it’ll work eventually. Where as with GTK, you’ll come across limitations when you want to emulate non-default-behaviour.

Yet on top of the world, there lies Cocoa. Cocoa is the Objective-C based toolkit for Mac OSX, and is despite the oddness of Objective-C, it has a wonderful separation of data and view when it comes to the really bulky stuff like Grids. I was so happy when I came across the – complicated but workable – mechanism of requesting table data via function calls instead of having to fill some custom datatype. It enabled me to make callbacks to my own code, get the data directly from my own data-types at runtime, and Cocoa makes sure it turns up on the screen.

The biggest problem with Cocoa is that you’ll come across things that don’t work the way you’re supposed to when working primarily on Windows. For example; I tried to make menu’s pop-up on any X-Y-location on a window, and there wasn’t such a thing. Following some examples that described workarounds didn’t really work either. And then it got me starting to think about what I really wanted it to do. I didn’t really want the menu to pop-up ‘Anywhere’ like I first thought. You don’t want a popup to appear on some panel, textlabel or even a button, you want it on specific controls like listboxes, grids and editboxes, and even more specifically; you want it when you right-click on a specific spot. And there lies the solution, because that is exactly what Cocoa asks of you. It wants you to say if you want a menu when such an event occurs, and then it will display your menu.

Most downsides of Cocoa can be overcome, but are annoying at first. The first thing you’ll notice when coding interfaces manually instead of with the fancy XCode Designer, is that the Y coordinate is upside down. There is supposedly a delegate function that can reverse the coordinates, but I just solved it in a more mathematical way – as in subtracting the control’s expected y from the parent control’s height, thus mirroring the coordinates as they are handed to Cocoa.

The second thing is a weird bug that I solved with a dirty hack. The test applications didn’t respond to much mouse events, and not at all at keyboard events. Instead, it decided the Console deserved the keystrokes more than my application. For some reason I came across a function that requested the attention of the entire display, and then releasing it again.

CGCaptureAllDisplaysWithOptions( kCGCaptureNoFill );
CGReleaseAllDisplays();

I really have no idea how I came up with the idea, I googled my ass off and didn’t find anything at all on the subject. I have no idea how to solve it any other way, but it works.

The third thing is the Garbage Collector. It is absolutely annoying, but yes it makes sense. It sounded reasonable to set up autorelease pools, allocate and release whatever I could do myself, but then I stumbled upon a large amount of warnings that eventually after a very long time of debugging led me to the culprit. The warning occurred when I tried to setText or setTitle of certain objects. It seems that the moment of setting, automatically thus leaves the old variable without a home, and putting an autoreleasepool around the setfunction makes the old value tumble right into the garbagebin. Like this:

NSAutoreleasePool *tmpPool = [[NSAutoreleasePool alloc] init];
NSString *s = [[NSString alloc] initWithCString: caption encoding: NSUTF8StringEncoding];
[control setTitle: s];
[s release];
[tmpPool release];

Well I suppose I could go on and on about this, but it’s not exactly the best blog-entry I’ve ever written so far. So it’s perhaps best I leave it at this and try to make some kind of sense next time.

 

Until then.

 

Add comment May 20, 2008


RSS Twitter

 

December 2009
S M T W T F S
« Nov    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

Blogroll

Meta

Top Posts