Skip to content

AttachConsole over AllocConsole #11

Description

@JustArion

Hi, in ModLoader.cpp#L135 BOOL AllocConsole is called.

An alternate proposal is to call BOOL AttachConsole first, then if that fails call AllocConsole.

The reasoning behind this is that you can launch the game from the CLI and the Console Data will be sent to the Console who started the game (if any) instead of making a new console on launch.

You can attach to the parent process by calling AttachConsole(ATTACH_PARENT_PROCESS);
The function returns true on success, and false if there's no parent console (eg. the user double-clicked the program and launched it)

The proposed change can be made like this:

void ModLoader::OpenTerminal()
{
    if (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole())
    {
        freopen_s((FILE**)stdout, "CONOUT$", "w", stdout);
        SetWindowText(GetConsoleWindow(), "Elden Mod Loader");
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions