gpt4 book ai didi

c++ - 当 Visual Studio 未以管理员身份运行时(GLFW/glad 应用程序),KernelBase.dll 异常代码 0x0EEDFADE(但没有崩溃)

转载 作者:行者123 更新时间:2023-12-02 16:37:55 24 4
gpt4 key购买 nike

我正在使用 Visual Studio 2019 并以以下简单的 OpenGL 程序作为最小示例(使用 GLFW 和 GLAD):

#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>

void error_callback(int error, const char* description) {
std::cout << "GLFW error: " << description << " (" << error << ")\n";
}

int main() {
if (!glfwInit()) exit(-1);
glfwSetErrorCallback(error_callback);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(640, 480, "GLFW Test Application", nullptr, nullptr);
if (!window) exit(-1);
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) exit(-1);
glViewport(0, 0, 640, 480);
glClearColor(0.6f, 0.6f, 0.1f, 1.f);
while (!glfwWindowShouldClose(window)) {
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
}

该程序运行良好,但在运行时,我会以几秒到大约 20 秒甚至更多秒的间隔在调试输出窗口中得到类似的行:

Exception thrown at 0x00007FFE61EEA799 (KernelBase.dll) in vcpkg_test.exe: 0x0EEDFADE (parameters: 0x0000000001D0A34E, 0x000001C13E322BA0, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000).
Exception thrown at 0x00007FFE61EEA799 (KernelBase.dll) in vcpkg_test.exe: 0x0EEDFADE (parameters: 0x0000000001D0A34E, 0x000001C13DC7CE40, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000).
Exception thrown at 0x00007FFE61EEA799 (KernelBase.dll) in vcpkg_test.exe: 0x0EEDFADE (parameters: 0x0000000001D0A34E, 0x000001C13DC7CDE0, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000, 0x0000000000000000).

虽然程序一直在运行,工作正常并且退出时退出代码为 0。当我在 Visual Studio 之外执行 EXE 文件时它也工作正常。当我将 VS 设置为在所有异常时中断,然后我看到异常发生在这个调用中(win32_init.c,“createHelperWindow”方法):

_glfw.win32.helperWindowHandle =
CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,
_GLFW_WNDCLASSNAME,
L"GLFW message window",
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0, 0, 1, 1,
NULL, NULL,
GetModuleHandleW(NULL),
NULL);

我已经花了几个小时在谷歌上试图找到解决这个问题的方法。我得到的唯一“提示”是当我以管理员身份运行 VS19 时,异常不会发生。有人知道是什么原因造成的吗?还是我应该忽略它,因为它运行良好?但这感觉不对……

更新/解决方案

我遵循了 Ben 的回答中的提示(参见已接受的回答)。启用中断第一次机会异常后,我得到了以下堆栈跟踪: stack trace

DLL“ammemb64.dll”也出现在模块窗口中。它属于“Actual Multiple Monitors”软件,关闭该应用程序后,异常消失。

最佳答案

根据 Google 的说法,这是 Delphi 使用的操作系统异常(结构化异常)代码。由于您不是用 Delphi 编写的,所以很可能某些用 Delphi 编写的程序正在 Hook 到所有正在运行的进程中。当您以管理员模式运行时,您的进程拥有足够的特权,钩子(Hook)无法触及它。

如果您想找到罪魁祸首,请在 Visual Studio Exceptions 对话框(右键单击条目“Win32 Exceptions”并选择 Add ,那么您将能够获得 0x0EEDFADE 的条目)。并查看堆栈跟踪,几乎可以肯定对 kernelbase.dll 的调用是通过某些第三方 DLL 进行的。

您还可以通过在调试时查看 Visual Studio 中的“模块”列表来获得线索,以查看哪些 DLL 加载到您的进程中,但与操作系统或 C++ 运行时无关。可能 DLL 的路径名将是一个死的赠品。

这是一个存在的问题,在 CreateWindow 调用期间发生未知(但不同)的异常,也是 Hook DLL 的结果:Create CFrameWnd gives first-chance exceptions--why?

特别是,我同意@IInspectable 就该问题发表的评论中的每一个字:

This is likely an effect caused by an application running in your desktop, that installs a global hook or causes code to run in your process using other infrastructure. Inside the handler an exception is raised, and later caught (otherwise you'd see a second-chance exception, together with an uncaught exception dialog). To solve this you'd have to identify the faulting application, and remove it from your system. Other than that, there's nothing wrong with your code.

这里是钩子(Hook)导致异常的相同问题的另一个实例:first chance exception in standard win32 wndproc

关于c++ - 当 Visual Studio 未以管理员身份运行时(GLFW/glad 应用程序),KernelBase.dll 异常代码 0x0EEDFADE(但没有崩溃),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62267856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com