[Guide] Compiling Ahk_h's source step by step Topic is solved

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

[Guide] Compiling Ahk_h's source step by step  Topic is solved

Post by kyuuuri » 24 Feb 2019, 11:20

Hello, as title says this is a tutorial/guide on how to compile ahk_h's source code with Visual Studio.
English is not my main language so any corrections will be appreciated. I'm not an expert, so all these steps will be exactly what I did to compile ahk_h. (some steps might not be needed).

Requirements
Ahk_h's source: https://github.com/HotKeyIt/ahkdll
Visual Studio 2017 Community Edition: https://visualstudio.microsoft.com/es/thank-you-downloading-visual-studio/?sku=Community&rel=15



1. Installing Visual Studio 2017 Community Edition
The first time you open VS17 you will see a menu that has a lot of checkboxes.
Make sure to check all those boxes on the image

1. Compiling ahk_h's source code

1.1. Opening source code in Visual Studio
Double click AutoHotkey.sln (file downloaded from github), wait until it finishes loading.


1.2. Setting Autohotkey as StartUp project
Right click Autohotkey and click on "Set as StartUp project"


1.3. Compiling the source
Click on Build -> Batch Build...
Check the following boxes
Once you have done that click on "Build" and wait until it finishes. (it might take like 5 minutes).


1.4. Cleaning up and packing
Execute ahkdll-master\CleanUpAndPack.exe (file downloaded from github inside ahk_h's source)
Then go to ahkdll-master\bin and you will see 6 folders

If you don't understand what does each version mean you can check here: https://www.autohotkey.com/boards/viewtopic.php?f=65&t=73168



2. Changing default password

2.1. Getting all g_default_pwd's references
2.1.1. On the left side of the screen double click on "Autohotkey" then double click on "Source Files" and then double click on "utils.cpp"
2.1.2 Press ctrl+f, set the search to current document and search "g_default_pwd"
2.1.3 Right click on "g_default_pwd" and select "Find All References"


2.2. First reference (globaldata.cpp) Skip if you don't want to change password's length
2.2.1 Click the 1st reference


2.3. Second reference (globaldata.h) Skip if you don't want to change password's length
2.3.1 Click the 2nd reference


2.4. Third reference (script.cpp) Skip if you don't want to change password's length
2.4.1 Click the 3rd reference


2.5. Eighth reference (util.cpp)
2.4.1 Click the 8th reference


To-do
  • Add how to make a dynamic password.

Troubleshooting:
1. "Missing dlls" and "couldn't link..." errors
Check if you followed the steps correctly. If you did then it might be because you updated Visual Studio and "$(LibraryPath)" changed to Spectre dlls but you didn't download Spectre libs.
There are 2 ways to fix it: Download Spectre library using Visual Studio Installer or inside Visual Studio do right click on "Autohotkey"->"Properties"->"C/C++"->"Code Generation" and search for "Spectre Mitigation" on the panel in the right side and change its value to "Disabled".

IMPORTANT
As said at the start EVERYTHING here was made thanks to Joe Glines's webinars, please if this guide was helpful for you go to this video like and subscribe because this guide is made by watching that video, if you liked the guide you liked the video: https://www.youtube.com/watch?v=ao5FdsqWTVQ and also part 2: https://www.youtube.com/watch?v=tiL_bIebTx4 and of course thanks to HotKeyIt for all you do for ahk's community.

Updates:
  1. I forgot to thank HotKeyIt for making everything possible.
  2. Added a Troubleshoot section
  3. Updated step 2
  4. Deleted Troubleshoot section as it was not needed anymore, added how to change password.
  5. Fixed a typo in step 2.5
  6. Added Troubleshoot section again :D.
  7. Updated to new version of ahk_h
Old guide
Last edited by kyuuuri on 03 Mar 2020, 02:36, edited 8 times in total.

guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: [Guide] Compiling Ahk_h's source step by step

Post by guest3456 » 25 Feb 2019, 12:43

great guide. thanks a lot for this. i had used this older guide in the past:
https://www.autohotkey.com/boards/viewtopic.php?f=22&t=13373


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

Re: [Guide] Compiling Ahk_h's source step by step

Post by swagfag » 25 Feb 2019, 13:07

yes this will indeed come in handy, so, well done

kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: [Guide] Compiling Ahk_h's source step by step

Post by kyuuuri » 27 Feb 2019, 11:13

Updated: Deleted Troubleshoot section as it was not needed anymore, added how to change password.

guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: [Guide] Compiling Ahk_h's source step by step

Post by guest3456 » 28 Feb 2019, 22:14

kyuuuri wrote:
27 Feb 2019, 11:13
Updated: Deleted Troubleshoot section as it was not needed anymore, added how to change password.
thanks for the update very useful i will be trying this soon.

quick note you have "abc" in the example pw and then you quote "abd" in the spoiler


kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: [Guide] Compiling Ahk_h's source step by step

Post by kyuuuri » 01 Mar 2019, 09:41

guest3456 wrote:
28 Feb 2019, 22:14
kyuuuri wrote:
27 Feb 2019, 11:13
Updated: Deleted Troubleshoot section as it was not needed anymore, added how to change password.
thanks for the update very useful i will be trying this soon.

quick note you have "abc" in the example pw and then you quote "abd" in the spoiler
Thanks, will fix that

NoGame407
Posts: 1
Joined: 02 Mar 2019, 13:44

Re: [Guide] Compiling Ahk_h's source step by step

Post by NoGame407 » 06 Mar 2019, 17:59

For some reason my 2017 VC never ask to upgrade the solution when I open it. When I compile the scripts with my newly minted ahk2exe either nothing happens upon opening them or i get the can not extract AHK error.

freespacing
Posts: 150
Joined: 28 Sep 2016, 11:14
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by freespacing » 28 Apr 2019, 13:01

Huge thanks to @kyuuuri and everyone else who made this guide possible… starting with HotkeyIt.
It's wonderful to have these step-by-step details.

Visual Studio 2019 just came out, so I have to ask: has anyone had success following these steps in VS2019?
Just upgraded from VS2015 and would prefer not to install VS2017 as well if that can be avoided.

Regarding WinSDK, substituted this string (the path exists):
'C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\shared';
On my side, it failed with this:
Error C1047 The object or library file 'source\lib\libMinHook.x86.lib' was created with an older compiler than other objects; rebuild old objects and libraries

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by HotKeyIt » 28 Apr 2019, 15:47

You will need to recompile https://github.com/TsudaKageyu/minhook
You can also try using precompiled libraries. Replace the libMinHook files here: https://github.com/HotKeyIt/ahkdll/tree/master/source/lib

freespacing
Posts: 150
Joined: 28 Sep 2016, 11:14
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by freespacing » 29 Apr 2019, 08:13

Thank you @HotKeyIt
Since there's no sln file provided with MinHook and I want to minimize suffering, I think I'll wait until someone releases a pre-compiled versions (as you suggested) done in VS2019. It's probably only a matter of months. ;)

Hope you have a great week.

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by HotKeyIt » 29 Apr 2019, 17:22

The latest sln should be fine, just give it a try.

AkosiHeart01
Posts: 1
Joined: 18 Mar 2019, 22:10

Re: [Guide] Compiling Ahk_h's source step by step

Post by AkosiHeart01 » 06 May 2019, 02:42

Set password from source code (ahkdll-master) ; compile script
1) got 990kb only compare to 2MB from ahkdll-v1-release-master
2) CleanUpAndPack.ahk
\ahkdll-master\bin\Win32a\AutoHotkey.exe
The system cannot find the path specified. do i need to build all?

HotKeyIt
Posts: 2364
Joined: 29 Sep 2013, 18:35
Contact:

Re: [Guide] Compiling Ahk_h's source step by step

Post by HotKeyIt » 06 May 2019, 15:47

Yes, alternatively you can adapt CleanUpAndPack.ahk.

kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: [Guide] Compiling Ahk_h's source step by step

Post by kyuuuri » 06 May 2019, 22:08

AkosiHeart01 wrote:
06 May 2019, 02:42
Set password from source code (ahkdll-master) ; compile script
1) got 990kb only compare to 2MB from ahkdll-v1-release-master
2) CleanUpAndPack.ahk
\ahkdll-master\bin\Win32a\AutoHotkey.exe
The system cannot find the path specified. do i need to build all?
As HotKeyIt said, you need to build all if you don't want to adapt CleanUpAndPack.ahk

norths1
Posts: 21
Joined: 12 Mar 2017, 03:06

Re: [Guide] Compiling Ahk_h's source step by step

Post by norths1 » 08 May 2019, 15:05

don't forget to make your own encryption techniques and to add more anti-debugging ones, otherwise it won't protect your scripts from being easily decrypted

and it's not compiling, it's packing and encrypting

SOTE
Posts: 1426
Joined: 15 Jun 2015, 06:21

Re: [Guide] Compiling Ahk_h's source step by step

Post by SOTE » 11 May 2019, 04:17

norths1 wrote:
08 May 2019, 15:05
don't forget to make your own encryption techniques and to add more anti-debugging ones, otherwise it won't protect your scripts from being easily decrypted

and it's not compiling, it's packing and encrypting
Might be good if you could provide some examples of added anti-debugging measures. A lot of people would probably not know what you mean by this or what additional steps they could take.

User avatar
Tomer
Posts: 366
Joined: 21 Aug 2016, 05:11

Re: [Guide] Compiling Ahk_h's source step by step

Post by Tomer » 13 May 2019, 03:25

Will look into it.
Thanks!

User avatar
manehscripts
Posts: 126
Joined: 03 May 2019, 16:10

Re: [Guide] Compiling Ahk_h's source step by step

Post by manehscripts » 11 Jun 2019, 09:09

I did the whole process correctly, but it presents this error, can anyone help me?
It presents this error but compiles. Weird
Screenshot_4.png
Screenshot_4.png (60.39 KiB) Viewed 25483 times
-----------------------------------------------------------
Stop to think, shut up to resist, and act to win!

kyuuuri
Posts: 340
Joined: 09 Jan 2016, 19:20

Re: [Guide] Compiling Ahk_h's source step by step

Post by kyuuuri » 11 Jun 2019, 11:57

manehscripts wrote:
11 Jun 2019, 09:09
I did the whole process correctly, but it presents this error, can anyone help me?
It presents this error but compiles. Weird
Screenshot_4.png
Those are simple warnings, you can ignore them. Basically you have 7 warnings about deprecated / non-supported features, 4 truncation, and 2 that give you information about conflicts between libs.

User avatar
manehscripts
Posts: 126
Joined: 03 May 2019, 16:10

Re: [Guide] Compiling Ahk_h's source step by step

Post by manehscripts » 27 Jul 2019, 11:58

kyuuuri wrote:
11 Jun 2019, 11:57
manehscripts wrote:
11 Jun 2019, 09:09
I did the whole process correctly, but it presents this error, can anyone help me?
It presents this error but compiles. Weird
Screenshot_4.png
Those are simple warnings, you can ignore them. Basically you have 7 warnings about deprecated / non-supported features, 4 truncation, and 2 that give you information about conflicts between libs.
Thank you bro!
I'm trying to compile only the .exe that I need, in this case: \bin\x64w
But it has an error, it only works when I set ALL compilation options. This really makes it a very slow process, and I don't even use the other compiled files.

Would there be any way to compile just the .exe that I need without error?
-----------------------------------------------------------
Stop to think, shut up to resist, and act to win!

Post Reply

Return to “AutoHotkey_H”