[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).

svn path=/trunk/; revision=51813
This commit is contained in:
Eric Kohl 2011-05-17 19:24:19 +00:00
parent 1ba6d6e079
commit 5adfc1c07b
12 changed files with 344 additions and 0 deletions

View file

@ -49,6 +49,7 @@ set(baseaddress_dinput 0x5f580000)
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)

View file

@ -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" />

View file

@ -357,6 +357,7 @@ dll\win32\msimtf\msimtf.dll 1
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

View file

@ -99,6 +99,7 @@ add_subdirectory(msimtf)
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)

View file

@ -0,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)

View file

@ -0,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 */

View file

@ -0,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 */

View file

@ -0,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>

View file

@ -0,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>

View file

@ -0,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

View file

@ -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>

Binary file not shown.