• R/O
  • HTTP
  • SSH
  • HTTPS

thirdparty-altwindirstat: Commit

A - since abandoned - fork of WinDirStat which had some interesting changes.

Original home: https://github.com/ariccio/altWinDirStat


Commit MetaInfo

Révision6de2f96d48dcaa569693112342d11a2d3be1db4f (tree)
l'heure2016-08-26 12:33:05
AuteurAlexander Riccio <alexander@ricc...>
CommiterAlexander Riccio

Message de Log

tweak string handling code, & give myself headache

Change Summary

Modification

--- a/WinDirStat/windirstat/ChildrenHeapManager.cpp
+++ b/WinDirStat/windirstat/ChildrenHeapManager.cpp
@@ -17,28 +17,31 @@ WDS_FILE_INCLUDE_MESSAGE
1717 #include "macros_that_scare_small_children.h"
1818
1919 _Success_( SUCCEEDED( return ) )
20-const HRESULT Children_String_Heap_Manager_Impl::copy_name_str_into_buffer( _Pre_invalid_ _Always_(_Post_z_) _Post_readable_size_( new_name_length ) wchar_t*& new_name_ptr, _In_ _In_range_( 0, UINT16_MAX ) const rsize_t& new_name_length, const std::wstring& name ) {
20+const HRESULT Children_String_Heap_Manager_Impl::copy_name_str_into_buffer( _Pre_invalid_ _Always_(_Post_z_) _Out_writes_( new_name_length ) wchar_t*& new_name_ptr, _In_ _In_range_( 0, UINT16_MAX ) const rsize_t& new_name_length, const std::wstring& name ) {
2121 ASSERT( m_buffer_size > m_buffer_filled );
2222 ASSERT( new_name_length < UINT16_MAX );
2323 ASSERT( new_name_length == ( name.length( ) + 1 ) );
2424 new_name_ptr = ( ( this->m_string_buffer ) + m_buffer_filled );
2525 ASSERT( ( m_buffer_filled + new_name_length ) < m_buffer_size );
26- m_buffer_filled += new_name_length;
26+
2727 ASSERT( m_buffer_filled < m_buffer_size );
2828
2929 PWSTR pszend = NULL;
3030
3131 //god this is ugly.
32- const rsize_t buffer_space_remaining = ( m_buffer_size - m_buffer_filled + new_name_length );
32+ const rsize_t buffer_space_remaining = ( m_buffer_size - m_buffer_filled );
3333
3434 ASSERT( m_buffer_size >= buffer_space_remaining );
3535
36- rsize_t chars_remaining = buffer_space_remaining;
36+ //rsize_t chars_remaining = buffer_space_remaining;
3737 //TODO: replace with StringCchCopyNEx, for speed.
38- const HRESULT res = StringCchCopyExW( new_name_ptr, ( buffer_space_remaining ), name.c_str( ), &pszend, &chars_remaining, 0 );
38+ const HRESULT res = StringCchCopyExW( new_name_ptr, buffer_space_remaining, name.c_str( ), &pszend, NULL, 0 );
39+
40+ //ASSERT( m_buffer_filled < m_buffer_size );
3941 ASSERT( SUCCEEDED( res ) );
40- ASSERT( pszend == ( new_name_ptr + wcslen( new_name_ptr ) ) );
42+
4143 if ( SUCCEEDED( res ) ) {
44+ m_buffer_filled += new_name_length;
4245 #ifdef DEBUG
4346 ASSERT( wcslen( new_name_ptr ) == ( new_name_length - 1u ) );
4447 ASSERT( wcscmp( new_name_ptr, name.c_str( ) ) == 0 );
@@ -46,19 +49,24 @@ const HRESULT Children_String_Heap_Manager_Impl::copy_name_str_into_buffer( _Pre
4649 ASSERT( ( da_ptrdiff / sizeof( wchar_t ) ) == ( new_name_length - 1u ) );
4750 #endif
4851 ASSERT( m_buffer_filled < m_buffer_size );
49- ASSERT( ( m_buffer_filled + chars_remaining ) == m_buffer_size );
50- ASSERT( m_string_buffer + m_buffer_filled == pszend );
52+ //ASSERT( ( m_buffer_filled + chars_remaining ) == m_buffer_size );
53+ ASSERT( m_string_buffer + m_buffer_filled == pszend + 1 );
54+ ASSERT( pszend < ( m_string_buffer + m_buffer_size ) );
55+ ASSERT( ( m_string_buffer + m_buffer_filled ) == ( new_name_ptr + wcslen( new_name_ptr ) + 1 ) );
5156 return res;
5257 }
5358 WDS_STRSAFE_E_INVALID_PARAMETER_HANDLER( res, "StringCchCopyExW" );
5459 WDS_ASSERT_EXPECTED_STRING_FORMAT_FAILURE_HRESULT( res );
55-
56- new_name_length = ( wcslen( new_name_ptr ) + 1u );
60+ ASSERT( res == STRSAFE_E_INSUFFICIENT_BUFFER );
61+ ASSERT( pszend == ( new_name_ptr + wcslen( new_name_ptr ) + 1 ) );
62+ ASSERT( wcslen( new_name_ptr ) == ( new_name_length - 1u ) );
5763
5864
5965 //m_buffer_filled -= new_name_length;
60- m_buffer_filled = ( m_buffer_size - chars_remaining );
61- ASSERT( m_string_buffer + m_buffer_filled == pszend );
66+ //const std::ptrdiff_t da_ptrdiff = ( std::ptrdiff_t( pszend ) - std::ptrdiff_t( new_name_ptr ) );
67+ m_buffer_filled += wcslen( new_name_ptr ) + 1;
68+ //m_buffer_filled = ( m_buffer_size - chars_remaining );
69+ ASSERT( m_string_buffer + m_buffer_filled == pszend + 1 );
6270 new_name_ptr = ( ( this->m_string_buffer ) + m_buffer_filled );
6371 displayWindowsMsgBoxWithMessage( L"Copy of name_str into Children_String_Heap_Manager failed!!!" );
6472
--- a/WinDirStat/windirstat/ChildrenHeapManager.h
+++ b/WinDirStat/windirstat/ChildrenHeapManager.h
@@ -37,7 +37,7 @@ struct Children_String_Heap_Manager_Impl final {
3737 // }
3838
3939 _Success_( SUCCEEDED( return ) )
40- const HRESULT copy_name_str_into_buffer( _Pre_invalid_ _Post_z_ _Post_readable_size_( new_name_length ) wchar_t*& new_name_ptr, _In_ _In_range_( 0, UINT16_MAX ) const rsize_t& new_name_length, const std::wstring& name );
40+ const HRESULT copy_name_str_into_buffer( _Pre_invalid_ _Always_(_Post_z_) _Out_writes_( new_name_length ) wchar_t*& new_name_ptr, _In_ _In_range_( 0, UINT16_MAX ) const rsize_t& new_name_length, const std::wstring& name );
4141
4242 _Field_range_(0, SIZE_T_MAX) const size_t m_buffer_size;
4343 _Field_range_(<=, m_buffer_size) size_t m_buffer_filled;
--- a/WinDirStat/windirstat/globalhelpers.cpp
+++ b/WinDirStat/windirstat/globalhelpers.cpp
@@ -1058,7 +1058,7 @@ BOOL GetItem_HDM_GETITEM( _In_ _In_range_( >=, 0 ) const int nPos, _Out_ HDITEM*
10581058 }
10591059
10601060 _Success_( return )
1061-BOOL GetItemRect_LVM_GETITEMRECT( _In_ const HWND hWnd, _In_ _In_range_( >=, 0 ) const int nItem, _Out_ RECT* const rect, _In_ _In_range_( LVIR_BOUNDS, LVIR_SELECTBOUNDS ) const UINT nCode ) {
1061+BOOL GetItemRect_LVM_GETITEMRECT( _In_ const HWND hWnd, _In_ _In_range_( >=, 0 ) const int nItem, _Out_ RECT* const rect, _In_ _In_range_( LVIR_BOUNDS, LVIR_SELECTBOUNDS ) const LONG nCode ) {
10621062 /*
10631063 BOOL GetItemRect(int nItem, LPRECT lpRect, UINT nCode) const
10641064 {
@@ -1080,7 +1080,7 @@ BOOL GetItemRect_LVM_GETITEMRECT( _In_ const HWND hWnd, _In_ _In_range_( >=, 0 )
10801080 //LVIR_SELECTBOUNDS
10811081 ASSERT( ::IsWindow( hWnd ) );
10821082 rect->left = nCode;
1083- return static_cast<BOOL>( ::SendMessageW( hWnd, LVM_GETITEMRECT, nItem, reinterpret_cast<LPARAM>( rect ) ) );
1083+ return static_cast<BOOL>( ::SendMessageW( hWnd, LVM_GETITEMRECT, static_cast<WPARAM>( nItem ), reinterpret_cast<LPARAM>( rect ) ) );
10841084 }
10851085
10861086 _Ret_range_( 0, 100 ) INT Treemap_Options::GetBrightnessPercent( ) const {
--- a/WinDirStat/windirstat/globalhelpers.h
+++ b/WinDirStat/windirstat/globalhelpers.h
@@ -189,9 +189,13 @@ void trace_full_path( _In_z_ PCWSTR const path );
189189
190190 int GetItemCount_HDM_GETITEMCOUNT( _In_ HWND hWnd );
191191 int GetColumnWidth_LVM_GETCOLUMNWIDTH( _In_ HWND hWnd, _In_ _In_range_( >=, 0 ) int nCol );
192+
193+
194+_Success_( return )
192195 BOOL GetItem_HDM_GETITEM( _In_ _In_range_( >=, 0 ) const int nPos, _Out_ HDITEM* const pHeaderItem, _In_ const HWND hWnd );
193196
194-BOOL GetItemRect( _In_ const HWND hWnd, _In_ _In_range_( >=, 0 ) const int nItem, _Inout_ RECT* const rect, _In_ _In_range_( LVIR_BOUNDS, LVIR_SELECTBOUNDS ) const UINT nCode );
197+_Success_( return )
198+BOOL GetItemRect_LVM_GETITEMRECT( _In_ const HWND hWnd, _In_ _In_range_( >=, 0 ) const int nItem, _Out_ RECT* const rect, _In_ _In_range_( LVIR_BOUNDS, LVIR_SELECTBOUNDS ) const LONG nCode );
195199
196200 // Collection of all treemap options.
197201 struct Treemap_Options final {
--- a/WinDirStat/windirstat/ownerdrawnlistcontrol.h
+++ b/WinDirStat/windirstat/ownerdrawnlistcontrol.h
@@ -878,7 +878,7 @@ public:
878878 int col_array[ col_array_size ] = { 0 };
879879
880880 //const auto itemCount = CListCtrl::GetHeaderCtrl( )->GetItemCount( );
881- const auto itemCount = GetItemCount_HDM_GETITEMCOUNT( m_hWnd );
881+ const auto itemCount = GetItemCount_HDM_GETITEMCOUNT( CListCtrl::GetHeaderCtrl( )->m_hWnd );
882882
883883 if ( itemCount < 2 ) {
884884 //CPersistence expects more than one item arrays
@@ -1373,7 +1373,7 @@ public:
13731373 HDITEM hditem = { };
13741374 hditem.mask = HDI_FORMAT;
13751375 //VERIFY( thisHeaderControl->GetItem( col, &hditem ) );
1376- VERIFY( GetItem_HDM_GETITEM( 0, &hditem, m_hWnd ) );
1376+ VERIFY( GetItem_HDM_GETITEM( col, &hditem, hWnd ) );
13771377 return ( hditem.fmt bitand HDF_RIGHT ) != 0;
13781378 }
13791379
@@ -1541,7 +1541,7 @@ private:
15411541 //Probably NOT vectorizable anyway.
15421542 //Not vectorized: 1304, loop includes assignments of different sizes
15431543 for ( INT i = 0; i < header_ctrl_item_count; i++ ) {
1544- VERIFY( GetItem_HDM_GETITEM( 0, &hdi, header_hWnd ) );
1544+ VERIFY( GetItem_HDM_GETITEM( columnOrder[ i ], &hdi, header_hWnd ) );
15451545
15461546 //VERIFY( header_ctrl->GetItem( columnOrder[ i ], &hdi ) );
15471547 x += hdi.cxy;
@@ -1615,6 +1615,15 @@ protected:
16151615 }
16161616 afx_msg void OnHdnItemchanging( NMHDR *pNMHDR, LRESULT *pResult ) {
16171617 UNREFERENCED_PARAMETER( pNMHDR );
1618+ /*
1619+ LRESULT CWnd::Default()
1620+ {
1621+ // call DefWindowProc with the last message
1622+ _AFX_THREAD_STATE* pThreadState = _afxThreadState.GetData();
1623+ return DefWindowProc(pThreadState->m_lastSentMsg.message,
1624+ pThreadState->m_lastSentMsg.wParam, pThreadState->m_lastSentMsg.lParam);
1625+ }
1626+ */
16181627 CWnd::Default( );
16191628 /*
16201629 _AFXWIN_INLINE void CWnd::InvalidateRect(LPCRECT lpRect, BOOL bErase = 1)
--- a/WinDirStat/windirstat/windirstat.cpp
+++ b/WinDirStat/windirstat/windirstat.cpp
@@ -227,6 +227,15 @@ SetProcessMitigationPolicy(
227227
228228 enable_EXTENSION_POINT_mitigation( SetProcessMitigationPolicy_f );
229229 enable_strict_HANDLE_check_mitigation( SetProcessMitigationPolicy_f );
230+ //TODO:
231+ //ProhibitDynamicCode: https://msdn.microsoft.com/en-us/library/windows/desktop/mt706243.aspx
232+ //EnableControlFlowGuard: https://msdn.microsoft.com/en-us/library/windows/desktop/mt654121.aspx
233+ //
234+
235+ //(Win 10 only):
236+ //MicrosoftSignedOnly:https://msdn.microsoft.com/en-us/library/windows/desktop/mt706242.aspx
237+ //DisableNonSystemFonts: https://msdn.microsoft.com/en-us/library/windows/desktop/mt706244.aspx
238+
230239 }
231240
232241
Afficher sur ancien navigateur de dépôt.