AutoHotkey Community

It is currently May 26th, 2012, 5:24 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 356 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 24  Next
Author Message
 Post subject:
PostPosted: April 7th, 2008, 1:16 am 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
SKAN wrote:
I have adapted the machine code...
Clever!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 7th, 2008, 7:33 am 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
:)

.. 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 2:47 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 4:14 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
I would also very much like to see that function, and please if someone does could I see the source code as well :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 4:31 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 4:57 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 5:33 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
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")
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 20th, 2008, 5:57 pm 
Offline

Joined: March 11th, 2008, 11:36 pm
Posts: 291
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 22nd, 2008, 7:16 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 22nd, 2008, 3:11 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
GuestAHK wrote:
has it been proven to somehow load a DLL from memory?
I don't know if it was done with AHK, but Lexikos pointed to a C solution (a mini loader) http://www.joachim-bauch.de/tutorials/load_dll_memory.html/en.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 23rd, 2008, 8:54 pm 
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. :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 26th, 2008, 1:13 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2008, 2:39 pm 
Offline

Joined: November 20th, 2008, 6:00 pm
Posts: 72
Location: Thionville, France
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 !


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2008, 3:03 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2008, 5:11 pm 
Offline

Joined: November 20th, 2008, 6:00 pm
Posts: 72
Location: Thionville, France
Ok, thank you, I will see that.

Edit :
Amazing ! It's exactly what I need.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 356 posts ]  Go to page Previous  1 ... 10, 11, 12, 13, 14, 15, 16 ... 24  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: ELengefeld, Stigg and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group