View previous topic :: View next topic |
Author |
Message |
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Jan 14, 2020 6:26 am Post subject: Calling and use windows apps library function via CE Lua |
|
|
Hi, are there easy ways (including tutorial if any) to call windows apps library function and use in CE Lua script.
Say, I knew what is a windows apps library (dll) functions including the parameters (easy to be found on MSDN), then how the easy way to call it via CE Lua script?.
Say for example: call 'mciSendCommandA' a function own by winmm.dll
Any helps, tutorial or suggestions from CE Lua experts?.
Description: |
|
Filesize: |
91.87 KB |
Viewed: |
4479 Time(s) |
|
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Tue Jan 14, 2020 6:47 am Post subject: |
|
|
ce already has winmm loaded by default, so you can just do
Code: |
memorystore=createMemoryStream()
--use memorystore.writeByte/Word/Dword to fill in the memorystore
executeCodeLocalEx('mciSendCommandA', IDDevice, msg, flags, memorystore.Memory)
|
_________________
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 |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Tue Jan 14, 2020 8:50 am Post subject: |
|
|
Thanks, DB for the answer and sample.
Anyway, is CE loaded all windows libraries functions or only some libs. by default, I mean in CE 7.0 ?. Thanks
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1247
|
Posted: Tue Jan 14, 2020 9:14 am Post subject: |
|
|
CE 7.0; It all started with "executeCodeLocalEx()".
Now I miss some old functions.
Please DB; 32-bit Trainer.exe must have code that supports 32-64 bit scanners!
is "targetIs64Bit ()" in the .exe installation: does not work in a 32-bit browser.
Or, while "targetIs32Bit" is: 64 bit does not work in the browser.
2 separate Trainer produce and determine the area of use, + process is happening.
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 19, 2020 5:20 am Post subject: |
|
|
Follows DB information, I try using executeCodeLocalEx() for learn purpose.
Code: | function MessageBox()
memorystore=createMemoryStream()
executeCodeLocalEx("user32.MessageBoxA", HWND, LPCSTR, LPCSTR, UINT, memorystore.Memory)
end
MessageBox(0, "Hello From Lua", "User32 Message Box", 0) |
Not work. How use executeCodeLocalEx() properly?. Any example / tutorial?
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 19, 2020 5:55 am Post subject: |
|
|
executeCodeLocalEx() for now only 64bit CE
Code: |
function MessageBox(title,text,uType)
return executeCodeLocalEx("user32.MessageBoxA", MainForm.Handle, text, title, uType)
end
local a = MessageBox("The title", "the text", 1) -- MB_OKCANCEL
print(a) -- 1 - OK, 2 - cancel
local a = MessageBox("The title", "the text", 2) -- MB_ABORTRETRYIGNORE
print(a) -- 3 - ABORT 4 - RETRY 5 - IGNORE
local a = MessageBox("The title", "the text", 4) -- MB_YESNO
print(a) -- 6 - YES 7 - NO |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 19, 2020 8:16 am Post subject: |
|
|
mgr.inz.Player wrote: | executeCodeLocalEx() for now only 64bit CE |
Thank you for the example, that is I need to understand the concept while using executeCodeLocalEx().
Anyhow when executing your example code above, CE suddenly stops working. What's wrong?.
My system: Win 7 Ultimate (64bit) and CE 7.0 (running cheatengine-x86_64,exe).
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 19, 2020 8:27 am Post subject: |
|
|
Hmm. Something's wrong.
After you said you have CE freeze issues I tried executing my examples many many times in row. And CE closed itself without any errors.
I will check it with GDB.
_________________
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1247
|
Posted: Sun Jan 19, 2020 8:28 am Post subject: |
|
|
Corroder wrote: | mgr.inz.Player wrote: | executeCodeLocalEx() for now only 64bit CE |
Thank you for the example, that is I need to understand the concept while using executeCodeLocalEx().
Anyhow when executing your example code above, CE suddenly stops working. What's wrong?.
My system: Win 7 Ultimate (64bit) and CE 7.0 (running cheatengine-x86_64,exe). |
It works for me.
my system: Win 10 (64bit) and CE 7.0 (running cheatengine-x86_64,exe)
result:
1
4
6
Description: |
|
Filesize: |
24.17 KB |
Viewed: |
4366 Time(s) |
|
_________________
|
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 19, 2020 8:47 am Post subject: |
|
|
Play with it a little more. Execute MessageBox function.
With messagebox still visible try to click other CE windows ('Lua Engine', 'MemoryViewer').
I get this under GDB
Code: | gdb: unknown target exception 0xc0000028 at 0x7fffbfe9eb78
Program received signal ?, Unknown signal.
0x00007fffbfe9eb78 in ?? ()
(gdb) bt
#0 0x00007fffbfe9eb78 in ?? ()
#1 0x12020e2100000000 in ?? ()
#2 0x0000000000450e21 in SYSUTILS$_$TUNICODEENCODING_$__$$_GETPREAMBLE$$TBYTES ()
#3 0x0000000000f328c0 in VMT_$STDCTRLS_$$_TCUSTOMBUTTON ()
#4 0x0000000000f31f88 in VMT_$STDCTRLS_$$_TBUTTONACTIONLINK$indirect ()
#5 0x00000000000602ff in ?? ()
#6 0x0000000000000000 in ?? ()
(gdb) |
Probably above backtrace also is wrong because of stack corruption...
EDIT:
Stacktrace shown from another CE instance attached to crashed CE:
_________________
Last edited by mgr.inz.Player on Sun Jan 19, 2020 9:30 am; edited 1 time in total |
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 19, 2020 9:18 am Post subject: |
|
|
Probably above backtrace also is wrong because of stack corruption or libraries conflict when loading, incase in windows 64 system there are two user32.dll (in System32 and SysWOW64).
Code: | --local path = "C:\\Windows\\SysWOW64\\user32.dll"
local path = "C:\\Windows\\System32\\user32.dll"
local f = assert(package.loadlib(path, "luaopen_user32"))
f()
memorystore=createMemoryStream()
function MessageBox(title,text,uType)
return executeCodeLocalEx("user32.MessageBoxA", MainForm.Handle, text, title, uType)
end
local a = MessageBox("The title", "the text", 1, memorystore.Memory) -- MB_OKCANCEL
print(a) -- 1 - OK, 2 - cancel
local a = MessageBox("The title", "the text", 2, memorystore.Memory) -- MB_ABORTRETRYIGNORE
print(a) -- 3 - ABORT 4 - RETRY 5 - IGNORE
local a = MessageBox("The title", "the text", 4, memorystore.Memory) -- MB_YESNO
print(a) -- 6 - YES 7 - NO |
The code above makes CE hang/crash. Anyhow, the important point for this topic is how to implementing executeCodeLocalEx() by the example given.
EDIT: which GDB version you use?. 8.3 ?
@Aylin: The code works on your machine. Is it show a 'message box' GUI?
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
mgr.inz.Player I post too much Reputation: 218
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Jan 19, 2020 9:32 am Post subject: |
|
|
Quote: | which GDB version you use?. 8.3 ? |
GDB shipped with Lazarus.
Those message windows do not crash CE:
Code: | -- messageDialog(text,messagetype,buttons,...)
-- messagetype:
-- 0 - mtWarning;
-- 1 - mtError;
-- 2 - mtInformation;
-- 3 - mtConfirmation;
messageDialog('Test1',0,mbYes,mbNo)
showMessage('Test2') |
_________________
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Sun Jan 19, 2020 10:48 am Post subject: |
|
|
mgr.inz.Player wrote: |
EDIT:
Stacktrace shown from another CE instance attached to crashed CE: |
So, how to fix the problem?. Any chance?
EDIT:
I found this using VS Debugger
Unhandled exception at 0x00000000778D96F8 (ntdll.dll) in cheatengine-x86_64.exe: 0xC0000028: An invalid or unaligned stack was encountered during an unwind operation.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25287 Location: The netherlands
|
Posted: Sun Jan 19, 2020 11:31 am Post subject: |
|
|
Messagebox will start it's own messageloop dispatcher (dispatchmessage) while it's still inside lua's stack
so, it will invoke lua's cleanup routines while some of it's internal locks are still held, and while the current thread is the owner thread, this will be allowed.
look into re-entrant code and functions, I don't think lua is one of these
also, if an exception happens and it would backtrace, it would end up crashing as it's not in an actual stack
(could of course be that the stack is not properly setup, but do some tests with easier functions that don't end up calling all of CE)
_________________
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 |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1247
|
Posted: Sun Jan 19, 2020 12:12 pm Post subject: |
|
|
@Aylin: The code works on your machine. Is it show a 'message box' GUI?[/quote]
I am sorry for my late answer.
Yes, Windows warning message is coming.
It looks like you have enabled VB.Script.
Description: |
|
Filesize: |
32.99 KB |
Viewed: |
4305 Time(s) |
|
Description: |
|
Filesize: |
32.46 KB |
Viewed: |
4305 Time(s) |
|
Description: |
|
Filesize: |
31.13 KB |
Viewed: |
4305 Time(s) |
|
_________________
|
|
Back to top |
|
|
|