diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-20 02:47:57 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2017-05-20 02:47:57 +0300 |
commit | f4f39e74fae3c8b8d8fdb2f560e8a50777b6de1d (patch) | |
tree | a15a2c289e6d0f5fa8ccb2d71b1c4af24f0bd4b9 /src/utils | |
parent | don't load multiple PDBs with the same base (diff) | |
download | winapi-debug-f4f39e74fae3c8b8d8fdb2f560e8a50777b6de1d.tar.gz winapi-debug-f4f39e74fae3c8b8d8fdb2f560e8a50777b6de1d.zip |
don't load the same PDB twice
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/file.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
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; + } } } |