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
80a69b6b
Commit
80a69b6b
authored
Nov 25, 1998
by
Ulrich Weigand
Committed by
Alexandre Julliard
Nov 25, 1998
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved ...Resource16 routines to loader/resource.c.
Implemented accessing PE-file resources with 16-bit resource routines.
parent
5443a7e6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
235 additions
and
77 deletions
+235
-77
module.h
include/module.h
+10
-0
resource.c
loader/ne/resource.c
+34
-75
resource.c
loader/resource.c
+191
-2
No files found.
include/module.h
View file @
80a69b6b
...
...
@@ -52,6 +52,7 @@ typedef struct _NE_MODULE
WORD
self_loading_sel
;
/* 46 Selector used for self-loading apps. */
LPDOSTASK
lpDosTask
;
LPVOID
dos_image
;
/* pointer to DOS memory (for DOS apps) */
LPVOID
hRsrcMap
;
/* HRSRC 16->32 map (for 32-bit modules) */
}
NE_MODULE
;
...
...
@@ -168,6 +169,11 @@ extern HINSTANCE16 NE_LoadModule( LPCSTR name, HINSTANCE16 *hPrevInstance,
/* loader/ne/resource.c */
extern
HGLOBAL16
WINAPI
NE_DefResourceHandler
(
HGLOBAL16
,
HMODULE16
,
HRSRC16
);
extern
BOOL32
NE_InitResourceHandler
(
HMODULE16
hModule
);
extern
HRSRC16
NE_FindResource
(
NE_MODULE
*
pModule
,
LPCSTR
name
,
LPCSTR
type
);
extern
INT16
NE_AccessResource
(
NE_MODULE
*
pModule
,
HRSRC16
hRsrc
);
extern
DWORD
NE_SizeofResource
(
NE_MODULE
*
pModule
,
HRSRC16
hRsrc
);
extern
HGLOBAL16
NE_LoadResource
(
NE_MODULE
*
pModule
,
HRSRC16
hRsrc
);
extern
BOOL16
NE_FreeResource
(
NE_MODULE
*
pModule
,
HGLOBAL16
handle
);
/* loader/ne/segment.c */
extern
BOOL32
NE_LoadSegment
(
NE_MODULE
*
pModule
,
WORD
segnum
);
...
...
@@ -178,6 +184,10 @@ extern BOOL32 NE_CreateSegments( NE_MODULE *pModule );
extern
HINSTANCE16
NE_CreateInstance
(
NE_MODULE
*
pModule
,
HINSTANCE16
*
prev
,
BOOL32
lib_only
);
/* loader/ne/convert.c */
HGLOBAL16
NE_LoadPEResource
(
NE_MODULE
*
pModule
,
WORD
type
,
LPVOID
bits
,
DWORD
size
);
BOOL16
NE_FreePEResource
(
NE_MODULE
*
pModule
,
HGLOBAL16
handle
);
/* if1632/builtin.c */
extern
BOOL32
BUILTIN_Init
(
void
);
extern
HMODULE16
BUILTIN_LoadModule
(
LPCSTR
name
,
BOOL32
force
);
...
...
loader/ne/resource.c
View file @
80a69b6b
This diff is collapsed.
Click to expand it.
loader/resource.c
View file @
80a69b6b
...
...
@@ -20,6 +20,7 @@
#include "task.h"
#include "process.h"
#include "module.h"
#include "file.h"
#include "resource.h"
#include "debug.h"
#include "libres.h"
...
...
@@ -28,6 +29,111 @@
extern
WORD
WINE_LanguageId
;
#define HRSRC_MAP_BLOCKSIZE 16
typedef
struct
_HRSRC_ELEM
{
HANDLE32
hRsrc
;
WORD
type
;
}
HRSRC_ELEM
;
typedef
struct
_HRSRC_MAP
{
int
nAlloc
;
int
nUsed
;
HRSRC_ELEM
*
elem
;
}
HRSRC_MAP
;
/**********************************************************************
* MapHRsrc32To16
*/
static
HRSRC16
MapHRsrc32To16
(
NE_MODULE
*
pModule
,
HANDLE32
hRsrc32
,
WORD
type
)
{
HRSRC_MAP
*
map
=
(
HRSRC_MAP
*
)
pModule
->
hRsrcMap
;
HRSRC_ELEM
*
newElem
;
int
i
;
/* On first call, initialize HRSRC map */
if
(
!
map
)
{
if
(
!
(
map
=
(
HRSRC_MAP
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
HRSRC_MAP
)
)
)
)
{
ERR
(
resource
,
"Cannot allocate HRSRC map
\n
"
);
return
0
;
}
pModule
->
hRsrcMap
=
(
LPVOID
)
map
;
}
/* Check whether HRSRC32 already in map */
for
(
i
=
0
;
i
<
map
->
nUsed
;
i
++
)
if
(
map
->
elem
[
i
].
hRsrc
==
hRsrc32
)
return
(
HRSRC16
)(
i
+
1
);
/* If no space left, grow table */
if
(
map
->
nUsed
==
map
->
nAlloc
)
{
if
(
!
(
newElem
=
(
HRSRC_ELEM
*
)
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
map
->
elem
,
(
map
->
nAlloc
+
HRSRC_MAP_BLOCKSIZE
)
*
sizeof
(
HRSRC_ELEM
)
)
))
{
ERR
(
resource
,
"Cannot grow HRSRC map
\n
"
);
return
0
;
}
map
->
elem
=
newElem
;
map
->
nAlloc
+=
HRSRC_MAP_BLOCKSIZE
;
}
/* Add HRSRC32 to table */
map
->
elem
[
map
->
nUsed
].
hRsrc
=
hRsrc32
;
map
->
elem
[
map
->
nUsed
].
type
=
type
;
map
->
nUsed
++
;
return
(
HRSRC16
)
map
->
nUsed
;
}
/**********************************************************************
* MapHRsrc16To32
*/
static
HANDLE32
MapHRsrc16To32
(
NE_MODULE
*
pModule
,
HRSRC16
hRsrc16
)
{
HRSRC_MAP
*
map
=
(
HRSRC_MAP
*
)
pModule
->
hRsrcMap
;
if
(
!
map
||
!
hRsrc16
||
(
int
)
hRsrc16
>
map
->
nUsed
)
return
0
;
return
map
->
elem
[(
int
)
hRsrc16
-
1
].
hRsrc
;
}
/**********************************************************************
* MapHRsrc16ToType
*/
static
WORD
MapHRsrc16ToType
(
NE_MODULE
*
pModule
,
HRSRC16
hRsrc16
)
{
HRSRC_MAP
*
map
=
(
HRSRC_MAP
*
)
pModule
->
hRsrcMap
;
if
(
!
map
||
!
hRsrc16
||
(
int
)
hRsrc16
>
map
->
nUsed
)
return
0
;
return
map
->
elem
[(
int
)
hRsrc16
-
1
].
type
;
}
/**********************************************************************
* FindResource16 (KERNEL.60)
*/
HRSRC16
WINAPI
FindResource16
(
HMODULE16
hModule
,
SEGPTR
name
,
SEGPTR
type
)
{
LPCSTR
nameStr
=
HIWORD
(
name
)
?
PTR_SEG_TO_LIN
(
name
)
:
(
LPCSTR
)
name
;
LPCSTR
typeStr
=
HIWORD
(
type
)
?
PTR_SEG_TO_LIN
(
type
)
:
(
LPCSTR
)
type
;
NE_MODULE
*
pModule
=
NE_GetPtr
(
hModule
);
if
(
!
pModule
)
return
0
;
if
(
pModule
->
module32
)
{
HANDLE32
hRsrc32
=
FindResource32A
(
pModule
->
module32
,
nameStr
,
typeStr
);
return
MapHRsrc32To16
(
pModule
,
hRsrc32
,
HIWORD
(
type
)
?
0
:
type
);
}
return
NE_FindResource
(
pModule
,
nameStr
,
typeStr
);
}
/**********************************************************************
* FindResource32A (KERNEL32.128)
...
...
@@ -107,6 +213,27 @@ HRSRC32 WINAPI FindResource32W(HINSTANCE32 hModule, LPCWSTR name, LPCWSTR type)
return
FindResourceEx32W
(
hModule
,
type
,
name
,
WINE_LanguageId
);
}
/**********************************************************************
* LoadResource16 (KERNEL.61)
*/
HGLOBAL16
WINAPI
LoadResource16
(
HMODULE16
hModule
,
HRSRC16
hRsrc
)
{
NE_MODULE
*
pModule
=
NE_GetPtr
(
hModule
);
if
(
!
pModule
)
return
0
;
if
(
pModule
->
module32
)
{
HANDLE32
hRsrc32
=
MapHRsrc16To32
(
pModule
,
hRsrc
);
WORD
type
=
MapHRsrc16ToType
(
pModule
,
hRsrc
);
HGLOBAL32
image
=
LoadResource32
(
pModule
->
module32
,
hRsrc32
);
DWORD
size
=
SizeofResource32
(
pModule
->
module32
,
hRsrc32
);
LPVOID
bits
=
LockResource32
(
image
);
return
NE_LoadPEResource
(
pModule
,
type
,
bits
,
size
);
}
return
NE_LoadResource
(
pModule
,
hRsrc
);
}
/**********************************************************************
* LoadResource32 (KERNEL32.370)
...
...
@@ -144,6 +271,21 @@ HGLOBAL32 WINAPI LoadResource32(
return
0
;
}
/**********************************************************************
* LockResource16 (KERNEL.62)
*/
SEGPTR
WINAPI
WIN16_LockResource16
(
HGLOBAL16
handle
)
{
TRACE
(
resource
,
"handle=%04x
\n
"
,
handle
);
if
(
!
handle
)
return
(
SEGPTR
)
0
;
/* May need to reload the resource if discarded */
return
(
SEGPTR
)
WIN16_GlobalLock16
(
handle
);
}
LPVOID
WINAPI
LockResource16
(
HGLOBAL16
handle
)
{
return
(
LPVOID
)
PTR_SEG_TO_LIN
(
WIN16_LockResource16
(
handle
)
);
}
/**********************************************************************
* LockResource32 (KERNEL32.384)
...
...
@@ -155,6 +297,20 @@ LPVOID WINAPI LockResource32( HGLOBAL32 handle )
/**********************************************************************
* FreeResource16 (KERNEL.63)
*/
BOOL16
WINAPI
FreeResource16
(
HGLOBAL16
handle
)
{
NE_MODULE
*
pModule
=
NE_GetPtr
(
FarGetOwner
(
handle
)
);
if
(
!
pModule
)
return
handle
;
if
(
pModule
->
module32
)
return
NE_FreePEResource
(
pModule
,
handle
);
return
NE_FreeResource
(
pModule
,
handle
);
}
/**********************************************************************
* FreeResource32 (KERNEL32.145)
*/
BOOL32
WINAPI
FreeResource32
(
HGLOBAL32
handle
)
...
...
@@ -163,6 +319,23 @@ BOOL32 WINAPI FreeResource32( HGLOBAL32 handle )
return
TRUE
;
}
/**********************************************************************
* AccessResource16 (KERNEL.64)
*/
INT16
WINAPI
AccessResource16
(
HINSTANCE16
hModule
,
HRSRC16
hRsrc
)
{
NE_MODULE
*
pModule
=
NE_GetPtr
(
hModule
);
if
(
!
pModule
)
return
0
;
if
(
pModule
->
module32
)
{
HANDLE32
hRsrc32
=
MapHRsrc16To32
(
pModule
,
hRsrc
);
HFILE32
hFile32
=
AccessResource32
(
pModule
->
module32
,
hRsrc32
);
return
HFILE32_TO_HFILE16
(
hFile32
);
}
return
NE_AccessResource
(
pModule
,
hRsrc
);
}
/**********************************************************************
* AccessResource32 (KERNEL32.64)
...
...
@@ -175,6 +348,23 @@ INT32 WINAPI AccessResource32( HMODULE32 hModule, HRSRC32 hRsrc )
/**********************************************************************
* SizeofResource16 (KERNEL.65)
*/
DWORD
WINAPI
SizeofResource16
(
HMODULE16
hModule
,
HRSRC16
hRsrc
)
{
NE_MODULE
*
pModule
=
NE_GetPtr
(
hModule
);
if
(
!
pModule
)
return
0
;
if
(
pModule
->
module32
)
{
HANDLE32
hRsrc32
=
MapHRsrc16To32
(
pModule
,
hRsrc
);
return
SizeofResource32
(
hModule
,
hRsrc32
);
}
return
NE_SizeofResource
(
pModule
,
hRsrc
);
}
/**********************************************************************
* SizeofResource32 (KERNEL32.522)
*/
DWORD
WINAPI
SizeofResource32
(
HINSTANCE32
hModule
,
HRSRC32
hRsrc
)
...
...
@@ -190,8 +380,7 @@ DWORD WINAPI SizeofResource32( HINSTANCE32 hModule, HRSRC32 hRsrc )
return
PE_SizeofResource32
(
hModule
,
hRsrc
);
case
MODULE32_ELF
:
FIXME
(
module
,
"Not implemented for ELF modules
\n
"
);
break
;
return
LIBRES_SizeofResource
(
hModule
,
hRsrc
);
default:
ERR
(
module
,
"unknown module type %d
\n
"
,
wm
->
type
);
...
...
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