Fix file sharing issue.
If a file was previously opened with FILE_SHARE_WRITE by some other process, the call to CreateFile was failing with ERROR_SHARING_VIOLATION. With this change YARA can read files that were opened with FILE_SHARE_WRITE by other processes.
Thanks to Frank Boldewin for reporting and finding the root cause of this issue.
@@ -270,7 +270,7 @@ YR_API int yr_filemap_map_ex(
fd = CreateFileA(
file_path,
GENERIC_READ,
- FILE_SHARE_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,
