Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Access Violation, and attempt to call global 'close' nil

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DTeCH
Newbie cheater
Reputation: 0

Joined: 19 Jul 2013
Posts: 23
Location: Cayman Islands

PostPosted: Sat Oct 05, 2013 12:43 am    Post subject: Access Violation, and attempt to call global 'close' nil Reply with quote

Access Violation, & attempt to call global 'close' (a nil value) when I try to close the trainer.


Hello again guys. Smile



This problem has been haunting me for months. It's really getting to me. Foul language + TAX has been coming out of my mouth because of it.

I have been developing since 1988, & have gained a level of patience that was never in me to begin with, due to the continual attempts to blame the language of being super buggy, only to find months later (after I've calmed down, & gave up on the project) that it was a simple overlooked DOT in the wrong place, or something declared with a Capital letter in it, but the rest of the code calls it without the Capital, & causes it to not be recognized.

Simple things like that has placed bags under my eyes over the years. So... I've learned to be patient, & resume working until I can spot the obvious error later by not even looking for it. Smile


However, this LUA thing is getting me to the point of cursing like a spoiled little school girl. Razz

My Trainer project has gone from v1.0 to v1.53 (54 releases). Each version has it's own folder which includes the xxx.CT, xxx.CETRAINER, xxx-Plain.CETRAINER, xxx-32.exe, & xxx-64.exe of that specific version.

I have been comparing like crazy to try to locate the error location to no avail.


I started the project with CE v6.2, & since maybe v1.20 of my trainer, I switched to CE v6.3

My issue started when I added the customeSound scripts from mgr.inz.Player located forum.cheatengine.org/viewtopic.php?t=565651 .

The scripts work flawlessly, but now these errors won't piss off, & let the trainer close as usual. What confuses me is the fact that it did close several times normally when I was working on it from a copy of v1.44 of the trainer renamed to v1.53 Alternate.

While re-writing it to match v1.53 I quickly realized that it compiled, & ran + closed as usual with the scripts from mgr.inz.Player in place from the early stages of the re-write, however, the problem seemed to spring up when I was done with the re-write, & left the close button, & Form's OnClose event for last due to the fact that these edits were what caused my issues from the original v1.53 project, & added the following to them:

Code:
function CloseClick()
   control_setEnabled(CETrainer_CEButton12, false)--Close Button
   sleep(200)
   customSound.PlaySound(6)
   sleep(1000)
   closeCE()--close()
end

function FormClose(sender)
closeCE()
return caFree --Possible options: caHide, caFree, caMinimize, caNone
end


The problem returned... but now, not only did it return, & behaved just like the original v1.53 project, it was exactly like the original project - by that I mean, when I remove the edits made to those 2 functions, the Trainer will no longer start. Identical issue as the original project.

I'm lost. I looked for a cheatengine log file, also looked for an entry in the Event Viewer, & nothing. No messages from anywhere about anything to do with anything.

So I think my frustrations are warranted this time. Smile

I did more than 1 re-write, & did it slowly as well to make sure it wasn't something I missed. They all behaved exactly as explained above.

I compiled, & ran the trainer after adding every extra button to make it match v1.53, & it worked each time up to the addition to the last 2 functions shown above... and when removed, causes the trainer not to start. Task Manager shows them just sitting there, & while I had VS2010 debugger attached to one of them (was not running) when I closed the other instances (about 6), the following message popped up in Task Manager for each process:

Code:
Unable to Terminate Process

   The operation could not be completed.
X
   The operation is not valid for this process


...but they appeared to close fine.


I was beginning to think it was because cheatengine was loaded in the background somewhere, or something in a crashed hanging state, so I terminated every instance I could find, & the trainer still won't start.

Did I mention I was lost? Razz

I also ran other older versions, & they all work fine... giving me false hope to try v1.53 again, only to wanna slap the monitor off my desk. Very Happy


HELP plz. Greatly appreciate you guys Smile

_________________
Hitler... When all else fails, you'll be in the right state of mind. Jesus Saves.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Sat Oct 05, 2013 3:04 am    Post subject: Reply with quote

Use print to make your own log
Does your lua script contain the customsound code? And if not, is it launched eventually another way?

Also, run the lua script in the .ct instead of .cetrainer or.exe to get a better view on what could go wrong

And if you post the unencrypted .cetrainer or even .ct we could check what goes wrong

_________________
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
View user's profile Send private message MSN Messenger
DTeCH
Newbie cheater
Reputation: 0

Joined: 19 Jul 2013
Posts: 23
Location: Cayman Islands

PostPosted: Sat Oct 05, 2013 6:36 am    Post subject: Reply with quote

Thanks Byte Smile


Looks like the customSound script calls an injected instance of winmm.PlaySoundA that some how locks the trainer thread. When a simple MouseUp, or MouseDown sound plays, the OnClick event gets ignored... which is strange because it worked before. Might be a memory bug, or some other code execution timing related issue, because it doesnt happen every single time.

My closing problem went away when I removed both the MouseUp, & MouseDown customSound sound effects for the close button. Had to do the same for the Attach to Browser Button. Strange.

Really wanted this trainer to follow in the SFX footsteps of my BOT tools... at least in appearance, & effects Smile

LUA is seriously limited, but I'm going with it because it works nicely with Cheatengine, but i can't seem to find any code samples for VS.NET. I hate that my browser game trainers are single threaded, & blocking... freezing the GUI with each call to a function that takes a few moments to complete. I used Teamviewer a few minutes ago to run the trainer on both a 64 bit system, & a low memory single core laptop in Puerto Rico, & South Dakota which both took over 10 minutes to attach to Google Chrome, SRWare Iron, Comodo Dragon, CoolNovo, & Chromium.

Threading is so easy in VS.NET, & really makes me feel like I'm going backwards instead of forwards if I don't use it. Razz

If there are any code bits laying around to import a Cheatengine.dll of some type, & use it from within C#.net, or VB.NET, I'd really love to know about them. Even an alternative set of calls to mimic what you have achieved with cheat-engine from within VS.NET to be able to use the calling convention similar to the trainer maker's LUA atmosphere.

I don't have the ambition to write one from scratch just for free trainers.

Thanks again for the print info. I'm learning more, & more here each day. Very Happy

_________________
Hitler... When all else fails, you'll be in the right state of mind. Jesus Saves.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25811
Location: The netherlands

PostPosted: Sat Oct 05, 2013 7:19 am    Post subject: Reply with quote

createNativeThread(function) executes the given function in a different thread

Note though that i don't think that the customsound code is thread safe, so you can only use one thread to play sounds

_________________
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
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Oct 05, 2013 7:21 am    Post subject: Reply with quote

Just post your CT file so we could check it.

About sound,

Code:
  push 5
  push 0
  push [eax*8+00400600]
  call winmm.PlaySoundA

Means:
0x5 = 0x4 (SND_MEMORY) + 0x1 (SND_ASYNC, play asynchronously, so if another thread will call PlaySoundA, this one will immediately turn off, there's no problem with threads)
0x0 - hmod, (must be NULL unless SND_RESOURCE)
[eax*8+00400600] - points to a sound loaded in memory



If you want sound "onTrainerClose", you have to use timer. sleep(200) and sleep(1000) you used, cause windows.sleep (http://msdn.microsoft.com/en-us/library/windows/desktop/ms686298%28v=vs.85%29.aspx)


Lua - this is scripting language, not programming language.



NewPossibilities_Trainer.cetrainer
 Description:
demo trainer

Download
 Filename:  NewPossibilities_Trainer.cetrainer
 Filesize:  407.67 KB
 Downloaded:  809 Time(s)


NewPossibilities_Trainer.ct
 Description:
Source

Download
 Filename:  NewPossibilities_Trainer.ct
 Filesize:  505.59 KB
 Downloaded:  1873 Time(s)


_________________
Back to top
View user's profile Send private message MSN Messenger
DTeCH
Newbie cheater
Reputation: 0

Joined: 19 Jul 2013
Posts: 23
Location: Cayman Islands

PostPosted: Sat Oct 05, 2013 8:55 am    Post subject: Reply with quote

I'm experimenting with createNativeThread(function) with, & without customSound. Very Happy


Yea, the customSound seemed to stop playing the previous .wav the moment another call to it is made, but I'm now experimenting with createNativeThread(function). Will let you guys know the result. Razz


Thanks again for the quick responses.

_________________
Hitler... When all else fails, you'll be in the right state of mind. Jesus Saves.
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Oct 05, 2013 9:36 am    Post subject: Reply with quote

OK, as you want.



"Access Violation, & attempt to call global 'close' (a nil value) "
read this one:
http://forum.cheatengine.org/viewtopic.php?t=566876
(use lua file from recent post - link)




 

_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites