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
257c56f5
Commit
257c56f5
authored
Apr 08, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
Apr 09, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntoskrnl.exe: Implement ExAcquireResourceExclusiveLite().
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
1304b4c7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
9 deletions
+72
-9
ntoskrnl.c
dlls/ntoskrnl.exe/ntoskrnl.c
+0
-9
sync.c
dlls/ntoskrnl.exe/sync.c
+71
-0
wdm.h
include/ddk/wdm.h
+1
-0
No files found.
dlls/ntoskrnl.exe/ntoskrnl.c
View file @
257c56f5
...
...
@@ -3356,15 +3356,6 @@ NTSTATUS WINAPI IoCsqInitialize(PIO_CSQ csq, PIO_CSQ_INSERT_IRP insert_irp, PIO_
}
/***********************************************************************
* ExAcquireResourceExclusiveLite (NTOSKRNL.EXE.@)
*/
BOOLEAN
WINAPI
ExAcquireResourceExclusiveLite
(
PERESOURCE
resource
,
BOOLEAN
wait
)
{
FIXME
(
":%p %u stub
\n
"
,
resource
,
wait
);
return
TRUE
;
}
/***********************************************************************
* ExDeleteResourceLite (NTOSKRNL.EXE.@)
*/
NTSTATUS
WINAPI
ExDeleteResourceLite
(
PERESOURCE
resource
)
...
...
dlls/ntoskrnl.exe/sync.c
View file @
257c56f5
...
...
@@ -30,6 +30,7 @@
#include "ddk/wdm.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "ntoskrnl_private.h"
...
...
@@ -718,6 +719,19 @@ void WINAPI ExReleaseFastMutexUnsafe( FAST_MUTEX *mutex )
KeSetEvent
(
&
mutex
->
Event
,
IO_NO_INCREMENT
,
FALSE
);
}
/* Use of the fields of an ERESOURCE structure seems to vary wildly between
* Windows versions. The below implementation uses them as follows:
*
* OwnerTable - contains a list of shared owners, including threads which do
* not currently own the resource
* OwnerTable[i].OwnerThread - shared owner TID
* OwnerTable[i].OwnerCount - recursion count of this shared owner (may be 0)
* OwnerEntry.OwnerThread - the owner TID if exclusively owned
* OwnerEntry.TableSize - the number of entries in OwnerTable, including threads
* which do not currently own the resource
* ActiveEntries - total number of acquisitions (incl. recursive ones)
*/
/***********************************************************************
* ExInitializeResourceLite (NTOSKRNL.EXE.@)
*/
...
...
@@ -727,3 +741,60 @@ NTSTATUS WINAPI ExInitializeResourceLite( ERESOURCE *resource )
memset
(
resource
,
0
,
sizeof
(
*
resource
));
return
STATUS_SUCCESS
;
}
/***********************************************************************
* ExAcquireResourceExclusiveLite (NTOSKRNL.EXE.@)
*/
BOOLEAN
WINAPI
ExAcquireResourceExclusiveLite
(
ERESOURCE
*
resource
,
BOOLEAN
wait
)
{
KIRQL
irql
;
TRACE
(
"resource %p, wait %u.
\n
"
,
resource
,
wait
);
KeAcquireSpinLock
(
&
resource
->
SpinLock
,
&
irql
);
if
(
resource
->
OwnerEntry
.
OwnerThread
==
(
ERESOURCE_THREAD
)
KeGetCurrentThread
())
{
resource
->
ActiveEntries
++
;
KeReleaseSpinLock
(
&
resource
->
SpinLock
,
irql
);
return
TRUE
;
}
/* In order to avoid a race between waiting for the ExclusiveWaiters event
* and grabbing the lock, do not grab the resource if it is unclaimed but
* has waiters; instead queue ourselves. */
else
if
(
!
resource
->
ActiveEntries
&&
!
resource
->
NumberOfExclusiveWaiters
&&
!
resource
->
NumberOfSharedWaiters
)
{
resource
->
Flag
|=
ResourceOwnedExclusive
;
resource
->
OwnerEntry
.
OwnerThread
=
(
ERESOURCE_THREAD
)
KeGetCurrentThread
();
resource
->
ActiveEntries
++
;
KeReleaseSpinLock
(
&
resource
->
SpinLock
,
irql
);
return
TRUE
;
}
else
if
(
!
wait
)
{
KeReleaseSpinLock
(
&
resource
->
SpinLock
,
irql
);
return
FALSE
;
}
if
(
!
resource
->
ExclusiveWaiters
)
{
resource
->
ExclusiveWaiters
=
heap_alloc
(
sizeof
(
*
resource
->
ExclusiveWaiters
)
);
KeInitializeEvent
(
resource
->
ExclusiveWaiters
,
SynchronizationEvent
,
FALSE
);
}
resource
->
NumberOfExclusiveWaiters
++
;
KeReleaseSpinLock
(
&
resource
->
SpinLock
,
irql
);
KeWaitForSingleObject
(
resource
->
ExclusiveWaiters
,
Executive
,
KernelMode
,
FALSE
,
NULL
);
KeAcquireSpinLock
(
&
resource
->
SpinLock
,
&
irql
);
resource
->
Flag
|=
ResourceOwnedExclusive
;
resource
->
OwnerEntry
.
OwnerThread
=
(
ERESOURCE_THREAD
)
KeGetCurrentThread
();
resource
->
ActiveEntries
++
;
resource
->
NumberOfExclusiveWaiters
--
;
KeReleaseSpinLock
(
&
resource
->
SpinLock
,
irql
);
return
TRUE
;
}
include/ddk/wdm.h
View file @
257c56f5
...
...
@@ -1512,6 +1512,7 @@ static inline void IoSetCompletionRoutine(IRP *irp, PIO_COMPLETION_ROUTINE routi
NTSTATUS
WINAPI
DbgQueryDebugFilterState
(
ULONG
,
ULONG
);
void
WINAPI
ExAcquireFastMutexUnsafe
(
PFAST_MUTEX
);
BOOLEAN
WINAPI
ExAcquireResourceExclusiveLite
(
ERESOURCE
*
,
BOOLEAN
);
PVOID
WINAPI
ExAllocatePool
(
POOL_TYPE
,
SIZE_T
);
PVOID
WINAPI
ExAllocatePoolWithQuota
(
POOL_TYPE
,
SIZE_T
);
PVOID
WINAPI
ExAllocatePoolWithTag
(
POOL_TYPE
,
SIZE_T
,
ULONG
);
...
...
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