Click here to Skip to main content
14,981,116 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
I have an executable, and I can't do this through code.
I want to inject a little conditional when running the file. This will prevent people of changing the name of the executable.
It would be like:
If this.filename != "RightName" then STOP running

Any ideas? I know it is a bit odd, but I really need that.

Edit:
Ok. I'm a Game Unity Developer. Before game and some of the code I wrote starts, Unity starts a little window, where you can inject some things through cheat engine or some things like that.
I have some problems with hackers, but I need to fix one, that works by changing the name of the executable. I can't program anything because, hackers can edit my code too by decompiling Unity's DLL.

What I have tried:

I couldn't try nothing, because I don't know much about this.
I searched a lot, but I couldn't find any results.
Posted
Updated 17-Jun-20 1:18am
v2
Comments
[no name] 16-Jun-20 13:51pm
   
And why c#?
ZurdoDev 16-Jun-20 14:05pm
   
Why not?
G44Gonzalo [ G44 YT ] 16-Jun-20 15:20pm
   
Well thank you, but that is not what I'm searching for.
ZurdoDev 16-Jun-20 15:28pm
   
Then you need to be more clear about what you want because it tells you how to get the name of the executing file. You can compare it to whatever you want and then do whatever you want.
G44Gonzalo [ G44 YT ] 17-Jun-20 6:28am
   
Ok, I should write this before. I'm a Game Unity Developer. Before game and some of the code I wrote starts, Unity starts a little window, where you can inject some things through cheat engine or some things like that.
I have some problems with hackers, but I need to fix one, that works by changing the name of the executable. I can't program anything because, hackers can edit my code too by decompiling Unity's DLL.
ZurdoDev 17-Jun-20 7:49am
   
Yes, that is a completely different story. I would contact Unity and ask them how they suggest you handle that.

When all is said and done; you cannot.

The only real way to do this would be within the code of the actual application.

While you could wrap the executable inside of another package, but then you could also subvert that by calling the file directly.
   
Comments
ZurdoDev 16-Jun-20 14:05pm
   
If you had a windows console app (as a simple example) in the main() you could check the file name and exit if it isn't what you wanted.
MadMyche 16-Jun-20 17:53pm
   
That does not meet the requirement I have an executable, and I can't do this through code
ZurdoDev 16-Jun-20 18:19pm
   
The OP is saying they don’t know how to do it through code, not that the requirement is to not use code.
MadMyche 16-Jun-20 18:59pm
   
As you commented earlier, the OP needs to clarify the question
I used to do this some time ago to support an aspect oriented framework over the top of COM and automation. I eventually abandoned the effort even though it worked.

There are several problems with this approach.

It will flag most virus scanners.

In many cases it is not reliable if the executable changes.

It may not work with DEP, which these days is active on most machines I think.
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900