From f4f39e74fae3c8b8d8fdb2f560e8a50777b6de1d Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Sat, 20 May 2017 02:47:57 +0300 Subject: don't load the same PDB twice --- src/utils/file.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/utils') diff --git a/src/utils/file.cpp b/src/utils/file.cpp index f013d90..dba8a38 100644 --- a/src/utils/file.cpp +++ b/src/utils/file.cpp @@ -44,5 +44,31 @@ namespace pdb return result; } + + ID query_id(const std::string& path) + { + const Handle handle{CreateFileA( + path.c_str(), + FILE_READ_ATTRIBUTES, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL)}; + + if (handle.get() == INVALID_HANDLE_VALUE) + throw error::windows(GetLastError()); + + ID id; + + if (!GetFileInformationByHandleEx( + handle.get(), + FileIdInfo, + &id, + sizeof(id))) + throw error::windows(GetLastError()); + + return id; + } } } -- cgit v1.2.3