Skip to content

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

Merged
ElektroKill merged 1 commit intodnSpyEx:masterfrom
rigdern:rigdern/unity-attach-to-process
Sep 13, 2023
Merged

Fix some processes missing from "Attach to Process (Unity)"#242
ElektroKill merged 1 commit intodnSpyEx:masterfrom
rigdern:rigdern/unity-attach-to-process

Conversation

@rigdern
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
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