-
-
Notifications
You must be signed in to change notification settings - Fork 395
Stopped infinite "Handling DRM" bug #1575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4142,7 +4142,7 @@ private fun unpackExecutableFile( | |||||||||||
| try { | ||||||||||||
| val origDll = File("${imageFs.wineprefix}/dosdevices/a:/$relDllPath") | ||||||||||||
| if (origDll.exists()) { | ||||||||||||
| val genCmd = "wine z:\\generate_interfaces_file.exe A:\\" + relDllPath.replace('/', '\\') | ||||||||||||
| val genCmd = "wine cmd /c \"z:\\generate_interfaces_file.exe A:\\" + relDllPath.replace('/', '\\') + " & wineserver -k\"" | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The Prompt for AI agents
Suggested change
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents |
||||||||||||
| Timber.i("Running generate_interfaces_file $genCmd") | ||||||||||||
| val genOutput = guestProgramLauncherComponent.execShellCommand(genCmd) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -208,6 +208,9 @@ public static int exec(String command, String[] envp, File workingDir) { | |||||||||||||
| // such as SteamTokenLogin | ||||||||||||||
| public static String execWithOutput(String command, String[] envp, File workingDir, boolean includeStderr) { | ||||||||||||||
| StringBuilder output = new StringBuilder(); | ||||||||||||||
| final StringBuilder stdoutBuf = new StringBuilder(); | ||||||||||||||
| final StringBuilder stderrBuf = new StringBuilder(); | ||||||||||||||
| Thread stdoutDrainer = null; | ||||||||||||||
| Thread stderrDrainer = null; | ||||||||||||||
| try { | ||||||||||||||
| if (BuildConfig.MODERN_ANDROID) command = "/system/bin/linker64 " + command; | ||||||||||||||
|
|
@@ -221,45 +224,43 @@ public static String execWithOutput(String command, String[] envp, File workingD | |||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| if (workingDir != null) pb.directory(workingDir); | ||||||||||||||
| pb.redirectErrorStream(includeStderr); // merge only when caller wants stderr | ||||||||||||||
|
|
||||||||||||||
| java.lang.Process process = pb.start(); | ||||||||||||||
|
|
||||||||||||||
| // When not merging, drain stderr on a daemon thread to prevent pipe-buffer deadlock. | ||||||||||||||
| // SteamTokenLogin uses this when calling includeStderr=false | ||||||||||||||
| if (!includeStderr) { | ||||||||||||||
| final InputStream stderrStream = process.getErrorStream(); | ||||||||||||||
| stderrDrainer = new Thread(() -> { | ||||||||||||||
| try { | ||||||||||||||
| byte[] buf = new byte[4096]; | ||||||||||||||
| while (stderrStream.read(buf) != -1) { | ||||||||||||||
| if (Thread.currentThread().isInterrupted()) | ||||||||||||||
| break; | ||||||||||||||
| } | ||||||||||||||
| } catch (IOException ignored) {} | ||||||||||||||
| }, "stderr-drainer"); | ||||||||||||||
| stderrDrainer.setDaemon(true); // won't block app shutdown if something goes wrong | ||||||||||||||
| stderrDrainer.start(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Read stdout (or the merged stream) inline; EOF arrives after the process exits. | ||||||||||||||
| try (BufferedReader r = new BufferedReader(new InputStreamReader(process.getInputStream()))) { | ||||||||||||||
| String l; | ||||||||||||||
| while ((l = r.readLine()) != null) output.append(l).append("\n"); | ||||||||||||||
| } | ||||||||||||||
| final InputStream stdoutStream = process.getInputStream(); | ||||||||||||||
| stdoutDrainer = new Thread(() -> { | ||||||||||||||
| try (BufferedReader r = new BufferedReader(new InputStreamReader(stdoutStream))) { | ||||||||||||||
| String l; | ||||||||||||||
| while ((l = r.readLine()) != null) stdoutBuf.append(l).append("\n"); | ||||||||||||||
| } catch (IOException ignored) {} | ||||||||||||||
| }, "stdout-drainer"); | ||||||||||||||
| stdoutDrainer.setDaemon(true); | ||||||||||||||
| stdoutDrainer.start(); | ||||||||||||||
|
|
||||||||||||||
| final InputStream stderrStream = process.getErrorStream(); | ||||||||||||||
| stderrDrainer = new Thread(() -> { | ||||||||||||||
| try (BufferedReader r = new BufferedReader(new InputStreamReader(stderrStream))) { | ||||||||||||||
| String l; | ||||||||||||||
| while ((l = r.readLine()) != null) { | ||||||||||||||
| if (includeStderr) stderrBuf.append(l).append("\n"); | ||||||||||||||
| } | ||||||||||||||
| } catch (IOException ignored) {} | ||||||||||||||
| }, "stderr-drainer"); | ||||||||||||||
| stderrDrainer.setDaemon(true); | ||||||||||||||
| stderrDrainer.start(); | ||||||||||||||
|
|
||||||||||||||
| // Process has already exited (we drained its stdout to EOF). | ||||||||||||||
| // waitFor() reaps the OS process-table entry. | ||||||||||||||
| process.waitFor(); | ||||||||||||||
| try { stdoutStream.close(); } catch (IOException ignored) {} | ||||||||||||||
| try { stderrStream.close(); } catch (IOException ignored) {} | ||||||||||||||
| stdoutDrainer.join(5_000); | ||||||||||||||
| stderrDrainer.join(5_000); | ||||||||||||||
|
Comment on lines
+253
to
+256
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Streams are closed before drainer threads finish, which can truncate captured output/logs. Prompt for AI agents
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| if (stderrDrainer != null) { | ||||||||||||||
| stderrDrainer.join(5_000); // bounded wait; daemon thread is reaped on JVM exit anyway | ||||||||||||||
| } | ||||||||||||||
| output.append(stdoutBuf); | ||||||||||||||
| if (includeStderr) output.append(stderrBuf); | ||||||||||||||
| } catch (Exception e) { | ||||||||||||||
| output.append("Error: ").append(e.getMessage()); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Format output: trim trailing whitespace/newlines | ||||||||||||||
| return output.toString().trim(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quote and escape the DLL path inside the
cmd /cpayload.At Line 4145,
relDllPathis concatenated unquoted intowine cmd /c "...". If the path contains spaces (or cmd metacharacters),generate_interfaces_file.exeparsing breaks and may execute unintended fragments. Wrap theA:\...argument in quotes and escape embedded quotes.Suggested patch
📝 Committable suggestion
🤖 Prompt for AI Agents