Public Group

# void * as parameter gives "abstract class" error

This topic is 3760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I found an example of a d3d9 hook on these forums (located here) and I'm trying to convert it to d3d8. I've replaced all the member functions of IDirect3DDevice9 with the ones of IDirect3DDevice8 (and I'm hoping that's all that I need to do... if I need to set up hooking differently for d3d8 someone let me know please) but I'm running into a problem with several functions that are different from the d3d9 versions, specifically ones with void * as a parameter, like this one:
STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE;

I'm getting this error:
c:\documents and settings\ben self\desktop\direct3d-hook (8)\direct3d-hook\mydirect3d8.h(101) : error C2259: 'MyDirect3DDevice8' : cannot instantiate abstract class
due to following members:
'HRESULT IDirect3DDevice8::SetVertexShaderConstant(DWORD,const void *,DWORD)' : is abstract
c:\program files\microsoft directx 9.0 sdk (october 2004)\include\d3d8.h(331) : see declaration of 'IDirect3DDevice8::SetVertexShaderConstant'
'HRESULT IDirect3DDevice8::GetVertexShaderConstant(DWORD,void *,DWORD)' : is abstract
c:\program files\microsoft directx 9.0 sdk (october 2004)\include\d3d8.h(332) : see declaration of 'IDirect3DDevice8::GetVertexShaderConstant'
'HRESULT IDirect3DDevice8::SetPixelShaderConstant(DWORD,const void *,DWORD)' : is abstract
c:\program files\microsoft directx 9.0 sdk (october 2004)\include\d3d8.h(343) : see declaration of 'IDirect3DDevice8::SetPixelShaderConstant'
'HRESULT IDirect3DDevice8::GetPixelShaderConstant(DWORD,void *,DWORD)' : is abstract
c:\program files\microsoft directx 9.0 sdk (october 2004)\include\d3d8.h(344) : see declaration of 'IDirect3DDevice8::GetPixelShaderConstant'
in this line:
*ppReturnedDeviceInterface = new MyDirect3DDevice8(this, *ppReturnedDeviceInterface);

What do these mean, and how do I fix them? If you want to see the whole code, it is basically exactly the same as the d3d9 hooking example except the functions are the d3d8 ones.

##### Share on other sites
The pointer(*) have nothing to do with your errors. This hooker work as a subclass of IDirect3D9/IDirect3DDevice9 and simply call the parent function for nearly all the functions. The problem is that those class (and directx8 version) are virtual pure abstract and you need to redefine all functions in your subclass or else it won't compile.

Now, what you want is to check d3d8.h or MSDN IDirect3D8/IDirect3DDevice8 documentation and check all functions one by one the name/number of arguments/type of arguments/type of return value and if something differ from the 9 version, change it so it's the same as dx8. The error you get it because DX8 only have a GetVertexShaderConstant and DX9 have multiple functions GetVertexShaderConstantF/GetVertexShaderConstantI/GetVertexShaderConstantB instead.

Now,... might I know why on hell would you want to revert back to DirectX8?

##### Share on other sites
Quote:
 Now, what you want is to check d3d8.h or MSDN IDirect3D8/IDirect3DDevice8 documentation and check all functions one by one the name/number of arguments/type of arguments/type of return value and if something differ from the 9 version, change it so it's the same as dx8.

Yeah, I've already done that. These are the only functions that are giving errors.

Fortunately, even though I've already done that, you solved it for me anyway! It turns out that in those four functions I missed changing something from 9 to 8 and I rechecked them and fixed it. I thought it was maybe the "void *" because all four of them had that.

Now at least it compiles... but the 21 typecasting warnings worry me slightly... oh well.

And the reason I'm going back to 8 is because I want to hook a certian application that uses d3d8.

EDIT: By the way, can anyone tell me how to actually get this hooking thing working? I can't even get it to work with the "Vertices.exe" it comes with.

• 18
• 11
• 19
• 9
• 52
• ### Forum Statistics

• Total Topics
631397
• Total Posts
2999810
×