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
32d2be57
Commit
32d2be57
authored
Jun 01, 2009
by
Tony Wasserka
Committed by
Alexandre Julliard
Jun 02, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
d3dx9: Add utility functions for loading files and resources into memory.
parent
f9222833
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
1 deletion
+110
-1
Makefile.in
dlls/d3dx9_36/Makefile.in
+2
-1
d3dx9_36_private.h
dlls/d3dx9_36/d3dx9_36_private.h
+4
-0
util.c
dlls/d3dx9_36/util.c
+104
-0
No files found.
dlls/d3dx9_36/Makefile.in
View file @
32d2be57
...
...
@@ -13,7 +13,8 @@ C_SRCS = \
mesh.c
\
shader.c
\
sprite.c
\
surface.c
surface.c
\
util.c
RC_SRCS
=
version.rc
...
...
dlls/d3dx9_36/d3dx9_36_private.h
View file @
32d2be57
...
...
@@ -26,6 +26,10 @@
#include "wingdi.h"
#include "d3dx9.h"
/* for internal use */
HRESULT
map_view_of_file
(
LPCWSTR
filename
,
LPVOID
*
buffer
,
DWORD
*
length
);
HRESULT
load_resource_into_memory
(
HMODULE
module
,
HRSRC
resinfo
,
LPVOID
*
buffer
,
DWORD
*
length
);
/* ID3DXFont */
typedef
struct
ID3DXFontImpl
...
...
dlls/d3dx9_36/util.c
0 → 100644
View file @
32d2be57
/*
* Copyright (C) 2009 Tony Wasserka
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
*/
#include "wine/debug.h"
#include "d3dx9_36_private.h"
/************************************************************
* map_view_of_file
*
* Loads a file into buffer and stores the number of read bytes in length.
*
* PARAMS
* filename [I] name of the file to be loaded
* buffer [O] pointer to destination buffer
* length [O] size of the obtained data
*
* RETURNS
* Success: D3D_OK
* Failure:
* see error codes for CreateFileW, GetFileSize, CreateFileMapping and MapViewOfFile
*
* NOTES
* The caller must UnmapViewOfFile when it doesn't need the data anymore
*
*/
HRESULT
map_view_of_file
(
LPCWSTR
filename
,
LPVOID
*
buffer
,
DWORD
*
length
)
{
HANDLE
hfile
,
hmapping
=
NULL
;
hfile
=
CreateFileW
(
filename
,
GENERIC_READ
,
FILE_SHARE_READ
,
0
,
OPEN_EXISTING
,
0
,
0
);
if
(
hfile
==
INVALID_HANDLE_VALUE
)
goto
error
;
*
length
=
GetFileSize
(
hfile
,
NULL
);
if
(
*
length
==
INVALID_FILE_SIZE
)
goto
error
;
hmapping
=
CreateFileMappingW
(
hfile
,
NULL
,
PAGE_READONLY
,
0
,
0
,
NULL
);
if
(
!
hmapping
)
goto
error
;
*
buffer
=
MapViewOfFile
(
hmapping
,
FILE_MAP_READ
,
0
,
0
,
0
);
if
(
*
buffer
==
NULL
)
goto
error
;
CloseHandle
(
hmapping
);
CloseHandle
(
hfile
);
return
S_OK
;
error:
CloseHandle
(
hmapping
);
CloseHandle
(
hfile
);
return
HRESULT_FROM_WIN32
(
GetLastError
());
}
/************************************************************
* load_resource_into_memory
*
* Loads a resource into buffer and stores the number of
* read bytes in length.
*
* PARAMS
* module [I] handle to the module
* resinfo [I] handle to the resource's information block
* buffer [O] pointer to destination buffer
* length [O] size of the obtained data
*
* RETURNS
* Success: D3D_OK
* Failure:
* See error codes for SizeofResource, LoadResource and LockResource
*
* NOTES
* The memory doesn't need to be freed by the caller manually
*
*/
HRESULT
load_resource_into_memory
(
HMODULE
module
,
HRSRC
resinfo
,
LPVOID
*
buffer
,
DWORD
*
length
)
{
HGLOBAL
resource
;
*
length
=
SizeofResource
(
module
,
resinfo
);
if
(
*
length
==
0
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
resource
=
LoadResource
(
module
,
resinfo
);
if
(
!
resource
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
*
buffer
=
LockResource
(
resource
);
if
(
*
buffer
==
NULL
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
return
S_OK
;
}
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