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
a3a26885
Commit
a3a26885
authored
Jun 09, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Jun 10, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Cleanup and simplify (Global|Local)Handle.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
parent
866d7d0c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
70 deletions
+21
-70
heap.c
dlls/kernel32/heap.c
+21
-70
No files found.
dlls/kernel32/heap.c
View file @
a3a26885
...
@@ -236,64 +236,10 @@ BOOL WINAPI GlobalUnlock( HGLOBAL handle )
...
@@ -236,64 +236,10 @@ BOOL WINAPI GlobalUnlock( HGLOBAL handle )
/***********************************************************************
/***********************************************************************
* GlobalHandle (KERNEL32.@)
* GlobalHandle (KERNEL32.@)
*
* Get the handle associated with the pointer to a global memory block.
*
* RETURNS
* Handle: Success
* NULL: Failure
*/
*/
HGLOBAL
WINAPI
GlobalHandle
(
const
void
*
ptr
)
HGLOBAL
WINAPI
GlobalHandle
(
const
void
*
ptr
)
{
{
struct
mem_entry
*
mem
;
return
LocalHandle
(
ptr
);
HGLOBAL
handle
;
ULONG
flags
;
TRACE_
(
globalmem
)(
"ptr %p
\n
"
,
ptr
);
if
(
!
ptr
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
RtlLockHeap
(
GetProcessHeap
()
);
__TRY
{
handle
=
0
;
/* note that if ptr is a pointer to a block allocated by */
/* GlobalAlloc with GMEM_MOVEABLE then magic test in HeapValidate */
/* will fail. */
if
((
ptr
=
unsafe_ptr_from_HLOCAL
(
(
HLOCAL
)
ptr
)))
{
if
(
!
RtlGetUserInfoHeap
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
(
void
*
)
ptr
,
&
handle
,
&
flags
))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
handle
=
0
;
}
break
;
}
else
handle
=
(
HGLOBAL
)
ptr
;
/* Now test handle either passed in or retrieved from pointer */
if
((
mem
=
unsafe_mem_from_HLOCAL
(
handle
)))
{
if
(
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
mem
->
ptr
))
/* obj(-handle) valid arena? */
break
;
/* valid moveable block */
}
handle
=
0
;
SetLastError
(
ERROR_INVALID_HANDLE
);
}
__EXCEPT_PAGE_FAULT
{
SetLastError
(
ERROR_INVALID_HANDLE
);
handle
=
0
;
}
__ENDTRY
RtlUnlockHeap
(
GetProcessHeap
()
);
return
handle
;
}
}
/***********************************************************************
/***********************************************************************
...
@@ -438,23 +384,28 @@ UINT WINAPI LocalFlags( HLOCAL handle )
...
@@ -438,23 +384,28 @@ UINT WINAPI LocalFlags( HLOCAL handle )
/***********************************************************************
/***********************************************************************
* LocalHandle (KERNEL32.@)
* LocalHandle (KERNEL32.@)
*
* Get the handle associated with the pointer to a local memory block.
*
* RETURNS
* Handle: Success
* NULL: Failure
*
* NOTES
* Windows memory management does not provide a separate local heap
* and global heap.
*/
*/
HLOCAL
WINAPI
LocalHandle
(
HLOCAL
WINAPI
LocalHandle
(
const
void
*
ptr
)
LPCVOID
ptr
/* [in] Address of local memory block */
{
)
{
HLOCAL
handle
;
return
GlobalHandle
(
ptr
);
ULONG
flags
;
}
TRACE_
(
globalmem
)(
"ptr %p
\n
"
,
ptr
);
if
(
!
ptr
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
if
(
!
RtlGetUserInfoHeap
(
GetProcessHeap
(),
0
,
(
void
*
)
ptr
,
&
handle
,
&
flags
))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
0
;
}
return
handle
;
}
/***********************************************************************
/***********************************************************************
* LocalShrink (KERNEL32.@)
* LocalShrink (KERNEL32.@)
...
...
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