0

I have a dll that injects into a process but when i try to create a window using glfw and imgui my window pointer is apparently uninitialised the errors showing up are C6001 and C4703 the create window void is called a function in dllmain

my gui code is:

void GameRun() {
MessageBox(NULL, "Inject Successful", "Turtle Client", MB_OK);
/* Initialize the library */
GLFWwindow* window;
if (!glfwInit())

    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(640, 480, "Test", NULL, NULL);
if (!window)
{
    glfwTerminate();
}

/* Make the window's context current */
glfwMakeContextCurrent(window);
gladLoadGL(glfwGetProcAddress);
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init("#version 460");


/* Loop until the user closes the window */
while (!glfwWindowShouldClose(window))
{
    glfwPollEvents();
    glClearColor(0, 0, 255, 100);
    glClear(GL_COLOR_BUFFER_BIT);
    ImGui_ImplOpenGL3_NewFrame();
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();

    //init window
    ImGui::SetWindowSize(ImVec2((float)25, (float)15));
    ImGui::Begin("window");

    //imgui buttons etc
    ImGui::Text("Hi");
    ImGui::Button("test123", ImVec2((float)70, (float)20));

    ImGui::End();
    ImGui::Render();
    ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
    glfwSwapBuffers(window);
}
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplGlfw_Shutdown();
ImGui::DestroyContext();
glfwDestroyWindow(window);
glfwTerminate();
}

Thanks in advance -seaturtle

  • 1
    Please look at your code. You only initialize `window` if `glfwInit` failed. – G.M. Oct 06 '22 at 19:31
  • Change `GLFWwindow* window;` to `GLFWwindow* window{};` and fix the bad logic in the conditional that @G.M. mentioned. You may want to print a message and exit the application if glfwInit failed. – drescherjm Oct 06 '22 at 19:39

0 Answers0