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
72c562ce
Commit
72c562ce
authored
Apr 21, 2021
by
Paul Gofman
Committed by
Alexandre Julliard
Apr 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Do not impose 32 bit limits on Win64 in GlobalMemoryStatus().
Signed-off-by:
Paul Gofman
<
pgofman@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d1b80f4d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
10 deletions
+57
-10
heap.c
dlls/kernel32/heap.c
+11
-10
heap.c
dlls/kernel32/tests/heap.c
+46
-0
No files found.
dlls/kernel32/heap.c
View file @
72c562ce
...
...
@@ -543,7 +543,9 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
{
MEMORYSTATUSEX
memstatus
;
OSVERSIONINFOW
osver
;
#ifndef _WIN64
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
GetModuleHandleW
(
0
)
);
#endif
/* Because GlobalMemoryStatus is identical to GlobalMemoryStatusEX save
for one extra field in the struct, and the lack of a bug, we simply
...
...
@@ -561,6 +563,14 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
osver
.
dwOSVersionInfoSize
=
sizeof
(
osver
);
GetVersionExW
(
&
osver
);
lpBuffer
->
dwTotalPhys
=
memstatus
.
ullTotalPhys
;
lpBuffer
->
dwAvailPhys
=
memstatus
.
ullAvailPhys
;
lpBuffer
->
dwTotalPageFile
=
memstatus
.
ullTotalPageFile
;
lpBuffer
->
dwAvailPageFile
=
memstatus
.
ullAvailPageFile
;
lpBuffer
->
dwTotalVirtual
=
memstatus
.
ullTotalVirtual
;
lpBuffer
->
dwAvailVirtual
=
memstatus
.
ullAvailVirtual
;
#ifndef _WIN64
if
(
osver
.
dwMajorVersion
>=
5
||
osver
.
dwPlatformId
==
VER_PLATFORM_WIN32_WINDOWS
)
{
lpBuffer
->
dwTotalPhys
=
min
(
memstatus
.
ullTotalPhys
,
MAXDWORD
);
...
...
@@ -570,16 +580,6 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
lpBuffer
->
dwAvailPageFile
=
min
(
memstatus
.
ullAvailPageFile
,
MAXDWORD
);
lpBuffer
->
dwTotalVirtual
=
min
(
memstatus
.
ullTotalVirtual
,
MAXDWORD
);
lpBuffer
->
dwAvailVirtual
=
min
(
memstatus
.
ullAvailVirtual
,
MAXDWORD
);
}
else
/* duplicate NT bug */
{
lpBuffer
->
dwTotalPhys
=
memstatus
.
ullTotalPhys
;
lpBuffer
->
dwAvailPhys
=
memstatus
.
ullAvailPhys
;
lpBuffer
->
dwTotalPageFile
=
memstatus
.
ullTotalPageFile
;
lpBuffer
->
dwAvailPageFile
=
memstatus
.
ullAvailPageFile
;
lpBuffer
->
dwTotalVirtual
=
memstatus
.
ullTotalVirtual
;
lpBuffer
->
dwAvailVirtual
=
memstatus
.
ullAvailVirtual
;
}
/* values are limited to 2Gb unless the app has the IMAGE_FILE_LARGE_ADDRESS_AWARE flag */
...
...
@@ -603,6 +603,7 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
if
(
lpBuffer
->
dwTotalPageFile
>
MAXLONG
)
lpBuffer
->
dwTotalPageFile
=
MAXLONG
;
if
(
lpBuffer
->
dwAvailPageFile
>
MAXLONG
)
lpBuffer
->
dwAvailPageFile
=
MAXLONG
;
}
#endif
TRACE
(
"Length %u, MemoryLoad %u, TotalPhys %lx, AvailPhys %lx,"
" TotalPageFile %lx, AvailPageFile %lx, TotalVirtual %lx, AvailVirtual %lx
\n
"
,
...
...
dlls/kernel32/tests/heap.c
View file @
72c562ce
...
...
@@ -1213,6 +1213,51 @@ static void test_GetPhysicallyInstalledSystemMemory(void)
"expected total_memory >= memstatus.ullTotalPhys / 1024
\n
"
);
}
static
BOOL
compare_ulong64
(
ULONG64
v1
,
ULONG64
v2
,
ULONG64
max_diff
)
{
ULONG64
diff
=
v1
>
v2
?
v1
-
v2
:
v2
-
v1
;
return
diff
<=
max_diff
;
}
static
void
test_GlobalMemoryStatus
(
void
)
{
static
const
ULONG64
max_diff
=
0x200000
;
MEMORYSTATUSEX
memex
;
MEMORYSTATUS
mem
;
SIZE_T
size
;
mem
.
dwLength
=
sizeof
(
mem
);
GlobalMemoryStatus
(
&
mem
);
memex
.
dwLength
=
sizeof
(
memex
);
GlobalMemoryStatusEx
(
&
memex
);
/* Compare values approximately as the available memory may change between
* GlobalMemoryStatus() and GlobalMemoryStatusEx() calls. */
size
=
min
(
memex
.
ullTotalPhys
,
~
(
SIZE_T
)
0
>>
1
);
ok
(
compare_ulong64
(
mem
.
dwTotalPhys
,
size
,
max_diff
),
"Got unexpected dwTotalPhys %s, size %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwTotalPhys
),
wine_dbgstr_longlong
(
size
));
size
=
min
(
memex
.
ullAvailPhys
,
~
(
SIZE_T
)
0
>>
1
);
ok
(
compare_ulong64
(
mem
.
dwAvailPhys
,
size
,
max_diff
),
"Got unexpected dwAvailPhys %s, size %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwAvailPhys
),
wine_dbgstr_longlong
(
size
));
size
=
min
(
memex
.
ullTotalPageFile
,
~
(
SIZE_T
)
0
);
ok
(
compare_ulong64
(
mem
.
dwTotalPageFile
,
size
,
max_diff
),
"Got unexpected dwTotalPageFile %s, size %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwTotalPageFile
),
wine_dbgstr_longlong
(
size
));
size
=
min
(
memex
.
ullAvailPageFile
,
~
(
SIZE_T
)
0
);
ok
(
compare_ulong64
(
mem
.
dwAvailPageFile
,
size
,
max_diff
),
"Got unexpected dwAvailPageFile %s, size %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwAvailPageFile
),
wine_dbgstr_longlong
(
size
));
ok
(
compare_ulong64
(
mem
.
dwTotalVirtual
,
memex
.
ullTotalVirtual
,
max_diff
),
"Got unexpected dwTotalVirtual %s, ullTotalVirtual %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwTotalVirtual
),
wine_dbgstr_longlong
(
memex
.
ullTotalVirtual
));
ok
(
compare_ulong64
(
mem
.
dwAvailVirtual
,
memex
.
ullAvailVirtual
,
max_diff
),
"Got unexpected dwAvailVirtual %s, ullAvailVirtual %s.
\n
"
,
wine_dbgstr_longlong
(
mem
.
dwAvailVirtual
),
wine_dbgstr_longlong
(
memex
.
ullAvailVirtual
));
}
START_TEST
(
heap
)
{
int
argc
;
...
...
@@ -1246,6 +1291,7 @@ START_TEST(heap)
test_HeapQueryInformation
();
test_GetPhysicallyInstalledSystemMemory
();
test_GlobalMemoryStatus
();
if
(
pRtlGetNtGlobalFlags
)
{
...
...
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