Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
5bc9da34
Commit
5bc9da34
authored
Feb 03, 2009
by
Christian Costa
Committed by
Alexandre Julliard
Feb 04, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dxof: Fix object files size limitation by mapping them into memory.
parent
8dc84666
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
d3dxof.c
dlls/d3dxof/d3dxof.c
+28
-24
d3dxof_private.h
dlls/d3dxof/d3dxof_private.h
+2
-0
No files found.
dlls/d3dxof/d3dxof.c
View file @
5bc9da34
...
...
@@ -46,8 +46,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
#define XOFFILE_FORMAT_FLOAT_BITS_32 MAKEFOUR('0','0','3','2')
#define XOFFILE_FORMAT_FLOAT_BITS_64 MAKEFOUR('0','0','6','4')
#define MAX_INPUT_SIZE 2000000
static
const
struct
IDirectXFileVtbl
IDirectXFile_Vtbl
;
static
const
struct
IDirectXFileBinaryVtbl
IDirectXFileBinary_Vtbl
;
static
const
struct
IDirectXFileDataVtbl
IDirectXFileData_Vtbl
;
...
...
@@ -130,8 +128,11 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
IDirectXFileEnumObjectImpl
*
object
;
HRESULT
hr
;
DWORD
header
[
4
];
DWORD
size
;
HANDLE
hFile
=
INVALID_HANDLE_VALUE
;
HANDLE
file_mapping
=
0
;
LPBYTE
buffer
=
NULL
;
DWORD
file_size
=
0
;
LPDXFILELOADMEMORY
lpdxflm
=
NULL
;
TRACE
(
"(%p/%p)->(%p,%x,%p)
\n
"
,
This
,
iface
,
pvSource
,
dwLoadOptions
,
ppEnumObj
);
...
...
@@ -150,17 +151,27 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
return
DXFILEERR_FILENOTFOUND
;
}
if
(
!
ReadFile
(
hFile
,
header
,
16
,
&
size
,
NULL
))
file_size
=
GetFileSize
(
hFile
,
NULL
);
if
(
file_size
<
16
)
{
hr
=
DXFILEERR_BADVALUE
;
hr
=
DXFILEERR_BADFILETYPE
;
goto
error
;
}
file_mapping
=
CreateFileMappingA
(
hFile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
if
(
!
file_mapping
)
{
hr
=
DXFILEERR_BADFILETYPE
;
goto
error
;
}
if
(
size
<
16
)
buffer
=
MapViewOfFile
(
file_mapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
if
(
!
buffer
)
{
hr
=
DXFILEERR_BADFILETYPE
;
goto
error
;
}
memcpy
(
header
,
buffer
,
16
);
}
else
if
(
dwLoadOptions
==
DXFILELOAD_FROMMEMORY
)
{
...
...
@@ -224,6 +235,8 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
object
->
source
=
dwLoadOptions
;
object
->
hFile
=
hFile
;
object
->
file_mapping
=
file_mapping
;
object
->
buffer
=
buffer
;
object
->
pDirectXFile
=
This
;
object
->
buf
.
pdxf
=
This
;
object
->
buf
.
txt
=
(
header
[
2
]
==
XOFFILE_FORMAT_TEXT
);
...
...
@@ -232,22 +245,8 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
if
(
dwLoadOptions
==
DXFILELOAD_FROMFILE
)
{
object
->
buf
.
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
MAX_INPUT_SIZE
+
1
);
if
(
!
object
->
buf
.
buffer
)
{
ERR
(
"Out of memory
\n
"
);
hr
=
DXFILEERR_BADALLOC
;
goto
error
;
}
ReadFile
(
hFile
,
object
->
buf
.
buffer
,
MAX_INPUT_SIZE
+
1
,
&
object
->
buf
.
rem_bytes
,
NULL
);
if
(
object
->
buf
.
rem_bytes
>
MAX_INPUT_SIZE
)
{
FIXME
(
"File size > %d not supported yet
\n
"
,
MAX_INPUT_SIZE
);
HeapFree
(
GetProcessHeap
(),
0
,
object
->
buf
.
buffer
);
hr
=
DXFILEERR_PARSEERROR
;
goto
error
;
}
object
->
buf
.
buffer
=
buffer
+
16
;
object
->
buf
.
rem_bytes
=
file_size
-
16
;
}
else
{
...
...
@@ -255,7 +254,7 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
object
->
buf
.
rem_bytes
=
lpdxflm
->
dSize
;
}
TRACE
(
"
Read %d bytes
\n
"
,
object
->
buf
.
rem_bytes
);
TRACE
(
"
Object size is %d bytes
\n
"
,
object
->
buf
.
rem_bytes
+
16
);
*
ppEnumObj
=
(
LPDIRECTXFILEENUMOBJECT
)
object
;
...
...
@@ -286,6 +285,10 @@ static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPV
return
DXFILE_OK
;
error:
if
(
buffer
)
UnmapViewOfFile
(
buffer
);
if
(
file_mapping
)
CloseHandle
(
file_mapping
);
if
(
hFile
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
hFile
);
*
ppEnumObj
=
NULL
;
...
...
@@ -972,7 +975,8 @@ static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* i
}
if
(
This
->
source
==
DXFILELOAD_FROMFILE
)
{
HeapFree
(
GetProcessHeap
(),
0
,
This
->
buf
.
buffer
);
UnmapViewOfFile
(
This
->
buffer
);
CloseHandle
(
This
->
file_mapping
);
CloseHandle
(
This
->
hFile
);
}
HeapFree
(
GetProcessHeap
(),
0
,
This
);
...
...
dlls/d3dxof/d3dxof_private.h
View file @
5bc9da34
...
...
@@ -149,6 +149,8 @@ typedef struct {
LONG
ref
;
DXFILELOADOPTIONS
source
;
HANDLE
hFile
;
HANDLE
file_mapping
;
LPBYTE
buffer
;
parse_buffer
buf
;
IDirectXFileImpl
*
pDirectXFile
;
ULONG
nb_xobjects
;
...
...
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