15

I have installed, apparently successfully, com0com v2.2.2.0 on a 64bit Windows 7 machine.

I run the command utility, like this:

command> install PortName=COM9 PortName=COM8
       CNCA0 PortName=COM9
       CNCB0 PortName=COM8
ComDB: COM8 - logged as "in use"
ComDB: COM9 - logged as "in use"

command> busynames COM?*
COM3
COM4
COM5
COM6
COM8
COM9
COMPOSITEBATTERY

Note: logged as "in use" is NOT an error message?

Then I try to open COM8 like this

m_hIDComDev = CreateFileA( szCodedPort, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL );
if( m_hIDComDev == NULL  || m_hIDComDev == INVALID_HANDLE_VALUE ) {

    wchar_t * lpMsgBuf;
    DWORD dw = ::GetLastError(); 
    FormatMessage(
        FORMAT_MESSAGE_ALLOCATE_BUFFER | 
        FORMAT_MESSAGE_FROM_SYSTEM |
        FORMAT_MESSAGE_IGNORE_INSERTS,
        NULL,
        dw,
        MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
        (LPTSTR) &lpMsgBuf,
        0, NULL );

    myErrorMsg = (char*)malloc( 200 );
    sprintf(myErrorMsg,"Error creating connection %s ( %s ) %S",
        szPort,szCodedPort,lpMsgBuf);

This fails with

Error creating connection COM8 ( COM8 ) The system cannot find the file specified.

I have tried both "COM8" and "\\.\COM8".

Note that the exact same call to CreateFileA works perfectly on a 'real' COM port.

Q: Can someone tell me what the problem is?

A: On windows 7 64 bit you have to enable testing of unsigned drivers.

  • Run a command prompt as administrator. ( It is not enough just to run from an account with admin privileges. See here for details of how to do this. )

  • Type in the command bcdedit -set TESTSIGNING ON

  • reboot. ( Windows will place a "test Mode" note on the bottom right of the desktop )

For Windows 8 this method does not work satisfactorily or easily. Here is some discussion of the issues and workarounds.

Alternatively you might want to try a signed version - I have NOT tried this myself.

ravenspoint
  • 19,093
  • 6
  • 57
  • 103
  • 1
    It shows `COM8 - logged as "in use"` - that is likely your problem. – Jonathon Reinhart Jan 07 '12 at 20:36
  • @Jonathon Reinhart Are you familiar with com0com? The "in use" message, according to hints in the documentation, implies only that these COM ports have been assigned by the com0com driver and will therefore not be assigned again. If the OS thought they were busy, it would give me a different error. AFAIK! – ravenspoint Jan 07 '12 at 22:40
  • 1
    "In use" is normally an error message. Nice about open source, you can read the code to see what it is actually supposed to mean. – Hans Passant Jan 07 '12 at 22:51
  • Yes, I have used com0com, but was accessing it with C#. Sorry I can't be of more help. – Jonathon Reinhart Jan 07 '12 at 22:59
  • @Hans Passant OK, what is causing the error? – ravenspoint Jan 07 '12 at 23:15
  • Why are you explicitly calling the ANSI version of the `CreateFile` function? Hans is telling you to look at the source code for the com0com project to see what the error message you're getting means. The problem obviously lies there if calling `CreateFile` works for a "real" COM port, as you say. – Cody Gray - on strike Jan 08 '12 at 03:57

3 Answers3

19

In case anyone is referencing this, and interested in this topic, the 2.2.2.0 version of com0com is signed for 64-bit Windows. This removes the need to jump through the hoops of putting Windows in "test" mode.

  • 2
    The 3.0.0.0 version **does** **not** **work** on Windows 7 64Bit. 2.2.2.0 works perfectly. – Zac Nov 12 '14 at 10:40
  • 1
    There's no Changes.txt in the 3.0.0.0 folder on SourceForge. Does anyone know what changed between 2.2.2.0 and 3.0.0.0? – DaAwesomeP Jan 19 '15 at 17:37
9

Here are my points:

  • Microsoft requires 64-bit drivers to be signed.
  • com0com.sys (64bit) is a mere unsigned kernel-mode driver.

SoftWx has written an interesting tutorial on installing it on a 64 bit Windows 7 machine. You can fetch it here.

menjaraz
  • 7,551
  • 4
  • 41
  • 81
  • Thanks. This pointed me in the right direction. The trick is to run bcdedit from a commend prompt started 'as administrator'. It is not enough just to run from an account with administrator privileges. – ravenspoint Jan 09 '12 at 14:13
  • The only problem with this solution is that Windows must be in test mode in order for the driver to work. Once you reboot, you will not be able to use it anymore. This solution is not permanent, and I don't want to leave my computer in driver test mode all the time (it poses a security risk). – DaAwesomeP Jan 19 '15 at 17:42
1

This is a very old post, but just to add some help if somebody stumbles across it like I did.

After Windows 10 Version 2004 you may need to disable Secure Boot in your BIOS.

I got a signed version 3.0 of the app from SourceForge, this worked perfectly on my one PC (Windows 10 Pro Version 2004). I just installed the app and two pairs of linked ports were immediately created.

On my laptop (Windows 10 Pro Version 20H2), I did not get the same results. No COM ports were created and in the device manager the devices could not be configured. After changing the BIOS setting, I reinstalled and all went smoothly.

Links for reference:

https://sourceforge.net/projects/com0com/

https://sourceforge.net/projects/signed-drivers/files/com0com/v3.0/

To answer @DaAwesomeP above (I do not have the rep to put it in the comments), there is a repo on GitHub https://github.com/paulakg4/com0com where I can see a changes.txt. If I compare the dates, it looks like the same version 3.0 in there.

JannesH
  • 33
  • 1
  • 1
  • 8