Second I believe CreateQuery of d3d9 isn't correct. MSDN states that ppQuery can be NULL as explained above. Right now d3d9's CreateQuery returns D3DERR_INVALIDCALL when ppQuery is NULL. Further I'm not sure if wined3d's CreateQuery is correctly called from d3d9 as ppQuery isn't passed to it but some other object which isn't NULL if I'm right.
The call to wined3d from d3d9 is correct, didn't look well for all different datatypes and pointer tricks. Then only the 'NULL=ppQuery' line is wrong in d3d9's CreateQuery.
Roderick