[ofw] [RFC] [PATCH 4/12] winverbs: implement IWVProvider
Fab Tillier
ftillier at windows.microsoft.com
Sat Mar 15 00:42:31 PDT 2008
>Userspace WinVerb implementation for the winverb provider.
>
>The provider class is responsible for opening the file to communicate
>with the winverb driver. A simple Open() stub has been created for
>this, which will need to be coordinated with the driver implementation,
>once it's ready.
>
>Signed-off-by: Sean Hefty <sean.hefty at intel.com>
>---
>
>Index: core/winverbs/user/wv_provider.cpp
>===================================================================
>--- core/winverbs/user/wv_provider.cpp (revision 981)
>+++ core/winverbs/user/wv_provider.cpp (working copy)
>@@ -27,21 +27,48 @@
> * SOFTWARE.
> */
>
>+#include <iba\ib_al.h>
>+
> #include "wv_base.h"
> #include "wv_provider.h"
> #include "wv_device.h"
>+#include "wv_ep.h"
>+#include "wv_listen.h"
>
>+CWVProvider::CWVProvider()
>+{
>+ m_nRef = 1;
>+ InterlockedIncrement(&WvRef);
>+
>+ m_hFile = INVALID_HANDLE_VALUE;
>+}
>+
> STDMETHODIMP CWVProvider::
>+Open(void)
>+{
>+ m_hFile = CreateFileW(L"\\\\.\\WinVerbs", GENERIC_READ | GENERIC_WRITE,
>+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
>+ FILE_FLAG_OVERLAPPED, NULL);
>+
>+ return (m_hFile == INVALID_HANDLE_VALUE) ? WV_UNSUCCESSFUL : WV_SUCCESS;
>+}
>+
>+CWVProvider::~CWVProvider()
>+{
>+ CloseHandle(m_hFile);
What happens if m_hFile == INVALID_HANDLE_VALUE?
>+ InterlockedDecrement(&WvRef);
>+}
>+
>@@ -103,17 +157,18 @@
Use a static function of the CWVDevice class to create an instance. This goes for all the rest of the methods that allocate an object.
> CWVDevice *dev;
>
> dev = new CWVDevice(this);
>- if (!dev)
>- {
>+ if (dev == NULL) {
> hr = WV_NO_MEMORY;
> goto err1;
> }
>
> dev->QueryInterface(IID_IWVDevice, (LPVOID*) ppDevice);
>+ dev->Release();
>
> hr = dev->Open(Guid);
>- if (hr != WV_SUCCESS)
>+ if (FAILED(hr)) {
> goto err2;
>+ }
>
> return WV_SUCCESS;
>
More information about the ofw
mailing list