我正在编写一个应该读取调试日志、解析日志并激活谷歌文本到语音的代码,这将提供有关吐出它的游戏的信息。
该日志具有 UTF-8 编码,因此我在代码中使用宽字符串,代码编译和解析字符串都很好,直到我尝试创建一个类对象。
然后我得到一个访问冲突:
'CMakeProject1.exe' (Win32): Loaded 'C:\Users\OptoCloud\CMakeBuilds\e36ef523-902d-0932-93cd-2201bbe1e731\build\x64-Release\CMakeProject1\CMakeProject1.exe'. Symbols loaded.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Program Files\AVAST Software\Avast\x64\aswhooka.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140.dll'. Cannot find or open the PDB file.
'CMakeProject1.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140.dll'. Cannot find or open the PDB file.
The thread 0x4174 has exited with code 0 (0x0).
Exception thrown at 0x00007FF7FBDA92B3 in CMakeProject1.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
#include <string>
#include <chrono>
#include <thread>
#include <iostream>
#include <fstream>
#include <windows.h>
#include <cstdlib>
#include <vector>
#include <map>
#include <thread>
#include <mutex>
#include <locale>
#include <codecvt>
std::wstring line;
std::wstring passed_string;
std::string path = "c:\\Users\\OptoCloud\\AppData\\LocalLow\\Game\\output_log.txt";
std::wifstream file(path, std::ios::binary);
class Create_Object
{
public:
Create_Object();
Create_Object(std::wstring passed_string);
std::wstring Object_string = 0;
};
Create_Object::Create_Object() {}
Create_Object::Create_Object(std::wstring passed_string)
{
Object_string.reserve(passed_string.length());
Object_string = passed_string;
}
std::map<std::wstring, Create_Object> objectlist;
int main()
{
while (true)
{
file.open(path.data());
if (file.is_open())
{
while (std::getline(file, line))
{
if (line.find(L"DELIMITER1") != std::string::npos)
{
passed_string = line.substr(line.find(L"DELIMITER1"), line.find(L"DELIMITER2"));
objectlist[passed_string] = Create_Object(passed_string); ///////////////////////POINT OF CRASH////////////////////////////////
}
file.close();
break;
}
}
}
return 1;
}
(已编辑)