The source code for msports is already available in the DDK.
--
Best regards,
Alex Ionescu
On 2011-05-17, at 3:24 PM, ekohl(a)svn.reactos.org wrote:
  Author: ekohl
 Date: Tue May 17 19:24:19 2011
 New Revision: 51813
 URL: 
http://svn.reactos.org/svn/reactos?rev=51813&view=rev
 Log:
 [MSPORTS]
 - Implement a simple class installer that assigns the friendly name "Serial Port
(COMx)" to all serial ports.
 - Enable the class installer in ports.inf.
 - Add parallel port installer configuration to ports.inf (disabled).
 Added:
    trunk/reactos/dll/win32/msports/   (with props)
    trunk/reactos/dll/win32/msports/CMakeLists.txt   (with props)
    trunk/reactos/dll/win32/msports/classinst.c   (with props)
    trunk/reactos/dll/win32/msports/msports.c   (with props)
    trunk/reactos/dll/win32/msports/msports.rbuild   (with props)
    trunk/reactos/dll/win32/msports/msports.rc   (with props)
    trunk/reactos/dll/win32/msports/msports.spec   (with props)
 Modified:
    trunk/reactos/baseaddress.cmake
    trunk/reactos/baseaddress.rbuild
    trunk/reactos/boot/bootdata/packages/reactos.dff
    trunk/reactos/dll/win32/CMakeLists.txt
    trunk/reactos/dll/win32/win32.rbuild
    trunk/reactos/media/inf/ports.inf
 Modified: trunk/reactos/baseaddress.cmake
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/baseaddress.cmake?rev=5181…
 ==============================================================================
 --- trunk/reactos/baseaddress.cmake [iso-8859-1] (original)
 +++ trunk/reactos/baseaddress.cmake [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -49,6 +49,7 @@
 set(baseaddress_netid                  0x5f660000)
 set(baseaddress_ntprint                        0x5f6a0000)
 set(baseaddress_mssip32                        0x60430000)
 +set(baseaddress_msports                       0x60450000)
 set(baseaddress_msisip                 0x60b10000)
 set(baseaddress_inseng                 0x61000000)
 set(baseaddress_qedit                  0x611c0000)
 Modified: trunk/reactos/baseaddress.rbuild
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/baseaddress.rbuild?rev=518…
 ==============================================================================
 --- trunk/reactos/baseaddress.rbuild [iso-8859-1] (original)
 +++ trunk/reactos/baseaddress.rbuild [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -52,6 +52,7 @@
        <property name="BASEADDRESS_NETID"
value="0x5f660000" />
        <property name="BASEADDRESS_NTPRINT"
value="0x5f6a0000" />
        <property name="BASEADDRESS_MSSIP32"
value="0x60430000" />
 +      <property name="BASEADDRESS_MSPORTS"
value="0x60450000" />
        <property name="BASEADDRESS_MSISIP"
value="0x60b10000" />
        <property name="BASEADDRESS_INSENG"
value="0x61000000" />
        <property name="BASEADDRESS_QEDIT"
value="0x611c0000" />
 Modified: trunk/reactos/boot/bootdata/packages/reactos.dff
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
 ==============================================================================
 --- trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] (original)
 +++ trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] Tue May 17 19:24:19
2011
 @@ -357,6 +357,7 @@
 dll\win32\msisip\msisip.dll                         1
 dll\win32\msisys.ocx\msisys.ocx                     1
 dll\win32\msnet32\msnet32.dll                       1
 +dll\win32\msports\msports.dll                       1
 dll\win32\msrle32\msrle32.dll                       1
 dll\win32\mssign32\mssign32.dll                     1
 dll\win32\mssip32\mssip32.dll                       1
 Modified: trunk/reactos/dll/win32/CMakeLists.txt
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/CMakeLists.txt?r…
 ==============================================================================
 --- trunk/reactos/dll/win32/CMakeLists.txt [iso-8859-1] (original)
 +++ trunk/reactos/dll/win32/CMakeLists.txt [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -99,6 +99,7 @@
 add_subdirectory(msisip)
 add_subdirectory(msisys.ocx)
 #add_subdirectory(msnet32) #to be deleted in trunk.
 +add_subdirectory(msports)
 add_subdirectory(msrle32)
 add_subdirectory(mssign32)
 add_subdirectory(mssip32)
 Propchange: trunk/reactos/dll/win32/msports/
 ------------------------------------------------------------------------------
 --- bugtraq:logregex (added)
 +++ bugtraq:logregex Tue May 17 19:24:19 2011
 @@ -1,0 +1,2 @@
 +([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
 +(\d+)
 Propchange: trunk/reactos/dll/win32/msports/
 ------------------------------------------------------------------------------
    bugtraq:message = See issue #%BUGID% for more details.
 Propchange: trunk/reactos/dll/win32/msports/
 ------------------------------------------------------------------------------
    bugtraq:url = 
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
 Propchange: trunk/reactos/dll/win32/msports/
 ------------------------------------------------------------------------------
    tsvn:logminsize = 10
 Added: trunk/reactos/dll/win32/msports/CMakeLists.txt
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/CMakeLis…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/CMakeLists.txt (added)
 +++ trunk/reactos/dll/win32/msports/CMakeLists.txt [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,24 @@
 +
 +set_unicode()
 +
 +spec2def(msports.dll msports.spec)
 +
 +list(APPEND SOURCE
 +    classinst.c
 +    msports.c
 +    parallel.c
 +    serial.c
 +    msports.rc
 +    ${CMAKE_CURRENT_BINARY_DIR}/msports_stubs.c
 +    ${CMAKE_CURRENT_BINARY_DIR}/msports.def)
 +
 +add_library(msports SHARED ${SOURCE})
 +
 +set_module_type(msports win32dll)
 +
 +target_link_libraries(msports wine)
 +
 +add_importlibs(msports comctl32 setupapi advapi32 user32 kernel32 ntdll)
 +
 +add_cd_file(TARGET msports DESTINATION reactos/system32 FOR all)
 +add_importlib_target(msports.spec)
 Propchange: trunk/reactos/dll/win32/msports/CMakeLists.txt
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/CMakeLists.txt
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Added: trunk/reactos/dll/win32/msports/classinst.c
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/classins…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/classinst.c (added)
 +++ trunk/reactos/dll/win32/msports/classinst.c [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,250 @@
 +/*
 + * PROJECT:     ReactOS system libraries
 + * LICENSE:     GPL - See COPYING in the top level directory
 + * FILE:        dlls\win32\msports\classinst.c
 + * PURPOSE:     Ports class installer
 + * PROGRAMMERS: Copyright 2011 Eric Kohl
 + */
 +
 +#include <windows.h>
 +#include <setupapi.h>
 +#include <wine/debug.h>
 +
 +WINE_DEFAULT_DEBUG_CHANNEL(msports);
 +
 +
 +typedef enum _PORT_TYPE
 +{
 +    UnknownPort,
 +    ParallelPort,
 +    SerialPort
 +} PORT_TYPE;
 +
 +
 +static DWORD
 +InstallSerialPort(IN HDEVINFO DeviceInfoSet,
 +                  IN PSP_DEVINFO_DATA DeviceInfoData)
 +{
 +    LPWSTR pszFriendlyName = L"Serial Port (COMx)";
 +
 +    TRACE("InstallSerialPort(%p, %p)\n",
 +          DeviceInfoSet, DeviceInfoData);
 +
 +    /* Install the device */
 +    if (!SetupDiInstallDevice(DeviceInfoSet,
 +                              DeviceInfoData))
 +    {
 +        return GetLastError();
 +    }
 +
 +    /* Set the friendly name for the device */
 +    SetupDiSetDeviceRegistryPropertyW(DeviceInfoSet,
 +                                      DeviceInfoData,
 +                                      SPDRP_FRIENDLYNAME,
 +                                      (LPBYTE)pszFriendlyName,
 +                                      (wcslen(pszFriendlyName) + 1) * sizeof(WCHAR));
 +
 +    return ERROR_SUCCESS;
 +}
 +
 +
 +static DWORD
 +InstallParallelPort(IN HDEVINFO DeviceInfoSet,
 +                    IN PSP_DEVINFO_DATA DeviceInfoData)
 +{
 +     FIXME("InstallParallelPort(%p, %p)\n",
 +           DeviceInfoSet, DeviceInfoData);
 +     return ERROR_DI_DO_DEFAULT;
 +}
 +
 +
 +VOID
 +InstallDeviceData(IN HDEVINFO DeviceInfoSet,
 +                  IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 +{
 +    HKEY hKey = NULL;
 +    HINF hInf = INVALID_HANDLE_VALUE;
 +    SP_DRVINFO_DATA DriverInfoData;
 +    PSP_DRVINFO_DETAIL_DATA DriverInfoDetailData;
 +    WCHAR InfSectionWithExt[256];
 +    BYTE buffer[2048];
 +    DWORD dwRequired;
 +
 +    TRACE("InstallDeviceData()\n");
 +
 +    hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet,
 +                                   DeviceInfoData,
 +                                   DICS_FLAG_GLOBAL,
 +                                   0,
 +                                   DIREG_DRV,
 +                                   NULL,
 +                                   NULL);
 +    if (hKey == NULL)
 +        goto done;
 +
 +    DriverInfoData.cbSize = sizeof(SP_DRVINFO_DATA);
 +    if (!SetupDiGetSelectedDriverW(DeviceInfoSet,
 +                                   DeviceInfoData,
 +                                   &DriverInfoData))
 +    {
 +        goto done;
 +    }
 +
 +    DriverInfoDetailData = (PSP_DRVINFO_DETAIL_DATA)buffer;
 +    DriverInfoDetailData->cbSize = sizeof(SP_DRVINFO_DETAIL_DATA);
 +    if (!SetupDiGetDriverInfoDetailW(DeviceInfoSet,
 +                                     DeviceInfoData,
 +                                     &DriverInfoData,
 +                                     DriverInfoDetailData,
 +                                     2048,
 +                                     &dwRequired))
 +    {
 +        if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
 +            goto done;
 +    }
 +
 +    TRACE("Inf file name: %S\n", DriverInfoDetailData->InfFileName);
 +
 +    hInf = SetupOpenInfFileW(DriverInfoDetailData->InfFileName,
 +                             NULL,
 +                             INF_STYLE_WIN4,
 +                             NULL);
 +    if (hInf == INVALID_HANDLE_VALUE)
 +        goto done;
 +
 +    TRACE("Section name: %S\n", DriverInfoDetailData->SectionName);
 +
 +    SetupDiGetActualSectionToInstallW(hInf,
 +                                      DriverInfoDetailData->SectionName,
 +                                      InfSectionWithExt,
 +                                      256,
 +                                      NULL,
 +                                      NULL);
 +
 +    TRACE("InfSectionWithExt: %S\n", InfSectionWithExt);
 +
 +    SetupInstallFromInfSectionW(NULL,
 +                                hInf,
 +                                InfSectionWithExt,
 +                                SPINST_REGISTRY,
 +                                hKey,
 +                                NULL,
 +                                0,
 +                                NULL,
 +                                NULL,
 +                                NULL,
 +                                NULL);
 +
 +    TRACE("Done\n");
 +
 +done:;
 +    if (hKey != NULL)
 +        RegCloseKey(hKey);
 +
 +    if (hInf != INVALID_HANDLE_VALUE)
 +        SetupCloseInfFile(hInf);
 +}
 +
 +
 +
 +PORT_TYPE
 +GetPortType(IN HDEVINFO DeviceInfoSet,
 +            IN PSP_DEVINFO_DATA DeviceInfoData)
 +{
 +    HKEY hKey = NULL;
 +    DWORD dwSize;
 +    DWORD dwType = 0;
 +    BYTE bData = 0;
 +    PORT_TYPE PortType = UnknownPort;
 +    LONG lError;
 +
 +    TRACE("GetPortType()\n");
 +
 +    hKey = SetupDiCreateDevRegKeyW(DeviceInfoSet,
 +                                   DeviceInfoData,
 +                                   DICS_FLAG_GLOBAL,
 +                                   0,
 +                                   DIREG_DRV,
 +                                   NULL,
 +                                   NULL);
 +    if (hKey == NULL)
 +    {
 +        goto done;
 +    }
 +
 +    dwSize = sizeof(BYTE);
 +    lError = RegQueryValueExW(hKey,
 +                              L"PortSubClass",
 +                              NULL,
 +                              &dwType,
 +                              &bData,
 +                              &dwSize);
 +
 +    TRACE("lError: %ld\n", lError);
 +    TRACE("dwSize: %lu\n", dwSize);
 +    TRACE("dwType: %lu\n", dwType);
 +
 +    if (lError == ERROR_SUCCESS &&
 +        dwSize == sizeof(BYTE) &&
 +        dwType == REG_BINARY)
 +    {
 +        if (bData == 0)
 +            PortType = ParallelPort;
 +        else
 +            PortType = SerialPort;
 +    }
 +
 +done:;
 +    if (hKey != NULL)
 +        RegCloseKey(hKey);
 +
 +    TRACE("GetPortType() returns %u \n", PortType);
 +
 +    return PortType;
 +}
 +
 +
 +static DWORD
 +InstallPort(IN HDEVINFO DeviceInfoSet,
 +            IN PSP_DEVINFO_DATA DeviceInfoData)
 +{
 +    PORT_TYPE PortType;
 +
 +    InstallDeviceData(DeviceInfoSet, DeviceInfoData);
 +
 +    PortType = GetPortType(DeviceInfoSet, DeviceInfoData);
 +    switch (PortType)
 +    {
 +        case ParallelPort:
 +            return InstallParallelPort(DeviceInfoSet, DeviceInfoData);
 +
 +        case SerialPort:
 +            return InstallSerialPort(DeviceInfoSet, DeviceInfoData);
 +
 +        default:
 +            return ERROR_DI_DO_DEFAULT;
 +    }
 +}
 +
 +
 +DWORD
 +WINAPI
 +PortsClassInstaller(IN DI_FUNCTION InstallFunction,
 +                    IN HDEVINFO DeviceInfoSet,
 +                    IN PSP_DEVINFO_DATA DeviceInfoData OPTIONAL)
 +{
 +    TRACE("PortsClassInstaller(%lu, %p, %p)\n",
 +          InstallFunction, DeviceInfoSet, DeviceInfoData);
 +
 +    switch (InstallFunction)
 +    {
 +        case DIF_INSTALLDEVICE:
 +            return InstallPort(DeviceInfoSet, DeviceInfoData);
 +
 +        default:
 +            TRACE("Install function %u ignored\n", InstallFunction);
 +            return ERROR_DI_DO_DEFAULT;
 +    }
 +}
 +
 +/* EOF */
 Propchange: trunk/reactos/dll/win32/msports/classinst.c
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/classinst.c
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Added: trunk/reactos/dll/win32/msports/msports.c
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/msports.…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/msports.c (added)
 +++ trunk/reactos/dll/win32/msports/msports.c [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,33 @@
 +/*
 + * PROJECT:     Ports installer library
 + * LICENSE:     GPL - See COPYING in the top level directory
 + * FILE:        dll/win32/msports/msports.c
 + * PURPOSE:     Library main function
 + * COPYRIGHT:   Copyright 2011 Eric Kohl
 + */
 +
 +#include <windows.h>
 +#include <wine/debug.h>
 +
 +
 +WINE_DEFAULT_DEBUG_CHANNEL(msports);
 +
 +
 +BOOL
 +WINAPI
 +DllMain(HINSTANCE hinstDll,
 +        DWORD dwReason,
 +        LPVOID reserved)
 +{
 +    switch (dwReason)
 +    {
 +        case DLL_PROCESS_ATTACH:
 +            TRACE("DLL_PROCESS_ATTACH\n");
 +            DisableThreadLibraryCalls(hinstDll);
 +            break;
 +    }
 +
 +    return TRUE;
 +}
 +
 +/* EOF */
 Propchange: trunk/reactos/dll/win32/msports/msports.c
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/msports.c
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Added: trunk/reactos/dll/win32/msports/msports.rbuild
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/msports.…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/msports.rbuild (added)
 +++ trunk/reactos/dll/win32/msports/msports.rbuild [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,11 @@
 +<module name="msports" type="win32dll"
baseaddress="${BASEADDRESS_MSPORTS}" installbase="system32"
installname="msports.dll" unicode="yes">
 +      <include base="msports">.</include>
 +      <importlibrary definition="msports.spec" />
 +      <library>wine</library>
 +      <library>kernel32</library>
 +      <library>advapi32</library>
 +      <library>setupapi</library>
 +      <file>classinst.c</file>
 +      <file>msports.c</file>
 +      <file>msports.rc</file>
 +</module>
 Propchange: trunk/reactos/dll/win32/msports/msports.rbuild
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/msports.rbuild
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Added: trunk/reactos/dll/win32/msports/msports.rc
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/msports.…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/msports.rc (added)
 +++ trunk/reactos/dll/win32/msports/msports.rc [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,7 @@
 +#include <windows.h>
 +
 +#define REACTOS_VERSION_DLL
 +#define REACTOS_STR_FILE_DESCRIPTION  "Ports Class Installer\0"
 +#define REACTOS_STR_INTERNAL_NAME     "msports\0"
 +#define REACTOS_STR_ORIGINAL_FILENAME "msports.dll\0"
 +#include <reactos/version.rc>
 Propchange: trunk/reactos/dll/win32/msports/msports.rc
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/msports.rc
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Added: trunk/reactos/dll/win32/msports/msports.spec
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msports/msports.…
 ==============================================================================
 --- trunk/reactos/dll/win32/msports/msports.spec (added)
 +++ trunk/reactos/dll/win32/msports/msports.spec [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -1,0 +1,12 @@
 +@ stub ComDBClaimNextFreePort
 +@ stub ComDBClaimPort
 +@ stub ComDBClose
 +@ stub ComDBGetCurrentPortUsage
 +@ stub ComDBOpen
 +@ stub ComDBReleasePort
 +@ stub ComDBResizeDatabase
 +@ stdcall LibMain(ptr long ptr) DllMain
 +@ stub ParallelPortPropPageProvider
 +@ stdcall PortsClassInstaller(long ptr ptr)
 +@ stub SerialDisplayAdvancedSettings
 +@ stub SerialPortPropPageProvider
 Propchange: trunk/reactos/dll/win32/msports/msports.spec
 ------------------------------------------------------------------------------
    svn:eol-style = native
 Propchange: trunk/reactos/dll/win32/msports/msports.spec
 ------------------------------------------------------------------------------
    svn:keywords = author date id revision
 Modified: trunk/reactos/dll/win32/win32.rbuild
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/win32.rbuild?rev…
 ==============================================================================
 --- trunk/reactos/dll/win32/win32.rbuild [iso-8859-1] (original)
 +++ trunk/reactos/dll/win32/win32.rbuild [iso-8859-1] Tue May 17 19:24:19 2011
 @@ -295,6 +295,9 @@
 <directory name="msnet32">
        <xi:include href="msnet32/msnet32.rbuild" />
 </directory>
 +<directory name="msports">
 +      <xi:include href="msports/msports.rbuild" />
 +</directory>
 <directory name="msrle32">
        <xi:include href="msrle32/msrle32.rbuild" />
 </directory>
 Modified: trunk/reactos/media/inf/ports.inf
 URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/media/inf/ports.inf?rev=51…
 ==============================================================================
 Binary files - no diff available.