' ########################################################################################
' Microsoft Windows
' File: mtpext.inc
' Contents: Structures and constants needed to issue vendor-specific Media Transfer
' Protocol (MTP) commands through DeviceIOControl mechanism.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_mtpext_PBI)
#DEFINE PBX_mtpext_PBI
%MTPEXT_INC = 1
'//
'// Pass this value in the dwIoControlCode argument of IWMDMDevice3::DeviceIoControl
'// to execute a direct MTP command
'//
%IOCTL_MTP_CUSTOM_COMMAND = &H3150544d
'//
'// MTP command request
'//
%MTP_COMMAND_MAX_PARAMS = 5
%MTP_RESPONSE_MAX_PARAMS = 5
'//
'// MTP response codes
'//
%MTP_RESPONSE_OK = &H2001??
'#pragma pack(push, Old, 1)
' // Size = 35 bytes
TYPE MTP_COMMAND_DATA_IN BYTE
 OpCode AS WORD ' WORD // Opcode
 NumParams AS DWORD ' DWORD // Number of parameters passed in
 Params(%MTP_COMMAND_MAX_PARAMS - 1) AS DWORD ' DWORD // Parameters to the command
 NextPhase AS DWORD ' DWORD // Indicates whether the command has a read data,
 ' // write data, or no data phase.
 CommandWriteDataSize AS DWORD ' DWORD // Number of bytes contained in CommandWriteData.
 CommandWriteData(0) AS BYTE ' BYTE // Optional first byte of data to
 ' // write to the device if NextPhase is MTP_NEXTPHASE_WRITE_DATA
END TYPE
'//
'// MTP response block
'//
' // Size = 31 bytes
TYPE MTP_COMMAND_DATA_OUT BYTE
 ResponseCode AS WORD ' WORD // Response code
 NumParams AS DWORD ' DWORD // Number of parameters for this response
 Params(%MTP_RESPONSE_MAX_PARAMS - 1) AS DWORD ' DWORD // Parameters of the response
 CommandReadDataSize AS DWORD ' DWORD // Number of bytes contained in CommandReadData.
 CommandReadData(0) AS BYTE ' BYTE // Optional first byte of data to
 ' // read from the device if
 ' // MTP_COMMAND_DATA_IN::NextPhase was MTP_NEXTPHASE_READ_DATA
END TYPE
'#pragma pack(pop, Old)
'//
'// Handy structure size constants
'//
'#define SIZEOF_REQUIRED_COMMAND_DATA_IN (sizeof(MTP_COMMAND_DATA_IN) - 1)
'#define SIZEOF_REQUIRED_COMMAND_DATA_OUT (sizeof(MTP_COMMAND_DATA_OUT) - 1)
'//
'// NextPhase constants
'//
%MTP_NEXTPHASE_READ_DATA = 1
%MTP_NEXTPHASE_WRITE_DATA = 2
%MTP_NEXTPHASE_NO_DATA = 3