C++: setting an AHK script as a variable in cpp source

Talk about things C/C++, some related to AutoHotkey
0x00
Posts: 87
Joined: 22 Jan 2019, 13:12

C++: setting an AHK script as a variable in cpp source

24 Mar 2019, 21:02

[SOLVED] It seems ahk_h had implemented all the functionality i sought. Cheers to HotKeyIt.


Let me clarify my intent isn't encryption,obfuscation or anything in that regard, i'm simply trying to embed A default script in the interpreter. By default script i mean how if <ahk>.exe is run, <ahk>.ahk is loaded from working directory or my documents. I've seen one or two posts inquiring about this,but there was no definitive response, and i figure i'd try to make a better case as to why this is a valid & even great idea.

I'm not asking for lexikos to make this a feature or anything, i'm more asking for directions as to how i might approach this, it's easy enough to set a script as a variable in the source, but i can't quiet figure out how to get the interpreter to load the variable afterwards, i've so far tried & failed at reloading the script with the variable piped in(couldn't pipe it properly) & tried using the script-variable where a script is expected to be piped in(broke the source with every approach).

I'm certain both approaches only failed due to my current limitations with cpp,i'm solid with c though,for reference.

I know this will stir up some suspicion as to my motives & such, so here's a fine revision of my motives & how i see this being useful,in the broader scheme of things.

Why?
  • +A default script embeded where other scripts can be run as well, i know ahk_h offers something of the kind, it'd be nice in ahk_l is all.
  • +Allows Integrating Compatibility Patches & StdLib's written in Ahk as though they were a part of the interpreter.
    • ++Allows extending Ahk with code written in Ahk, where performance isn't an issue.
      • I think a lot of primitive features such as function wrappers for legacy commands aren't integrated into ahk v1 because it isn't worth the time,and is available for use in stdlib, i think this is a fine illustration of a patch easily doable with an embedded append to executed scripts,i think not every feature ought to be implemented in cpp, it's simply a time sink & a burden.
      ++It's just cool...
      ++Allows simpler prototyping of (experimental)features,do it as a patch & depending on feedback & time, rewrite in cpp.
  • +Script can still be retrieved by string dump of the process, so it doesn't defy the current ethos of ahk_l,it doesn't offer false or any protection for that matter...
  • +Makes Ahk more powerful & extensible...
  • +Provides yet another way to compile your scripts...
Why Not?
  • -Guaranteed Malicious Misuse
    • ++Although, the official Ahk binary won't be flagged as the culprit-by all but the AV engines.
      ++The Import table will still identify it as malicious, as Ahk's rather 'dangerous' import table will be flagged when contained by any executable that isn't a widely distributed binary with a known hash.
      ++Any half good AV will flag a compressed exe if indeed compresssed & unpack it even, therefore there's really no simple way to conceal the capabilities of the binary.
Thanks for reading & Appreciate any pointers as to how i can execute a script stored as a variable in the Ahk Source.
Last edited by 0x00 on 27 Mar 2019, 00:49, edited 1 time in total.
HotKeyIt
Posts: 2134
Joined: 29 Sep 2013, 18:35
Contact:

Re: C++: setting an AHK script as a variable in cpp source

25 Mar 2019, 14:15

All this is implemented in ahk_h, so why not simply use it.
Including a default script in cpp is not a good idea since it won't be able to receive parameters, instead in ahk_h you can execute a different script then compiled one by using /E or /Execute (therefore you have to use the exe instead bin for compilation!).
0x00
Posts: 87
Joined: 22 Jan 2019, 13:12

Re: C++: setting an AHK script as a variable in cpp source

26 Mar 2019, 02:00

HotKeyIt wrote:
25 Mar 2019, 14:15
Yeah,i know executing other scripts from a compiled script is doable with your fork, that was more an initial motivation, i was trying to do this more for the other reasons.
Specifically the ability to mod AutoHotKey.exe, i always recompile every update with a few scripted modifications, but nothing major because i couldn't justify the time it would require.
And to be more accurate, i set out to embed a default script, and ended up now trying to at the very least append a default script to every executed script.


But if it's at all possible to call functions in a compiled script from a script executed by a compiled script in ahk_h then I'd consider my request solved. I don't imagine it is though, i just tested it...
So is there a way to do this at least?

Appreciate you taking the time, thanks.
HotKeyIt
Posts: 2134
Joined: 29 Sep 2013, 18:35
Contact:

Re: C++: setting an AHK script as a variable in cpp source

26 Mar 2019, 16:35

Yes it is.
The simplest is to add it to LIB resources, this works like a normal library, take a look in resources of the exe with ResourceHacker.
0x00
Posts: 87
Joined: 22 Jan 2019, 13:12

Re: C++: setting an AHK script as a variable in cpp source

27 Mar 2019, 00:46

wow, i dunno how i missed that, thanks. problem solved.
amyhimesama1598

Re: C++: setting an AHK script as a variable in cpp source

11 Nov 2019, 14:25

0x00 wrote:
24 Mar 2019, 21:02
[SOLVED] It seems ahk_h had implemented all the functionality i sought. Cheers to HotKeyIt.


Let me clarify my intent isn't encryption,obfuscation or anything in that regard, i'm simply trying to embed A default script in the interpreter. By default script i mean how if <ahk>.exe is run, <ahk>.ahk is loaded from working directory or my documents. I've seen one or two posts inquiring about this,but there was no definitive response, and i figure i'd try to make a better case as to why this is a valid & even great idea.

I'm not asking for lexikos to make this a feature or anything, i'm more asking for directions as to how i might approach this, it's easy enough to set a script as a variable in the source, but i can't quiet figure out how to get the interpreter to load the variable afterwards, i've so far tried & failed at reloading the script with the variable piped in(couldn't pipe it properly) & tried using the script-variable where a script is expected to be piped in(broke the source with every approach).

I'm certain both approaches only failed due to my current limitations with cpp,i'm solid with c though,for reference.

I know this will stir up some suspicion as to my motives & such, so here's a fine revision of my motives & how i see this being useful,in the broader scheme of things.

Why?
  • +A default script embeded where other scripts can be run as well, i know ahk_h offers something of the kind, it'd be nice in ahk_l is all.
  • +Allows Integrating Compatibility Patches & StdLib's written in Ahk as though they were a part of the interpreter.
    • ++Allows extending Ahk with code written in Ahk, where performance isn't an issue.
      • I think a lot of primitive features such as function wrappers for legacy commands aren't integrated into ahk v1 because it isn't worth the time,and is available for use in stdlib, i think this is a fine illustration of a patch easily doable with an embedded append to executed scripts,i think not every feature ought to be implemented in cpp, it's simply a time sink & a burden.
      ++It's just cool...
      ++Allows simpler prototyping of (experimental)features,do it as a patch & depending on feedback & time, rewrite in cpp.
  • +Script can still be retrieved by string dump of the process, so it doesn't defy the current ethos of ahk_l,it doesn't offer false or any protection for that matter...
  • +Makes Ahk more powerful & extensible...
  • +Provides yet another way to compile your scripts...
Why Not?
  • -Guaranteed Malicious Misuse
    • ++Although, the official Ahk binary won't be flagged as the culprit-by all but the AV engines.
      ++The Import table will still identify it as malicious, as Ahk's rather 'dangerous' import table will be flagged when contained by any executable that isn't a widely distributed binary with a known hash.
      ++Any half good AV will flag a compressed exe if indeed compresssed & unpack it even, therefore there's really no simple way to conceal the capabilities of the binary.
Thanks for reading & Appreciate any pointers as to how i can execute a script stored as a variable in the Ahk Source.
Including a default script in cpp is not a good idea since it won't be able to receive parameters, instead in ahk_h you can execute a different script then compiled one by using /E or /Execute (therefore you have to use the exe instead bin for compilation!).
0x00
Posts: 87
Joined: 22 Jan 2019, 13:12

Re: C++: setting an AHK script as a variable in cpp source

21 Nov 2019, 01:46

@amyhimesama1598
, I'm going to have to disagree with you on that, if nothing else you can embed the stdlib as in how ahk_h does right now & at the very least whole premise of a default script as currently defined also doesn't allow passing params, so it's simply an alternate implementation of an existing feature & for me at least, given I recompile every update to my preferences it's a very useful extension, though I'm contempt with using ahk_h given lexikos' focus on ahk v2.
humms
Posts: 2
Joined: 23 Nov 2019, 05:24
Contact:

Re: C++: setting an AHK script as a variable in cpp source

23 Nov 2019, 05:44

Yes it is.
The simplest is to add it to LIB resources, this works like a normal library, take a look in resources of the exe with ResourceHacker.

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 6 guests