This patch should fix the problem with Queries http://www.winehq.org/pipermail/wine-devel/2005-October/041237.html
This patch is not the same as the problem for halflife2. In case ppQuery is NULL applications can detect if a certain query Type is supported. This should indeed fail for unsupported types. In case of halflife2 ppQuery isn't NULL and right D3D_OK is returned while it are unsupported types. Returning D3DERR_NOTAVAILABLE seems to be right to me. (the attached patch implements what I mean; the patch is on top of the other patch you showed me)
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.
When the Query mechanism isn't available halflife2 moves over to a different backend (I think). Suddenly the screen becomes black and you see hundreds of lines like this: fixme:d3d_surface:IWineD3DSurfaceImpl_UnlockRect unsupported unlocking to surface surf@0x7fe1d810 usage(512)
When I let CreateQuery 'fail' as it should in my opinion for unsupported query types then halflife2 stops working. It prints those unlockrect lines and it seems to get out of video memory. I think the d3d bug stuff should be handled here and if it is correct, the hl2 breaking caused by patches like this should be handled in bugzilla.
Roderick