View previous topic :: View next topic |
Author |
Message |
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Sat Oct 21, 2017 1:29 pm Post subject: How does Cheat Engine free the mouse cursor? |
|
|
I'm working with a bad PC port, which somehow locks the cursor to the center of the screen when the game has focus.
When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again.
How does CE achieve this? I'd like to not have to run the game again to use other programs.
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1586
|
Posted: Sat Oct 21, 2017 4:18 pm Post subject: |
|
|
MulleDK19 wrote: | How does CE achieve this? I'd like to not have to run the game again to use other programs. |
it should not affect the other programs
MulleDK19 wrote: | When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again. |
its a breakpoint as the name says, it stop the execution of a process when a condition is hit.
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
|
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Sat Oct 21, 2017 4:36 pm Post subject: |
|
|
OldCheatEngineUser wrote: | MulleDK19 wrote: | How does CE achieve this? I'd like to not have to run the game again to use other programs. |
it should not affect the other programs
MulleDK19 wrote: | When CE hits a breakpoint, the cursor lock is on, so I can't use the mouse in any window, EXCEPT CE. Whenever CE takes focus, the lock is gone, until it loses focus again. |
its a breakpoint as the name says, it stop the execution of a process when a condition is hit. |
You're not making any sense, so I'm assuming you've misunderstood.
The problem is that the game locks the cursor to the center of the screen when the game has focus. When CE hits a breakpoint, the game cannot release the lock when alt+tabbing to another window, so the cursor is locked to the screen until I run the process again, so I can't move the cursor while the game is in a break state.
IMGUR . com / I4mpqsu.gifv
EXCEPT when CE has focus. CE somehow removes the cursor lock when it gains focus, and reinstates it when it loses focus. So I can still work in CE when the game is paused, but not any other window like IDA, VS, etc.
So either there's some voodoo magic going on, or CE knows the type of cursor lock the game is using and deliberately disables it while it has focus.
I'd like to know what CE does to unlock the cursor, so I can write a program to unlock the cursor for all windows not just CE's.
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 457
Joined: 09 May 2003 Posts: 25262 Location: The netherlands
|
Posted: Sat Oct 21, 2017 5:29 pm Post subject: |
|
|
CE is 99% programming and 1% voodoo magic, so i have to guess it's that part
CE doesn't really do anything to the mouse cursor.
but what you describe is that the game constantly moves the mousecursor to the center of the screen (easy way to detect mouse movement)
when the game gets interrupted by a breakpoint that code doesn't run, so the mouse is released
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Sat Oct 21, 2017 6:12 pm Post subject: |
|
|
Dark Byte wrote: | when the game gets interrupted by a breakpoint that code doesn't run, so the mouse is released |
You'd think. The problem is, the cursor is still being set to the center of the screen when it hits a breakpoint. The lock only stops when CE receives focus.
Breakpoint, cursor locked to screen.
focus CE, cursor unlocked.
unfocus CE, cursor locked.
focus CE, cursor unlocked.
unfocus CE, cursor locked.
focus VS, cursor locked.
focus IDA, cursor locked.
focus CE, cursor unlocked.
resume execution, cursor remains unlocked until game receives focus.
|
|
Back to top |
|
|
OldCheatEngineUser Whateven rank Reputation: 20
Joined: 01 Feb 2016 Posts: 1586
|
Posted: Sat Oct 21, 2017 7:10 pm Post subject: |
|
|
i just ran a game that disable windows functions and i used a breakpoint just for experimenting purpose.
if i didnt misunderstood, then a similar thing happened to me.
maybe because the software disable windows functions?
EDIT + NOTE:
the game also force full screen mode, so yeah it could be a reason too.
one more thing is the process is paused when you are on your desktop.
_________________
About Me;
I Use CE Since Version 1.X, And Still Learning How To Use It Well!
Jul 26, 2020
STN wrote: | i am a sweetheart. |
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8516 Location: 127.0.0.1
|
Posted: Sat Oct 21, 2017 9:59 pm Post subject: |
|
|
If you are looking for API that would be causing the cursor locking:
- ClipCursor
- SetCursorPos
If the mouse is being hidden:
- ShowCursor
During debugging times you could hook these API and prevent them from being called properly if they are what is being used to lock the cursor as you are describing. Various rendering engines also have their own cursor handling stuff within them, such as the older versions of Direct3D up to D3D9. (OGL and so on each have their own as well.)
_________________
- Retired. |
|
Back to top |
|
|
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Mon Oct 23, 2017 7:52 pm Post subject: |
|
|
atom0s wrote: | If you are looking for API that would be causing the cursor locking:
- ClipCursor
- SetCursorPos
If the mouse is being hidden:
- ShowCursor
During debugging times you could hook these API and prevent them from being called properly if they are what is being used to lock the cursor as you are describing. Various rendering engines also have their own cursor handling stuff within them, such as the older versions of Direct3D up to D3D9. (OGL and so on each have their own as well.) |
I know what the game does. The question is how CE prevents the cursor from being set.
I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus.
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Mon Oct 23, 2017 10:28 pm Post subject: |
|
|
MulleDK19 wrote: | I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus. |
Could not replicate:
Code: | int main(int argc, char** argv)
{
std::cout << "Freezing cursor position.\nHold Ctrl to quit." << std::endl;
POINT p;
if (!GetCursorPos(&p))
return 1;
while (!(GetAsyncKeyState(0x11) >> 15))
{
SetCursorPos(p.x, p.y);
Sleep(2000);
}
return 0;
} |
You could look through CE's source if you want to, but if the person who wrote the code couldn't think of anything, you probably won't find anything.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Tue Oct 24, 2017 12:19 am Post subject: |
|
|
ParkourPenguin wrote: | MulleDK19 wrote: | I did some experimentation. Calling SetCursorPos in a custom app in a loop, sets the mouse, but when CE gains focus, the mouse can no longer be moved by the app. CE is doing something that prevents SetCursorPos on the OS level when it has focus. |
Could not replicate:
Code: | int main(int argc, char** argv)
{
std::cout << "Freezing cursor position.\nHold Ctrl to quit." << std::endl;
POINT p;
if (!GetCursorPos(&p))
return 1;
while (!(GetAsyncKeyState(0x11) >> 15))
{
SetCursorPos(p.x, p.y);
Sleep(2000);
}
return 0;
} |
You could look through CE's source if you want to, but if the person who wrote the code couldn't think of anything, you probably won't find anything. |
I just used the exact code you posted (well not exact, made it set to 10,10, and 200ms). Same thing, SetCursorPos does nothing when CE has focus. v6.7
https://i.imgur.com/GWIT76t.gifv
|
|
Back to top |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Tue Oct 24, 2017 8:36 am Post subject: |
|
|
I do get that behaviour when CE is run as administrator and the process calling SetCursorPos is not. Try running the other software as administrator.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
|
MulleDK19 Cheater Reputation: 0
Joined: 12 Aug 2012 Posts: 25 Location: Denmark
|
Posted: Tue Oct 24, 2017 3:56 pm Post subject: |
|
|
ParkourPenguin wrote: | I do get that behaviour when CE is run as administrator and the process calling SetCursorPos is not. Try running the other software as administrator. |
Well, mystery solved; thanks.
Well that sucks. Now I either have to patch SetCursorPos every time the game hits a breakpoint, or run all my programs as admin.
|
|
Back to top |
|
|
|