Script crashing game after an hour and a half

Ask gaming related questions (AHK v1.1 and older)
Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Script crashing game after an hour and a half

Post by Sleepwalker » 01 Aug 2020, 14:30

Hi there,

I've been working on this script on and off for a few days now, I thought that it was my VM set up that was crashing it but I've come to the realization that it's actually the script itself crashing the game when it runs for too long. I tested this by restarting the script after an hour and it lasted much longer than if I just left it running.

I'd appreciate some help to figure out the cause, if possible I'd like to be able to run the script for at least 8 hours at a time.

I run 2 virtual machines, each has its own assigned 6 cores clocked at 4.2ghz and 4 gigs of ram to use so I don't see resources being too much of an issue, but when I run the script for that long the game starts stuttering like hell and eventually freezes all together with no crash report, I can run the game non stop without the script running.

Before you read I know it looks janky as hell but it's the only way I could get the game to recognize an input, I tried many other various things to no avail, the game does not accept a constant key down input you have to keep repeating that input for anything to actually happen ingame.

At first I thought it was because the CPU couldn't catch up since only one of the VM's was crashing so I added a bunch of sleep functions but that didn't help too much.

Thank you.

Code: Select all

l::
ExitApp

p::

Loop,

{
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {w down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {w down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {w down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {w down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {s down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {s down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {s down}, Phantasy Star Online 2
			}
	Sleep, 5000
	Loop, 100
			{
			ControlSend,, {s down}, Phantasy Star Online 2
			}
}

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 01 Aug 2020, 14:38

Would it be because it requires a w up to counteract each w down input? like could those w down inputs be creating some kind of memory leak by stacking over and over?

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script crashing game after an hour and a half

Post by Xtra » 01 Aug 2020, 14:57

Check the Event Viewer logs for what the problem is.

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 01 Aug 2020, 15:16

It's a pretty generic error it's giving out tbh from what I see online it's a pretty bland code it gives out whenever the game freezes up, I can't really decipher exactly what the reason is for it crashing but it only crashes when the script is running. does it look like the script should be causing any stability issues? like is the thing I mentioned above ever a problem or it doesn't work like that anyways?

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script crashing game after an hour and a half

Post by Xtra » 01 Aug 2020, 15:38

Spamming keys 100 times in a row could be using a lot of cpu at times and the game is having issues with that.

I think the main issue is no sleep in the inner loops. Adding sleep 16 will reduce cpu use to almost nothing. I added key up after the inner loops which wont hurt to have. Loop, 4 simplifies what you are doing.

Give this a try:

Code: Select all

l::
ExitApp

p::
Loop
{
    Loop, 4
    {
        Sleep, 5000
        Loop, 100
        {
            ControlSend,, {w down}, Phantasy Star Online 2
            Sleep, 16
        }
    }
    ControlSend,, {w up}, Phantasy Star Online 2
    
    Loop, 4
    {
        Sleep, 5000
        Loop, 100
        {
            ControlSend,, {s down}, Phantasy Star Online 2
            Sleep, 16
        }
    }
    ControlSend,, {s up}, Phantasy Star Online 2
}
return

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 01 Aug 2020, 16:01

I'll give this a go and report back if any more issues arise, If it does crash again I'm pretty sure I can rule out AHK then I'll see if I can get support on the game forums for the crash. Thanks for your help, I thought my Sleep, 5000's would have been enough on the outer loops but we will see.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Script crashing game after an hour and a half

Post by swagfag » 01 Aug 2020, 16:19

ur thread title claims ur game crashes, ur thread body says ur game freezes. later on it says its actually ur VM that is crashing.
which is it then?
I thought that it was my VM set up that was crashing it but I've come to the realization that it's actually the script itself crashing the game when it runs for too long. I tested this by ...
...running ur game and script outside the VM?
...restarting the script after an hour and it lasted much longer than if I just left it running.
well nevermind then. wait, what does this even mean? are u implying ur game freezes even when no scripts are running along side it? it seems like thats what ure implying
see if I can get support on the game forums for the crash
doubt it. the game could be mishandling artificial input(purposefully or not), but nobodys gonna tell u this. for all we know, the game could have an anticheat that bricks itself every 30 mins if 10k keystrokes have been sent in the past 30 mins.

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 01 Aug 2020, 17:52

swagfag wrote:
01 Aug 2020, 16:19
ur thread title claims ur game crashes, ur thread body says ur game freezes. later on it says its actually ur VM that is crashing.
which is it then?
I thought that it was my VM set up that was crashing it but I've come to the realization that it's actually the script itself crashing the game when it runs for too long. I tested this by ...
...running ur game and script outside the VM?
...restarting the script after an hour and it lasted much longer than if I just left it running.
well nevermind then. wait, what does this even mean? are u implying ur game freezes even when no scripts are running along side it? it seems like thats what ure implying
see if I can get support on the game forums for the crash
doubt it. the game could be mishandling artificial input(purposefully or not), but nobodys gonna tell u this. for all we know, the game could have an anticheat that bricks itself every 30 mins if 10k keystrokes have been sent in the past 30 mins.
Sorry for mistyping a few things in my main post. The game starts to stutter, then freezes, then crashes. The game only starts developing these symptoms when the script is ran for over an hour, if I don't run the script I don't crash at all in fact I can play for many hours on end.
All testing was done inside the VM.
I got some help on a third party forum that reckons its something to do with DX10, which makes no sense really since the game runs in DX9 but thanks for all your help, at least I can say it's not the script it could just be system instability as a whole causing these issues.

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 02 Aug 2020, 07:48

It is definitely the script, I noticed when I press caps lock when the script is running it flashes on and off like crazy too.
Here's a crash dump for the game but I'm not too sure if it helps.

Code: Select all

pso2.exe caused an Access Violation at location 00007FF822BF2E0A in module gpapi.dll Reading from location 0000000000000140.

AddrPC           Params
00007FF822BF2E0A 000000005FFF0148 000000005FFF0150 0000E146BDAAB1AA  gpapi.dll!CGPSvcBindingHandleFactory::Destroy
00007FF822BF401F 000000005FFF0148 000000005FFF0150 0000000000000000  gpapi.dll!DllMain
00007FF822BF383F 00007FF822BF0000 0000000000000000 0000000000000001  gpapi.dll!__DllMainCRTStartup
00007FF826BE7B3D 0000000061F54EB0 00007FF822BF0000 00007FF800000000  ntdll.dll!LdrpCallInitRoutine
00007FF826C13CE1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!LdrShutdownProcess
00007FF826596FD4 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF826BFCEC1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

pso2.exe caused an Access Violation at location 00007FF822BF2E0A in module gpapi.dll Reading from location 0000000000000140.

AddrPC           Params
00007FF822BF2E0A 000000005FFF0148 000000005FFF0150 0000E146BDAAB1AA  gpapi.dll!CGPSvcBindingHandleFactory::Destroy
00007FF822BF401F 000000005FFF0148 000000005FFF0150 0000000000000000  gpapi.dll!DllMain
00007FF822BF383F 00007FF822BF0000 0000000000000000 0000000000000001  gpapi.dll!__DllMainCRTStartup
00007FF826BE7B3D 0000000061F54EB0 00007FF822BF0000 00007FF800000000  ntdll.dll!LdrpCallInitRoutine
00007FF826C13CE1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!LdrShutdownProcess
00007FF826596FD4 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF826BFCEC1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

Sleepwalker
Posts: 9
Joined: 31 Jul 2020, 19:31

Re: Script crashing game after an hour and a half

Post by Sleepwalker » 02 Aug 2020, 07:50

Sleepwalker wrote:
02 Aug 2020, 07:48
It is definitely the script, I noticed when I press caps lock when the script is running it flashes on and off like crazy too.
Here's a crash dump for the game but I'm not too sure if it helps.

This crash was on my main system not a VM

Code: Select all

pso2.exe caused an Access Violation at location 00007FF822BF2E0A in module gpapi.dll Reading from location 0000000000000140.

AddrPC           Params
00007FF822BF2E0A 000000005FFF0148 000000005FFF0150 0000E146BDAAB1AA  gpapi.dll!CGPSvcBindingHandleFactory::Destroy
00007FF822BF401F 000000005FFF0148 000000005FFF0150 0000000000000000  gpapi.dll!DllMain
00007FF822BF383F 00007FF822BF0000 0000000000000000 0000000000000001  gpapi.dll!__DllMainCRTStartup
00007FF826BE7B3D 0000000061F54EB0 00007FF822BF0000 00007FF800000000  ntdll.dll!LdrpCallInitRoutine
00007FF826C13CE1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!LdrShutdownProcess
00007FF826596FD4 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF826BFCEC1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

pso2.exe caused an Access Violation at location 00007FF822BF2E0A in module gpapi.dll Reading from location 0000000000000140.

AddrPC           Params
00007FF822BF2E0A 000000005FFF0148 000000005FFF0150 0000E146BDAAB1AA  gpapi.dll!CGPSvcBindingHandleFactory::Destroy
00007FF822BF401F 000000005FFF0148 000000005FFF0150 0000000000000000  gpapi.dll!DllMain
00007FF822BF383F 00007FF822BF0000 0000000000000000 0000000000000001  gpapi.dll!__DllMainCRTStartup
00007FF826BE7B3D 0000000061F54EB0 00007FF822BF0000 00007FF800000000  ntdll.dll!LdrpCallInitRoutine
00007FF826C13CE1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!LdrShutdownProcess
00007FF826596FD4 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FF826BFCEC1 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: Script crashing game after an hour and a half

Post by Xtra » 02 Aug 2020, 10:58

You failed to mention your game uses GameGuard.
There is your problem.
GL

gregster
Posts: 9020
Joined: 30 Sep 2013, 06:48

Re: Script crashing game after an hour and a half

Post by gregster » 02 Aug 2020, 14:07

Sleepwalker wrote:
02 Aug 2020, 07:48
I noticed when I press caps lock when the script is running it flashes on and off like crazy too.
This can be expected, afaik, if you are sending small letters and is intended behaviour.
While Capslock is ON, Send needs to de-activate it to be able to send small letters; after sending, the Capslock state gets immediately restored. There you have your flicker...

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Script crashing game after an hour and a half

Post by swagfag » 02 Aug 2020, 15:44

its no use trying to analyze the dump. the stack trace is likely merely indicative of the symptom rather than the cause.

first test to see whether Sending normally causes the game to crash after a while.
  • if it does, then try having AutoHotInterception's mouse driver produce keystrokes instead(but bear in mind, depending on the anticheat, u might not be even able to launch the game. or worse yet, u get instabanned/flagged. if u still crash with the mouse driver, then either something's badly implemented on the game side(purposefully or not) or the anticheat is crashing ur game)
  • if it doesnt crash, then ControlSend is the culprit. try posting the WM_CHAR and/or WM_KEYDOWN / WM_KEYUP messages to the game window directly, instead of using ctrlsend. if u still crash, either the game is coded badly or the anticheat is kicking in
the next obvious step is bypassing the anticheat, buuuuut.......

Post Reply

Return to “Gaming Help (v1)”