MCPcopy Create free account
hub / github.com/DFIR-ORC/dfir-orc / GetVolumeSerialUsingFileHandle

Function GetVolumeSerialUsingFileHandle

src/OrcLib/Location.cpp:213–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void GetVolumeSerialUsingFileHandle(const std::wstring& path, uint32_t& volumeSerial32, std::error_code& ec)
214{
215 using namespace Orc;
216
217 auto hVolume = CreateFileApi(
218 path.c_str(),
219 GENERIC_READ,
220 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
221 NULL,
222 OPEN_EXISTING,
223 FILE_FLAG_BACKUP_SEMANTICS,
224 NULL);
225
226 if (!hVolume)
227 {
228 Log::Debug(L"Failed CreateFileW '{}' [{}]", path, hVolume.error());
229 return;
230 }
231
232 BY_HANDLE_FILE_INFORMATION info;
233 if (!GetFileInformationByHandle(hVolume->value(), &info))
234 {
235 ec = LastWin32Error();
236 Log::Debug(L"Failed GetFileInformationByHandle '{}' [{}]", path, ec);
237 return;
238 }
239
240 volumeSerial32 = info.dwVolumeSerialNumber;
241}
242
243void GetVolumeSerial32(std::wstring path, uint32_t& volumeSerial32, std::error_code& ec)
244{

Callers 1

GetVolumeSerial32Function · 0.85

Calls 4

CreateFileApiFunction · 0.85
c_strMethod · 0.80
DebugFunction · 0.50
LastWin32ErrorFunction · 0.50

Tested by

no test coverage detected