best AutoHotkey machine code functions

Get help with using AutoHotkey and its commands and hotkeys
User avatar
jeeswg
Posts: 6469
Joined: 19 Dec 2016, 01:58
Location: UK

best AutoHotkey machine code functions

25 May 2017, 01:18

I've found some useful machine code functions for use with AutoHotkey, I wondered if anyone had any other machine code functions that they recommended. Thanks.

[e.g. InBuf currently x32 only]
Machine code binary buffer searching regardless of NULL - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/2362 ... s-of-null/
InBuf function currently 32-bit only (machine code binary buffer searching) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=28393

[e.g. Gdip_ImageSearch x64/x32]
AutoHotkey/Functions/Gdip_ImageSearch at master · MasterFocus/AutoHotkey · GitHub
https://github.com/MasterFocus/AutoHotk ... mageSearch

Machine code functions: Bit Wizardry - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/1948 ... -wizardry/

==================================================

[EDIT:]
AHK machine code functions tend be either pure assembly language or converted from a programming language e.g. C++.

Machine code binary buffer searching regardless of NULL - Scripts and Functions - AutoHotkey Community
https://autohotkey.com/board/topic/2362 ... s-of-null/
This seems to be the first pure assembler function written for AHK.
Last edited by jeeswg on 26 May 2017, 18:02, edited 1 time in total.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 3778
Joined: 17 Jul 2016, 01:02
Contact:

Re: best AutoHotkey machine code functions

25 May 2017, 03:40

Good topic jeeswg, I have a minor contribution, I leave it as an exercise for you to figure out an application for it :lol:

Code: Select all

returnInt(n){
	; Input: 
	;	- n, integer in range (-2**31, 2**31-1), i.e., (-2147483648, 2147483647)
	; Return:
	;	- bin, address pointing to binary code for returning the integer, n.
	; Misc:
	;	When making "many" allocations, call VirtualFree(bin) when done with bin. 
	; Example:
	;	r:=returnInt(37)
	;	MsgBox, % DllCall(r) ; 37
	;	VirtualFree(r)
	; Url:
	;	- https://msdn.microsoft.com/en-us/library/windows/desktop/aa366887(v=vs.85).aspx 	(VirtualAlloc function)
	;	- https://msdn.microsoft.com/en-us/library/windows/desktop/aa366786(v=vs.85).aspx 	(Memory Protection Constants)
	;	- http://ref.x86asm.net 															(X86 Opcode and Instruction Reference)
	;
	static dwSize:=6, flProtect:=0x40	; PAGE_EXECUTE_READWRITE
	static flAllocationType:=0x1000 	; MEM_COMMIT
	static mov:=0xb8, ret:=0xc3
	bin:=DllCall("Kernel32.dll\VirtualAlloc", "Uptr",0, "Ptr", dwSize, "Uint", flAllocationType, "Uint", flProtect, "Ptr")
	NumPut(mov,bin+0,"Char"),NumPut(n,bin+1,"Int"),NumPut(ret,bin+5,"Char")	
	return bin
}
VirtualFree(lpAddress){
	static dwFreeType:=0x8000 ; MEM_RELEASE
	return DllCall("Kernel32.dll\VirtualFree", "Ptr", lpAddress, "Ptr", 0, "Uint", dwFreeType)  ; Non-zero return is ok!
}
User avatar
jeeswg
Posts: 6469
Joined: 19 Dec 2016, 01:58
Location: UK

Re: best AutoHotkey machine code functions

16 Oct 2018, 14:37

- The function by itself works a little like an RNG.
- Wow, so you wrote a machine code function in pure ASM after all. A function to return a specified number. :thumbup:
- Anything more to say about it? Cheers.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Helgef
Posts: 3778
Joined: 17 Jul 2016, 01:02
Contact:

Re: best AutoHotkey machine code functions

17 Oct 2018, 02:38

The function by itself works a little like an RNG.
No.
Anything more to say about it?
It is much faster than callbackcreate(()=>n)

Cheers.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], vsub and 213 guests