Skip to content
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

Fix some processes missing from "Attach to Process (Unity)" #242

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

rigdern
Copy link

@rigdern rigdern commented Sep 11, 2023

Problem

When using "Debug -> Attach to Process (Unity)...", my Unity process is not shown. Here's a screenshot:

image

Root cause

It seems that my Unity player data string has a slightly different format than dnSpy expects which causes its regex to fail on it.

In the debugger, I can see that my Unity process's player data string is:

[IP] 10.0.1.10 [Port] 55000 [Flags] 2 [Guid] 886973232 [EditorId] 0 [Version] 1048832 [Id] WindowsPlayer(2,Rigderns-PC) [Debug] 1 [PackageName] WindowsPlayer [ProjectName] <no name>

TryParseUnityPlayerData bails here because the value it parsed for machine doesn't match Dns.GetHostName():

  • machine: "2,Rigderns-PC"
  • Dns.GetHostName(): "Rigderns-PC"

Solution

I updated the regex to account for the possibility of a number and comma preceding the machine name. I verified "machine" is parsed properly regardless of whether it is preceded by a number. Examples:

  • For WindowsPlayer(2,Rigderns-PC), "machine" is parsed as Rigderns-PC
  • For WindowsPlayer(Rigderns-PC), "machine" is parsed as Rigderns-PC

(If there's test infrastructure in place, let me know and I can add some tests for this.)

I also verified that my Unity process is now listed in the "Attach to Process (Unity)" window.

I added an optional non-capturing group to take care of the number & comma that comes before the machine name on my machine.
@ElektroKill
Copy link
Member

ElektroKill commented Sep 13, 2023

Hi,

Thanks for the contribution! Were you perhaps able to figure out why your version of the Unity player had the additional number in the data string and what is the purpose of this additional number?

Other than that, LGTM!

@rigdern
Copy link
Author

rigdern commented Sep 13, 2023

No, unfortunately I couldn't find any official documentation about the Unity player data string format.

These are the mentions of the player data string that I found but none of them give insights on the meaning on that part of it:

@ElektroKill ElektroKill merged commit 2cbd254 into dnSpyEx:master Sep 13, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants