Вот как выглядит мой код чтения:
Код: Выделить всё
#include
#include
#include
#include
#include
#include "mt_reader.hpp"
#include "Utils/error.hpp"
mt_reader::mt_reader(std::wstring volume_name) {
std::wstring valid_name = volume_name;
if (valid_name.back() == '\\') {
valid_name.pop_back();
}
_handle_disk = CreateFileW(
valid_name.c_str(),
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
nullptr
);
if (_handle_disk == INVALID_HANDLE_VALUE) {
auto err = win_error(GetLastError(),ERROR_LOC);
if (err.Get_First_Error_Code()!=0) {
win_error::print(err);
}
} else {
auto temp_read = read(0, _boot_record, 0x200, 'a');
if (!temp_read.has_value()) {
win_error::print(temp_read.error().add_to_error_stack("Caller: read error", ERROR_LOC));
}
}
}
mt_reader::~mt_reader() {
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/79857919/issue-with-multithreaded-concurrent-use-of-readfile-windows-api[/url]