falahati / NetworkAdapterSelector

A simple solution to let you force bind a program to a specific network adapter
GNU General Public License v2.0
229 stars 38 forks source link

Unable to use because it renames the Window name. #10

Open acidreian666 opened 4 years ago

acidreian666 commented 4 years ago

Unable to use because it renames the Window name. please create a parameter that allows you to inject to the specific PID. Without changing the window name with the IP address. It causes compatibility issues for specific programs.

falahati commented 4 years ago

You can currently attach it to a specific process using PID: https://github.com/falahati/NetworkAdapterSelector#command-line-parameters

However, I need to add a flag to disable the change to the Window's title.

acidreian666 commented 4 years ago

If you added the flag it would be greatly appreciated!

acidreian666 commented 4 years ago

I noticed you added the flag to the the source to allow the main window to not be renamed. but would it be possible to get a released version i don't know how to compile it.

falahati commented 4 years ago

Fix will be released as part of version 2 that I am writing now in the last couple of days. Hopefully, it will be released soon.

acidreian666 commented 4 years ago

Any update Falahati?

acidreian666 commented 4 years ago

Can you please compile the updated changes for this enhancement? @falahati

hobby-lc commented 4 years ago

Can you please compile the updated changes for this enhancement? @falahati

The code is not finished yet. Please give him sometime to fix the code.

@falahati I complied it using VSCode and the following error msg will be shown when the programme tried to hook : "The given user library does not export a proper Run...."

It seems that the function "Run" in Guest.cs is not declared correctly (variable for changeWindowTitle is missing). https://github.com/falahati/NetworkAdapterSelector/blob/5e98ad79aeea62f8caac59b9556e6edd9093fbe9/NetworkAdapterSelector.Hook/Guest.cs#L92-L97

The programme can run properly after I added an extra variable in the Run function, but it seems that the flag do not have any effect on stopping the title change.

falahati commented 4 years ago

You are right; it seems that I missed the parameter for the Run method and only added it to the constructor. But adding it should be enough since the logic is already there. You don't need to assign the variable to anything at this stage.

Keep in mind that you also need to execute the program with --title false or --title 0 argument when injecting. And this means that injection by shell extension always has this value as true.

hobby-lc commented 4 years ago

You are right; it seems that I missed the parameter for the Run method and only added it to the constructor. But adding it should be enough since the logic is already there. You don't need to assign the variable to anything at this stage.

Keep in mind that you also need to execute the program with --title false or --title 0 argument when injecting. And this means that injection by shell extension always has this value as true.

@falahati

First of all, I am not familiar with C# programming. My information below may be wrong.

The following code is not working. I run debug in VSCode and it seems that value of ChangeWindowTitle is always "True" no matter what value provided after "--title". https://github.com/falahati/NetworkAdapterSelector/blob/5e98ad79aeea62f8caac59b9556e6edd9093fbe9/NetworkAdapterSelector.Hook/CommandLineOptions.cs#L93

According to the following https://github.com/commandlineparser/commandline/issues/290

Booleans do not take arguments. They are flags, so including the boolean flag means 'true' and leaving it out means 'false'.

With reference to page below: https://stackoverflow.com/questions/35873835/command-line-parser-library-boolean-parameter

I changed the code as follow: public bool? ChangeWindowTitle { get; set; }

And now the argument should take values "true|false". (tested empty or "0" after "--title" is not working)

For your information and Thank you.

falahati commented 4 years ago

Thank you for the report. It happens probably since the flag has a default value of true.