Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
bc4a4f5f
Commit
bc4a4f5f
authored
Jan 07, 2013
by
Rico Schüller
Committed by
Alexandre Julliard
Jan 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Handle invalid byte code in D3DXFindShaderComment().
parent
ae9b07fd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
5 deletions
+31
-5
shader.c
dlls/d3dx9_36/shader.c
+10
-5
shader.c
dlls/d3dx9_36/tests/shader.c
+21
-0
No files found.
dlls/d3dx9_36/shader.c
View file @
bc4a4f5f
...
...
@@ -40,6 +40,11 @@ HRESULT WINAPI D3DAssemble(LPCVOID data, SIZE_T datasize, LPCSTR filename,
UINT
flags
,
ID3DBlob
**
shader
,
ID3DBlob
**
error_messages
);
static
inline
BOOL
is_valid_bytecode
(
DWORD
token
)
{
return
(
token
&
0xfffe0000
)
==
0xfffe0000
;
}
const
char
*
WINAPI
D3DXGetPixelShaderProfile
(
struct
IDirect3DDevice9
*
device
)
{
D3DCAPS9
caps
;
...
...
@@ -147,17 +152,17 @@ const char * WINAPI D3DXGetVertexShaderProfile(struct IDirect3DDevice9 *device)
return
NULL
;
}
HRESULT
WINAPI
D3DXFindShaderComment
(
CONST
DWORD
*
byte_code
,
DWORD
fourcc
,
LPCVOID
*
data
,
UINT
*
size
)
HRESULT
WINAPI
D3DXFindShaderComment
(
const
DWORD
*
byte_code
,
DWORD
fourcc
,
const
void
**
data
,
UINT
*
size
)
{
CONST
DWORD
*
ptr
=
byte_code
;
const
DWORD
*
ptr
=
byte_code
;
TRACE
(
"
(%p, %x, %p, %p)
\n
"
,
byte_code
,
fourcc
,
data
,
size
);
TRACE
(
"
byte_code %p, fourcc %x, data %p, size %p
\n
"
,
byte_code
,
fourcc
,
data
,
size
);
if
(
data
)
*
data
=
NULL
;
if
(
size
)
*
size
=
0
;
if
(
!
byte_code
)
return
D3DERR_INVALIDCALL
;
if
(
!
byte_code
)
return
D3DERR_INVALIDCALL
;
if
(
!
is_valid_bytecode
(
*
byte_code
))
return
D3DXERR_INVALIDDATA
;
while
(
*++
ptr
!=
D3DSIO_END
)
{
...
...
dlls/d3dx9_36/tests/shader.c
View file @
bc4a4f5f
...
...
@@ -20,6 +20,12 @@
#include "wine/test.h"
#include "d3dx9.h"
static
const
DWORD
shader_zero
[]
=
{
0x0
};
static
const
DWORD
shader_invalid
[]
=
{
0xeeee0100
};
static
const
DWORD
shader_empty
[]
=
{
0xfffeffff
,
0x0000ffff
};
static
const
DWORD
simple_vs
[]
=
{
0xfffe0101
,
/* vs_1_1 */
0x0000001f
,
0x80000000
,
0x900f0000
,
/* dcl_position0 v0 */
...
...
@@ -330,6 +336,21 @@ static void test_find_shader_comment(void)
ok
(
hr
==
D3D_OK
,
"Got result %x, expected 0 (D3D_OK)
\n
"
,
hr
);
ok
(
data
==
(
LPCVOID
)(
shader_with_ctab
+
6
),
"Got result %p, expected %p
\n
"
,
data
,
shader_with_ctab
+
6
);
ok
(
size
==
28
,
"Got result %d, expected 28
\n
"
,
size
);
hr
=
D3DXFindShaderComment
(
shader_zero
,
MAKEFOURCC
(
'C'
,
'T'
,
'A'
,
'B'
),
&
data
,
&
size
);
ok
(
hr
==
D3DXERR_INVALIDDATA
,
"Got result %x, expected %x (D3DXERR_INVALIDDATA)
\n
"
,
hr
,
D3DXERR_INVALIDDATA
);
ok
(
!
data
,
"Got %p, expected NULL
\n
"
,
data
);
ok
(
!
size
,
"Got %u, expected 0
\n
"
,
size
);
hr
=
D3DXFindShaderComment
(
shader_invalid
,
MAKEFOURCC
(
'C'
,
'T'
,
'A'
,
'B'
),
&
data
,
&
size
);
ok
(
hr
==
D3DXERR_INVALIDDATA
,
"Got result %x, expected %x (D3DXERR_INVALIDDATA)
\n
"
,
hr
,
D3DXERR_INVALIDDATA
);
ok
(
!
data
,
"Got %p, expected NULL
\n
"
,
data
);
ok
(
!
size
,
"Got %u, expected 0
\n
"
,
size
);
hr
=
D3DXFindShaderComment
(
shader_empty
,
MAKEFOURCC
(
'C'
,
'T'
,
'A'
,
'B'
),
&
data
,
&
size
);
ok
(
hr
==
S_FALSE
,
"Got result %x, expected %x (S_FALSE)
\n
"
,
hr
,
S_FALSE
);
ok
(
!
data
,
"Got %p, expected NULL
\n
"
,
data
);
ok
(
!
size
,
"Got %u, expected 0
\n
"
,
size
);
}
static
void
test_get_shader_constant_table_ex
(
void
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment