CEAutoAttach icon indicating copy to clipboard operation
CEAutoAttach copied to clipboard

Why a binary?

Open FreeER opened this issue 7 years ago • 2 comments

If you're going to use a script that checks an environment variable is there any reason for the executable at all?

Why not just a script that sets whatever the first argument is to the environment variable and then starts CE.

Ok, like an hour later....

command to start CE tested in x64dbg (snapshot_2017-06-21_18-53) on Windows 10 (Version 1607) with CE 6.7 and the x86-64 CE tutorial (v 3.3) :)

powershell -Command "[Environment]::SetEnvironmentVariable('CEAutoAttach', '%PID%','User'); $f = ${env:ProgramFiles(x86)} + '\Cheat Engine 6.7\cheat engine.exe'; start $f; [Environment]::SetEnvironmentVariable('CEAutoAttach',$null,'User')"

Why does Windows make this so difficult? linux (and probably mac) would just be like (CEAutoAttach=%PID%; /usr/bin/CheatEngine)... that's why I thought of this in the first place sigh

And yes, I ended up with powershell because I had even more issues with getting cmd's set to work (/v /c kept turning into \v \c for one thing)... There's probably a way to not assume x64 or the CE version but, "quick" and dirty. The main issue with PS was getting the concatenation to not add a new line and break the start command, which was solved by assigning to a variable... You could probably also use a powershell script and just run that from x64dbg but, untested.

CEAutoAttach.lua (just leave it in autorun)

PID = os.getenv('CEAutoAttach')
if PID then openProcess(tonumber(PID)) end

Anyways, the point is that if you can do it without requiring a binary file then I don't have to trust your binary, or read your code, or get it to compile. And it's a bit easier to share

FreeER avatar Jun 25 '17 02:06 FreeER

The reason I did a binary is that environment variables are not inherited from a non-elevated context and I didn't feel like figuring out a workaround like you did 😄 I also don't have any concern of trust for my own binaries 👍

It is really weird that powershell allows you to pass along environment variables from the unelevated context like that, but perhaps there is a reason for it...

mrexodia avatar Jun 25 '17 03:06 mrexodia

Ah :)

You can set user level environment variables, ones that only affect the current user, but not "machine" wide ones for all users (see the third argument to SetEnvironmentVariable), knew it should be possible so I didn't mind looking for the workaround 😄

As for the trust, if I think something is useful for me I try to think about whether it'd be useful for others and what might prevent them from using it. While I haven't personally branched out to using other debuggers, I find CE can usually do anything I want (though I don't come across much AntiCheat or anything), I have seen others doing so, which is why I found this interesting when I saw the issue on the CE repo :)

FreeER avatar Jun 25 '17 03:06 FreeER