qmgr: Implement DLL server registration.
This commit is contained in:
parent
9b478283c5
commit
313a903a85
|
@ -394,6 +394,7 @@ dlls/qedit/tests/qedit_crosstest.exe
|
||||||
dlls/qedit/tests/testlist.c
|
dlls/qedit/tests/testlist.c
|
||||||
dlls/qmgr/qmgr_local.h
|
dlls/qmgr/qmgr_local.h
|
||||||
dlls/qmgr/qmgr_local_i.c
|
dlls/qmgr/qmgr_local_i.c
|
||||||
|
dlls/qmgr/rsrc.res
|
||||||
dlls/qmgrprxy/qmgrprxy.h
|
dlls/qmgrprxy/qmgrprxy.h
|
||||||
dlls/qmgrprxy/qmgrprxy_i.c
|
dlls/qmgrprxy/qmgrprxy_i.c
|
||||||
dlls/qmgrprxy/qmgrprxy_p.c
|
dlls/qmgrprxy/qmgrprxy_p.c
|
||||||
|
|
|
@ -3,7 +3,7 @@ TOPOBJDIR = ../..
|
||||||
SRCDIR = @srcdir@
|
SRCDIR = @srcdir@
|
||||||
VPATH = @srcdir@
|
VPATH = @srcdir@
|
||||||
MODULE = qmgr.dll
|
MODULE = qmgr.dll
|
||||||
IMPORTS = kernel32
|
IMPORTS = advpack advapi32 kernel32
|
||||||
EXTRALIBS = -luuid
|
EXTRALIBS = -luuid
|
||||||
|
|
||||||
C_SRCS = \
|
C_SRCS = \
|
||||||
|
@ -11,6 +11,8 @@ C_SRCS = \
|
||||||
qmgr.c \
|
qmgr.c \
|
||||||
qmgr_main.c
|
qmgr_main.c
|
||||||
|
|
||||||
|
RC_SRCS = rsrc.rc
|
||||||
|
|
||||||
IDL_I_SRCS = qmgr_local.idl
|
IDL_I_SRCS = qmgr_local.idl
|
||||||
|
|
||||||
@MAKE_DLL_RULES@
|
@MAKE_DLL_RULES@
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#define COBJMACROS
|
#define COBJMACROS
|
||||||
#include "bits.h"
|
#include "bits.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/* Background copy manager vtbl and related data */
|
/* Background copy manager vtbl and related data */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
@ -43,4 +45,13 @@ extern ClassFactoryImpl BITS_ClassFactory;
|
||||||
|
|
||||||
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
|
HRESULT BackgroundCopyManagerConstructor(IUnknown *pUnkOuter, LPVOID *ppObj);
|
||||||
|
|
||||||
|
/* Little helper functions */
|
||||||
|
static inline char *
|
||||||
|
qmgr_strdup(const char *s)
|
||||||
|
{
|
||||||
|
size_t n = strlen(s) + 1;
|
||||||
|
char *d = HeapAlloc(GetProcessHeap(), 0, n);
|
||||||
|
return d ? memcpy(d, s, n) : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* __QMGR_H__ */
|
#endif /* __QMGR_H__ */
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
[version]
|
||||||
|
Signature="$CHICAGO$"
|
||||||
|
|
||||||
|
[RegisterDll]
|
||||||
|
AddReg = Qmgr.Reg
|
||||||
|
|
||||||
|
[UnregisterDll]
|
||||||
|
DelReg = Qmgr.Reg
|
||||||
|
|
||||||
|
[Qmgr.Reg]
|
||||||
|
HKCR,"AppID\BITS","AppID",,"%CLSID_BackgroundCopyQMgr%"
|
||||||
|
HKCR,"AppID\%CLSID_BackgroundCopyQMgr%","LocalService",,"BITS"
|
||||||
|
HKCR,"CLSID\%CLSID_BackgroundCopyManager%","AppID",,"%CLSID_BackgroundCopyQMgr%"
|
||||||
|
|
||||||
|
HKLM,"Software\Microsoft\Windows NT\CurrentVersion\SvcHost","netsvcs",0x00010000,"BITS"
|
||||||
|
HKLM,"System\CurrentControlSet\Services\BITS\Parameters","ServiceDll",0x00020000,"qmgr.dll"
|
|
@ -1,2 +1,2 @@
|
||||||
@ stub DllRegisterServer
|
@ stdcall -private DllRegisterServer()
|
||||||
@ stub DllUnregisterServer
|
@ stdcall -private DllUnregisterServer()
|
||||||
|
|
|
@ -21,15 +21,29 @@
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "windef.h"
|
#include "objbase.h"
|
||||||
#include "winbase.h"
|
#include "winuser.h"
|
||||||
|
#include "winreg.h"
|
||||||
|
#include "advpub.h"
|
||||||
|
#include "olectl.h"
|
||||||
|
#include "winsvc.h"
|
||||||
|
|
||||||
|
#include "bits.h"
|
||||||
|
#include "qmgr.h"
|
||||||
|
#include "initguid.h"
|
||||||
|
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
|
||||||
|
|
||||||
|
/* Handle to the base address of this DLL */
|
||||||
|
static HINSTANCE hInst;
|
||||||
|
|
||||||
|
/* Other GUIDs used by this module */
|
||||||
|
DEFINE_GUID(CLSID_BackgroundCopyQMgr, 0x69AD4AEE, 0x51BE, 0x439b, 0xA9,0x2C, 0x86,0xAE,0x49,0x0E,0x8B,0x30);
|
||||||
|
|
||||||
/* Entry point for DLL */
|
/* Entry point for DLL */
|
||||||
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +55,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
return FALSE; /* prefer native version */
|
return FALSE; /* prefer native version */
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
DisableThreadLibraryCalls(hinstDLL);
|
DisableThreadLibraryCalls(hinstDLL);
|
||||||
|
hInst = hinstDLL;
|
||||||
break;
|
break;
|
||||||
case DLL_PROCESS_DETACH:
|
case DLL_PROCESS_DETACH:
|
||||||
break;
|
break;
|
||||||
|
@ -48,3 +63,114 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HRESULT init_register_strtable(STRTABLEA *strtable)
|
||||||
|
{
|
||||||
|
#define CLSID_EXPANSION_ENTRY(id) { "CLSID_" #id, &CLSID_ ## id }
|
||||||
|
static const struct {
|
||||||
|
const char *name;
|
||||||
|
const CLSID *clsid;
|
||||||
|
} expns[] = {
|
||||||
|
CLSID_EXPANSION_ENTRY(BackgroundCopyQMgr),
|
||||||
|
CLSID_EXPANSION_ENTRY(BackgroundCopyManager)
|
||||||
|
};
|
||||||
|
#undef CLSID_EXPANSION_ENTRY
|
||||||
|
static STRENTRYA pse[sizeof expns / sizeof expns[0]];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
strtable->cEntries = sizeof pse / sizeof pse[0];
|
||||||
|
strtable->pse = pse;
|
||||||
|
for (i = 0; i < strtable->cEntries; i++) {
|
||||||
|
static const char dummy_sample[] = "{12345678-1234-1234-1234-123456789012}";
|
||||||
|
const CLSID *clsid = expns[i].clsid;
|
||||||
|
pse[i].pszName = qmgr_strdup(expns[i].name);
|
||||||
|
pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, sizeof dummy_sample);
|
||||||
|
if (!pse[i].pszName || !pse[i].pszValue)
|
||||||
|
return E_OUTOFMEMORY;
|
||||||
|
sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||||
|
clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
|
||||||
|
clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4],
|
||||||
|
clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void cleanup_register_strtable(STRTABLEA *strtable)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < strtable->cEntries; i++) {
|
||||||
|
HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszName);
|
||||||
|
HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszValue);
|
||||||
|
if (!strtable->pse[i].pszName || !strtable->pse[i].pszValue)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static HRESULT register_service(BOOL do_register)
|
||||||
|
{
|
||||||
|
static const WCHAR name[] = { 'B','I','T','S', 0 };
|
||||||
|
static const WCHAR path[] = { 's','v','c','h','o','s','t','.','e','x','e',
|
||||||
|
' ','-','k',' ','n','e','t','s','v','c','s', 0 };
|
||||||
|
SC_HANDLE scm, service;
|
||||||
|
HRESULT hr = S_OK;
|
||||||
|
|
||||||
|
scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
|
||||||
|
if (!scm)
|
||||||
|
return SELFREG_E_CLASS;
|
||||||
|
|
||||||
|
if (do_register)
|
||||||
|
service = CreateServiceW(scm, name, name, SERVICE_ALL_ACCESS,
|
||||||
|
SERVICE_WIN32_OWN_PROCESS,
|
||||||
|
SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
|
||||||
|
path, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
else
|
||||||
|
service = OpenServiceW(scm, name, DELETE);
|
||||||
|
|
||||||
|
|
||||||
|
CloseServiceHandle(scm);
|
||||||
|
if (!service)
|
||||||
|
return SELFREG_E_CLASS;
|
||||||
|
|
||||||
|
if (!do_register)
|
||||||
|
hr = DeleteService(service) ? S_OK : SELFREG_E_CLASS;
|
||||||
|
|
||||||
|
CloseServiceHandle(service);
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use an INF file to register or unregister the DLL */
|
||||||
|
static HRESULT register_server(BOOL do_register)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
STRTABLEA strtable;
|
||||||
|
|
||||||
|
TRACE("(%x)\n", do_register);
|
||||||
|
|
||||||
|
hr = register_service(do_register);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
ERR("register_service failed: %d\n", GetLastError());
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = init_register_strtable(&strtable);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
hr = RegInstallA(hInst, do_register ? "RegisterDll" : "UnregisterDll",
|
||||||
|
&strtable);
|
||||||
|
cleanup_register_strtable(&strtable);
|
||||||
|
|
||||||
|
if (FAILED(hr))
|
||||||
|
ERR("RegInstall failed: %08x\n", hr);
|
||||||
|
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI DllRegisterServer(void)
|
||||||
|
{
|
||||||
|
return register_server(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI DllUnregisterServer(void)
|
||||||
|
{
|
||||||
|
return register_server(FALSE);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2007 Google (Roy Shea)
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2.1 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* @makedep: qmgr.inf */
|
||||||
|
REGINST REGINST qmgr.inf
|
|
@ -2196,6 +2196,8 @@ HKLM,%CurrentVersion%\Telephony\Country List\998,"SameAreaRule",,"G"
|
||||||
11,,objsel.dll,1
|
11,,objsel.dll,1
|
||||||
11,,qcap.dll,1
|
11,,qcap.dll,1
|
||||||
11,,qedit.dll,1
|
11,,qedit.dll,1
|
||||||
|
11,,qmgr.dll,1
|
||||||
|
11,,qmgrprxy.dll,1
|
||||||
11,,quartz.dll,1
|
11,,quartz.dll,1
|
||||||
11,,rsaenh.dll,1
|
11,,rsaenh.dll,1
|
||||||
11,,shdocvw.dll,1
|
11,,shdocvw.dll,1
|
||||||
|
|
Loading…
Reference in New Issue