Commit d38cce8d authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Implemented DevEnum dll.

parent c71301a3
Makefile
devenum.dll.dbg.c
devenum.res
devenum.spec.c
devenum.spec.def
......@@ -3,11 +3,20 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = devenum.dll
IMPORTS = ole32 oleaut32 winmm user32 advapi32 kernel32
EXTRALIBS = $(LIBUUID)
LDDLLFLAGS = @LDDLLFLAGS@
SYMBOLFILE = $(MODULE).tmp.o
C_SRCS = devenum_main.c
C_SRCS = \
createdevenum.c \
devenum_main.c \
factory.c \
mediacatenum.c \
parsedisplayname.c
RC_SRCS = devenum.rc
@MAKE_DLL_RULES@
......
/*
* Resources for Device Enumerator
*
* Copyright 2002 Robert Shearman
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "winnls.h"
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
STRINGTABLE DISCARDABLE
{
7 "Default DirectSound"
8 "DirectSound: %s"
9 "Default WaveOut Device"
10 "Default MidiOut Device"
}
1 VERSIONINFO
FILEVERSION 6,3,1,881
PRODUCTVERSION 6,3,1,881
FILEFLAGSMASK 0x30003fL
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "04090000"
BEGIN
VALUE "CompanyName", "Wine Developer Team\000"
VALUE "FileDescription", "Wine Device Enumerator Library\000"
VALUE "FileVersion", "6.3.1.881\000"
VALUE "InternalName", "DEVENUM\000"
VALUE "LegalCopyright", "Copyright \251 2002\000"
VALUE "OriginalFilename", "DEVENUM.DLL\000"
VALUE "ProductName", "Wine\000"
VALUE "ProductVersion", "6.3.1.881\000"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 0
END
END
@ stub DllCanUnloadNow
@ stub DllGetClassObject
@ stdcall DllCanUnloadNow() DEVENUM_DllCanUnloadNow
@ stdcall DllGetClassObject(ptr ptr ptr) DEVENUM_DllGetClassObject
@ stdcall DllRegisterServer() DEVENUM_DllRegisterServer
@ stub DllUnregisterServer
@ stdcall DllUnregisterServer() DEVENUM_DllUnregisterServer
/*
* includes for devenum.dll
*
* Copyright (C) 2002 John K. Hohm
* Copyright (C) 2002 Robert Shearman
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* NOTES ON FILE:
* - Private file where devenum globals are declared
*/
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winreg.h"
#include "winerror.h"
#define COM_NO_WINDOWS_H
#include "ole2.h"
#include "strmif.h"
#include "wine/obj_property.h"
#include "wine/unicode.h"
#include "uuids.h"
/**********************************************************************
* Dll lifetime tracking declaration for devenum.dll
*/
extern DWORD dll_ref;
/**********************************************************************
* ClassFactory declaration for devenum.dll
*/
typedef struct
{
/* IUnknown fields */
ICOM_VFIELD(IClassFactory);
DWORD ref;
} ClassFactoryImpl;
typedef struct
{
ICOM_VFIELD(ICreateDevEnum);
DWORD ref;
} CreateDevEnumImpl;
typedef struct
{
ICOM_VFIELD(IEnumMoniker);
DWORD ref;
DWORD index;
HKEY hkey;
} EnumMonikerImpl;
typedef struct
{
ICOM_VFIELD(IMoniker);
DWORD ref;
HKEY hkey;
} MediaCatMoniker;
typedef struct
{
ICOM_VFIELD(IPropertyBag);
DWORD ref;
HKEY hkey;
} RegPropBagImpl;
typedef struct
{
ICOM_VFIELD(IParseDisplayName);
DWORD ref;
} ParseDisplayNameImpl;
MediaCatMoniker * DEVENUM_IMediaCatMoniker_Construct();
HRESULT WINAPI DEVENUM_ICreateDevEnum_CreateClassEnumerator(
ICreateDevEnum * iface,
REFCLSID clsidDeviceClass,
IEnumMoniker **ppEnumMoniker,
DWORD dwFlags);
extern ClassFactoryImpl DEVENUM_ClassFactory;
extern CreateDevEnumImpl DEVENUM_CreateDevEnum;
extern ParseDisplayNameImpl DEVENUM_ParseDisplayName;
/**********************************************************************
* Global string constant declarations
*/
extern const WCHAR clsid_keyname[6];
extern const WCHAR wszInstanceKeyName[];
extern const WCHAR wszRegSeperator[];
#define CLSID_STR_LEN (sizeof(clsid_keyname) / sizeof(WCHAR))
/**********************************************************************
* Resource IDs
*/
#define IDS_DEVENUM_DSDEFAULT 7
#define IDS_DEVENUM_DS 8
#define IDS_DEVENUM_WODEFAULT 9
#define IDS_DEVENUM_MIDEFAULT 10
#define IDS_DEVENUM_KSDEFAULT 11
#define IDS_DEVENUM_KS 12
/*
* ClassFactory implementation for DEVENUM.dll
*
* Copyright (C) 2002 John K. Hohm
* Copyright (C) 2002 Robert Shearman
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "devenum_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
/**********************************************************************
* DEVENUM_IClassFactory_QueryInterface (also IUnknown)
*/
static HRESULT WINAPI DEVENUM_IClassFactory_QueryInterface(
LPCLASSFACTORY iface,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS(ClassFactoryImpl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IClassFactory))
{
*ppvObj = (LPVOID)iface;
IClassFactory_AddRef(iface);
return S_OK;
}
else if (IsEqualGUID(riid, &IID_IParseDisplayName))
{
return IClassFactory_CreateInstance(iface, NULL, riid, ppvObj);
}
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
/**********************************************************************
* DEVENUM_IClassFactory_AddRef (also IUnknown)
*/
static ULONG WINAPI DEVENUM_IClassFactory_AddRef(LPCLASSFACTORY iface)
{
ICOM_THIS(ClassFactoryImpl, iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
This->ref++;
if (InterlockedIncrement(&This->ref) == 1) {
InterlockedIncrement(&dll_ref);
}
return This->ref;
}
/**********************************************************************
* DEVENUM_IClassFactory_Release (also IUnknown)
*/
static ULONG WINAPI DEVENUM_IClassFactory_Release(LPCLASSFACTORY iface)
{
ICOM_THIS(ClassFactoryImpl, iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
if (InterlockedDecrement(&This->ref) == 0) {
InterlockedDecrement(&dll_ref);
}
return This->ref;
}
/**********************************************************************
* DEVENUM_IClassFactory_CreateInstance
*/
static HRESULT WINAPI DEVENUM_IClassFactory_CreateInstance(
LPCLASSFACTORY iface,
LPUNKNOWN pUnkOuter,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS(ClassFactoryImpl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
/* Don't support aggregation (Windows doesn't) */
if (pUnkOuter != NULL) return CLASS_E_NOAGGREGATION;
if (IsEqualGUID(&IID_ICreateDevEnum, riid))
{
*ppvObj = &DEVENUM_CreateDevEnum;
return S_OK;
}
if (IsEqualGUID(&IID_IParseDisplayName, riid))
{
*ppvObj = &DEVENUM_ParseDisplayName;
return S_OK;
}
return CLASS_E_CLASSNOTAVAILABLE;
}
/**********************************************************************
* DEVENUM_IClassFactory_LockServer
*/
static HRESULT WINAPI DEVENUM_IClassFactory_LockServer(
LPCLASSFACTORY iface,
BOOL fLock)
{
TRACE("\n");
if (fLock != FALSE) {
IClassFactory_AddRef(iface);
} else {
IClassFactory_Release(iface);
}
return S_OK;
}
/**********************************************************************
* IClassFactory_Vtbl
*/
static ICOM_VTABLE(IClassFactory) IClassFactory_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
DEVENUM_IClassFactory_QueryInterface,
DEVENUM_IClassFactory_AddRef,
DEVENUM_IClassFactory_Release,
DEVENUM_IClassFactory_CreateInstance,
DEVENUM_IClassFactory_LockServer
};
/**********************************************************************
* static ClassFactory instance
*/
ClassFactoryImpl DEVENUM_ClassFactory = { &IClassFactory_Vtbl, 0 };
/*
* IParseDisplayName implementation for DEVENUM.dll
*
* Copyright (C) 2002 Robert Shearman
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* NOTES ON THIS FILE:
* - Implements IParseDisplayName interface which creates a moniker
* from a string in a special format
*/
#include "devenum_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(devenum);
static HRESULT WINAPI DEVENUM_IParseDisplayName_QueryInterface(
LPPARSEDISPLAYNAME iface,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS(ParseDisplayNameImpl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IParseDisplayName))
{
*ppvObj = (LPVOID)iface;
IParseDisplayName_AddRef(iface);
return S_OK;
}
FIXME("- no interface\n\tIID:\t%s\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
/**********************************************************************
* DEVENUM_IParseDisplayName_AddRef (also IUnknown)
*/
static ULONG WINAPI DEVENUM_IParseDisplayName_AddRef(LPPARSEDISPLAYNAME iface)
{
ICOM_THIS(ParseDisplayNameImpl, iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
if (InterlockedIncrement(&This->ref) == 1) {
InterlockedIncrement(&dll_ref);
}
return ++This->ref;
}
/**********************************************************************
* DEVENUM_IParseDisplayName_Release (also IUnknown)
*/
static ULONG WINAPI DEVENUM_IParseDisplayName_Release(LPPARSEDISPLAYNAME iface)
{
ICOM_THIS(ParseDisplayNameImpl, iface);
ULONG ref;
TRACE("\n");
if (This == NULL) return E_POINTER;
ref = --This->ref;
if (InterlockedDecrement(&This->ref) == 0) {
InterlockedDecrement(&dll_ref);
}
return ref;
}
/**********************************************************************
* DEVENUM_IParseDisplayName_ParseDisplayName
*
* Creates a moniker referenced to by the display string argument
*
* POSSIBLE BUGS:
* Might not handle more complicated strings properly (ie not in
* "@device:sw:{CLSID1}\{CLSID2}" format
*/
static HRESULT WINAPI DEVENUM_IParseDisplayName_ParseDisplayName(
LPPARSEDISPLAYNAME iface,
IBindCtx *pbc,
LPOLESTR pszDisplayName,
ULONG *pchEaten,
IMoniker **ppmkOut)
{
LPOLESTR pszBetween = NULL;
LPOLESTR pszClass = NULL;
IEnumMoniker * pEm = NULL;
MediaCatMoniker * pMoniker = NULL;
CLSID clsidDevice;
HRESULT res = S_OK;
TRACE("(%p, %s, %p, %p)\n", pbc, debugstr_w(pszDisplayName), pchEaten, ppmkOut);
*ppmkOut = NULL;
if (pchEaten)
*pchEaten = strlenW(pszDisplayName);
pszDisplayName = strchrW(pszDisplayName, '{');
pszBetween = strchrW(pszDisplayName, '}') + 2;
/* size = pszBetween - pszDisplayName - 1 (for '\\' after CLSID)
* + 1 (for NULL character)
*/
pszClass = CoTaskMemAlloc((int)(pszBetween - pszDisplayName) * sizeof(WCHAR));
if (!pszClass)
return E_OUTOFMEMORY;
strncpyW(pszClass, pszDisplayName, (int)(pszBetween - pszDisplayName) - 1);
pszClass[(int)(pszBetween - pszDisplayName) - 1] = 0;
TRACE("Device CLSID: %s\n", debugstr_w(pszClass));
res = CLSIDFromString(pszClass, &clsidDevice);
if (SUCCEEDED(res))
{
res = DEVENUM_ICreateDevEnum_CreateClassEnumerator((ICreateDevEnum *)&DEVENUM_CreateDevEnum, &clsidDevice, &pEm, 0);
}
if (SUCCEEDED(res))
{
pMoniker = DEVENUM_IMediaCatMoniker_Construct();
if (pMoniker)
{
if (RegCreateKeyW(((EnumMonikerImpl *)pEm)->hkey,
pszBetween,
&pMoniker->hkey) == ERROR_SUCCESS)
*ppmkOut = (LPMONIKER)pMoniker;
else
{
IMoniker_Release((LPMONIKER)pMoniker);
res = MK_E_NOOBJECT;
}
}
}
if (pEm)
IEnumMoniker_Release(pEm);
if (pszClass)
CoTaskMemFree(pszClass);
TRACE("-- returning: %lx\n", res);
return res;
}
/**********************************************************************
* IParseDisplayName_Vtbl
*/
static ICOM_VTABLE(IParseDisplayName) IParseDisplayName_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
DEVENUM_IParseDisplayName_QueryInterface,
DEVENUM_IParseDisplayName_AddRef,
DEVENUM_IParseDisplayName_Release,
DEVENUM_IParseDisplayName_ParseDisplayName
};
/* The one instance of this class */
ParseDisplayNameImpl DEVENUM_ParseDisplayName = { &IParseDisplayName_Vtbl, 0 };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment