@@ -1601,7 +1601,7 @@ ClrDataAccess::GetDomainFromContext(CLRDATA_ADDRESS contextAddr, CLRDATA_ADDRESS
1601
1601
1602
1602
1603
1603
HRESULT
1604
- ClrDataAccess::GetObjectStringData (CLRDATA_ADDRESS obj, unsigned int count, _Inout_updates_z_ (count) WCHAR * stringData, unsigned int * pNeeded)
1604
+ ClrDataAccess::GetObjectStringData (CLRDATA_ADDRESS obj, unsigned int count, _Inout_updates_z_ (count) WCHAR* stringData, unsigned int * pNeeded)
1605
1605
{
1606
1606
if (obj == 0 )
1607
1607
return E_INVALIDARG;
@@ -1611,44 +1611,73 @@ ClrDataAccess::GetObjectStringData(CLRDATA_ADDRESS obj, unsigned int count, _Ino
1611
1611
1612
1612
SOSDacEnter ();
1613
1613
1614
+ if (m_cdacSos != NULL )
1615
+ {
1616
+ hr = m_cdacSos->GetObjectStringData (obj, count, stringData, pNeeded);
1617
+ if (FAILED (hr))
1618
+ {
1619
+ hr = GetObjectStringDataImpl (obj, count, stringData, pNeeded);
1620
+ }
1621
+ #ifdef _DEBUG
1622
+ else
1623
+ {
1624
+ unsigned int neededLocal;
1625
+ SString stringDataLocal;
1626
+ HRESULT hrLocal = GetObjectStringDataImpl (obj, count, stringDataLocal.OpenUnicodeBuffer (count), &neededLocal);
1627
+ _ASSERTE (hr == hrLocal);
1628
+ _ASSERTE (pNeeded == NULL || *pNeeded == neededLocal);
1629
+ _ASSERTE (u16_strncmp (stringData, stringDataLocal, count) == 0 );
1630
+ }
1631
+ #endif
1632
+ }
1633
+ else
1634
+ {
1635
+ hr = GetObjectStringDataImpl (obj, count, stringData, pNeeded);
1636
+ }
1637
+
1638
+ SOSDacLeave ();
1639
+ return hr;
1640
+ }
1641
+
1642
+ HRESULT
1643
+ ClrDataAccess::GetObjectStringDataImpl (CLRDATA_ADDRESS obj, unsigned int count, _Inout_updates_z_ (count) WCHAR *stringData, unsigned int *pNeeded)
1644
+ {
1614
1645
TADDR mtTADDR = DACGetMethodTableFromObjectPointer (TO_TADDR (obj), m_pTarget);
1615
1646
PTR_MethodTable mt = PTR_MethodTable (mtTADDR);
1616
1647
1617
1648
// Object must be a string
1618
1649
BOOL bFree = FALSE ;
1619
1650
if (!DacValidateMethodTable (mt, bFree))
1620
- hr = E_INVALIDARG;
1621
- else if (HOST_CDADDR (mt) != HOST_CDADDR (g_pStringClass))
1622
- hr = E_INVALIDARG;
1651
+ return E_INVALIDARG;
1623
1652
1624
- if (SUCCEEDED (hr))
1625
- {
1626
- PTR_StringObject str (TO_TADDR (obj));
1627
- ULONG32 needed = (ULONG32)str->GetStringLength () + 1 ;
1653
+ if (HOST_CDADDR (mt) != HOST_CDADDR (g_pStringClass))
1654
+ return E_INVALIDARG;
1628
1655
1629
- if (stringData && count > 0 )
1630
- {
1631
- if (count > needed)
1632
- count = needed;
1656
+ PTR_StringObject str (TO_TADDR (obj));
1657
+ ULONG32 needed = (ULONG32)str->GetStringLength () + 1 ;
1633
1658
1634
- TADDR pszStr = TO_TADDR (obj)+offsetof (StringObject, m_FirstChar);
1635
- hr = m_pTarget->ReadVirtual (pszStr, (PBYTE)stringData, count * sizeof (WCHAR), &needed);
1659
+ HRESULT hr;
1660
+ if (stringData && count > 0 )
1661
+ {
1662
+ if (count > needed)
1663
+ count = needed;
1636
1664
1637
- if (SUCCEEDED (hr))
1638
- stringData[count - 1 ] = W (' \0 ' );
1639
- else
1640
- stringData[0 ] = W (' \0 ' );
1641
- }
1642
- else
1643
- {
1644
- hr = E_INVALIDARG;
1645
- }
1665
+ TADDR pszStr = TO_TADDR (obj)+offsetof (StringObject, m_FirstChar);
1666
+ hr = m_pTarget->ReadVirtual (pszStr, (PBYTE)stringData, count * sizeof (WCHAR), &needed);
1646
1667
1647
- if (pNeeded)
1648
- *pNeeded = needed;
1668
+ if (SUCCEEDED (hr))
1669
+ stringData[count - 1 ] = W (' \0 ' );
1670
+ else
1671
+ stringData[0 ] = W (' \0 ' );
1672
+ }
1673
+ else
1674
+ {
1675
+ hr = E_INVALIDARG;
1649
1676
}
1650
1677
1651
- SOSDacLeave ();
1678
+ if (pNeeded)
1679
+ *pNeeded = needed;
1680
+
1652
1681
return hr;
1653
1682
}
1654
1683
0 commit comments