~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/qmgr/qmgr_main.c

Version: ~ [ wine-1.5.31 ] ~ [ wine-1.5.30 ] ~ [ wine-1.5.29 ] ~ [ wine-1.5.28 ] ~ [ wine-1.5.27 ] ~ [ wine-1.5.26 ] ~ [ wine-1.5.25 ] ~ [ wine-1.5.24 ] ~ [ wine-1.5.23 ] ~ [ wine-1.5.22 ] ~ [ wine-1.5.21 ] ~ [ wine-1.5.20 ] ~ [ wine-1.5.19 ] ~ [ wine-1.5.18 ] ~ [ wine-1.5.17 ] ~ [ wine-1.5.16 ] ~ [ wine-1.5.15 ] ~ [ wine-1.5.14 ] ~ [ wine-1.5.13 ] ~ [ wine-1.5.12 ] ~ [ wine-1.5.11 ] ~ [ wine-1.5.10 ] ~ [ wine-1.5.9 ] ~ [ wine-1.5.8 ] ~ [ wine-1.5.7 ] ~ [ wine-1.4.1 ] ~ [ wine-1.5.6 ] ~ [ wine-1.5.5 ] ~ [ wine-1.5.4 ] ~ [ wine-1.5.3 ] ~ [ wine-1.5.2 ] ~ [ wine-1.5.1 ] ~ [ wine-1.5.0 ] ~ [ wine-1.4 ] ~ [ wine-1.4-rc6 ] ~ [ wine-1.4-rc5 ] ~ [ wine-1.4-rc4 ] ~ [ wine-1.4-rc3 ] ~ [ wine-1.4-rc2 ] ~ [ wine-1.4-rc1 ] ~ [ wine-1.3.37 ] ~ [ wine-1.3.36 ] ~ [ wine-1.3.35 ] ~ [ wine-1.3.34 ] ~ [ wine-1.3.33 ] ~ [ wine-1.3.32 ] ~ [ wine-1.3.31 ] ~ [ wine-1.3.30 ] ~ [ wine-1.3.29 ] ~ [ wine-1.3.28 ] ~ [ wine-1.3.27 ] ~ [ wine-1.3.26 ] ~ [ wine-1.3.25 ] ~ [ wine-1.3.24 ] ~ [ wine-1.3.23 ] ~ [ wine-1.3.22 ] ~ [ wine-1.3.21 ] ~ [ wine-1.3.20 ] ~ [ wine-1.3.19 ] ~ [ wine-1.3.18 ] ~ [ wine-1.2.3 ] ~ [ wine-1.3.17 ] ~ [ wine-1.3.16 ] ~ [ wine-1.3.15 ] ~ [ wine-1.3.14 ] ~ [ wine-1.3.13 ] ~ [ wine-1.3.12 ] ~ [ wine-1.3.11 ] ~ [ wine-1.3.10 ] ~ [ wine-1.3.9 ] ~ [ wine-1.2.2 ] ~ [ wine-1.3.8 ] ~ [ wine-1.3.7 ] ~ [ wine-1.3.6 ] ~ [ wine-1.3.5 ] ~ [ wine-1.2.1 ] ~ [ wine-1.3.4 ] ~ [ wine-1.3.3 ] ~ [ wine-1.3.2 ] ~ [ wine-1.3.1 ] ~ [ wine-1.3.0 ] ~ [ wine-1.2 ] ~ [ wine-1.2-rc7 ] ~ [ wine-1.2-rc6 ] ~ [ wine-1.2-rc5 ] ~ [ wine-1.2-rc4 ] ~ [ wine-1.2-rc3 ] ~ [ wine-1.2-rc2 ] ~ [ wine-1.2-rc1 ] ~ [ wine-1.1.44 ] ~ [ wine-1.1.43 ] ~ [ wine-1.1.42 ] ~ [ wine-1.1.41 ] ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Main DLL interface to Queue Manager (BITS)
  3  *
  4  * Background Intelligent Transfer Service (BITS) interface.  Dll is named
  5  * qmgr for backwards compatibility with early versions of BITS.
  6  *
  7  * Copyright 2007 Google (Roy Shea)
  8  *
  9  * This library is free software; you can redistribute it and/or
 10  * modify it under the terms of the GNU Lesser General Public
 11  * License as published by the Free Software Foundation; either
 12  * version 2.1 of the License, or (at your option) any later version.
 13  *
 14  * This library is distributed in the hope that it will be useful,
 15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17  * Lesser General Public License for more details.
 18  *
 19  * You should have received a copy of the GNU Lesser General Public
 20  * License along with this library; if not, write to the Free Software
 21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 22  */
 23 
 24 #include <stdio.h>
 25 
 26 #include "objbase.h"
 27 #include "winuser.h"
 28 #include "winreg.h"
 29 #include "advpub.h"
 30 #include "olectl.h"
 31 #include "winsvc.h"
 32 
 33 #include "bits.h"
 34 #include "qmgr.h"
 35 #include "initguid.h"
 36 
 37 #include "wine/debug.h"
 38 
 39 WINE_DEFAULT_DEBUG_CHANNEL(qmgr);
 40 
 41 /* Handle to the base address of this DLL */
 42 static HINSTANCE hInst;
 43 
 44 /* Other GUIDs used by this module */
 45 DEFINE_GUID(CLSID_BackgroundCopyQMgr, 0x69AD4AEE, 0x51BE, 0x439b, 0xA9,0x2C, 0x86,0xAE,0x49,0x0E,0x8B,0x30);
 46 
 47 /* Entry point for DLL */
 48 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 49 {
 50     TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
 51 
 52     switch (fdwReason)
 53     {
 54         case DLL_WINE_PREATTACH:
 55             return FALSE;  /* prefer native version */
 56         case DLL_PROCESS_ATTACH:
 57             DisableThreadLibraryCalls(hinstDLL);
 58             hInst = hinstDLL;
 59             break;
 60         case DLL_PROCESS_DETACH:
 61             break;
 62     }
 63 
 64     return TRUE;
 65 }
 66 
 67 static HRESULT init_register_strtable(STRTABLEA *strtable)
 68 {
 69 #define CLSID_EXPANSION_ENTRY(id) { "CLSID_" #id, &CLSID_ ## id }
 70     static const struct {
 71         const char *name;
 72         const CLSID *clsid;
 73     } expns[] =  {
 74         CLSID_EXPANSION_ENTRY(BackgroundCopyQMgr),
 75         CLSID_EXPANSION_ENTRY(BackgroundCopyManager)
 76     };
 77 #undef CLSID_EXPANSION_ENTRY
 78     static STRENTRYA pse[sizeof expns / sizeof expns[0]];
 79     DWORD i;
 80 
 81     strtable->cEntries = sizeof pse / sizeof pse[0];
 82     strtable->pse = pse;
 83     for (i = 0; i < strtable->cEntries; i++) {
 84         static const char dummy_sample[] = "{12345678-1234-1234-1234-123456789012}";
 85         const CLSID *clsid = expns[i].clsid;
 86         pse[i].pszName = qmgr_strdup(expns[i].name);
 87         pse[i].pszValue = HeapAlloc(GetProcessHeap(), 0, sizeof dummy_sample);
 88         if (!pse[i].pszName || !pse[i].pszValue)
 89             return E_OUTOFMEMORY;
 90         sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
 91                 clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
 92                 clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4],
 93                 clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
 94     }
 95 
 96     return S_OK;
 97 }
 98 
 99 static void cleanup_register_strtable(STRTABLEA *strtable)
100 {
101     DWORD i;
102     for (i = 0; i < strtable->cEntries; i++) {
103         HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszName);
104         HeapFree(GetProcessHeap(), 0, strtable->pse[i].pszValue);
105         if (!strtable->pse[i].pszName || !strtable->pse[i].pszValue)
106             return;
107     }
108 }
109 
110 static HRESULT register_service(BOOL do_register)
111 {
112     static const WCHAR name[] = { 'B','I','T','S', 0 };
113     static const WCHAR path[] = { 's','v','c','h','o','s','t','.','e','x','e',
114                                   ' ','-','k',' ','n','e','t','s','v','c','s', 0 };
115     SC_HANDLE scm, service;
116 
117     scm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
118     if (!scm)
119         return SELFREG_E_CLASS;
120 
121     if (do_register)
122         service = CreateServiceW(scm, name, name, SERVICE_ALL_ACCESS,
123                                  SERVICE_WIN32_OWN_PROCESS,
124                                  SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,
125                                  path, NULL, NULL, NULL, NULL, NULL);
126     else
127         service = OpenServiceW(scm, name, DELETE);
128 
129 
130     CloseServiceHandle(scm);
131     if (service)
132     {
133         if (!do_register) DeleteService(service);
134         CloseServiceHandle(service);
135     }
136     return S_OK;
137 }
138 
139 /* Use an INF file to register or unregister the DLL */
140 static HRESULT register_server(BOOL do_register)
141 {
142     HRESULT hr;
143     STRTABLEA strtable;
144     HMODULE hAdvpack;
145     HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
146     static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
147 
148     TRACE("(%x)\n", do_register);
149 
150     hr = register_service(do_register);
151     if (FAILED(hr)) {
152         ERR("register_service failed: %d\n", GetLastError());
153         return hr;
154     }
155 
156     hAdvpack = LoadLibraryW(wszAdvpack);
157     pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
158 
159     hr = init_register_strtable(&strtable);
160     if (SUCCEEDED(hr))
161         hr = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll",
162                          &strtable);
163     cleanup_register_strtable(&strtable);
164 
165     if (FAILED(hr))
166         ERR("RegInstall failed: %08x\n", hr);
167 
168     return hr;
169 }
170 
171 HRESULT WINAPI DllRegisterServer(void)
172 {
173     return register_server(TRUE);
174 }
175 
176 HRESULT WINAPI DllUnregisterServer(void)
177 {
178     return register_server(FALSE);
179 }
180 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.