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
146ff491
Commit
146ff491
authored
Oct 14, 2013
by
Nikolay Sivov
Committed by
Alexandre Julliard
Oct 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Support pinning module refcount with LdrAddRefDll().
parent
abdf0252
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
2 deletions
+60
-2
loader.c
dlls/ntdll/loader.c
+5
-2
rtl.c
dlls/ntdll/tests/rtl.c
+52
-0
winternl.h
include/winternl.h
+3
-0
No files found.
dlls/ntdll/loader.c
View file @
146ff491
...
...
@@ -2124,13 +2124,16 @@ NTSTATUS WINAPI LdrAddRefDll( ULONG flags, HMODULE module )
NTSTATUS
ret
=
STATUS_SUCCESS
;
WINE_MODREF
*
wm
;
if
(
flags
)
FIXME
(
"%p flags %x not implemented
\n
"
,
module
,
flags
);
if
(
flags
&
~
LDR_ADDREF_DLL_PIN
)
FIXME
(
"%p flags %x not implemented
\n
"
,
module
,
flags
);
RtlEnterCriticalSection
(
&
loader_section
);
if
((
wm
=
get_modref
(
module
)))
{
if
(
wm
->
ldr
.
LoadCount
!=
-
1
)
wm
->
ldr
.
LoadCount
++
;
if
(
flags
&
LDR_ADDREF_DLL_PIN
)
wm
->
ldr
.
LoadCount
=
-
1
;
else
if
(
wm
->
ldr
.
LoadCount
!=
-
1
)
wm
->
ldr
.
LoadCount
++
;
TRACE
(
"(%s) ldr.LoadCount: %d
\n
"
,
debugstr_w
(
wm
->
ldr
.
BaseDllName
.
Buffer
),
wm
->
ldr
.
LoadCount
);
}
else
ret
=
STATUS_INVALID_PARAMETER
;
...
...
dlls/ntdll/tests/rtl.c
View file @
146ff491
...
...
@@ -89,6 +89,7 @@ static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,US
static
CHAR
*
(
WINAPI
*
pRtlIpv4AddressToStringA
)(
const
IN_ADDR
*
,
LPSTR
);
static
NTSTATUS
(
WINAPI
*
pRtlIpv4AddressToStringExA
)(
const
IN_ADDR
*
,
USHORT
,
LPSTR
,
PULONG
);
static
NTSTATUS
(
WINAPI
*
pRtlIpv4StringToAddressA
)(
PCSTR
,
BOOLEAN
,
PCSTR
*
,
IN_ADDR
*
);
static
NTSTATUS
(
WINAPI
*
pLdrAddRefDll
)(
ULONG
,
HMODULE
);
static
HMODULE
hkernel32
=
0
;
static
BOOL
(
WINAPI
*
pIsWow64Process
)(
HANDLE
,
PBOOL
);
...
...
@@ -133,6 +134,7 @@ static void InitFunctionPtrs(void)
pRtlIpv4AddressToStringA
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlIpv4AddressToStringA"
);
pRtlIpv4AddressToStringExA
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlIpv4AddressToStringExA"
);
pRtlIpv4StringToAddressA
=
(
void
*
)
GetProcAddress
(
hntdll
,
"RtlIpv4StringToAddressA"
);
pLdrAddRefDll
=
(
void
*
)
GetProcAddress
(
hntdll
,
"LdrAddRefDll"
);
}
hkernel32
=
LoadLibraryA
(
"kernel32.dll"
);
ok
(
hkernel32
!=
0
,
"LoadLibrary failed
\n
"
);
...
...
@@ -1486,6 +1488,55 @@ static void test_RtlIpv4StringToAddress(void)
}
}
static
void
test_LdrAddRefDll
(
void
)
{
HMODULE
mod
,
mod2
;
NTSTATUS
status
;
BOOL
ret
;
mod
=
LoadLibraryA
(
"comctl32.dll"
);
ok
(
mod
!=
NULL
,
"got %p
\n
"
,
mod
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
mod2
=
GetModuleHandleA
(
"comctl32.dll"
);
ok
(
mod2
==
NULL
,
"got %p
\n
"
,
mod2
);
/* load, addref and release 2 times */
mod
=
LoadLibraryA
(
"comctl32.dll"
);
ok
(
mod
!=
NULL
,
"got %p
\n
"
,
mod
);
status
=
pLdrAddRefDll
(
0
,
mod
);
ok
(
status
==
STATUS_SUCCESS
,
"got 0x%08x
\n
"
,
status
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
mod2
=
GetModuleHandleA
(
"comctl32.dll"
);
ok
(
mod2
!=
NULL
,
"got %p
\n
"
,
mod2
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
mod2
=
GetModuleHandleA
(
"comctl32.dll"
);
ok
(
mod2
==
NULL
,
"got %p
\n
"
,
mod2
);
/* pin refcount */
mod
=
LoadLibraryA
(
"comctl32.dll"
);
ok
(
mod
!=
NULL
,
"got %p
\n
"
,
mod
);
status
=
pLdrAddRefDll
(
LDR_ADDREF_DLL_PIN
,
mod
);
ok
(
status
==
STATUS_SUCCESS
,
"got 0x%08x
\n
"
,
status
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
ret
=
FreeLibrary
(
mod
);
ok
(
ret
,
"got %d
\n
"
,
ret
);
mod2
=
GetModuleHandleA
(
"comctl32.dll"
);
ok
(
mod2
!=
NULL
,
"got %p
\n
"
,
mod2
);
}
START_TEST
(
rtl
)
{
InitFunctionPtrs
();
...
...
@@ -1510,4 +1561,5 @@ START_TEST(rtl)
test_RtlIpv4AddressToString
();
test_RtlIpv4AddressToStringEx
();
test_RtlIpv4StringToAddress
();
test_LdrAddRefDll
();
}
include/winternl.h
View file @
146ff491
...
...
@@ -1970,6 +1970,9 @@ typedef struct _LDR_MODULE
#define LDR_DONT_RESOLVE_REFS 0x40000000
#define LDR_WINE_INTERNAL 0x80000000
/* flag for LdrAddRefDll */
#define LDR_ADDREF_DLL_PIN 0x00000001
/* FIXME: to be checked */
#define MAXIMUM_FILENAME_LENGTH 256
...
...
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