| View previous topic :: View next topic |
| Author |
Message |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Mon Apr 07, 2008 12:16 am Post subject: |
|
|
| SKAN wrote: | | I have adapted the machine code... | Clever! |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Mon Apr 07, 2008 6:33 am Post subject: |
|
|
.. and I was using your BSwap mcode like this:
| Code: | bs16 := chr(138) chr(225) chr(138) chr(197) chr(195) ; Laszlo's bswap16
bs32 := chr(139) chr(193) chr(015) chr(200) chr(195) ; Laszlo's bswap32 |
|
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Fri Jun 20, 2008 1:47 pm Post subject: |
|
|
First of all, Thanks Laszlo for providing machine code world to ahk.
although i had 0% knowledge of machine code i'd like to try it.
currently i'm trying to make ID3 tag extractor() using mcode. (bin2hex)
it was successful but i want it to run by 100% mcode powered
will there be any chance to get mcode for Hex2Chr()? or even Bin2Chr()
Thanks in advance ! _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Fri Jun 20, 2008 3:14 pm Post subject: |
|
|
I would also very much like to see that function, and please if someone does could I see the source code as well  |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Fri Jun 20, 2008 3:31 pm Post subject: |
|
|
What should these functions exactly do? E.g., should Hex2Chr ignore any non-printable characters from a hex stream, and provide an AHK string as the result? If you know that all characters are printable, Hex2Bin does the same. You only have to update the variable's internally-stored length to the length of its current contents with VarSetCapacity(Bin,-1). If you want to stop at the first NUL, the above VarSetCapacity call will set the length correctly, after you copied a long enough chunk of the data.
You might be better served with DllCall("RtlMoveMemory"… or a string copy function of the C runtime library: msvcrt, to avoid the hex conversion intermediate step. |
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Fri Jun 20, 2008 3:57 pm Post subject: |
|
|
For example i got this hexes from the mp3 file
| Code: | ;about 30 bytes only
hex := 46756E6E792053746172000000000000000000000000000000000000000
|
and i used below loop for Hex2Chr
| Code: | Loop, 60 ;hex passed to this loop
If Mod(A_Index,2)=1
Title .= Chr("0x" . SubStr(Hex, A_Index,2)) |
i'd like to make whole processes to be proceed by MCode for speed.
and i know that it can be accomplished without MCode but for learning purpose
does it make clear? However thanks for quick answer. _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Fri Jun 20, 2008 4:33 pm Post subject: |
|
|
The Hex2Bin function does it: | Code: | hex = 46756E6E792053746172000000000000000000000000000000000000000
Loop 60
If A_Index & 1
Title .= Chr("0x" . SubStr(Hex, A_Index,2))
MsgBox %Title%
MCode(Hex2Bin,"568b74240c8a164684d2743b578b7c240c538ac2c0e806b109f6e98ac802cac0e10"
. "4880f8a164684d2741a8ac2c0e806b309f6eb80e20f02c20ac188078a16474684d275cd5b5f5ec3")
VarSetCapacity(Title, ceil(StrLen(hex)/2))
DllCall(&Hex2Bin, "UInt",&Title, "UInt",&hex, "CDECL")
VarSetCapacity(Title, -1)
MsgBox %Title%
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")
} |
|
|
| Back to top |
|
 |
heresy
Joined: 11 Mar 2008 Posts: 291
|
Posted: Fri Jun 20, 2008 4:57 pm Post subject: |
|
|
Cool! i never knew that i already have enough functions to do so.
i'm gonna decode your code.
Thanks for sharing your experience, knowledge, skills as always! _________________ Easy WinAPI - Dive into Windows API World
Benchmark your AutoHotkey skills at PlayAHK.com |
|
| Back to top |
|
 |
GuestAHK Guest
|
Posted: Sun Jun 22, 2008 6:16 am Post subject: |
|
|
| Laszlo wrote: | I guess IsWindowVisible was just an example.
If you want to call a dll function from within a machine code function, you probably need some extra system calls (like "LoadLibrary", which loads the desired function into memory, and then search for the address of the function). I have not tried, but it should be possible. A simpler solution could be to break up the machine code to stand alone pieces and use AHK's dllcall in between to call the needed external functions. |
Hello, I am following along this thread, and wondering -- has it been proven to somehow load a DLL from memory? |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
|
| Back to top |
|
 |
GuestAHK Guest
|
Posted: Mon Jun 23, 2008 7:54 pm Post subject: |
|
|
Quite interesting at that link ....I wonder if it is possible, or anyone attempted yet to translate this concept to AHK with any kind of success? Seen any work in that direction? It is certainly way beyond my skill level there, ... but I think it would be a very interesting way to manage script dependency resources.  |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Thu Jun 26, 2008 12:13 pm Post subject: |
|
|
It would be very useful to translate this to AHK.
The actuall C moudle is only 400 code lines and it shouldn't be very hard to translate it to AHK by the person who knows what is doing.
The good thing is that module is well tested as its used in py2exe.
The problem is that this task is lengthy and errorpone as bunch of large structures are used. Lexikos struct parser would be very helpfull. Few C macros need to be translated to, but generally, it isn't hard to translate this code even without understanding at all what is it about. _________________
 |
|
| Back to top |
|
 |
Yook
Joined: 20 Nov 2008 Posts: 70 Location: Thionville, France
|
Posted: Tue Dec 23, 2008 1:39 pm Post subject: |
|
|
Hi!
I remember having used machine code without really knowing how it worked, to control the mouse pointer in my early QBasic programs.
I haven't taken time to try to understand how it really works, however, I wondered if there was a way to lock mouse cursor in a defined zone of the screen (really lock it, not getting cursor back into the zone, with a Timer, when it goes out), using machine code.
Any idea?
Thanks in advance ! |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Tue Dec 23, 2008 2:03 pm Post subject: |
|
|
|
|
| Back to top |
|
 |
Yook
Joined: 20 Nov 2008 Posts: 70 Location: Thionville, France
|
Posted: Tue Dec 23, 2008 4:11 pm Post subject: |
|
|
Ok, thank you, I will see that.
Edit :
Amazing ! It's exactly what I need. |
|
| Back to top |
|
 |
|