mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-11-29 01:24:11 +01:00
[d3d8/9] Add several Set/GetPrivateData validations
This commit is contained in:
parent
48d8e7c402
commit
0e6be8a48b
@ -29,6 +29,8 @@ namespace dxvk {
|
|||||||
DWORD Flags) final {
|
DWORD Flags) final {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
if (Flags & D3DSPD_IUNKNOWN) {
|
if (Flags & D3DSPD_IUNKNOWN) {
|
||||||
|
if(unlikely(SizeOfData != sizeof(IUnknown*)))
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
IUnknown* unknown =
|
IUnknown* unknown =
|
||||||
const_cast<IUnknown*>(
|
const_cast<IUnknown*>(
|
||||||
reinterpret_cast<const IUnknown*>(pData));
|
reinterpret_cast<const IUnknown*>(pData));
|
||||||
@ -39,7 +41,7 @@ namespace dxvk {
|
|||||||
hr = m_privateData.setData(
|
hr = m_privateData.setData(
|
||||||
refguid, SizeOfData, pData);
|
refguid, SizeOfData, pData);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr)))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
@ -49,11 +51,20 @@ namespace dxvk {
|
|||||||
REFGUID refguid,
|
REFGUID refguid,
|
||||||
void* pData,
|
void* pData,
|
||||||
DWORD* pSizeOfData) final {
|
DWORD* pSizeOfData) final {
|
||||||
|
if (unlikely(pData == nullptr && pSizeOfData == nullptr))
|
||||||
|
return D3DERR_NOTFOUND;
|
||||||
|
|
||||||
HRESULT hr = m_privateData.getData(
|
HRESULT hr = m_privateData.getData(
|
||||||
refguid, reinterpret_cast<UINT*>(pSizeOfData), pData);
|
refguid, reinterpret_cast<UINT*>(pSizeOfData), pData);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr))) {
|
||||||
return D3DERR_INVALIDCALL;
|
if(hr == DXGI_ERROR_MORE_DATA)
|
||||||
|
return D3DERR_MOREDATA;
|
||||||
|
else if (hr == DXGI_ERROR_NOT_FOUND)
|
||||||
|
return D3DERR_NOTFOUND;
|
||||||
|
else
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
}
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
@ -61,7 +72,7 @@ namespace dxvk {
|
|||||||
HRESULT STDMETHODCALLTYPE FreePrivateData(REFGUID refguid) final {
|
HRESULT STDMETHODCALLTYPE FreePrivateData(REFGUID refguid) final {
|
||||||
HRESULT hr = m_privateData.setData(refguid, 0, nullptr);
|
HRESULT hr = m_privateData.setData(refguid, 0, nullptr);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr)))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
|
@ -22,6 +22,8 @@ namespace dxvk {
|
|||||||
DWORD Flags) final {
|
DWORD Flags) final {
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
if (Flags & D3DSPD_IUNKNOWN) {
|
if (Flags & D3DSPD_IUNKNOWN) {
|
||||||
|
if(unlikely(SizeOfData != sizeof(IUnknown*)))
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
IUnknown* unknown =
|
IUnknown* unknown =
|
||||||
const_cast<IUnknown*>(
|
const_cast<IUnknown*>(
|
||||||
reinterpret_cast<const IUnknown*>(pData));
|
reinterpret_cast<const IUnknown*>(pData));
|
||||||
@ -32,7 +34,7 @@ namespace dxvk {
|
|||||||
hr = m_privateData.setData(
|
hr = m_privateData.setData(
|
||||||
refguid, SizeOfData, pData);
|
refguid, SizeOfData, pData);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr)))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
@ -42,11 +44,20 @@ namespace dxvk {
|
|||||||
REFGUID refguid,
|
REFGUID refguid,
|
||||||
void* pData,
|
void* pData,
|
||||||
DWORD* pSizeOfData) final {
|
DWORD* pSizeOfData) final {
|
||||||
|
if (unlikely(pData == nullptr && pSizeOfData == nullptr))
|
||||||
|
return D3DERR_NOTFOUND;
|
||||||
|
|
||||||
HRESULT hr = m_privateData.getData(
|
HRESULT hr = m_privateData.getData(
|
||||||
refguid, reinterpret_cast<UINT*>(pSizeOfData), pData);
|
refguid, reinterpret_cast<UINT*>(pSizeOfData), pData);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr))) {
|
||||||
return D3DERR_INVALIDCALL;
|
if(hr == DXGI_ERROR_MORE_DATA)
|
||||||
|
return D3DERR_MOREDATA;
|
||||||
|
else if (hr == DXGI_ERROR_NOT_FOUND)
|
||||||
|
return D3DERR_NOTFOUND;
|
||||||
|
else
|
||||||
|
return D3DERR_INVALIDCALL;
|
||||||
|
}
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
}
|
}
|
||||||
@ -54,7 +65,7 @@ namespace dxvk {
|
|||||||
HRESULT STDMETHODCALLTYPE FreePrivateData(REFGUID refguid) final {
|
HRESULT STDMETHODCALLTYPE FreePrivateData(REFGUID refguid) final {
|
||||||
HRESULT hr = m_privateData.setData(refguid, 0, nullptr);
|
HRESULT hr = m_privateData.setData(refguid, 0, nullptr);
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (unlikely(FAILED(hr)))
|
||||||
return D3DERR_INVALIDCALL;
|
return D3DERR_INVALIDCALL;
|
||||||
|
|
||||||
return D3D_OK;
|
return D3D_OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user