http://bugs.winehq.org/show_bug.cgi?id=30592
Bug #: 30592 Summary: Give kernel32.GetDiskFreeSpaceExW a trace message to better diagnose free disk space overflow problems with Win9X era apps/games Product: Wine Version: 1.5.3 Platform: x86 OS/Version: Linux Status: NEW Severity: enhancement Priority: P2 Component: kernel32 AssignedTo: wine-bugs@winehq.org ReportedBy: focht@gmx.net Classification: Unclassified
Hello,
another enhancement request for better diagnosis ...
Sometimes I encounter broken Win9X era apps/games that suffer from GetDiskFreeSpaceA/W overflows.
Example code which contains overflows:
--- snip --- 0x00428414: pushl %ecx 0x00428415: pushl %eax 0x00428416: leal 0x1c(%esp),%ecx 0x0042841a: pushl %edx 0x0042841b: leal 0x10(%esp),%eax 0x0042841f: pushl %ecx 0x00428420: pushl %eax 0x00428421: call *0x8a75fc -> 0x7b88273a GetDiskFreeSpaceA 0x00428427: movl 0xc(%esp),%ecx ; ecx = free_clusters 0x0042842b: movl 0x320(%esp),%eax ; needed space (compare value) 0x00428432: imull 0x10(%esp),%ecx ; ecx *= sector_bytes 0x00428437: imull 0x14(%esp),%ecx ; ecx *= cluster_sectors 0x0042843c: cmpl %ecx,%eax 0x0042843e: jnle 0x0042844c 0x00428440: xorl %eax,%eax 0x00428442: popl %ebx 0x00428443: addl $0x318,%esp 0x00428449: ret $0x4 0x0042844c: subl %ecx,%eax 0x0042844e: popl %ebx --- snip ---
If you currently do +volume trace:
--- snip --- 0024:Call KERNEL32.GetDiskFreeSpaceA(0032eccc "C:\",0032ecdc,0032ecd8,0032ecd4,0032ece0) ret=00428427 0024:trace:volume:GetDiskFreeSpaceW L"C:\",0x32ecdc,0x32ecd8,0x32ecd4,0x32ece0 0024:Ret KERNEL32.GetDiskFreeSpaceA() retval=00000001 ret=00428427 ... 0024:trace:msvcrt:pf_printf_a Format is: "You do not have enough disk space to run King's Quest: Mask of Eternity. Please free up %d megs of space and try again." --- snip ---
I'd like to see all the information returned to caller when doing +volume trace.
Source: http://source.winehq.org/git/wine.git/blob/1726427113b141535c2bb9e93879e409b...
--- snip --- 1598 BOOL WINAPI GetDiskFreeSpaceExW( LPCWSTR root, PULARGE_INTEGER avail, 1599 PULARGE_INTEGER total, PULARGE_INTEGER totalfree ) 1600 { 1601 FILE_FS_SIZE_INFORMATION info; 1602 IO_STATUS_BLOCK io; 1603 NTSTATUS status; 1604 HANDLE handle; 1605 UINT units; 1606 1607 TRACE( "%s,%p,%p,%p\n", debugstr_w(root), avail, total, totalfree ); 1608 1609 if (!open_device_root( root, &handle )) return FALSE; 1610 1611 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation ); 1612 NtClose( handle ); 1613 if (status != STATUS_SUCCESS) 1614 { 1615 SetLastError( RtlNtStatusToDosError(status) ); 1616 return FALSE; 1617 } 1618 1619 units = info.SectorsPerAllocationUnit * info.BytesPerSector; 1620 if (total) total->QuadPart = info.TotalAllocationUnits.QuadPart * units; 1621 if (totalfree) totalfree->QuadPart = info.AvailableAllocationUnits.QuadPart * units; 1622 /* FIXME: this one should take quotas into account */ 1623 if (avail) avail->QuadPart = info.AvailableAllocationUnits.QuadPart * units; 1624 return TRUE; 1625 } --- snip ---
Before the return on line 1624 a TRACE() would be very helpful, printing the actual values of out parameters: cluster_sector, sector_bytes, free_clusters, total_clusters Additionally a hint if the values were capped due to Win9X compat (capped=0/1).
Actual 32-bits overflow warning would be a bonus but not required ;-)
Thanks.
Regards
http://bugs.winehq.org/show_bug.cgi?id=30592
Anastasius Focht focht@gmx.net changed:
What |Removed |Added ---------------------------------------------------------------------------- Summary|Give |Give |kernel32.GetDiskFreeSpaceEx |kernel32.GetDiskFreeSpaceW |W a trace message to better |a trace message to better |diagnose free disk space |diagnose free disk space |overflow problems with |overflow problems with |Win9X era apps/games |Win9X era apps/games
--- Comment #1 from Anastasius Focht focht@gmx.net 2012-05-04 10:08:19 CDT --- Hello,
*grmbl* sorry .. it is GetDiskFreeSpaceW for diagnosis, not the "Ex" version. The "Ex" version avoids these problems.
http://source.winehq.org/git/wine.git/blob/1726427113b141535c2bb9e93879e409b...
---- snip --- 1646 BOOL WINAPI GetDiskFreeSpaceW( LPCWSTR root, LPDWORD cluster_sectors, 1647 LPDWORD sector_bytes, LPDWORD free_clusters, 1648 LPDWORD total_clusters ) 1649 { 1650 FILE_FS_SIZE_INFORMATION info; 1651 IO_STATUS_BLOCK io; 1652 NTSTATUS status; 1653 HANDLE handle; 1654 UINT units; 1655 1656 TRACE( "%s,%p,%p,%p,%p\n", debugstr_w(root), 1657 cluster_sectors, sector_bytes, free_clusters, total_clusters ); 1658 1659 if (!open_device_root( root, &handle )) return FALSE; 1660 1661 status = NtQueryVolumeInformationFile( handle, &io, &info, sizeof(info), FileFsSizeInformation ); 1662 NtClose( handle ); 1663 if (status != STATUS_SUCCESS) 1664 { 1665 SetLastError( RtlNtStatusToDosError(status) ); 1666 return FALSE; 1667 } 1668 1669 units = info.SectorsPerAllocationUnit * info.BytesPerSector; 1670 1671 if( GetVersion() & 0x80000000) { /* win3.x, 9x, ME */ 1672 /* cap the size and available at 2GB as per specs */ 1673 if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff) { 1674 info.TotalAllocationUnits.QuadPart = 0x7fffffff / units; 1675 if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff) 1676 info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units; 1677 } 1678 /* nr. of clusters is always <= 65335 */ 1679 while( info.TotalAllocationUnits.QuadPart > 65535 ) { 1680 info.TotalAllocationUnits.QuadPart /= 2; 1681 info.AvailableAllocationUnits.QuadPart /= 2; 1682 info.SectorsPerAllocationUnit *= 2; 1683 } 1684 } 1685 1686 if (cluster_sectors) *cluster_sectors = info.SectorsPerAllocationUnit; 1687 if (sector_bytes) *sector_bytes = info.BytesPerSector; 1688 if (free_clusters) *free_clusters = info.AvailableAllocationUnits.u.LowPart; 1689 if (total_clusters) *total_clusters = info.TotalAllocationUnits.u.LowPart; 1690 return TRUE; 1691 }
---- snip ---
Line 1690 ...
Regards
http://bugs.winehq.org/show_bug.cgi?id=30592
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Fixed by SHA1| |729afb18fe200a296498ec7fe15 | |cc221e3494f78 Status|NEW |RESOLVED Resolution| |FIXED
--- Comment #2 from Austin English austinenglish@gmail.com 2012-06-25 13:39:31 CDT --- http://source.winehq.org/git/wine.git/commitdiff/729afb18fe200a296498ec7fe15...
http://bugs.winehq.org/show_bug.cgi?id=30592
Alexandre Julliard julliard@winehq.org changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Alexandre Julliard julliard@winehq.org 2012-07-03 14:14:56 CDT --- Closing bugs fixed in 1.5.8.