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
fc12f812
Commit
fc12f812
authored
Mar 29, 2022
by
Rémi Bernon
Committed by
Alexandre Julliard
Mar 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Make Global* traces and identifiers more consistent.
Signed-off-by:
Rémi Bernon
<
rbernon@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
48ebc410
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
53 deletions
+58
-53
heap.c
dlls/kernel32/heap.c
+58
-53
No files found.
dlls/kernel32/heap.c
View file @
fc12f812
...
...
@@ -183,7 +183,7 @@ typedef struct __GLOBAL32_INTERN
* Lock a global memory object and return a pointer to first byte of the memory
*
* PARAMS
* h
mem
[I] Handle of the global memory object
* h
andle
[I] Handle of the global memory object
*
* RETURNS
* Success: Pointer to first byte of the memory block
...
...
@@ -193,9 +193,9 @@ typedef struct __GLOBAL32_INTERN
* When the handle is invalid, last error is set to ERROR_INVALID_HANDLE
*
*/
LPVOID
WINAPI
GlobalLock
(
HGLOBAL
hmem
)
void
*
WINAPI
GlobalLock
(
HGLOBAL
handle
)
{
return
LocalLock
(
h
mem
);
return
LocalLock
(
h
andle
);
}
...
...
@@ -205,7 +205,7 @@ LPVOID WINAPI GlobalLock(HGLOBAL hmem)
* Unlock a global memory object.
*
* PARAMS
* h
mem
[I] Handle of the global memory object
* h
andle
[I] Handle of the global memory object
*
* RETURNS
* Success: Object is still locked
...
...
@@ -215,10 +215,10 @@ LPVOID WINAPI GlobalLock(HGLOBAL hmem)
* When the handle is invalid, last error is set to ERROR_INVALID_HANDLE
*
*/
BOOL
WINAPI
GlobalUnlock
(
HGLOBAL
hmem
)
BOOL
WINAPI
GlobalUnlock
(
HGLOBAL
handle
)
{
if
(
ISPOINTER
(
h
mem
))
return
TRUE
;
return
LocalUnlock
(
h
mem
);
if
(
ISPOINTER
(
h
andle
))
return
TRUE
;
return
LocalUnlock
(
h
andle
);
}
...
...
@@ -231,13 +231,15 @@ BOOL WINAPI GlobalUnlock(HGLOBAL hmem)
* Handle: Success
* NULL: Failure
*/
HGLOBAL
WINAPI
GlobalHandle
(
LPCVOID
pmem
)
HGLOBAL
WINAPI
GlobalHandle
(
const
void
*
ptr
)
{
PGLOBAL32_INTERN
mem
;
HGLOBAL
handle
;
PGLOBAL32_INTERN
maybe_intern
;
LPCVOID
test
;
if
(
!
pmem
)
TRACE_
(
globalmem
)(
"ptr %p
\n
"
,
ptr
);
if
(
!
ptr
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
...
...
@@ -248,27 +250,27 @@ HGLOBAL WINAPI GlobalHandle( LPCVOID pmem )
{
handle
=
0
;
/* note that if p
mem is a pointer to a block allocated by
*/
/* note that if p
tr is a pointer to a block allocated by
*/
/* GlobalAlloc with GMEM_MOVEABLE then magic test in HeapValidate */
/* will fail. */
if
(
ISPOINTER
(
p
mem
))
if
(
ISPOINTER
(
p
tr
))
{
if
(
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
p
mem
))
if
(
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
p
tr
))
{
handle
=
(
HGLOBAL
)
p
mem
;
/* valid fixed block */
handle
=
(
HGLOBAL
)
p
tr
;
/* valid fixed block */
break
;
}
handle
=
POINTER_TO_HANDLE
(
p
mem
);
handle
=
POINTER_TO_HANDLE
(
p
tr
);
}
else
handle
=
(
HGLOBAL
)
p
mem
;
else
handle
=
(
HGLOBAL
)
p
tr
;
/* Now test handle either passed in or retrieved from pointer */
m
aybe_intern
=
HANDLE_TO_INTERN
(
handle
);
if
(
m
aybe_intern
->
Magic
==
MAGIC_GLOBAL_USED
)
m
em
=
HANDLE_TO_INTERN
(
handle
);
if
(
m
em
->
Magic
==
MAGIC_GLOBAL_USED
)
{
test
=
m
aybe_intern
->
Pointer
;
test
=
m
em
->
Pointer
;
if
(
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
(
const
char
*
)
test
-
HGLOBAL_STORAGE
)
&&
/* obj(-handle) valid arena? */
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
m
aybe_intern
))
/* intern valid arena? */
HeapValidate
(
GetProcessHeap
(),
HEAP_NO_SERIALIZE
,
m
em
))
/* intern valid arena? */
break
;
/* valid moveable block */
}
handle
=
0
;
...
...
@@ -294,9 +296,9 @@ HGLOBAL WINAPI GlobalHandle( LPCVOID pmem )
* Handle: Success
* NULL: Failure
*/
HGLOBAL
WINAPI
GlobalReAlloc
(
HGLOBAL
h
mem
,
SIZE_T
size
,
UINT
flags
)
HGLOBAL
WINAPI
GlobalReAlloc
(
HGLOBAL
h
andle
,
SIZE_T
size
,
UINT
flags
)
{
return
LocalReAlloc
(
h
mem
,
size
,
flags
);
return
LocalReAlloc
(
h
andle
,
size
,
flags
);
}
...
...
@@ -306,7 +308,7 @@ HGLOBAL WINAPI GlobalReAlloc( HGLOBAL hmem, SIZE_T size, UINT flags )
* Get the size of a global memory object.
*
* PARAMS
* h
mem
[I] Handle of the global memory object
* h
andle
[I] Handle of the global memory object
*
* RETURNS
* Failure: 0
...
...
@@ -316,44 +318,45 @@ HGLOBAL WINAPI GlobalReAlloc( HGLOBAL hmem, SIZE_T size, UINT flags )
* When the handle is invalid, last error is set to ERROR_INVALID_HANDLE
*
*/
SIZE_T
WINAPI
GlobalSize
(
HGLOBAL
hmem
)
SIZE_T
WINAPI
GlobalSize
(
HGLOBAL
handle
)
{
PGLOBAL32_INTERN
mem
;
SIZE_T
retval
;
PGLOBAL32_INTERN
pintern
;
if
(
!
((
ULONG_PTR
)
hmem
>>
16
))
TRACE_
(
globalmem
)(
"handle %p
\n
"
,
handle
);
if
(
!
((
ULONG_PTR
)
handle
>>
16
))
{
SetLastError
(
ERROR_INVALID_HANDLE
);
return
0
;
}
if
(
ISPOINTER
(
h
mem
))
if
(
ISPOINTER
(
h
andle
))
{
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
h
mem
);
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
h
andle
);
if
(
retval
==
~
(
SIZE_T
)
0
)
/* It might be a GMEM_MOVEABLE data pointer */
{
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
(
char
*
)
h
mem
-
HGLOBAL_STORAGE
);
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
(
char
*
)
h
andle
-
HGLOBAL_STORAGE
);
if
(
retval
!=
~
(
SIZE_T
)
0
)
retval
-=
HGLOBAL_STORAGE
;
}
}
else
{
RtlLockHeap
(
GetProcessHeap
()
);
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
mem
=
HANDLE_TO_INTERN
(
handle
);
if
(
mem
->
Magic
==
MAGIC_GLOBAL_USED
)
{
if
(
!
pintern
->
Pointer
)
/* handle case of GlobalAlloc( ??,0) */
if
(
!
mem
->
Pointer
)
/* handle case of GlobalAlloc( ??,0) */
retval
=
0
;
else
{
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
(
char
*
)
pintern
->
Pointer
-
HGLOBAL_STORAGE
);
retval
=
HeapSize
(
GetProcessHeap
(),
0
,
(
char
*
)
mem
->
Pointer
-
HGLOBAL_STORAGE
);
if
(
retval
!=
~
(
SIZE_T
)
0
)
retval
-=
HGLOBAL_STORAGE
;
}
}
else
{
WARN
(
"invalid handle %p (Magic: 0x%04x)
\n
"
,
hmem
,
pintern
->
Magic
);
WARN
_
(
globalmem
)(
"invalid handle %p
\n
"
,
handle
);
SetLastError
(
ERROR_INVALID_HANDLE
);
retval
=
0
;
}
...
...
@@ -367,36 +370,36 @@ SIZE_T WINAPI GlobalSize(HGLOBAL hmem)
/***********************************************************************
* GlobalWire (KERNEL32.@)
*/
LPVOID
WINAPI
GlobalWire
(
HGLOBAL
hmem
)
void
*
WINAPI
GlobalWire
(
HGLOBAL
handle
)
{
return
GlobalLock
(
hmem
);
return
GlobalLock
(
handle
);
}
/***********************************************************************
* GlobalUnWire (KERNEL32.@)
*/
BOOL
WINAPI
GlobalUnWire
(
HGLOBAL
hmem
)
BOOL
WINAPI
GlobalUnWire
(
HGLOBAL
handle
)
{
return
GlobalUnlock
(
hmem
);
return
GlobalUnlock
(
handle
);
}
/***********************************************************************
* GlobalFix (KERNEL32.@)
*/
VOID
WINAPI
GlobalFix
(
HGLOBAL
hmem
)
VOID
WINAPI
GlobalFix
(
HGLOBAL
handle
)
{
GlobalLock
(
h
mem
);
GlobalLock
(
h
andle
);
}
/***********************************************************************
* GlobalUnfix (KERNEL32.@)
*/
VOID
WINAPI
GlobalUnfix
(
HGLOBAL
hmem
)
VOID
WINAPI
GlobalUnfix
(
HGLOBAL
handle
)
{
GlobalUnlock
(
hmem
);
GlobalUnlock
(
handle
);
}
...
...
@@ -406,34 +409,36 @@ VOID WINAPI GlobalUnfix(HGLOBAL hmem)
* Get information about a global memory object.
*
* PARAMS
* h
mem [I] Handle of the global memory object
* h
andle [I] Handle of the global memory object
*
* RETURNS
* Failure: GMEM_INVALID_HANDLE, when the provided handle is invalid
* Failure: GMEM_INVALID_HANDLE, when the provided handle is invalid
* Success: Value specifying allocation flags and lock count
*
*/
UINT
WINAPI
GlobalFlags
(
HGLOBAL
hmem
)
UINT
WINAPI
GlobalFlags
(
HGLOBAL
handle
)
{
PGLOBAL32_INTERN
mem
;
DWORD
retval
;
PGLOBAL32_INTERN
pintern
;
if
(
ISPOINTER
(
hmem
))
TRACE_
(
globalmem
)(
"handle %p
\n
"
,
handle
);
if
(
ISPOINTER
(
handle
))
{
retval
=
0
;
}
else
{
RtlLockHeap
(
GetProcessHeap
()
);
pintern
=
HANDLE_TO_INTERN
(
hmem
);
if
(
pintern
->
Magic
==
MAGIC_GLOBAL_USED
)
mem
=
HANDLE_TO_INTERN
(
handle
);
if
(
mem
->
Magic
==
MAGIC_GLOBAL_USED
)
{
retval
=
pintern
->
LockCount
+
(
pintern
->
Flags
<<
8
);
if
(
pintern
->
Pointer
==
0
)
retval
|=
GMEM_DISCARDED
;
retval
=
mem
->
LockCount
+
(
mem
->
Flags
<<
8
);
if
(
mem
->
Pointer
==
0
)
retval
|=
GMEM_DISCARDED
;
}
else
{
WARN
(
"invalid handle %p (Magic: 0x%04x)
\n
"
,
hmem
,
pintern
->
Magic
);
WARN
_
(
globalmem
)(
"invalid handle %p
\n
"
,
handle
);
SetLastError
(
ERROR_INVALID_HANDLE
);
retval
=
GMEM_INVALID_HANDLE
;
}
...
...
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