From acc6f826433e639b1ba00c021ab5f9161eb56e59 Mon Sep 17 00:00:00 2001 From: vchtchetkine Date: Wed, 5 Aug 2009 16:57:18 -0700 Subject: Split AdbWinApi.dll into two dlls to remove dependency on WINUSB.DLL Move all WINUSB-dependent functionality into AdbWinUsbApi.dll in order to enable ADB on condition that WINUSB has not been installed. In this patch set new file (adb_winusb_api.h) has been added where I moved typedef that broke the build. Aso, adb_api.cpp and AdbWinApi.cpp were changed to include that new header file. BUG 2033924 --- host/windows/usb/api/adb_api.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'host/windows/usb/api/adb_api.cpp') diff --git a/host/windows/usb/api/adb_api.cpp b/host/windows/usb/api/adb_api.cpp index f9bd94e6c..e58bcf17a 100644 --- a/host/windows/usb/api/adb_api.cpp +++ b/host/windows/usb/api/adb_api.cpp @@ -24,11 +24,19 @@ #include "adb_object_handle.h" #include "adb_interface_enum.h" #include "adb_interface.h" -#include "adb_winusb_interface.h" #include "adb_legacy_interface.h" #include "adb_endpoint_object.h" #include "adb_io_completion.h" #include "adb_helper_routines.h" +#include "adb_winusb_api.h" + +/** \brief Points to InstantiateWinUsbInterface exported from AdbWinUsbApi.dll. + + This variable is initialized with the actual address in DllMain routine for + this DLL on DLL_PROCESS_ATTACH event. + @see PFN_INSTWINUSBINTERFACE for more information. +*/ +PFN_INSTWINUSBINTERFACE InstantiateWinUsbInterface = NULL; ADBAPIHANDLE __cdecl AdbEnumInterfaces(GUID class_id, bool exclude_not_present, @@ -101,11 +109,22 @@ ADBAPIHANDLE __cdecl AdbCreateInterfaceByName( ADBAPIHANDLE ret = NULL; try { - // Instantiate object + // Instantiate interface object, depending on the USB driver type. if (IsLegacyInterface(interface_name)) { + // We have legacy USB driver underneath us. obj = new AdbLegacyInterfaceObject(interface_name); } else { - obj = new AdbWinUsbInterfaceObject(interface_name); + // We have WinUsb driver underneath us. Make sure that AdbWinUsbApi.dll + // is loaded and its InstantiateWinUsbInterface routine address has + // been cached. + if (NULL != InstantiateWinUsbInterface) { + obj = InstantiateWinUsbInterface(interface_name); + if (NULL == obj) { + return NULL; + } + } else { + return NULL; + } } // Create handle for it -- cgit v1.2.3