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
950773dc
Commit
950773dc
authored
Sep 26, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move some handle functions to kernelbase.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
73ed539a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
126 deletions
+107
-126
api-ms-win-core-processenvironment-l1-1-0.spec
...ent-l1-1-0/api-ms-win-core-processenvironment-l1-1-0.spec
+1
-1
api-ms-win-core-processenvironment-l1-2-0.spec
...ent-l1-2-0/api-ms-win-core-processenvironment-l1-2-0.spec
+1
-1
kernel32.spec
dlls/kernel32/kernel32.spec
+4
-4
process.c
dlls/kernel32/process.c
+0
-109
console.c
dlls/kernelbase/console.c
+0
-6
kernelbase.h
dlls/kernelbase/kernelbase.h
+6
-0
kernelbase.spec
dlls/kernelbase/kernelbase.spec
+5
-5
process.c
dlls/kernelbase/process.c
+90
-0
No files found.
dlls/api-ms-win-core-processenvironment-l1-1-0/api-ms-win-core-processenvironment-l1-1-0.spec
View file @
950773dc
...
...
@@ -19,4 +19,4 @@
@ stdcall SetEnvironmentVariableA(str str) kernel32.SetEnvironmentVariableA
@ stdcall SetEnvironmentVariableW(wstr wstr) kernel32.SetEnvironmentVariableW
@ stdcall SetStdHandle(long long) kernel32.SetStdHandle
@ st
ub
SetStdHandleEx
@ st
dcall SetStdHandleEx(long long ptr) kernel32.
SetStdHandleEx
dlls/api-ms-win-core-processenvironment-l1-2-0/api-ms-win-core-processenvironment-l1-2-0.spec
View file @
950773dc
...
...
@@ -21,4 +21,4 @@
@ stdcall SetEnvironmentVariableA(str str) kernel32.SetEnvironmentVariableA
@ stdcall SetEnvironmentVariableW(wstr wstr) kernel32.SetEnvironmentVariableW
@ stdcall SetStdHandle(long long) kernel32.SetStdHandle
@ st
ub
SetStdHandleEx
@ st
dcall SetStdHandleEx(long long ptr) kernel32.
SetStdHandleEx
dlls/kernel32/kernel32.spec
View file @
950773dc
...
...
@@ -223,7 +223,7 @@
@ stdcall -import ClearCommBreak(long)
@ stdcall -import ClearCommError(long ptr ptr)
@ stdcall CloseConsoleHandle(long)
@ stdcall CloseHandle(long)
@ stdcall
-import
CloseHandle(long)
# @ stub ClosePrivateNamespace
@ stdcall CloseProfileUserMapping()
@ stub CloseSystemHandle
...
...
@@ -385,7 +385,7 @@
# @ stub DosPathToSessionPathA
# @ stub DosPathToSessionPathW
@ stdcall DuplicateConsoleHandle(long long long long)
@ stdcall DuplicateHandle(long long long ptr long long long)
@ stdcall
-import
DuplicateHandle(long long long ptr long long long)
# @ stub EnableThreadProfiling
@ stdcall EncodePointer(ptr) ntdll.RtlEncodePointer
@ stdcall EncodeSystemPointer(ptr) ntdll.RtlEncodeSystemPointer
...
...
@@ -695,7 +695,7 @@
@ stdcall GetGeoInfoA(long long ptr long long)
@ stdcall GetGeoInfoW(long long ptr long long)
@ stdcall GetHandleContext(long)
@ stdcall GetHandleInformation(long ptr)
@ stdcall
-import
GetHandleInformation(long ptr)
@ stub -i386 GetLSCallbackTarget
@ stub -i386 GetLSCallbackTemplate
@ stdcall GetLargePageMinimum()
...
...
@@ -1411,7 +1411,7 @@
# @ stub SetFirmwareEnvironmentVariableW
@ stdcall SetHandleContext(long long)
@ stdcall SetHandleCount(long)
@ stdcall SetHandleInformation(long long long)
@ stdcall
-import
SetHandleInformation(long long long)
@ stdcall SetInformationJobObject(long long ptr long)
@ stub SetLastConsoleEventActive
@ stdcall SetLastError(long) RtlSetLastWin32Error
...
...
dlls/kernel32/process.c
View file @
950773dc
...
...
@@ -3197,115 +3197,6 @@ DWORD WINAPI GetProcessFlags( DWORD processid )
}
/*********************************************************************
* CloseHandle (KERNEL32.@)
*
* Closes a handle.
*
* PARAMS
* handle [I] Handle to close.
*
* RETURNS
* Success: TRUE.
* Failure: FALSE, check GetLastError().
*/
BOOL
WINAPI
CloseHandle
(
HANDLE
handle
)
{
NTSTATUS
status
;
/* stdio handles need special treatment */
if
(
handle
==
(
HANDLE
)
STD_INPUT_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdInput
,
0
);
else
if
(
handle
==
(
HANDLE
)
STD_OUTPUT_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdOutput
,
0
);
else
if
(
handle
==
(
HANDLE
)
STD_ERROR_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdError
,
0
);
if
(
is_console_handle
(
handle
))
return
CloseConsoleHandle
(
handle
);
status
=
NtClose
(
handle
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
!
status
;
}
/*********************************************************************
* GetHandleInformation (KERNEL32.@)
*/
BOOL
WINAPI
GetHandleInformation
(
HANDLE
handle
,
LPDWORD
flags
)
{
OBJECT_DATA_INFORMATION
info
;
NTSTATUS
status
=
NtQueryObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
),
NULL
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
else
if
(
flags
)
{
*
flags
=
0
;
if
(
info
.
InheritHandle
)
*
flags
|=
HANDLE_FLAG_INHERIT
;
if
(
info
.
ProtectFromClose
)
*
flags
|=
HANDLE_FLAG_PROTECT_FROM_CLOSE
;
}
return
!
status
;
}
/*********************************************************************
* SetHandleInformation (KERNEL32.@)
*/
BOOL
WINAPI
SetHandleInformation
(
HANDLE
handle
,
DWORD
mask
,
DWORD
flags
)
{
OBJECT_DATA_INFORMATION
info
;
NTSTATUS
status
;
/* if not setting both fields, retrieve current value first */
if
((
mask
&
(
HANDLE_FLAG_INHERIT
|
HANDLE_FLAG_PROTECT_FROM_CLOSE
))
!=
(
HANDLE_FLAG_INHERIT
|
HANDLE_FLAG_PROTECT_FROM_CLOSE
))
{
if
((
status
=
NtQueryObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
),
NULL
)))
{
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
FALSE
;
}
}
if
(
mask
&
HANDLE_FLAG_INHERIT
)
info
.
InheritHandle
=
(
flags
&
HANDLE_FLAG_INHERIT
)
!=
0
;
if
(
mask
&
HANDLE_FLAG_PROTECT_FROM_CLOSE
)
info
.
ProtectFromClose
=
(
flags
&
HANDLE_FLAG_PROTECT_FROM_CLOSE
)
!=
0
;
status
=
NtSetInformationObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
)
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
!
status
;
}
/*********************************************************************
* DuplicateHandle (KERNEL32.@)
*/
BOOL
WINAPI
DuplicateHandle
(
HANDLE
source_process
,
HANDLE
source
,
HANDLE
dest_process
,
HANDLE
*
dest
,
DWORD
access
,
BOOL
inherit
,
DWORD
options
)
{
NTSTATUS
status
;
if
(
is_console_handle
(
source
))
{
/* FIXME: this test is not sufficient, we need to test process ids, not handles */
if
(
source_process
!=
dest_process
||
source_process
!=
GetCurrentProcess
())
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
*
dest
=
DuplicateConsoleHandle
(
source
,
access
,
inherit
,
options
);
return
(
*
dest
!=
INVALID_HANDLE_VALUE
);
}
status
=
NtDuplicateObject
(
source_process
,
source
,
dest_process
,
dest
,
access
,
inherit
?
OBJ_INHERIT
:
0
,
options
);
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
)
);
return
!
status
;
}
/***********************************************************************
* ConvertToGlobalHandle (KERNEL32.@)
*/
...
...
dlls/kernelbase/console.c
View file @
950773dc
...
...
@@ -56,12 +56,6 @@ static CRITICAL_SECTION console_section = { &critsect_debug, -1, 0, 0, 0, 0 };
static
WCHAR
input_exe
[
MAX_PATH
+
1
];
/* map a real wineserver handle onto a kernel32 console handle */
static
inline
HANDLE
console_handle_map
(
HANDLE
h
)
{
return
h
!=
INVALID_HANDLE_VALUE
?
(
HANDLE
)((
UINT_PTR
)
h
^
3
)
:
INVALID_HANDLE_VALUE
;
}
/* map a kernel32 console handle onto a real wineserver handle */
static
inline
obj_handle_t
console_handle_unmap
(
HANDLE
h
)
{
...
...
dlls/kernelbase/kernelbase.h
View file @
950773dc
...
...
@@ -36,6 +36,12 @@ static inline BOOL is_console_handle(HANDLE h)
return
h
!=
INVALID_HANDLE_VALUE
&&
((
UINT_PTR
)
h
&
3
)
==
3
;
}
/* map between ntdll handle and kernel32 console handle */
static
inline
HANDLE
console_handle_map
(
HANDLE
h
)
{
return
h
!=
INVALID_HANDLE_VALUE
?
(
HANDLE
)((
UINT_PTR
)
h
^
3
)
:
INVALID_HANDLE_VALUE
;
}
static
inline
BOOL
set_ntstatus
(
NTSTATUS
status
)
{
if
(
status
)
SetLastError
(
RtlNtStatusToDosError
(
status
));
...
...
dlls/kernelbase/kernelbase.spec
View file @
950773dc
...
...
@@ -135,7 +135,7 @@
@ stdcall ClearCommBreak(long)
@ stdcall ClearCommError(long ptr ptr)
# @ stub CloseGlobalizationUserSettingsKey
@ stdcall CloseHandle(long)
kernel32.CloseHandle
@ stdcall CloseHandle(long)
# @ stub ClosePackageInfo
# @ stub ClosePrivateNamespace
# @ stub CloseState
...
...
@@ -279,7 +279,7 @@
# @ stub DsReadNgcKeyW
# @ stub DsUnBindW
# @ stub DsWriteNgcKeyW
@ stdcall DuplicateHandle(long long long ptr long long long)
kernel32.DuplicateHandle
@ stdcall DuplicateHandle(long long long ptr long long long)
# @ stub DuplicateStateContainerHandle
@ stdcall DuplicateToken(long long ptr)
@ stdcall DuplicateTokenEx(long long ptr long long ptr)
...
...
@@ -531,7 +531,7 @@
# @ stub GetGPOListInternalA
# @ stub GetGPOListInternalW
@ stdcall GetGeoInfoW(long long ptr long long) kernel32.GetGeoInfoW
@ stdcall GetHandleInformation(long ptr)
kernel32.GetHandleInformation
@ stdcall GetHandleInformation(long ptr)
# @ stub GetHivePath
# @ stub GetIntegratedDisplaySize
# @ stub GetIsEdpEnabled
...
...
@@ -1440,8 +1440,8 @@
@ stdcall SetFileSecurityW(wstr long ptr)
@ stdcall SetFileTime(long ptr ptr ptr)
@ stdcall SetFileValidData(ptr int64)
@ stdcall SetHandleCount(long)
kernel32.SetHandleCount
@ stdcall SetHandleInformation(long long long)
kernel32.SetHandleInformation
@ stdcall SetHandleCount(long)
@ stdcall SetHandleInformation(long long long)
# @ stub SetIsDeveloperModeEnabled
# @ stub SetIsSideloadingEnabled
@ stdcall SetKernelObjectSecurity(long long ptr)
...
...
dlls/kernelbase/process.c
View file @
950773dc
...
...
@@ -42,6 +42,44 @@ static DWORD shutdown_priority = 0x280;
***********************************************************************/
/*********************************************************************
* CloseHandle (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
CloseHandle
(
HANDLE
handle
)
{
if
(
handle
==
(
HANDLE
)
STD_INPUT_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdInput
,
0
);
else
if
(
handle
==
(
HANDLE
)
STD_OUTPUT_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdOutput
,
0
);
else
if
(
handle
==
(
HANDLE
)
STD_ERROR_HANDLE
)
handle
=
InterlockedExchangePointer
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
hStdError
,
0
);
if
(
is_console_handle
(
handle
))
handle
=
console_handle_map
(
handle
);
return
set_ntstatus
(
NtClose
(
handle
));
}
/*********************************************************************
* DuplicateHandle (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
DuplicateHandle
(
HANDLE
source_process
,
HANDLE
source
,
HANDLE
dest_process
,
HANDLE
*
dest
,
DWORD
access
,
BOOL
inherit
,
DWORD
options
)
{
if
(
is_console_handle
(
source
))
{
source
=
console_handle_map
(
source
);
if
(
!
set_ntstatus
(
NtDuplicateObject
(
source_process
,
source
,
dest_process
,
dest
,
access
,
inherit
?
OBJ_INHERIT
:
0
,
options
)))
return
FALSE
;
*
dest
=
console_handle_map
(
*
dest
);
return
TRUE
;
}
return
set_ntstatus
(
NtDuplicateObject
(
source_process
,
source
,
dest_process
,
dest
,
access
,
inherit
?
OBJ_INHERIT
:
0
,
options
));
}
/****************************************************************************
* FlushInstructionCache (kernelbase.@)
*/
...
...
@@ -96,6 +134,26 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetExitCodeProcess( HANDLE process, LPDWORD exit_c
}
/*********************************************************************
* GetHandleInformation (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
GetHandleInformation
(
HANDLE
handle
,
DWORD
*
flags
)
{
OBJECT_DATA_INFORMATION
info
;
if
(
!
set_ntstatus
(
NtQueryObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
),
NULL
)))
return
FALSE
;
if
(
flags
)
{
*
flags
=
0
;
if
(
info
.
InheritHandle
)
*
flags
|=
HANDLE_FLAG_INHERIT
;
if
(
info
.
ProtectFromClose
)
*
flags
|=
HANDLE_FLAG_PROTECT_FROM_CLOSE
;
}
return
TRUE
;
}
/***********************************************************************
* GetPriorityClass (kernelbase.@)
*/
...
...
@@ -254,6 +312,38 @@ UINT WINAPI DECLSPEC_HOTPATCH SetErrorMode( UINT mode )
}
/*************************************************************************
* SetHandleCount (kernelbase.@)
*/
UINT
WINAPI
DECLSPEC_HOTPATCH
SetHandleCount
(
UINT
count
)
{
return
count
;
}
/*********************************************************************
* SetHandleInformation (kernelbase.@)
*/
BOOL
WINAPI
DECLSPEC_HOTPATCH
SetHandleInformation
(
HANDLE
handle
,
DWORD
mask
,
DWORD
flags
)
{
OBJECT_DATA_INFORMATION
info
;
/* if not setting both fields, retrieve current value first */
if
((
mask
&
(
HANDLE_FLAG_INHERIT
|
HANDLE_FLAG_PROTECT_FROM_CLOSE
))
!=
(
HANDLE_FLAG_INHERIT
|
HANDLE_FLAG_PROTECT_FROM_CLOSE
))
{
if
(
!
set_ntstatus
(
NtQueryObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
),
NULL
)))
return
FALSE
;
}
if
(
mask
&
HANDLE_FLAG_INHERIT
)
info
.
InheritHandle
=
(
flags
&
HANDLE_FLAG_INHERIT
)
!=
0
;
if
(
mask
&
HANDLE_FLAG_PROTECT_FROM_CLOSE
)
info
.
ProtectFromClose
=
(
flags
&
HANDLE_FLAG_PROTECT_FROM_CLOSE
)
!=
0
;
return
set_ntstatus
(
NtSetInformationObject
(
handle
,
ObjectDataInformation
,
&
info
,
sizeof
(
info
)
));
}
/***********************************************************************
* SetPriorityClass (kernelbase.@)
*/
...
...
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