MCode from 32bit to 64bit Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Archandrion
Posts: 31
Joined: 26 May 2018, 22:23

MCode from 32bit to 64bit

24 Jun 2018, 13:05

I have found out that Mcode in the Gdip_FilterColor() function below appears to have been compiled for the 32bit version of Autohotkey. Could anyone assist me in converting it to run on the 64bit version. The source code can be found at https://pastebin.com/vFgELSEi but I was unsuccessful in using the MCode generator at https://github.com/joedf/MCode4GCC to create viable code. It did spit out an MCode but just replacing that in the function did not work.


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus




And below is the MCode that MCode4GCC generated.

Code: [Select all] [Download] GeSHi © Codebox Plus

"2,x86:QVdBVkFVQVRVV1ZTSIPsOIuEJKgAAAAx7UmJz0SJhCSQAAAARIuEJKAAAABEiYwk"
. "mAAAAESNNJUAAAAAicGJRCQsi4QksAAAAInPQYnKRYnBwe8YRInGQYHhAAD/AIl8"
. "JCAPtv2LjCSQAAAAQYHiAAD/AEyJw8HuGEHB6hBBwekQiXwkKIXJD7bfRQ+2wESJ"
. "VCQkvwMAAAAPjuUAAACNDAMpw0WNJAGJXCQUQY0cAEEpwUEpwESNHAaJTCQQKcZE"
. "iUwkDIlcJBhEiUQkHEyJ+YXSRo0MN4n4D46OAAAAZpBBicCNWP1JAchFD7YQRTna"
. "d25BOfJyaUSNaP9JAc1FD7ZVAEU54ndYRDtUJAxyUUSNeP5JAc9FD7YXRDtUJBB3"
. "P0Q7VCQUcjhBidpJAcpBD7YaO1wkGHcoO1wkHHIiD7ZcJCBBiBgPtlwkJEGIXQAP"
. "tlwkKEGIHw+2XCQsQYgakIPABEQ5yA+FdP///4PFAQO8JJgAAAA5rCSQAAAAD4VN"
. "////McBIg8Q4W15fXUFcQV1BXkFfw5CQkJCQkJCQkJA="



The source code is:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Helgef
Posts: 3033
Joined: 17 Jul 2016, 01:02
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 13:16

Read the readme on joedf's github, you need to use the mcode function and make sure you use a 64 bit compiler, eg TDM-GCC.
User avatar
Flipeador
Posts: 866
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 13:31

2,x86:g+wYi0wkLIvBwegQUw+22IvBwegIVQ+26A+2wYlEJAhWi/GLTCQ8i8HB7hjB6BiJRCQUi8HB6BAPtsCJRCQYi8HB6AgPtsCJRCQcD7bBi0wkMIl0JBCJRCQghckPjr8AAACLRCQoi1QkQIPAAleLfCQwiUQkQIX/D46NAAAAjQwWiUwkPA+2cAE78Xdmi0wkFCvKO/FyWA+2MI0MEzvxd06LyyvKO/FyRg+2cP+NDCo78Xc7i80ryjvxcjOLTCQQD7Zw/gPKO/F3JYtMJBAryjvxchuLTCQYiEgBi0wkHIgIi0wkIIhI/4tMJCSISP6LTCQ8g8AEg+8BdYqLdCQUi0QkQIt8JDCLTCQ0A0QkOIPpAYlEJECJTCQ0D4VW////X15dM8Bbg8QYww==,x64:RIlMJCBEiUQkGFNVQVRBVUFWQVdIg+woRIuUJIAAAABFM+1Bi8JFD7b6wegQi+qLlCSIAAAARYvaRA+28EiL2UHB6xhBi8LB6AhED7bgi8LB6BiJRCQEi8LB6BAPtsCJRCQIi8LB6AgPtsCJRCQMD7bCiUQkEESJnCSAAAAARIksJEWFwA+OEgEAAIuEJJAAAACLTCRwSIl0JGBIiXwkIEUzwIXtD47YAAAAQYv1RY0UA0SLbCQERImUJIgAAABBD6/xDx9AAGYPH4QAAAAAAEaNDIZBjUkDD7YUGYv5QTvSD4eDAAAAQYvLK8g70XJ6QY1JAg+2FBlEi9lBjQwGO9F3X0GLzivIO9FyVkGNSQEPthQZRIvRQY0MBDvRdztBi8wryDvRcjJBD7YUGUGNDAc70XclQYvPK8g70XIci0wkCEGIDBuLTCQMQYgMGotMJBBBiAwZRIgsH0SLlCSIAAAARIucJIAAAABB/8BEO8UPjFr///9Eiywki0wkcESLTCR4Qf/FRIksJEQ76Q+MDf///0iLfCQgSIt0JGAzwEiDxChBX0FeQV1BXF1bww==

?
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2
Archandrion
Posts: 31
Joined: 26 May 2018, 22:23

Re: MCode from 32bit to 64bit

24 Jun 2018, 13:48

Helgef wrote:Read the readme on joedf's github, you need to use the mcode function and make sure you use a 64 bit compiler, eg TDM-GCC.



That's precisely what I did or at least I think I did. I put the path to the g++.exe from tdm64-gcc-5.1.0-2 in the GCC compiler field in MCode4GCC. I set the Optimizations option to Speed(-Ofast) and clicked the Generate MCode button. The relevant code in the Gdip_FilterColor() function appears to be:

Code: [Select all] [Download] GeSHi © Codebox Plus

	
VarSetCapacity(_FilterColor, StrLen(MCode_FilterColor)//2)
Loop % StrLen(MCode_FilterColor)//2 ;%
NumPut("0x" SubStr(MCode_FilterColor, (2*A_Index)-1, 2), _FilterColor, A_Index-1, "char")


And on joedf's github it says:

Code: [Select all] [Download] GeSHi © Codebox Plus

Laszlo's version :
How to use it : http://www.autohotkey.com/board/topic/19483-machine-code-functions-bit-wizardry

MCode(ByRef code, hex) { ; allocate memory and write Machine Code there
VarSetCapacity(code,StrLen(hex)//2)
Loop % StrLen(hex)//2
NumPut("0x" . SubStr(hex,2*A_Index-1,2), code, A_Index-1, "Char")
}


So they seem to be in agreement.

Flipeador wrote:
2,x86:g+wYi0wkLIvBwegQUw+22IvBwegIVQ+26A+2wYlEJAhWi/GLTCQ8i8HB7hjB6BiJRCQUi8HB6BAPtsCJRCQYi8HB6AgPtsCJRCQcD7bBi0wkMIl0JBCJRCQghckPjr8AAACLRCQoi1QkQIPAAleLfCQwiUQkQIX/D46NAAAAjQwWiUwkPA+2cAE78Xdmi0wkFCvKO/FyWA+2MI0MEzvxd06LyyvKO/FyRg+2cP+NDCo78Xc7i80ryjvxcjOLTCQQD7Zw/gPKO/F3JYtMJBAryjvxchuLTCQYiEgBi0wkHIgIi0wkIIhI/4tMJCSISP6LTCQ8g8AEg+8BdYqLdCQUi0QkQIt8JDCLTCQ0A0QkOIPpAYlEJECJTCQ0D4VW////X15dM8Bbg8QYww==,x64:RIlMJCBEiUQkGFNVQVRBVUFWQVdIg+woRIuUJIAAAABFM+1Bi8JFD7b6wegQi+qLlCSIAAAARYvaRA+28EiL2UHB6xhBi8LB6AhED7bgi8LB6BiJRCQEi8LB6BAPtsCJRCQIi8LB6AgPtsCJRCQMD7bCiUQkEESJnCSAAAAARIksJEWFwA+OEgEAAIuEJJAAAACLTCRwSIl0JGBIiXwkIEUzwIXtD47YAAAAQYv1RY0UA0SLbCQERImUJIgAAABBD6/xDx9AAGYPH4QAAAAAAEaNDIZBjUkDD7YUGYv5QTvSD4eDAAAAQYvLK8g70XJ6QY1JAg+2FBlEi9lBjQwGO9F3X0GLzivIO9FyVkGNSQEPthQZRIvRQY0MBDvRdztBi8wryDvRcjJBD7YUGUGNDAc70XclQYvPK8g70XIci0wkCEGIDBuLTCQMQYgMGotMJBBBiAwZRIgsH0SLlCSIAAAARIucJIAAAABB/8BEO8UPjFr///9Eiywki0wkcESLTCR4Qf/FRIksJEQ76Q+MDf///0iLfCQgSIt0JGAzwEiDxChBX0FeQV1BXF1bww==

?


I am not sure about these. Should I only use the code after 64? I didn't want to just try using only a part of it as I'm not sure if it could cause serious errors.
Last edited by Archandrion on 24 Jun 2018, 13:57, edited 2 times in total.
Helgef
Posts: 3033
Joined: 17 Jul 2016, 01:02
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 13:55

Try Bentschi's mcode function which you already read about in the readme ;)

Edit, hello Flipeador :wave:
User avatar
Flipeador
Posts: 866
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 14:23

I am not sure about these. Should I only use the code after 64? I didn't want to just try using only a part of it as I'm not sure if it could cause serious errors.

Read https://autohotkey.com/boards/viewtopic.php?f=7&t=32.

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus


Simply pass the entire string to the MCode function.

@Helgef Hi! :wave:
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2
Archandrion
Posts: 31
Joined: 26 May 2018, 22:23

Re: MCode from 32bit to 64bit

24 Jun 2018, 14:44

Flipeador wrote:
Simply pass the entire string to the MCode function.


I tried to pass the entire string to to the MCode function but it does not seem to work. This is the code I now have:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
nnnik
Posts: 2966
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: MCode from 32bit to 64bit

24 Jun 2018, 14:47

You dont need to use E := DllCall(&_FilterColor, "uint", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation) anymore
You can now just use E := DllCall(_FilterColor, "uint", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation)
Recommends AHK Studio
User avatar
Flipeador
Posts: 866
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 14:49

.. and I think "uint", Scan01 should be "uptr", Scan01.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2
Archandrion
Posts: 31
Joined: 26 May 2018, 22:23

Re: MCode from 32bit to 64bit

24 Jun 2018, 15:40

nnnik wrote:You dont need to use E := DllCall(&_FilterColor, "uint", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation) anymore
You can now just use E := DllCall(_FilterColor, "uint", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation)


Flipeador wrote:.. and I think "uint", Scan01 should be "uptr", Scan01.


I tried just replacing it first with E := DllCall(_FilterColor, "uint", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation) and then when that did not work tried E := DllCall(_FilterColor, "uptr", Scan01, "int", w, "int", h, "int", Stride1, "uint", Color, "uint", ReplaceColor, "int", Variation) but it still does not appear to have made the color change to the image. The code I now have is:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
Flipeador
Posts: 866
Joined: 15 Nov 2014, 21:31
GitHub: Flipeador
Location: Argentina
Contact:

Re: MCode from 32bit to 64bit

24 Jun 2018, 18:25

Maybe the problem is the machine code, I have used VS Community 2017. Test with AHKU32 with the previous machine code.

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

"2,x86:QVdBVkFVQVRVV1ZTSIPsOIuEJKgAAAAx7UmJz0SJhCSQAAAARIuEJKAAAABEiYwk"
. "mAAAAESNNJUAAAAAicGJRCQsi4QksAAAAInPQYnKRYnBwe8YRInGQYHhAAD/AIl8"
. "JCAPtv2LjCSQAAAAQYHiAAD/AEyJw8HuGEHB6hBBwekQiXwkKIXJD7bfRQ+2wESJ"
. "VCQkvwMAAAAPjuUAAACNDAMpw0WNJAGJXCQUQY0cAEEpwUEpwESNHAaJTCQQKcZE"
. "iUwkDIlcJBhEiUQkHEyJ+YXSRo0MN4n4D46OAAAAZpBBicCNWP1JAchFD7YQRTna"
. "d25BOfJyaUSNaP9JAc1FD7ZVAEU54ndYRDtUJAxyUUSNeP5JAc9FD7YXRDtUJBB3"
. "P0Q7VCQUcjhBidpJAcpBD7YaO1wkGHcoO1wkHHIiD7ZcJCBBiBgPtlwkJEGIXQAP"
. "tlwkKEGIHw+2XCQsQYgakIPABEQ5yA+FdP///4PFAQO8JJgAAAA5rCSQAAAAD4VN"
. "////McBIg8Q4W15fXUFcQV1BXkFfw5CQkJCQkJCQkJA="

It works?.
Windws 1♂ Pro 64-Bits I make scripts for AHKv2 (my v2 compiler) & WIN_7+ Spanish Argentina SublimeText 3 & AHKv2
iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: MCode from 32bit to 64bit

24 Jun 2018, 23:55

Here's a code example from one of my projects you can imitate:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

iseahound
Posts: 235
Joined: 13 Aug 2016, 21:04
GitHub: iseahound

Re: MCode from 32bit to 64bit  Topic is solved

25 Jun 2018, 00:07

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



untested.

For x64 code, use the MCode generator, by pointing it to "g++" from the x64 version found in win-builds. http://win-builds.org/doku.php Use the optimize for fast code/optimize for size options. Make sure you strip off the preceding x64/x86 characters, those are un-necessary in my version.
Archandrion
Posts: 31
Joined: 26 May 2018, 22:23

Re: MCode from 32bit to 64bit

25 Jun 2018, 12:45

iseahound wrote:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



untested.

For x64 code, use the MCode generator, by pointing it to "g++" from the x64 version found in win-builds. http://win-builds.org/doku.php Use the optimize for fast code/optimize for size options. Make sure you strip off the preceding x64/x86 characters, those are un-necessary in my version.


Thanks, that solved the issue.

Return to “Ask For Help”

Who is online

Users browsing this forum: jnkettenring, RyanAyton and 45 guests