Author: hbelusca
Date: Thu Sep 25 23:44:28 2014
New Revision: 64292
URL:
http://svn.reactos.org/svn/reactos?rev=64292&view=rev
Log:
[UMPNPMGR]
- Turn the user-mode PnP Manager into a dll, as it is in Windows. However, on Windows
2k/XP/2k3, the dll is managed by services.exe (the SC Manager) (and its entry point name
hardcoded in it), whereas on Vista/7+ it is managed by svchost.exe . Since we do not
support external dll hardcoded services management in services.exe, make it
svchost-compatible instead.
- In the .spec file, we mention that a few API set is exported (in stdcall), but we use it
also for RPC, and therefore one has to fix somewhere the calling conventions.
- Add/modify the registry entries accordingly.
Added:
trunk/reactos/base/services/umpnpmgr/umpnpmgr.spec (with props)
Modified:
trunk/reactos/base/services/umpnpmgr/CMakeLists.txt
trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
trunk/reactos/base/services/umpnpmgr/umpnpmgr.rc
trunk/reactos/boot/bootdata/hivesft.inf
trunk/reactos/boot/bootdata/hivesys.inf
Modified: trunk/reactos/base/services/umpnpmgr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/CMa…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/CMakeLists.txt [iso-8859-1] Thu Sep 25 23:44:28
2014
@@ -3,16 +3,19 @@
add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/pnp.idl)
+spec2def(umpnpmgr.dll umpnpmgr.spec ADD_IMPORTLIB)
-add_executable(umpnpmgr
+add_library(umpnpmgr SHARED
umpnpmgr.c
umpnpmgr.rc
- ${CMAKE_CURRENT_BINARY_DIR}/pnp_s.c)
+ ${CMAKE_CURRENT_BINARY_DIR}/pnp_s.c
+ ${CMAKE_CURRENT_BINARY_DIR}/umpnpmgr_stubs.c
+ ${CMAKE_CURRENT_BINARY_DIR}/umpnpmgr.def)
target_link_libraries(umpnpmgr
wdmguid
${PSEH_LIB})
-set_module_type(umpnpmgr win32cui UNICODE)
+set_module_type(umpnpmgr win32dll UNICODE)
add_importlibs(umpnpmgr advapi32 rpcrt4 userenv shlwapi msvcrt kernel32 ntdll)
add_cd_file(TARGET umpnpmgr DESTINATION reactos/system32 FOR all)
Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/ump…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.c [iso-8859-1] Thu Sep 25 23:44:28 2014
@@ -27,6 +27,7 @@
*/
/* INCLUDES *****************************************************************/
+
//#define HAVE_SLIST_ENTRY_IMPLEMENTED
#define WIN32_NO_STATUS
#define _INC_WINDOWS
@@ -52,13 +53,7 @@
/* GLOBALS ******************************************************************/
-static VOID CALLBACK ServiceMain(DWORD argc, LPWSTR *argv);
static WCHAR ServiceName[] = L"PlugPlay";
-static SERVICE_TABLE_ENTRYW ServiceTable[] =
-{
- {ServiceName, ServiceMain},
- {NULL, NULL}
-};
static SERVICE_STATUS_HANDLE ServiceStatusHandle;
static SERVICE_STATUS ServiceStatus;
@@ -102,7 +97,7 @@
DPRINT("RpcServerThread() called\n");
#if 0
- /* XP-compatible protocol sequence/endpoint */
+ /* 2k/XP/2k3-compatible protocol sequence/endpoint */
Status = RpcServerUseProtseqEpW(L"ncacn_np",
20,
L"\\pipe\\ntsvcs",
@@ -113,7 +108,7 @@
DPRINT1("RpcServerUseProtseqEpW() failed (Status %lx)\n", Status);
#endif
- /* Vista-compatible protocol sequence/endpoint */
+ /* Vista/7-compatible protocol sequence/endpoint */
Status = RpcServerUseProtseqEpW(L"ncacn_np",
20,
L"\\pipe\\plugplay",
@@ -1333,7 +1328,7 @@
}
}
-done:;
+done:
if (ret == CR_SUCCESS)
*pulTransferLen = *pulLength;
@@ -1438,7 +1433,7 @@
ret = CR_REGISTRY_ERROR;
}
-done:;
+done:
if (hPropKey != NULL)
RegCloseKey(hPropKey);
@@ -2642,7 +2637,7 @@
}
}
-done:;
+done:
if (ret == CR_SUCCESS)
*pulTransferLen = *pulLength;
@@ -2792,7 +2787,9 @@
/* Function 73 */
DWORD PNP_SetActiveService(
- handle_t hBinding)
+ handle_t hBinding,
+ LPWSTR pszFilter,
+ DWORD ulFlags)
{
UNIMPLEMENTED;
return CR_CALL_NOT_IMPLEMENTED;
@@ -3309,7 +3306,7 @@
}
-static VOID CALLBACK
+VOID WINAPI
ServiceMain(DWORD argc, LPTSTR *argv)
{
HANDLE hThread;
@@ -3363,22 +3360,18 @@
DPRINT("ServiceMain() done\n");
}
-
-int
-wmain(int argc, WCHAR *argv[])
+static DWORD
+InitializePnPManager(VOID)
{
BOOLEAN OldValue;
DWORD dwError;
- UNREFERENCED_PARAMETER(argc);
- UNREFERENCED_PARAMETER(argv);
-
- DPRINT("Umpnpmgr: main() started\n");
+ DPRINT("UMPNPMGR: InitializePnPManager() started\n");
/* We need this privilege for using CreateProcessAsUserW */
RtlAdjustPrivilege(SE_ASSIGNPRIMARYTOKEN_PRIVILEGE, TRUE, FALSE, &OldValue);
- hInstallEvent = CreateEvent(NULL, TRUE, SetupIsActive()/*FALSE*/, NULL);
+ hInstallEvent = CreateEventW(NULL, TRUE, SetupIsActive()/*FALSE*/, NULL);
if (hInstallEvent == NULL)
{
dwError = GetLastError();
@@ -3386,7 +3379,7 @@
return dwError;
}
- hDeviceInstallListNotEmpty = CreateEvent(NULL, FALSE, FALSE, NULL);
+ hDeviceInstallListNotEmpty = CreateEventW(NULL, FALSE, FALSE, NULL);
if (hDeviceInstallListNotEmpty == NULL)
{
dwError = GetLastError();
@@ -3433,13 +3426,28 @@
return dwError;
}
- StartServiceCtrlDispatcher(ServiceTable);
-
- DPRINT("Umpnpmgr: main() done\n");
-
- ExitThread(0);
+ DPRINT("UMPNPMGR: InitializePnPManager() done\n");
return 0;
}
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ DisableThreadLibraryCalls(hinstDLL);
+ InitializePnPManager();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+
+ return TRUE;
+}
+
/* EOF */
Modified: trunk/reactos/base/services/umpnpmgr/umpnpmgr.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/ump…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.rc [iso-8859-1] (original)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.rc [iso-8859-1] Thu Sep 25 23:44:28
2014
@@ -1,4 +1,5 @@
-#define REACTOS_STR_FILE_DESCRIPTION "User-Mode Plug and Play manager"
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "User-Mode Plug and Play Manager"
#define REACTOS_STR_INTERNAL_NAME "Umpnpmgr"
-#define REACTOS_STR_ORIGINAL_FILENAME "Umpnpmgr.exe"
+#define REACTOS_STR_ORIGINAL_FILENAME "umpnpmgr.dll"
#include <reactos/version.rc>
Added: trunk/reactos/base/services/umpnpmgr/umpnpmgr.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/umpnpmgr/ump…
==============================================================================
--- trunk/reactos/base/services/umpnpmgr/umpnpmgr.spec (added)
+++ trunk/reactos/base/services/umpnpmgr/umpnpmgr.spec [iso-8859-1] Thu Sep 25 23:44:28
2014
@@ -0,0 +1,15 @@
+@ stub DeleteServicePlugPlayRegKeys
+
+;;; FIXME: Windows UMPNPMGR exports those APIs.
+;;; Fix their calling convention before enabling these exports!!
+
+;@ stdcall PNP_GetDeviceList(long ptr ptr ptr long)
+;@ stdcall PNP_GetDeviceListSize(long ptr ptr long)
+;@ stdcall PNP_GetDeviceRegProp(long ptr long ptr ptr ptr ptr long)
+;@ stdcall PNP_HwProfFlags(long long ptr long ptr ptr ptr long long)
+;@ stdcall PNP_SetActiveService(long ptr long)
+
+@ stub RegisterScmCallback
+@ stub RegisterServiceNotification
+@ stdcall ServiceMain(long ptr) ;; If using SvcHost.exe (Vista+)
+;@ stdcall SvcEntry_PlugPlay(long long long long) ;; If using services.exe (<= 2k3)
Propchange: trunk/reactos/base/services/umpnpmgr/umpnpmgr.spec
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] Thu Sep 25 23:44:28 2014
@@ -1588,7 +1588,8 @@
; SvcHost services
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",,0x00000012
-HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\SvcHost",
"netsvcs",0x00010000,"DHCP","BITS"
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\SvcHost","DcomLaunch",0x00010000,"PlugPlay"
+HKLM,"SOFTWARE\Microsoft\Windows
NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"DHCP","BITS"
; Win32 config
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows",,0x00000012
Modified: trunk/reactos/boot/bootdata/hivesys.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesys.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesys.inf [iso-8859-1] Thu Sep 25 23:44:28 2014
@@ -1841,12 +1841,13 @@
; Plug and Play manager
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","DisplayName",0x00000000,"Plug
and Play"
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Description",0x00000000,"Detects
hardware changes and installs needed software if possible"
-HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ErrorControl",0x00010001,0x00000000
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ErrorControl",0x00010001,0x00000001
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Group",0x00000000,"PlugPlay"
-HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ImagePath",0x00020000,"%SystemRoot%\system32\umpnpmgr.exe"
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ImagePath",0x00020000,"%SystemRoot%\system32\svchost.exe
-k DcomLaunch"
HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","ObjectName",0x00000000,"LocalSystem"
-HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Start",0x00010001,0x00000004
-HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Type",0x00010001,0x00000010
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Start",0x00010001,0x00000002
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay","Type",0x00010001,0x00000020
+HKLM,"SYSTEM\CurrentControlSet\Services\PlugPlay\Parameters","ServiceDll",0x00020000,"%SystemRoot%\system32\umpnpmgr.dll"
; RPC service
HKLM,"SYSTEM\CurrentControlSet\Services\Rpcss","DisplayName",0x00000000,"Remote
Procedure Call"