[英]Xmemory Access violation reading location 0xFFFFFFFFFFFFFFFF
每當我運行此代碼時,我Exception thrown at 0x00007FF6CA077375 in console test.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
來自一個名為“xmemory”的文件,它應該做的是遍歷不同的文件夾來尋找指定的文件,所以它使用了一些遞歸,我不確定這是否是問題的一部分,它仍然是一個 WIP但我需要先對異常做一些事情。 我正在使用 Visual Studio 17.3.0、C++20 Standard (/std:c++20) 和 MinGW gcc 編譯器,以防萬一
#include <string>
#include <vector>
#include <iostream>
#include <filesystem>
using std::filesystem::directory_iterator;
namespace fs = std::filesystem;
using namespace std;
string endstr(string str, string delim) {
int i = str.length();
while (str[i] != delim[0])
{
if (i == 0) break;
i--;
}
return str.substr(i + 1, str.length());
}
string start = "C:\\";
vector<string> explored;
string fl;
string *dir;
string getFile(const char* item, string startPath)
{
for (const auto& file : directory_iterator(startPath))
{
fl = file.path().string();
cout << fl << endl;
if (fl == endstr(item, "\\")) {
return fl;
}
else if (file.is_directory()) {
if (find(explored.begin(), explored.end(), fl) != explored.end()) {
getFile(item, fl);
}
}
else {
break;
}
}
explored.push_back(fl);
}
int main() {
getFile("Terraria.exe", "C:\\");
}
編輯:調試日志 n 東西
調試
'console test.exe' (Win32): Loaded 'C:\Users\willk\source\repos\console test\x64\Debug\console test.exe'. Symbols loaded.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'.
'console test.exe' (Win32): Loaded 'C:\Program Files\Avast Software\Avast\aswhook.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\msvcp140d.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140d.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_1d.dll'.
'console test.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbased.dll'.
The thread 0x5cec has exited with code 0 (0x0).
Exception thrown at 0x00007FF703A47415 in console test.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
建造
Build started...
1>------ Build started: Project: console test, Configuration: Debug x64 ------
1>console test.cpp
1>C:\Users\willk\source\repos\console test\console test\console test.cpp(14,25): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
1>C:\Users\willk\source\repos\console test\console test\console test.cpp(45): warning C4715: 'getFile': not all control paths return a value
1>console test.vcxproj -> C:\Users\willk\source\repos\console test\x64\Debug\console test.exe
1>Done building project "console test.vcxproj".
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.