 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Fri Mar 27, 2009 3:04 pm Post subject: Integrate the Script to the CE-Runtime |
|
|
@Micha,
thank for ur great projekt. I am often working with Wince_HMI devices and its a great tool to avoid eloborate batch scripts.
Feature Request:
Unfortunately, if you want to protect an AHK script file, there is no oppurtinity to do this. There are no working AHK-Obfucators.
In addition, I guess, there's a no working exe-compiler for AHK Scripts on CE, so my idea was, if it would be possible, to modify your source code so much, to integrate the AHK-Script straightly to hte AutohotkeyCE.exe?!
I am not familiar with C++, it would be a great modification, if you could do the modifications to the source, so that you just include the ahk-code somewhere in the C++-Projekt to finally compile it. |
|
| Back to top |
|
 |
Guest
|
Posted: Sun Mar 29, 2009 2:53 am Post subject: Good idea |
|
|
That is a really good idea
Just being able to add a script in a c++ project then compiling it to be embedded as a resource or string value in AutoHotKeyCE.exe would be GREAT, at that point a dev could set up a server type situation where the script is posted to the server the build is made and an executable would be returned.
I support that one ^^ |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Tue Mar 31, 2009 5:51 pm Post subject: |
|
|
This could work - maybe but it's certainly not very practical. You can't "shoehorn" a script into a compiled executable. Every new script would have to be recompiled with the runtime built in. There may be some things Micha could do to make this a little easier, but in the end, you'd need to download a compiler and build/compile it yourself every time.
All that said, Micha has posted the source code, and you can download a good open source compiler (like Nant) on Sourceforge. If you want to learn about the process of building, creating a makefile, compiling, etc., download Linux From Scratch. It'll run from a Live CD and teach you all about the build/compile process. |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Wed Apr 01, 2009 12:09 am Post subject: Bug in ComboBox |
|
|
Only the first letter of the selected item is returned. Try it:
| Code: | Gui, 5:Add, Text,,Input panel for adding items?
Gui, 5:Add, ComboBox, vAltSIP, Transcriber||Keyboard|Block Recognizer|Letter Recognizer|NullKB
Gui, 5:Add, Text,,Default input panel to restore`n(after adding items)?
Gui, 5:Add, ComboBox, vRestoreSIP, Keyboard||Transcriber|Block Recognizer|Letter Recognizer|NullKB
gui, 5:add, button, gSetSip w40 h25 x100 y140, OK
Gui, 5:Show, center w220, Git-er-Done Settings
return
SetSip:
Gui, 5:Submit
MsgBox, AltSip = '%AltSip%'
MsgBox, RestoreSip = '%RestoreSip%'
Gui, 5:Destroy
exitapp
|
|
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Wed Apr 01, 2009 1:29 am Post subject: |
|
|
Tried a workaround.
| Code: | Gui, 5:Add, Text,,Input panel for adding items?
Gui, 5:Add, ComboBox, vCB1 gComboSel, Transcriber|Keyboard|Block Recognizer|Letter Recognizer|NullKB
Gui, 5:Add, Text,,Default input panel to restore`n(after adding items)?
Gui, 5:Add, ComboBox, vCB2 gComboSel, Keyboard|Transcriber|Block Recognizer|Letter Recognizer|NullKB
gui, 5:add, button, gAltSipDone w40 h25 x100 y140, OK
Gui, 5:Show, center w220, Git-er-Done Settings
return
ComboSel:
Gui, 5:Submit, NoHide
LB_item := %A_GuiControl%
MsgBox, You chose "%LB_item%" in "%A_GuiControl%"
return
AltSipDone:
Gui, 5:Destroy
exitapp
|
Same results.  |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Apr 01, 2009 9:56 am Post subject: |
|
|
| Donny Bahama wrote: | | This could work - maybe but it's certainly not very practical. You can't "shoehorn" a script into a compiled executable. Every new script would have to be recompiled with the runtime built in. There may be some things Micha could do to make this a little easier, but in the end, you'd need to download a compiler and build/compile it yourself every time. |
Imho this wouldnt be so tough, if the source projekt is already so much modified, that you can just include your target skript into it as a resource, to finally compile it?!
Either im pro Open souce, but in this case, i have to protect the script.
I dont have to be a good protection, neither it dont have to be hacker-proof, but for usual people, it shouldnt be readable.
So, could this done by anyone? Other ideas? |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Wed Apr 01, 2009 10:42 am Post subject: |
|
|
| Anonymous wrote: | | you can just include your target skript into it as a resource, to finally compile it?! | Agreed, it could probably be done that way. But again, you'd have to rebuild and recompile for every single script, and for the average user, that's not a trivial process. |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Apr 01, 2009 1:13 pm Post subject: |
|
|
it might be the better alternative:
An encryption/decryption routine; The AHK Script is encrypted, which autohotkeyce.exe has to decrypt internally. The Key/pw could be set in the source to compile an unique autohotkeyce.
logo78
(i am the poster of the messages above)
I should really go for a registration soon  |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Wed Apr 01, 2009 6:26 pm Post subject: |
|
|
| Anonymous wrote: | it might be the better alternative:
An encryption/decryption routine; The AHK Script is encrypted, which autohotkeyce.exe has to decrypt internally. The Key/pw could be set in the source to compile an unique autohotkeyce. | Now THAT I LIKE! Very smart. Very simple. Should be fairly easy for Micha to do.
It's easily hacked, though - once someone cracks the key, they can post it, and every single script encrypted this way could be decrypted. Unless AHKCE prompted you for the key, then there wouldn't be a single key to post on the 'net. (Though the keys for specific scripts/EXEs could be posted.)
This is like the lock on your front door; it keeps the honest people out, but if someone really wants in, they'll get in. Still, it's secure enough that I wouldn't hesitate to post commercial software - with a good, strong key.
Let's hope Micha will consider this. Probably WAY easier to do than getting the compiler working on CE.
Great idea, logo78! |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 500 Location: Germany
|
Posted: Sun Apr 05, 2009 6:30 pm Post subject: Re: Integrate the Script to the CE-Runtime |
|
|
| Anonymous wrote: | @Micha,
Feature Request:
Unfortunately, if you want to protect an AHK script file, there is no oppurtinity to do this. There are no working AHK-Obfucators.
In addition, I guess, there's a no working exe-compiler for AHK Scripts on CE, so my idea was, if it would be possible, to modify your source code so much, to integrate the AHK-Script straightly to hte AutohotkeyCE.exe?!
|
Hi,
I have a good and a bad news.
The good one is, the first "compiler" is working. I'll explain a little bit in another post.
The bad news is that there will be absolute no security. The script is just appended in plain text. Please have a look at my following post. I'll explain why...
If you "compile" a text file to the exe, the text will remain. It is not cryped in any way, so you will have no gain of security.
Ciao
Micha |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 500 Location: Germany
|
Posted: Sun Apr 05, 2009 6:38 pm Post subject: Re: Good idea |
|
|
| Anonymous wrote: | That is a really good idea
Just being able to add a script in a c++ project then compiling it to be embedded as a resource or string value in AutoHotKeyCE.exe would be GREAT, at that point a dev could set up a server type situation where the script is posted to the server the build is made and an executable would be returned.
I support that one ^^ |
Hi,
possible but I think that must be done by another user.
I'll write a post which explains a little bit the process of the compiler.
Your suggestion and the one of "Guest" is possible and you do not need a server.
On a windows (not CE) system the script you want to compile is "crypted" by a dll and "just" appended to the exe. The exe is reading the appended scrambled script and descramble it. Then the plain text is been processed and executed.
Someone can write a scrambler but the code to descramble is saved in the exe and it's very easy for a hacker-beginner to write an descrambler. Or you just debug the exe and break just before the script is being executed. You'll have the plain text in the memory.
I do not see a secure solution.
But more on my next post...
Ciao
Micha
Last edited by Micha on Mon Apr 06, 2009 4:14 pm; edited 1 time in total |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 500 Location: Germany
|
Posted: Sun Apr 05, 2009 6:50 pm Post subject: |
|
|
| Donny Bahama wrote: | Tried a workaround.
Same results.  |
Hi Donny Bahama,
same result, same reason
On WinCE everything is unicode. AHK is a none-unicode application so everything must be converted at thousand locations before the value is being processed by ahk. You have found another location. I'll fix it
Ciao
Micha |
|
| Back to top |
|
 |
Donny Bahama
Joined: 30 Dec 2006 Posts: 132 Location: Margaritaville (a state of mind somewhere between Inebriation and San Diego), CA
|
Posted: Sun Apr 05, 2009 7:00 pm Post subject: |
|
|
Thanks, Micha! And again, thanks for all your hard work on this!!!  |
|
| Back to top |
|
 |
Micha
Joined: 15 Nov 2005 Posts: 500 Location: Germany
|
Posted: Sun Apr 05, 2009 8:38 pm Post subject: |
|
|
Hi,
I'm trying to explain a little bit how the compiler and the compiled AHK-EXE is working (as far as I know ).
In the ahk code there are section which are executed when a normal script is run and other sections when the compiled exe is run (#ifdef's). So the most of the code of a compiled exe and the autohotkey.exe are the same.
One difference i.e. is: If the ahk script is started, the autohotkey.exe is loading the script line by line, parses the commands and starts the autorun section.
If the compiled exe is started the script is loaded from the end of the exe, being decrypted, parsed and run.
The compiler:
The autohotkey source project contains a debug/release project and one for the self executing exe. This part is building the AutoHotkeySC.bin file.
The compiler is copying that bin-file to the destination i.e copy AutoHotkeySC.bin -> myselfexecutingscript.exe.
The next steps are done by an closed source dll. The dll is used to read the script, scramble the content and adding the crypted script to the output exe.
I'm sure it is possible to debug the dll and rewrite it but I'm not sure if this is allowed so I will not try that approach.
Now you have an exe with the crypted script appended.
Starting the EXE:
After starting the EXE, Autohotkey is using functions of the statically linked dll. The function is allocating memory, loading the script of the end of the exe and decrypt it. Autohotkey will receive a pointer to the memory area where the decrypted script is saved to.
Now autohotkey is reading the script line by line parses it and executes the autoexec section.
The biggest problem is the closed source dll. It is compiled for a windows (95/NT) system and will not run with WinCE. So there are two possibilies:
1. Write your own dll with the same funtions and parameters
2. Completly remove the use of the dll and try to handle it by yourself.
To see soon results I've decided to try it without the dll (I'm not sure now if that was the correct approach)
I've spent more than two months to make the compiler work on WinCE.
The work is still not fully done, it's just an approach if it's possible to make the compiler work.
Another problem: The compiler is opening a lot of files. It's more complicated as I've outlined. The script is copied to the temp-folder, preparsed. Included files are being included, saved to another temp file and then appended to the bin/exe file.
On WinCE the compiler crashes after opening the temp file. I do not know why.
I have permanenty problems with WinCE. The executable crashes a lot of times. Most crashes are stack overflows. Autohotkey is allocating "a lot" of memory
#define LINE_SIZE (16384 + 1) // +1 for terminator. Don't increase LINE_SIZE above 65535 without considering ArgStruct::length's type (WORD).
char xxx[LINE_SIZE].
On a PC there's no problem but allocating that on the stack on CE crashes the executable.
So I had to rewrite a lot of lines to allocate that memory with "new" and "delete" it if the memory is not used anymore. Some big functions have a lot of returns. The function is left at dozent places. At every location I have to delete the memory. All I want to say: It lasts some time to make it work somehow.
After 4 weeks without an result I stopped trying to make the compiler work on CE. I've tried to generate the exe on a PC and transfer the exe to the CE device. That was working after some more weeks.
I've created a simple script. You have to change the path to the bin file and the path to the script and the destination path of the exe.
Than you can run the script and it appends the script to the renamed bin file.
Transfer it to the CE device and you will have an AHK-EXE with your script.
Be aware: The script is appended readable !!! No scrambling / crypting at the moment.
With that approach (running an ahk script to generate an exe) it should be possible to "compile" a script without a PC just on your CE device.
Another trap was the coding. On Windows most editors are generating text files. On CE the script must be saved in unicode format!!
If you want to generate an AHK EXE for your CE device with my script you MUST save your script in unicode format !!!
My script is just a very small one that does the job without any convenience.
I hope a member of the community will have the time and motivation to write a small convenient GUI
-------------------------------------------------------------------------
I have to apologize for many things:
I've created a lot of dlls for Autohotkey most without convenient scripts/wrappers so newbies can't use them easily. I've spent toooo much time on the dlls (some time I have should used with my family).
I've tried to prove that some things are working and doing the rough stuff. I never focused on the easy use of that stuff (no time / no motivation...)
I have so many interests and as most other people too less time. So my time has to be shared between ahk and about 7 other projects. My rare work on ahk does not mean I've lost interest it just means there's no time left. Sorry for that.
Why have I started to compile Autohotkey for CE devices?
As I wrote in my post, I'm owning a navigation system with CE. I'm trying a lot of things, searching software that runs on that crippled OS and so I'm killing the navigation system permanently. To reinstall all my changes (other navigation gui / software / settings / address book...) lasts about 40 minutes. I've killed it so often, I wished I can automate the installing procedure. But wait... I'm nowing a perfect piece of software. You all know what software I mean. But it doesn't run on CE..... So the idea was born to port it.
The only commands I have needed were Filecopy, Send, Winwaitactive and run. I did not need any gui or other things I have implemented. I've just done the things for you.
I'm not sure if I will continue work on AHKCE. My next idea between hundred others is to make a dll for ahk to control WPF applications. I think WPF is the next big thing. Future (and also a lot of current) software will use it more and more often and we need ahk to work with it.
-------------------------------------------------------------------------
What can be done to crypt scripts with the compiler:
We need i.e a dll or source code which can scramble textfiles. We also need the code to read the scrambled text and decrypt it. I know there are a lot of ready solutions but I haven't searched/googled for them. If we have found a suitable piece of code I can implement that to the autohotkey source.
How can you create an EXE with your favorite script for CE devices?
Download the following ZIP-File and extract it.
You'll find a bin-file and a script.
Open the script and adjust the path to the bin-file, to the script you want to compile and the destination exe.
Now assure that YOUR script is saved in unicode format. Now run my script.
The exe is being generated. Copy the EXE to your device and run it. Voila.
Why is the EXE so huge?
The Windows 95/NT exe is packed with UPX. That is a packer for exes. The exe is still runable without the need to manually extract it. That's one difference to packers like 7z or winrar. I'm sure you can download the WinCE UPX executable and compress your ahk-exe with that, but I haven't tried it.
http://www.autohotkey.net/~Micha/AutohotkeyCE/AHKCompiler.zip
I'll upload the source soon.
Ciao
Micha
Last edited by Micha on Mon Apr 06, 2009 4:31 pm; edited 1 time in total |
|
| Back to top |
|
 |
fincs
Joined: 05 May 2007 Posts: 447 Location: Seville, Spain
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|