2010-05-24

Compiling resource files with Visual Studio Express

If you pick a Visual Studio project with an MFC GUI app, and try to compile it with Visual Studio Express, you should run into the error:
fatal error RC1050: Cannot open include file 'afxres.h'.
The solution? Replace your:
#include "afxres.h"
from your .rc file with the following:
#include <windows.h>
#define IDC_STATIC -1

2010-05-14

running XP inside qemu on Windows

  • Compiled qemu from source using MinGW32/Msys (hint: add the "target-list=i386-softmmu" so that you only compile the target of interest to you). Haven't figured out how to get a Ctrl-Alt-2 that actually works yet...
  • Installed UltraVNC
  • Copied the qemu exec from i386-softmmu to pc-bios and ran everything from pc-bios
  • Created HDD image (with qemu-img)
  • Default of qemu on IPV6 system is to use IPV6 which makes the VNC connection unavailable - need to provide IPv4 address to -vnc option, and thus, from the pc-bios directory:
    qemu -usb -vnc 127.0.0.1:0 -hda winxp.img -m 512 -localtime -net user -net nic,model=rtl8139  -cdrom //./d:
  • Connected through UltraVNC viewer with "localhost::5900" and installed XP
  • First thing to do once XP is installed is to disable mouse acceleration by disabling "Enhance Pointer Precision" in Mouse Properties -> Pointer Options

2010-04-20

unresolved external symbol CLSID_FileOpenDialog

error LNK2001: unresolved external symbol IID_IFileOpenDialog
error LNK2001: unresolved external symbol CLSID_FileOpenDialog
You're missing uuid.lib.

2010-04-06

Launching the device manager in one click

A few of us need to have quick access to the device manager always, and while things have improved on Windows 7, we're still not there with regards to one click access. The solution:
C:\Windows\system32\mmc.exe C:\Windows\system32\devmgmt.msc

2010-03-24

Windows UAC and bash's "Bad File Number" error

Today's problem: trying to run a freshly compiled setup_driver.exe from MSYS/MinGW produces the following:
sh: ./setup_driver.exe: Bad file number
The reason: Microsoft's implementation of UAC will try to give a free pass to any application that has "setup" in its name, and run it in elevated mode (after asking for confirmation).
This doesn't fare well with most shells running on Windows, as they don't know how to call the UAC elevation process, and you get the error above.

Rename your application to something that does not contain "setup" and your problem is gone.
Also applies to variations of "install" in your name.

Dynamically building headers with automake / autotools

Say part of your build process is meant to generate a custom include file, eg. resource.h, built from embedded resources and you want to ensure that this header is always built before the rest.

The trick then is to add
BUILT_SOURCES = resource.h
in your Makefile/Makefile.am as all files mentioned as BUILT_SOURCES will be built before any of the normal compilation rules run.

This is what we do in WDI (Windows Driver Installer) for libusb 1.0 with a Makefile.am that looks like:
BUILT_SOURCES = resource.h
lib_LTLIBRARIES = libusb-wdi.la

LIB_SRC = resource.h infs.h usbi.h installer.h installer_library.h installer_library.c

libusb_wdi_la_CFLAGS = $(VISIBILITY_CFLAGS) $(AM_CFLAGS) -L../../libusb/libusb/.libs -lusb-1.0 
libusb_wdi_la_SOURCES = $(LIB_SRC)

resource.h:
    ../embedder/embedder.exe resource.h

clean-local:
    -rm -rf resource.h

2010-03-18

Removing trailing whitespaces in Visual Studio

The following will remove trailing whitespaces whenever you save a file in Visual Studio 2008. Convenient!
  1. Go to Tools -> Macros -> Macro Explorer
  2. Double click "MyMacros -> Module1
  3. In the new Project Explorer Tree, double click on "EnvironmentEvents" above "Module1"
  4. After the #End Region for #Region "Automatically generated code, do not modify", add the following:
    Private saved As Boolean = False
        Private Sub DocumentEvents_DocumentSaved(ByVal document As EnvDTE.Document) _
                                                 Handles DocumentEvents.DocumentSaved
            If Not saved Then
                Try
                    ' Remove all the trailing whitespaces.
                    DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _
                                         "{:Zs|\t}+$", _
                                         vsFindOptions.vsFindOptionsRegularExpression, _
                                         String.Empty, _
                                         vsFindTarget.vsFindTargetCurrentDocument, , , _
                                         vsFindResultsLocation.vsFindResultsNone)
    
                    saved = True
                    document.Save()
                Catch ex As Exception
                    MsgBox(ex.Message, MsgBoxStyle.OkOnly, "Trim White Space exception")
                End Try
            Else
                saved = False
            End If
        End Sub

2010-03-08

A service installation section in this inf is invalid

If you've been banging your head against the wall on this error, and you are trying to install a 64 bit driver on Windows 7 x64 or Windows Vista x64, the problem might simply be due to the ServiceBinary property of your inf file referencing the 32 bit driver (.sys) rather than the 64 bit.

Make sure then that you have something like:
ServiceBinary = %12%\mydriver_x64.sys
and try again. Might work better this time around.

2010-01-26

ERROR: "usb_mon_register" [drivers/usb/mon/usbmon.ko] undefined!

If you are getting this kind error in Linux when recompiling a kernel module, it usually means that your kernel configuration and the actual configuration used to compile your last kernel are out of sync.

This usually gets resolved by recompiling your kernel, and then (if needed) by recompiling your modules again. Of course, you will need to be running the new kernel for the modules to work.