Skip to content

Commit

Permalink
steam_helper: Run console apps with a new console
Browse files Browse the repository at this point in the history
This should allow Wine to show a wineconsole dialog for games which make
use of it. Suggested by Vincent.
  • Loading branch information
aeikum committed Aug 12, 2019
1 parent 948aeac commit d73b927
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/makefile_base.mak
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ $(STEAMEXE_CONFIGURE_FILES): $(STEAMEXE_SYN) $(MAKEFILE_DEP) | $(STEAMEXE_OBJ) $
cp ../$(STEAMEXE_SYN)/Makefile . && \
echo >> ./Makefile 'SRCDIR := ../$(STEAMEXE_SYN)' && \
echo >> ./Makefile 'vpath % $$(SRCDIR)' && \
echo >> ./Makefile 'steam_exe_LDFLAGS := -m32 -lsteam_api $$(steam_exe_LDFLAGS)'
echo >> ./Makefile 'steam_exe_LDFLAGS := -m32 -lsteam_api -lole32 $$(steam_exe_LDFLAGS)'

## steam goals
STEAMEXE_TARGETS = steam steam_configure
Expand Down
11 changes: 10 additions & 1 deletion steam_helper/steam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ static HANDLE run_process(void)
WCHAR *cmdline = GetCommandLineW();
STARTUPINFOW si = { sizeof(si) };
PROCESS_INFORMATION pi;
DWORD flags = 0;

/* skip argv[0] */
if (*cmdline == '"')
Expand Down Expand Up @@ -169,6 +170,8 @@ static HANDLE run_process(void)
WCHAR *start, *end, *dos, *remainder, *new_cmdline;
size_t argv0_len;
int r;
DWORD_PTR console;
SHFILEINFOW sfi;

static const WCHAR dquoteW[] = {'"',0};

Expand Down Expand Up @@ -220,6 +223,12 @@ static HANDLE run_process(void)

dos = wine_get_dos_file_name(scratchA);

CoInitialize(NULL);

console = SHGetFileInfoW(dos, 0, &sfi, sizeof(sfi), SHGFI_EXETYPE);
if (console && !HIWORD(console))
flags |= CREATE_NEW_CONSOLE;

new_cmdline = (WCHAR *)HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(dos) + 3 + lstrlenW(remainder) + 1) * sizeof(WCHAR));
lstrcpyW(new_cmdline, dquoteW);
Expand All @@ -233,7 +242,7 @@ static HANDLE run_process(void)
run:
WINE_TRACE("Running command %s\n", wine_dbgstr_w(cmdline));

if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
if (!CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, flags, NULL, NULL, &si, &pi))
{
WINE_ERR("Failed to create process %s: %u\n", wine_dbgstr_w(cmdline), GetLastError());
return INVALID_HANDLE_VALUE;
Expand Down

0 comments on commit d73b927

Please sign in to comment.