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
216c3b0d
Commit
216c3b0d
authored
Aug 13, 2007
by
Mikołaj Zalewski
Committed by
Alexandre Julliard
Aug 14, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: Allocate global memory with execute permission.
parent
454a6122
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
11 deletions
+20
-11
global16.c
dlls/kernel32/global16.c
+20
-11
No files found.
dlls/kernel32/global16.c
View file @
216c3b0d
...
@@ -93,6 +93,16 @@ static inline UINT DOSMEM_ResizeBlock(void *ptr, UINT size, BOOL exact)
...
@@ -93,6 +93,16 @@ static inline UINT DOSMEM_ResizeBlock(void *ptr, UINT size, BOOL exact)
return
winedos
.
ResizeDosBlock
?
winedos
.
ResizeDosBlock
(
ptr
,
size
,
TRUE
)
:
0
;
return
winedos
.
ResizeDosBlock
?
winedos
.
ResizeDosBlock
(
ptr
,
size
,
TRUE
)
:
0
;
}
}
static
HANDLE
get_win16_heap
(
void
)
{
static
HANDLE
win16_heap
;
/* we create global memory block with execute permission. The access can be limited
* for 16-bit code on selector level */
if
(
!
win16_heap
)
win16_heap
=
HeapCreate
(
HEAP_CREATE_ENABLE_EXECUTE
,
0
,
0
);
return
win16_heap
;
}
/***********************************************************************
/***********************************************************************
* GLOBAL_GetArena
* GLOBAL_GetArena
*
*
...
@@ -235,7 +245,7 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
...
@@ -235,7 +245,7 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
size
=
(
size
+
0x1f
)
&
~
0x1f
;
size
=
(
size
+
0x1f
)
&
~
0x1f
;
/* Allocate the linear memory */
/* Allocate the linear memory */
ptr
=
HeapAlloc
(
GetProcessH
eap
(),
0
,
size
);
ptr
=
HeapAlloc
(
get_win16_h
eap
(),
0
,
size
);
/* FIXME: free discardable blocks and try again? */
/* FIXME: free discardable blocks and try again? */
if
(
!
ptr
)
return
0
;
if
(
!
ptr
)
return
0
;
...
@@ -244,7 +254,7 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
...
@@ -244,7 +254,7 @@ HGLOBAL16 GLOBAL_Alloc( UINT16 flags, DWORD size, HGLOBAL16 hOwner, unsigned cha
handle
=
GLOBAL_CreateBlock
(
flags
,
ptr
,
size
,
hOwner
,
selflags
);
handle
=
GLOBAL_CreateBlock
(
flags
,
ptr
,
size
,
hOwner
,
selflags
);
if
(
!
handle
)
if
(
!
handle
)
{
{
HeapFree
(
GetProcessH
eap
(),
0
,
ptr
);
HeapFree
(
get_win16_h
eap
(),
0
,
ptr
);
return
0
;
return
0
;
}
}
...
@@ -293,6 +303,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -293,6 +303,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
void
*
ptr
,
*
newptr
;
void
*
ptr
,
*
newptr
;
GLOBALARENA
*
pArena
,
*
pNewArena
;
GLOBALARENA
*
pArena
,
*
pNewArena
;
WORD
sel
=
GlobalHandleToSel16
(
handle
);
WORD
sel
=
GlobalHandleToSel16
(
handle
);
HANDLE
heap
=
get_win16_heap
();
TRACE
(
"%04x %d flags=%04x
\n
"
,
TRACE
(
"%04x %d flags=%04x
\n
"
,
handle
,
size
,
flags
);
handle
,
size
,
flags
);
...
@@ -315,7 +326,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -315,7 +326,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
if
(
pArena
->
flags
&
GA_DOSMEM
)
if
(
pArena
->
flags
&
GA_DOSMEM
)
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
else
else
HeapFree
(
GetProcessHeap
()
,
0
,
(
void
*
)
pArena
->
base
);
HeapFree
(
heap
,
0
,
(
void
*
)
pArena
->
base
);
pArena
->
base
=
0
;
pArena
->
base
=
0
;
/* Note: we rely on the fact that SELECTOR_ReallocBlock won't
/* Note: we rely on the fact that SELECTOR_ReallocBlock won't
...
@@ -374,13 +385,11 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -374,13 +385,11 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
*/
*/
if
(
ptr
)
if
(
ptr
)
newptr
=
HeapReAlloc
(
GetProcessHeap
()
,
newptr
=
HeapReAlloc
(
heap
,
(
pArena
->
pageLockCount
>
0
)
?
HEAP_REALLOC_IN_PLACE_ONLY
:
0
,
(
pArena
->
pageLockCount
>
0
)
?
HEAP_REALLOC_IN_PLACE_ONLY
:
0
,
ptr
,
size
);
ptr
,
size
);
else
else
newptr
=
HeapAlloc
(
GetProcessHeap
(),
newptr
=
HeapAlloc
(
heap
,
0
,
size
);
(
pArena
->
pageLockCount
>
0
)
?
HEAP_REALLOC_IN_PLACE_ONLY
:
0
,
size
);
}
}
...
@@ -392,7 +401,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -392,7 +401,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
if
(
pArena
->
flags
&
GA_DOSMEM
)
if
(
pArena
->
flags
&
GA_DOSMEM
)
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
else
else
HeapFree
(
GetProcessHeap
()
,
0
,
ptr
);
HeapFree
(
heap
,
0
,
ptr
);
SELECTOR_FreeBlock
(
sel
);
SELECTOR_FreeBlock
(
sel
);
memset
(
pArena
,
0
,
sizeof
(
GLOBALARENA
)
);
memset
(
pArena
,
0
,
sizeof
(
GLOBALARENA
)
);
}
}
...
@@ -408,7 +417,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -408,7 +417,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
if
(
pArena
->
flags
&
GA_DOSMEM
)
if
(
pArena
->
flags
&
GA_DOSMEM
)
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
else
else
HeapFree
(
GetProcessHeap
()
,
0
,
ptr
);
HeapFree
(
heap
,
0
,
ptr
);
memset
(
pArena
,
0
,
sizeof
(
GLOBALARENA
)
);
memset
(
pArena
,
0
,
sizeof
(
GLOBALARENA
)
);
return
0
;
return
0
;
}
}
...
@@ -419,7 +428,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
...
@@ -419,7 +428,7 @@ HGLOBAL16 WINAPI GlobalReAlloc16(
if
(
pArena
->
flags
&
GA_DOSMEM
)
if
(
pArena
->
flags
&
GA_DOSMEM
)
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
DOSMEM_FreeBlock
(
(
void
*
)
pArena
->
base
);
else
else
HeapFree
(
GetProcessHeap
()
,
0
,
ptr
);
HeapFree
(
heap
,
0
,
ptr
);
SELECTOR_FreeBlock
(
sel
);
SELECTOR_FreeBlock
(
sel
);
return
0
;
return
0
;
}
}
...
@@ -463,7 +472,7 @@ HGLOBAL16 WINAPI GlobalFree16(
...
@@ -463,7 +472,7 @@ HGLOBAL16 WINAPI GlobalFree16(
TRACE
(
"%04x
\n
"
,
handle
);
TRACE
(
"%04x
\n
"
,
handle
);
if
(
!
GLOBAL_FreeBlock
(
handle
))
return
handle
;
/* failed */
if
(
!
GLOBAL_FreeBlock
(
handle
))
return
handle
;
/* failed */
HeapFree
(
GetProcessH
eap
(),
0
,
ptr
);
HeapFree
(
get_win16_h
eap
(),
0
,
ptr
);
return
0
;
return
0
;
}
}
...
...
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