I was able to get this to work:
I found event 1003 in applications and services logs, Microsoft-Windows-DriverFrameworks-UserMode for a phone plugged in to usb
Full xml of the event:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Microsoft-Windows-DriverFrameworks-UserMode" Guid="{2E35AAEB-857F-4BEB-A418-2E6C0E54D988}" />
<EventID>1003</EventID>
<Version>1</Version>
<Level>4</Level>
<Task>17</Task>
<Opcode>1</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2016-08-19T01:42:06.292278900Z" />
<EventRecordID>17516</EventRecordID>
<Correlation />
<Execution ProcessID="456" ThreadID="2932" />
<Channel>Microsoft-Windows-DriverFrameworks-UserMode/Operational</Channel>
<Computer>XXXX</Computer>
<Security UserID="S-1-5-18" />
</System>
- <UserData>
- <UMDFDriverManagerHostCreateStart lifetime="{AFEC92AD-6015-4AB4-86AE-F34CEE06A977}" xmlns:auto-ns2="http://schemas.microsoft.com/win/2004/08/events" xmlns="http://www.microsoft.com/DriverFrameworks/UserMode/Event">
<HostGuid>{193a1820-d9ac-4997-8c55-be817523f6aa}</HostGuid>
<DeviceInstanceId>USB.VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID.6&3400EB54&1&0000</DeviceInstanceId>
</UMDFDriverManagerHostCreateStart>
</UserData>
</Event>
And the custom event filter for my task:
<QueryList>
<Query Id="0" Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational">
<Select Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational">*[System[Provider[@Name='Microsoft-Windows-DriverFrameworks-UserMode'] and EventID=1003]] and *[UserData[UMDFDriverManagerHostCreateStart[DeviceInstanceId="USB.VID_04E8&PID_6860&MS_COMP_MTP&SAMSUNG_ANDROID.6&3400EB54&1&0000"]]]</Select>
</Query>
</QueryList>
Similarly for a USB drive it was event 2100, 2101, 2105, 2106
For a specific USB Drive:
- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
<Provider Name="Microsoft-Windows-DriverFrameworks-UserMode" Guid="{2E35AAEB-857F-4BEB-A418-2E6C0E54D988}" />
<EventID>2101</EventID>
<Version>1</Version>
<Level>4</Level>
<Task>37</Task>
<Opcode>2</Opcode>
<Keywords>0x8000000000000000</Keywords>
<TimeCreated SystemTime="2016-08-19T01:52:37.922289600Z" />
<EventRecordID>17662</EventRecordID>
<Correlation />
<Execution ProcessID="10956" ThreadID="11892" />
<Channel>Microsoft-Windows-DriverFrameworks-UserMode/Operational</Channel>
<Computer>XXXX</Computer>
<Security UserID="S-1-5-19" />
</System>
- <UserData>
- <UMDFHostDeviceRequest instance="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_SANDISK&PROD_SANDISK_CRUZER&REV_8.02#0774230A28933B7E&0#" lifetime="{4493DBFB-81E8-4277-933D-955C4DDDD482}" xmlns:auto-ns2="http://schemas.microsoft.com/win/2004/08/events" xmlns="http://www.microsoft.com/DriverFrameworks/UserMode/Event">
- <Request major="27" minor="20">
<Argument>0x0</Argument>
<Argument>0x141b</Argument>
<Argument>0x0</Argument>
<Argument>0x0</Argument>
</Request>
<Status>0</Status>
</UMDFHostDeviceRequest>
</UserData>
</Event>
It looks like event 2101 happens 3 times with slightly different "<request>"
tags when I plug in my usb drive:
<Request major="27" minor="20">
<Request major="27" minor="9">
<Request major="27" minor="0">
I have no idea what this means but here is a filter for only one of them to avoid multiple triggers: (this will only trigger for this specific USB drive)
<QueryList>
<Query Id="0" Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational">
<Select Path="Microsoft-Windows-DriverFrameworks-UserMode/Operational">*[System[Provider[@Name='Microsoft-Windows-DriverFrameworks-UserMode'] and EventID=2101]] and *[UserData[UMDFHostDeviceRequest[@instance="WPDBUSENUMROOT\UMB\2&37C186B&0&STORAGE#VOLUME#_??_USBSTOR#DISK&VEN_SANDISK&PROD_SANDISK_CRUZER&REV_8.02#0774230A28933B7E&0#" and Request[@major="27" and @minor="20"]]]]</Select>
</Query>
</QueryList>
Note that the ampersands must be escaped as &