Using 32-bit COM Call in 64-Bit Windows Application …

This was a new problem for me since I rarely ever need to write software that calls a COM object that is running on a second machine.  I am working on a data collection system that will integrate with our ERP system and is accessing it through the API that they provide.  The ERP system that I am connecting to is a 32-bit application and it will NOT run on a 64-bit system.  There is still some legacy code that they need to get migrated, and they are working on a full 64-bit update.  In my Visual Studio 2008 project I have a reference to a dll file that exposes the API needed to access the business rules and import or export data.  If I compile the project and run it on a 64-bit system, to program runs fine until I make a call against the API.  I then get this error:

“System.DllNotFoundException: Unable to load DLL ‘SERVICES’: The specified module could not be found. (Exception from HRESULT: 0x8007007E)”

After digging around, I found this is because I am calling a COM object that in turn is calling a 32-bit object which is not supported.  It is the act of the COM object running in the WOW64 subsystem making a call to a 32-bit object that is causing the problem.  At lest for the application that I am working on now, I was able to tell Visual Studio that the target CPU was a x86 and then everything ran fine.  This setting can be found at Project > Properties > Compile > Advanced Compile Options

screen

Hope this helps …

Windows 7 Installation …

I started the move to Windows 7 last night.  Just to make things interesting, I also moved to the 64 bit version.  The base installation was quick and painless.  I was installing on a Dell Latitude D630 with a nVidia video controller.

Windows 7 did a pretty good job of finding and configuring my hardware.  The only drivers that I needed were for the video controller and the finger reader.  Everything seems to be working good and the computer is running noticeable faster with a lower resource usage.

Here is a list of the software that I have had problems with:

  • Alcohol 52% – Alcohol 120% does work and they are working on a update for Alcohol 52%.  This is causing me more irritation than anything.  I have converted all my install CDs to ISO images and use Alcohol to mount them.
  • Acronis True Image Echo Workstation 9.1 – I just get a message that this program will not run on Windows 7.  Nothing that I could find on the Acronis web site, but there is a new version out.  The explorer shell extension seems to be working for browsing previously created images.  I may get stuck purchasing the new version.  I use this for backup and recovery.   Update: Purchased Acronis Backup & Recovery 10 Workstation and it supports Windows 7.
  • Microsoft SQL Server 2008 Developer Edition – This installs but would not run until Service Pack 1 was installed.

    Here is a list of the software that has installed without any problems:

    Recovering From a Corrupt Registry Hive

    We had a computer come in the office that was getting the following error today:

    Windows XP could not start because the following file is missing or corrupt:
    WINDOWSSYSTEM32CONFIGSYSTEM

    I found sever solutions to fix this, but all of them would cause the registry to be restored to the default Windows installation state.  This does not seem like a very good solution at all.  After digging around trying to find a way to run Windows Restore from the Recovery Console, I found a post that explained how to restore files backed up a Restore Point from the Recovery Console.

    The Steps required are:

    1. Log into the recovery console using a Windows install disk.
    2. Navigate to the windowssystem32config directory and rename the file system to something like system.bak
    3. Navigate to the System Volume Information directory.
      cd
      cd system~1
      cd _resto~1
    4. A quick dir command will give you a list of directories named RP and then  a number.  If you look at the timestamp for these directories it will let you know when the restore point was created.  Look for one that is dated JUST before you started to have this problem and navigate into it.
      cd rp#
    5. Within the RP# directory there will be a directory named snapshot. This is the directory with the registry hives in it, so will want to go there now.
      cd snapshot
    6. The SOFTWARE hive is named _REGISTRY_MACHINE_SOFTWARE and the SYSTEM hive is named _REGISTRY_MACHINE_SYSTEM.  Now we need to copy this hive into the location of the corrupt hive.
      copy _REGISTRY_MACHINE_SOFTWARE windowssystem32configsoftware
      or
      copy _REGISTRY_MACHINE_SYSTEM windowssystem32configsystem
    7. With any luck you can now type exit and let Windows reboot.

    This solution was information combined from the following two sources:
    Running System Restore from the Recovery Console (well, sort of)
    How to recover from a corrupted registry that prevents Windows XP from starting

    Major Systems Upgrade

    We have been making major changes at work the last six weeks. We replaced both of our old Dell Power Edge 4600 servers with three new Dell PowerEdge 2900 Servers. I went from having half a terabyte of storage to having two terabyte of storage. Two of the servers are running VMware ESX 3.5 and the other server is my Microsoft SQL server. When we purchased the new servers we did not get any tape drives on them because we wanted to change our backup method during the change.

    The basic server layout is:
    Physical Server 1 (PowerEdge 2900)

    • VM 1: Domain Controller
    • VM 2: File and Print Server
    • VM 3: Application Server

    Physical Server 2 (PowerEdge 2900)

    • VM 4: Intranet Server
    • VM 5: Domain Controller (Primary)
    • VM 6: Application Server

    Physical Server 3 (PowerEdge 2900)

    • ERP and MS SQL Server

    Physical Server 4 (PowerEdge 4600)

    • Backup Server

    For backups we are using Acronis TrueImage Echo Server to backup VM 2, VM 4, VM 5 and the Physical Server 3. We are creating full images on Sunday when to network to slowest and pushing them to the backup server. This process is taking about one hour. Monday through Friday we are doing differential backups on the save four machine and pushing them to the backup server. On the SQL server we are also doing log file backups every 30 minutes. These files are created locally and then copied to the backup server. The differential backup is only taking about five minutes total for the four servers. On Saturday we are using the ability of TrueImage to merge the full image from the previous Sunday and the last differential image from Friday into one file and then removing all the pieces from the week. At this point we have one image for each of the four servers that is current. All of the nightly processing done on these four servers is handled by a VBscript. (Note: The script has been saved as a text file for security on the web site.) Each night the backup server backs itself up to tape which will include all the image file from the other servers. We are not backing up VM 1 because it is a mirror of the other domain controller and in the event that we had to restore everything, I have never had much luck getting to domain controllers to resync after. VM 3 only changes when one of the applications on is updated. So after any application changes we make a snapshot of the VM and burn it to DVD to store off site. VM 6 has one data directory that changes so I pull that directory each night when the backup server backs up, other wise it is treated the same as VM 3.

    These changes have made a world of difference to our nightly processing. When everything was going to tape it was taking almost four hours total for all the servers to backup and the one time we did have a major hardware failure it took sixteen hours to get everything up and running. We did a test run after everything was up and running, and the full restore took under two hours have things running.

    I also finally got and answer to my question about our corporate pain threshold for data loss in a major failure. I have always been working to keep my exposure to less than four hours. Well it turns out the corporate standard is one WEEK. I was shocked to hear that. I am pretty sure that I will have NO problem meeting that requirement.

    Simple Linux Backup with SCP and TAR

    I ran into a problem this week when I tried to pull a file off of a backup and found out that I could not read any of the backup tapes that I had. I was using Dump to create the backups and when I tried to access them with Restore I got the error message that the tape was not a dump tape. I had tested this before I put the server into place, but something has changed in the last two months. I decided to change to a different method of creating backups. I am now going to tar the server and then use scp to move the tar file to a second server that is located off site.

    Lets start with setting the machines up so that we can transfer files between the two servers without being prompted for a password. For this posting server1 will be the server that is being backed up and server2 will be the server that we are sending the backup to.

    Configure the Client (server1)
    Create the client key without a password:
    [root@server1 /]# ssh-keygen -t dsa
    Generating public/private dsa key pair.
    Enter file in which to save the key [/root/.ssh/id_dsa]:
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /root/.ssh/id_dsa
    Your public key has been saved in /root/.ssh/id_dsa.pub
    The key fingerprint is 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:root@server1

    Lets take a look at the key:
    [root@server1 /]# cd ~/.shh
    [root@server1 /]# ls
    id_dsa id_dsa.pub known_hosts

    Copy the key to the server that we are going to copy the backup to:
    [root@server1 /]# scp -r id_dsa.pub root@server1:key-temp.pub

    Configure the server (server2)
    Lets make a .ssh directory if the directory does not exist:
    [root@server2:~#] mkdir .ssh
    [root@server2:~#] chmod 700 .ssh
    [root@server2:~#] cd .ssh

    Add the key for the client to the authorized keys:
    [root@server2:~#] cat ~/key-temp.pub >> authorized_keys
    [root@server2:~#] rm ~/key-temp.pub

    You should now be able to use ssh and scp from serve1 to server2 without being prompted for a password.

    From here I had to create the script for creating the tar file of server1 and then copying it to server2. I created a directory called backup to hold my script and the MySQL backups. So on server1 we are going to create the directory and the script:
    [root@server1: /#] cd /
    [root@server1: /#] mkdir /backup
    [root@server1: /#] cd /backup
    [root@server1: /#] nano backup.sh

    Now the script:
    #!/bin/sh

    # Define the variables for later use:
    BACKUPFILE=backup-$(date +%Y%m%d)
    OLDFILE=backup-$(date --date='7 day ago' +%Y%m%d) # We are keeping 7 days of databases dumps.
    EXCLUDES="--exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/media --exclude=$BACKUPFILE.tgz"
    BACKUPDIR=/
    COPYTO=root@server2:/root/.


    # Backup the MySQL Databases:
    mysqldump -uroot --opt databasename1 > /backup/databasename1-$BACKUPFILE.sql
    mysqldump -uroot --opt databasename2 > /backup/databasename2-$BACKUPFILE.sql


    # Create the tar file:
    tar cvpzf $BACKUPFILE.tgz $EXCLUDES $BACKUPDIR


    # Upload the tar file:
    scp -rp $BACKUPFILE.tgz $COPYTO


    # Remove the backup file:
    rm $BACKUPFILE.tgz
    rm /backup/databasename1-$OLDFILE.sql
    rm /backup/databasename2-$OLDFILE.sql

    You should now be able to backup server1 with the command:
    [root@server1: /#] sh /backup/backup.sh

    Just want to say thanks to David for his demo at the last ECLUG meeting, because it gave me the point to jump off at.

    ECLUG Meeting for December

    David Desrosiers did a pair of presentations for this months meeting. His first presentation was a short demonstration on Bash hacks and tips. Some of the things that can be done with Bash are:

    • Integer math
    • Scripting, functions, loops
      • Download sequential files remotely
      • Rename local files sequentially
      • Repeat a process ‘n’ times until completed

    • Regular expressions
      • Character classes
        • [:alnum:], [:alpha:], [:blank:], [:digit:], [:lower:] and so on.

      • Globbing

    • I/O redirection
    • vi! (no, seriously)
    • Subshells and restricted shells
    • Aliases and variables

    The second presentation was about Firefox and its extensions. So what makes Firefox different?

    • Support for enhanced “Tabbed Browsing”
      • Makes surfing the web faster

    • Advanced Privacy and Annoyance features
      • Pop-up blocking
      • Form and password management
      • Cookie preferences/expiration

    • Faster searching, find things easier
    • Better Bookmarks and History support
    • Does not directly support ActiveX
    • Customizable and extendable, thousands of extensions and themes available
    • Smart Download Manager
    • Standards compliant
    • Faster than other browsers out there
    • Fully Open Source

    Why not just use Internet Explorer?

    • Slow, implements many hacks and workarounds to achieve speed, breaks RFC standards
    • Insecure, source of many hijacked Windows machines (thousands of open security issues)
    • No updates in 4+ years (MSIE 7.x has recently been released in betas, not available for all Windows versions as yet), “long in the tooth”
    • No support for PNG images
    • Not standards-compliant, renders HTML horribly, no support for XHTML or CSS2/CSS3

    What are “Extensions” and how do I get them?

    • Used to add features not in the core browser. Find something lacking? Add an extension!
    • Used to replace features that you may not like. Changes how you interact with the browser
    • Change the way the browser “looks & feels” to make it easier for you to use it
    • Tools -> Extensions -> Get More Extensions
    • Point your browser to https://addons.mozilla.org/

    What extensions are available?

    • Blogging
    • Bookmarks
    • Contacts
    • Developer Tools
      • Greasemonkey – http://www.diveintogreasemonkey.org/
        • Allows you to write scripts that alter the web pages you visit, thousands of “user scripts” to start with

      • Timestamp Converter
        • Context menu option to convert the selected timestamp into a date.

      • Total Validator
        • Perform multiple validations and take screen shots in one go rather than using separate tools.

      • Prefbar
        • Gives the user more control over the pages viewed

      • Tamper Data
        • Use tamperdata to view and modify HTTP/HTTPS headers and post parameters.

      • Web Developer
        • Adds a menu and a toolbar with various web developer tools.

      • RankQuest SEO Toolbar
        • Quick access to more than 30 intuitive SEO tools

      • Google PageRank Status
        • Display the google pagerank in your browser’s status bar.

      • SearchStatus
        • Allows you to see how any and every website is performing (for SEM/SEOs)

      • Live HTTP Headers
        • Detailed information about HTTP request/response headers

      • FireBug
        • All of the tools you need to poke, prod, and monitor your JavaScript, CSS, HTML and Ajax are brought together

      • Leak Monitor
        • Pops up an alert dialog to warn chrome and extension developers about one particular type of leak (errant Javascript objects).

    • Dictionaries
    • Download Tools
      • Torrent Search
        • Search for torrents on the top 29 top torrent search engines

      • FlashGot
        • Download just one link, selected links or all the links of a page together at maximum speed with a single click

      • Linky
        • Open/download/validate links and pictures in tabs or windows.

      • DownThemAll
        • Lets you download all the links or images contained in a webpage directly or via advanced filters

      • Gmail Space
        • This extension allows you to use your Gmail Space (2 GB) for file storage. It acts as a remote machine.

    • Editing and Forms
    • Entertainment
    • Humor
    • Image Browsing
    • Kiosk Browsing
    • Languages
    • Message Reading
    • Miscellaneous
    • Navigation
    • News Reading
    • Privacy and Security
      • Adblock Plus/Adblock Filterset.G
        • Block annoying banner ads and other distracting page elements in a few clicks and automated updates of the latest filter lists

      • SwitchProxy Tool
        • lets you manage and switch between multiple proxy configurations quickly and easily, also acts as an anonymizer

      • CustomizeGoogle
        • Enhance Google search results by adding extra information (like links to Yahoo, Ask.com, MSN etc) and removing unwanted information (like ads and spam).

      • NoScript
        • NoScript allows JavaScript, Java and other executable content only for trusted domains of your choice, e.g. your home-banking web site.

      • DiggiDig
        • Adds a menu button next to the address bar with actions relevant to the current URL, for example to step out to the parent directory, or to visit the equivalent ftp URL, or to visit the site in archive.org and more

    • Search Tools
      • Free eBook Search
        • Search with the highlighted text for your favorite free ebooks in www.freebookzone.com by title, author, description, ISBN and other terms

      • Hyperwords
        • Click on text for searches, references, email, blogging, translation, shopping, maps & more

      • Cache View
        • Displays Google’s Cache, Coral’s Cache, Wayback Machine’s Cache, Dot Cache, and Tech Guru’s Cache of the current tab open via right-click or Tools menu

      • Enhanced History Manager
        • Flexible history management

      • Enhanced Bookmark Search
        • Search by Title, Location, description or keyword including more subsets
          (contains, starts/ends with, is/is not, doesn’t contain)

      • GooglePedia
        • Shows you a relevant Wikipedia article along with your search results. Clicking links in the article will trigger new Google searches; a very useful research tool.

      • Google Advanced Operations Toolbar
        • This toolbar provides a shortcut to some of Google’s advanced search functions

    • Tabbed Browsing
      • Tab Mix Plus
        • Includes such features as duplicating tabs, controlling tab focus, tab clicking options, undo closed tabs and windows, restoring tabs after a crash and more

      • Sage RSS Reader
        • Sage is a lightweight RSS and Atom feed aggregator extension for Mozilla Firefox

      • Sidebar on Right
        • Moves sidebar to the right side of the browser

      • Firefox Showcase
        • Showcase provides a new way to manage your Firefox tabs and windows by showing them as thumbnails in a single window, tab or sidebar

    • Web Annoyances
    • Website Integration
    • XUL Applications
    • Miscellaneous Extensions
      • ForecastFox
        • Get international weather forecasts from AccuWeather.com, and display it in any toolbar or statusbar with this highly customizable extension.

      • Blogger Web Comments
        • Makes it easy to see what bloggers are saying about a web page you’re viewing in Firefox and even write your own blog post about it, all without leaving the page itself.

      • FasterFox
        • Allows you to tweak many network and rendering settings such as simultaneous connections, pipelining, cache, DNS cache, and initial paint delay.

      • Shazou
        • Enables the user with one-ckick to map and geo-locate any website they are currently viewing.

    What is in Firefox 2.0 and Beyond

    • Visual changes to the Firefox interface
    • Built-in phishing protection
    • Enhanced search capabilities
    • Improved tabbed browsing
    • Resuming your browsing session
    • Previewing and subscribing to Web feeds
    • Inline spell checking
    • Live Titles
    • Improved Add-ons manager
    • JavaScript 1.7
    • Extended search plugin format
    • Updates to the extension system
    • Client-side session and persistent storage
    • SVG text
    • New Windows installer

    All of the information here was taken from a pair of Impress presentations that David had made for the presentation.

    The next meeting is scheduled for January 4th at 7PM at NFA. At this meeting Dave is going to be doing a presentation on Bash. The pre-meeting dinner will most likely be at Dillans in Norwich starting at 6PM.

    NASlite Boot Disk

    I was playing with NASlite the other day and could not create the boot disk by the method explained on their web site. The bootable disk is a 1722k disk. After some digging I found some something that worked. Note: This was only tested on Ubuntu 6.06.

    setfdprm /dev/fd0 1722/1440
    fdformat -n /dev/fd0
    dd if="image name here" of=/dev/fd0

    OpenVPN Setup (Updated 11/02/2006)

    I had two machines that I needed to install OpenVPN on yesterday, so I figured I would post the steps required to get them up and running. The servers where both running Ubuntu 6.06.

    Here are the quick and dirty steps:
    sudo apt-get install openvpn openssl

    cd /usr/share/doc/openvpn/examples
    sudo cp -R easy-rsa/ /etc/openvpn

    cd /etc/openvpn/easy-rsa
    sudo . ./vars
    sudo ./clean-all
    sudo ./build-ca
    Answer the questions to create the key

    Now we need to create the server key:
    sudo ./build-key-server server
    Again answer the questions to customize the key. You can use the defaults if you want and just enter the server name when asked. The name is required, if you do not enter a name the key will be a zero length and will not work. The error message if not all that straight forward, it only says the server failed to start.

    Now we need to create the client keys:
    sudo ./build-key 'name of key'
    Again answer the questions to customize the key. You can use the defaults if you want and just enter the computer name when asked. I like to use the name of the computer the key is for, because it makes it easier to keep track of the keys if you need to remove one. The name is required, if you do not enter a name the key will be a zero length and will not work. The error message if not all that straight forward, it only says the server failed to start.

    Now we create the Diffie-Hellman parameters:
    sudo ./build-dh

    When we pass the keys to the clients we need to distribute the following keys to each client:
    ca.crt goes to the client and the server.
    ca.key goes to the key signing machine only, which we set this on to be.
    dh{n}.pem goes to the server only.
    server.crt goes to the server only.
    server.key goes to the server only.
    .crt goes to the client only.
    .key goes to the client only.

    The last thing to do on the server is create the configuration file: (view sample)
    sudo vi /etc/openvpn/server.conf

    Restart the service and the server is done.
    sudo /etc/init.d/openvpn restart

    Next we have to create the configuration file for the client: (view sample)
    This file needs to be saved in the same directory as the keys. On windows the configuration file should be saved with a .ovpn extension. Just double-click this file to establish the connection. Establish the connection on *nix or Windows run openvpn [client config file]. With a little luck you should be connected now.

    VMware Server Setup

    After another night of getting called do to server failure, I have decided make some changes to the servers at work. Currently we have two Windows 2000 servers that are running most of the company. The basic problem is that one program, Track-It!, started to generate error and took down the server it was running on. It is installed on the Primary Domain controller, yes I know that is a bad idea, which in turn took the Backup Domain controller down. So when you only have two servers, that is the whole show. This is the problem with only having two servers, they both wear too many hats.

    The end result of all of this is that we were going to upgrade to Windows 2003 EE R2 during the July shutdown. This version allows you to run up to four virtual servers on one server. So now we are testing using VMware Server on ubuntu, with all the Windows servers running as virtual machines on top. If this works out good, we will look at maybe moving to VMware ESX next year, because it just is not in the budget for this year. I still have to workout how the backups are going to run. Right now I am looking at the Amanda Enterprise Edition backup software. This will also have to be tested before we put everything in place. I have been using ubuntu on my home server, which does get almost as much use as some of the servers at work, without ever having a crash.

    Hardware:
    Dell Poweredge 4400
    Dual Processer 2.2 GHz
    5 GB of memory

    Server 1 will be running 4 Windows 2003 EE servers.
    Server 2 will be running 1 Windows 2003 EE server, 1 Netware 3.12 server and 2 Windows XP desktops.

    Server Setup:
    Install ubuntu server on the hardware.
    Edit the source list for apt to enable all the software repositories.

    Install the other needed packages:
    sudo apt-get update
    sudo apt-get install linux-686 linux-headers-686 linux-image-686
    sudo apt-get install build-essential gcc g++ make fakeroot xinetd libdb2
    sudo apt-get samba openvpn x-window-system-core
    sudo apt-get dist-upgrade

    Download the vmware-server.tar.gz and copy to the /tmp directory
    Extract it tar -zxf vmware-server.tar.gz
    Move to the vmware-server-distrib directory and run ./vmware-install.pl

    This is all for getting the base server going.

    Bad Idea, Happy Ending

    I have been using Linux for almost two years now, however two weeks ago I became frustrated with some of the shortcomings of Linux. I formated my notebook and installed Windows XP on it. I develop software for several companies, so there are lots of tools and applications that need to be installed. After two days everything was installed and I was back in business. I took a total of three days of using Windows again to remember why I quit using it full time in the first place. It really does suck. Between to constant array of blue screens, lockups and other stupid problems. I always love it when you have two programs that just can not be installed on the same program. It didn’t take long for me to be back on Linux. So I am happily back on Ubuntu Dapper Drake.

    One of the first things I did after getting back on Ubuntu was to get the NetworkManager working. This is used for configuring wireless networks and works almost as good as the wireless ability in Windows. It also supports both WEP and WPA without any extra configuration. The steps to install NetworkManager are:

    sudo apt-get install network-manager-gnome
    sudo gtk-update-icon-cache -f /usr/share/icons/hicolor/
    sudo cp /etc/network/interfaces /etc/network/interfaces.back

    Edit the file interfaces so only the following lines are left:
    # The loopback network interface
    auto lo
    iface lo inet loopback

    Then a quick reboot and you should be ready to go. If you are using KDE then you can install network-manager-kde. If you do not edit the interfaces file then NetworkManager will not be able to control the nic cards.
    sudo vi /etc