adb윈도우용은 AdbWinApi.dll과 AdbWinUsbApi.dll과 함께 연동된다.
주요 API는 AdbWinApi.dll에 정의되어 있으며 AdbWinUsbApi.dll은 실제 Usb device와 연동부분을 책임진다.
오픈소스상의 아래 위치에 소스가 위치한다.
open_src/system/core/adb -> adb server, adb demon, adb client based on command-line의 소스가 OS별(linux, window, OSX)로 구현되어 있다.
open_src/developments/hosts/windows/usb -> 윈도우용 AdbWinApi.dll과 AdbWinUsbApi.dll의 소스와 드라이버등이 있다.
developments/hosts/windows/usb폴더구조는 다음과 같다.
adb_winapi_test : test app
api : AdbWinApi의 소스, adb.exe가 직접적으로 사용한다.
legacy : 드라이버
winusb : AdbWinUsbApi의 소스, Usb 연동부분에 대한 소스로 AdbWinApi가 로드하여 사용한다.
adb와 유사한 클라이언트 앱을 만들고자 한다면 AdbWinApi.dll이 노출하는 API들에 대한 스펙을 숙지하는것이 중요하다.
아래에 몇가지 API들을 소개한다.
adb_api.h
ADBWIN_API ADBAPIHANDLE __cdecl AdbEnumInterfaces(GUID class_id,
bool exclude_not_present,
bool exclude_removed,
bool active_only);
ADBWIN_API bool __cdecl AdbNextInterface(ADBAPIHANDLE adb_handle,
AdbInterfaceInfo* info,
unsigned long* size);
ADBWIN_API bool __cdecl AdbResetInterfaceEnum(ADBAPIHANDLE adb_handle);
ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterfaceByName(const wchar_t* interface_name);
ADBWIN_API ADBAPIHANDLE __cdecl AdbCreateInterface(GUID class_id,
unsigned short vendor_id,
unsigned short product_id,
unsigned char interface_id);
ADBWIN_API bool __cdecl AdbGetInterfaceName(ADBAPIHANDLE adb_interface,
void* buffer,
unsigned long* buffer_char_size,
bool ansi);
ADBWIN_API bool __cdecl AdbGetSerialNumber(ADBAPIHANDLE adb_interface,
void* buffer,
unsigned long* buffer_char_size,
bool ansi);
ADBWIN_API bool __cdecl AdbGetUsbDeviceDescriptor(ADBAPIHANDLE adb_interface,
USB_DEVICE_DESCRIPTOR* desc);
ADBWIN_API bool __cdecl AdbGetUsbConfigurationDescriptor(
ADBAPIHANDLE adb_interface,
USB_CONFIGURATION_DESCRIPTOR* desc);
ADBWIN_API bool __cdecl AdbGetUsbInterfaceDescriptor(ADBAPIHANDLE adb_interface,
USB_INTERFACE_DESCRIPTOR* desc);
ADBWIN_API bool __cdecl AdbGetEndpointInformation(ADBAPIHANDLE adb_interface,
unsigned char endpoint_index,
AdbEndpointInformation* info);
ADBWIN_API bool __cdecl AdbGetDefaultBulkReadEndpointInformation(
ADBAPIHANDLE adb_interface,
AdbEndpointInformation* info);
ADBWIN_API bool __cdecl AdbGetDefaultBulkWriteEndpointInformation(
ADBAPIHANDLE adb_interface,
AdbEndpointInformation* info);
ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenEndpoint(ADBAPIHANDLE adb_interface,
unsigned char endpoint_index,
AdbOpenAccessType access_type,
AdbOpenSharingMode sharing_mode);
ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkReadEndpoint(
ADBAPIHANDLE adb_interface,
AdbOpenAccessType access_type,
AdbOpenSharingMode sharing_mode);
ADBWIN_API ADBAPIHANDLE __cdecl AdbOpenDefaultBulkWriteEndpoint(
ADBAPIHANDLE adb_interface,
AdbOpenAccessType access_type,
AdbOpenSharingMode sharing_mode);
ADBWIN_API ADBAPIHANDLE __cdecl AdbGetEndpointInterface(ADBAPIHANDLE adb_endpoint);
ADBWIN_API bool __cdecl AdbQueryInformationEndpoint(ADBAPIHANDLE adb_endpoint,
AdbEndpointInformation* info);
ADBWIN_API ADBAPIHANDLE __cdecl AdbReadEndpointAsync(ADBAPIHANDLE adb_endpoint,
void* buffer,
unsigned long bytes_to_read,
unsigned long* bytes_read,
unsigned long time_out,
HANDLE event_handle);
ADBWIN_API ADBAPIHANDLE __cdecl AdbWriteEndpointAsync(ADBAPIHANDLE adb_endpoint,
void* buffer,
unsigned long bytes_to_write,
unsigned long* bytes_written,
unsigned long time_out,
HANDLE event_handle);
ADBWIN_API bool __cdecl AdbReadEndpointSync(ADBAPIHANDLE adb_endpoint,
void* buffer,
unsigned long bytes_to_read,
unsigned long* bytes_read,
unsigned long time_out);
ADBWIN_API bool __cdecl AdbWriteEndpointSync(ADBAPIHANDLE adb_endpoint,
void* buffer,
unsigned long bytes_to_write,
unsigned long* bytes_written,
unsigned long time_out);
ADBWIN_API bool __cdecl AdbGetOvelappedIoResult(ADBAPIHANDLE adb_io_completion,
LPOVERLAPPED overlapped,
unsigned long* bytes_transferred,
bool wait);
ADBWIN_API bool __cdecl AdbHasOvelappedIoComplated(ADBAPIHANDLE adb_io_completion);
ADBWIN_API bool __cdecl AdbCloseHandle(ADBAPIHANDLE adb_handle);