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
b2218370
Commit
b2218370
authored
Oct 15, 2007
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Fix GlobalMemoryStatus to take into account the IMAGE_FILE_LARGE_ADDRESS_AWARE flag.
Also the page file size must not be truncated to 2Gb no matter what the flag is set to.
parent
9fd2d443
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
heap.c
dlls/kernel32/heap.c
+31
-26
No files found.
dlls/kernel32/heap.c
View file @
b2218370
...
...
@@ -1220,13 +1220,18 @@ BOOL WINAPI GlobalMemoryStatusEx( LPMEMORYSTATUSEX lpmemex )
int
rval
;
#endif
if
(
lpmemex
->
dwLength
!=
sizeof
(
*
lpmemex
))
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
time
(
NULL
)
==
cache_lastchecked
)
{
memcpy
(
lpmemex
,
&
cached_memstatus
,
sizeof
(
*
lpmemex
));
return
TRUE
;
}
cache_lastchecked
=
time
(
NULL
);
lpmemex
->
dwLength
=
sizeof
(
*
lpmemex
);
lpmemex
->
dwMemoryLoad
=
0
;
lpmemex
->
ullTotalPhys
=
16
*
1024
*
1024
;
lpmemex
->
ullAvailPhys
=
16
*
1024
*
1024
;
...
...
@@ -1366,10 +1371,12 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
{
MEMORYSTATUSEX
memstatus
;
OSVERSIONINFOW
osver
;
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
GetModuleHandleW
(
0
)
);
/* Because GlobalMemoryStatus is identical to GlobalMemoryStatusEX save
for one extra field in the struct, and the lack of a bug, we simply
call GlobalMemoryStatusEx and copy the values across. */
memstatus
.
dwLength
=
sizeof
(
memstatus
);
GlobalMemoryStatusEx
(
&
memstatus
);
lpBuffer
->
dwLength
=
sizeof
(
*
lpBuffer
);
...
...
@@ -1377,7 +1384,6 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
/* Windows 2000 and later report -1 when values are greater than 4 Gb.
* NT reports values modulo 4 Gb.
* Values between 2 Gb and 4 Gb are rounded down to 2 Gb.
*/
osver
.
dwOSVersionInfoSize
=
sizeof
(
osver
);
...
...
@@ -1385,33 +1391,32 @@ VOID WINAPI GlobalMemoryStatus( LPMEMORYSTATUS lpBuffer )
if
(
osver
.
dwMajorVersion
>=
5
)
{
lpBuffer
->
dwTotalPhys
=
(
memstatus
.
ullTotalPhys
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullTotalPhys
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalPhys
;
lpBuffer
->
dwAvailPhys
=
(
memstatus
.
ullAvailPhys
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullAvailPhys
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailPhys
;
lpBuffer
->
dwTotalPageFile
=
(
memstatus
.
ullTotalPageFile
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullTotalPageFile
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalPageFile
;
lpBuffer
->
dwAvailPageFile
=
(
memstatus
.
ullAvailPageFile
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullAvailPageFile
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailPageFile
;
lpBuffer
->
dwTotalVirtual
=
(
memstatus
.
ullTotalVirtual
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullTotalVirtual
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalVirtual
;
lpBuffer
->
dwAvailVirtual
=
(
memstatus
.
ullAvailVirtual
>
MAXDWORD
)
?
MAXDWORD
:
(
memstatus
.
ullAvailVirtual
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailVirtual
;
lpBuffer
->
dwTotalPhys
=
min
(
memstatus
.
ullTotalPhys
,
MAXDWORD
);
lpBuffer
->
dwAvailPhys
=
min
(
memstatus
.
ullAvailPhys
,
MAXDWORD
);
lpBuffer
->
dwTotalPageFile
=
min
(
memstatus
.
ullTotalPageFile
,
MAXDWORD
);
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
>
MAXDWORD
)
?
memstatus
.
ullTotalPhys
:
(
memstatus
.
ullTotalPhys
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalPhys
;
lpBuffer
->
dwAvailPhys
=
(
memstatus
.
ullAvailPhys
>
MAXDWORD
)
?
memstatus
.
ullAvailPhys
:
(
memstatus
.
ullAvailPhys
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailPhys
;
lpBuffer
->
dwTotalPageFile
=
(
memstatus
.
ullTotalPageFile
>
MAXDWORD
)
?
memstatus
.
ullTotalPageFile
:
(
memstatus
.
ullTotalPageFile
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalPageFile
;
lpBuffer
->
dwAvailPageFile
=
(
memstatus
.
ullAvailPageFile
>
MAXDWORD
)
?
memstatus
.
ullAvailPageFile
:
(
memstatus
.
ullAvailPageFile
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailPageFile
;
lpBuffer
->
dwTotalVirtual
=
(
memstatus
.
ullTotalVirtual
>
MAXDWORD
)
?
memstatus
.
ullTotalVirtual
:
(
memstatus
.
ullTotalVirtual
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullTotalVirtual
;
lpBuffer
->
dwAvailVirtual
=
(
memstatus
.
ullAvailVirtual
>
MAXDWORD
)
?
memstatus
.
ullAvailVirtual
:
(
memstatus
.
ullAvailVirtual
>
MAXLONG
)
?
MAXLONG
:
memstatus
.
ullAvailVirtual
;
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 */
/* page file sizes are not limited (Adobe Illustrator 8 depends on this) */
if
(
!
(
nt
->
FileHeader
.
Characteristics
&
IMAGE_FILE_LARGE_ADDRESS_AWARE
))
{
if
(
lpBuffer
->
dwTotalPhys
>
MAXLONG
)
lpBuffer
->
dwTotalPhys
=
MAXLONG
;
if
(
lpBuffer
->
dwAvailPhys
>
MAXLONG
)
lpBuffer
->
dwAvailPhys
=
MAXLONG
;
if
(
lpBuffer
->
dwTotalVirtual
>
MAXLONG
)
lpBuffer
->
dwTotalVirtual
=
MAXLONG
;
if
(
lpBuffer
->
dwAvailVirtual
>
MAXLONG
)
lpBuffer
->
dwAvailVirtual
=
MAXLONG
;
}
/* work around for broken photoshop 4 installer */
...
...
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