@@ -885,30 +885,60 @@ HRESULT WOFReparseAttribute::GetStreams(
885
885
return E_FAIL;
886
886
}
887
887
888
- auto ntfsStream = make_shared<NTFSStream>();
889
- HRESULT hr = ntfsStream->OpenAllocatedDataStream (pVolReader, wofAttribute);
890
- if (FAILED (hr))
888
+ if (wofAttribute->IsResident ())
891
889
{
892
- Log::Error (L" Failed to open NTFSStream [{}]" , SystemError (hr));
893
- return hr;
890
+ auto bufferStream = make_shared<BufferStream<2048 >>();
891
+ HRESULT hr = bufferStream->Open ();
892
+ if (FAILED (hr))
893
+ {
894
+ return hr;
895
+ }
896
+
897
+ ULONGLONG ullBytesWritten = 0LL ;
898
+ hr = bufferStream->Write (
899
+ ((PBYTE)wofAttribute->Header ()) + wofAttribute->Header ()->Form .Resident .ValueOffset ,
900
+ wofAttribute->Header ()->Form .Resident .ValueLength ,
901
+ &ullBytesWritten);
902
+ if (FAILED (hr))
903
+ {
904
+ return hr;
905
+ }
906
+
907
+ if (ullBytesWritten != wofAttribute->Header ()->Form .Resident .ValueLength )
908
+ {
909
+ return HRESULT_FROM_WIN32 (ERROR_INVALID_DATA);
910
+ }
911
+
912
+ rawStream = bufferStream;
894
913
}
914
+ else
915
+ {
916
+ auto stream = make_shared<NTFSStream>();
917
+ HRESULT hr = stream->OpenAllocatedDataStream (pVolReader, wofAttribute);
918
+ if (FAILED (hr))
919
+ {
920
+ Log::Error (L" Failed to open NTFSStream [{}]" , SystemError (hr));
921
+ return hr;
922
+ }
895
923
896
- // Nonresident: checked in '::GetWofDataAttribute()'
897
- Log::Debug (
898
- " Open WOF stream (algorithm: {}, compressed size: {} uncompressed size: {})" ,
899
- ToString (m_algorithm),
900
- ntfsStream->GetSize (),
901
- dataAttribute->Header ()->Form .Nonresident .FileSize );
924
+ // Nonresident: checked in '::GetWofDataAttribute()'
925
+ Log::Debug (
926
+ " Open WOF stream (algorithm: {}, compressed size: {} uncompressed size: {})" ,
927
+ ToString (m_algorithm),
928
+ stream->GetSize (),
929
+ dataAttribute->Header ()->Form .Nonresident .FileSize );
930
+
931
+ rawStream = stream;
932
+ }
902
933
903
934
auto wofStream = make_shared<UncompressWofStream>();
904
- hr = wofStream->Open (ntfsStream , m_algorithm, dataAttribute->Header ()->Form .Nonresident .FileSize );
935
+ HRESULT hr = wofStream->Open (rawStream , m_algorithm, dataAttribute->Header ()->Form .Nonresident .FileSize );
905
936
if (FAILED (hr))
906
937
{
907
938
Log::Debug (" Failed to open wof stream [{}]" , SystemError (hr));
908
939
return hr;
909
940
}
910
941
911
- rawStream = ntfsStream;
912
942
dataStream = wofStream;
913
943
return S_OK;
914
944
}
0 commit comments