AutoHotkey Community

It is currently May 27th, 2012, 3:46 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 356 posts ]  Go to page Previous  1 ... 17, 18, 19, 20, 21, 22, 23, 24  Next
Author Message
 Post subject:
PostPosted: July 30th, 2010, 9:52 pm 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
ddk wrote:
I changed my OS to my nlited XP and since then I've had problems with bin2hex function:
Code:
MCode(Bin2Hex,"8B4C2404578B7C241085FF7E2F568B7424108A06C0E8042C0A8AD0C0EA052AC2044188018A06240F2C0A8AD0C0EA052AC2410441468801414F75D75EC601005FC3")

bin := "abc", VarSetCapacity(hex,9)
dllcall(&Bin2Hex, "uint",&hex, "uint",&bin, "uint",4, "cdecl")
VarSetCapacity(hex,-1) ; update StrLen
MsgBox %hex%           ; 31323300

That example returns me 4 boxes:
Code:
ㄶ〰㈶〰

And I guess that's not right :roll: I've also tried standalone version of bin2hex and not working, also tried the BinToHex.dll. My AHK version is 1.0.48.05.L52H20.


It seems like you're using a unicode build of AHK. Try using the Bin2Hex here instead.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 9:58 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
I got "61626300". The culprit could be the editor, too, if it saves the ahk file in other than pure ANSI/ASCII format.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 10:55 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
TheGood wrote:
ddk wrote:
I changed my OS to my nlited XP and since then I've had problems with bin2hex function:
Code:
MCode(Bin2Hex,"8B4C2404578B7C241085FF7E2F568B7424108A06C0E8042C0A8AD0C0EA052AC2044188018A06240F2C0A8AD0C0EA052AC2410441468801414F75D75EC601005FC3")

bin := "abc", VarSetCapacity(hex,9)
dllcall(&Bin2Hex, "uint",&hex, "uint",&bin, "uint",4, "cdecl")
VarSetCapacity(hex,-1) ; update StrLen
MsgBox %hex%           ; 31323300

That example returns me 4 boxes:
Code:
ㄶ〰㈶〰

And I guess that's not right :roll: I've also tried standalone version of bin2hex and not working, also tried the BinToHex.dll. My AHK version is 1.0.48.05.L52H20.


It seems like you're using a unicode build of AHK. Try using the Bin2Hex here instead.

If I used it right, it returns empty. As an editor I use latest Scite.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 10:59 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
- What is the encoding the latest Scite used for the script file?
- This tool was developed for AHK. You seem to use AHK_L, so post your question there.


Last edited by Laszlo on July 30th, 2010, 11:03 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 11:02 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
Laszlo wrote:
- What is the encoding the latest Scite used for the script file?
- What AHK version did you use to run the script?

- "Code Page Property"
- As said above: My AHK version is 1.0.48.05.L52H20.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 11:05 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
(you answered while I was editing my response... If you use AHK_L, post your question there. I don't have it.)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 11:11 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
@ddk
It is due to Unicode.
You will need to use StrGet()
Code:
MCode(Bin2Hex,"8B44240C568B742408578B7C24108D14073BFA7332538A07478AC8C0E904B3093AD91ADB80E30780C3"
. "3002D9240F881E46B1093AC81AC980E10780C13002C8880E463BFA72D05B5FC606005EC3")


VarSetCapacity(hex,9)
VarSetCapacity(bin,12)
StrPut("123",&bin,3,"CP0")

dllcall(&Bin2Hex, "uint",&hex, "uint",&bin, "uint",4, "cdecl")
VarSetCapacity(hex,-1) ; update StrLen
MsgBox % StrGet(&hex,"CP0")           ; 31323300

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Last edited by HotKeyIt on July 31st, 2010, 12:05 am, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 30th, 2010, 11:14 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
HotKeyIt wrote:
@ddk
It is due to Unicode.
You will need to use StrGet()
Code:
MCode(Bin2Hex,"8B44240C568B742408578B7C24108D14073BFA7332538A07478AC8C0E904B3093AD91ADB80E30780C3"
. "3002D9240F881E46B1093AC81AC980E10780C13002C8880E463BFA72D05B5FC606005EC3")

bin := "123", VarSetCapacity(hex,9)
dllcall(&Bin2Hex, "uint",&hex, "uint",&bin, "uint",4, "cdecl")
VarSetCapacity(hex,-1) ; update StrLen
MsgBox % StrGet(&hex,"UTF-8")           ; 31323300

Well, looking good, but it doesn't return 31323300 - it returns 31003200, which is "12" tho?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2010, 12:04 am 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Try above again, we need to use StrPut("123",...).

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 31st, 2010, 12:30 am 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
HotKeyIt wrote:
Try above again, we need to use StrPut("123",...).

Works, thanks again HotkeyIt, you are my savior :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 6:49 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
Hi again,

I tired to make a function of HotKeyIt's example, but Im getting random letters after decoding. My fucntion:
Code:
Bin2HexUni(hexa="") {
   len := StrLen(hexa)
   MCode(Bin2Hex,"8B44240C568B742408578B7C24108D14073BFA7332538A07478AC8C0E904B3093AD91ADB80E30780C3"
   . "3002D9240F881E46B1093AC81AC980E10780C13002C8880E463BFA72D05B5FC606005EC3")

   VarSetCapacity(hex,2*len)
   VarSetCapacity(bin,len)
   StrPut(hexa,&bin,len,"CP0")
   dllcall(&Bin2Hex, "uint",&hex, "uint",&bin, "uint",len, "cdecl")
   VarSetCapacity(hex,-1) ; update StrLen
      return StrGet(&hex,"CP0")           ; 31323300
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 12th, 2010, 7:01 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
There is no such thing as a hex representation of text. First you need to encode it. ANSI builds default to the default system code page (CP0, usually Windows-1252 but may be a creepy multibyte codepage such as Shift-JIS for Japanese computers), Unicode builds default to UTF-16.

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 18th, 2010, 1:30 am 
Offline

Joined: July 30th, 2007, 11:32 pm
Posts: 581
Here is a version of Bin2Hex which works on AHK_L x86/x64 ANSI/Unicode and vanilla AHK:

Code:
;By Laszlo
;http://www.autohotkey.com/forum/viewtopic.php?p=135522#135522
Bin2Hex(addr,len) {
    Static fun, ptr
    If (fun = "") {
        If A_IsUnicode
            If (A_PtrSize = 8)
                h=4533c94c8bd14585c07e63458bd86690440fb60248ffc2418bc9410fb6c0c0e8043c090fb6c00f97c14180e00f66f7d96683e1076603c8410fb6c06683c1304180f8096641890a418bc90f97c166f7d94983c2046683e1076603c86683c13049ffcb6641894afe75a76645890ac366448909c3
            Else h=558B6C241085ED7E5F568B74240C578B7C24148A078AC8C0E90447BA090000003AD11BD2F7DA66F7DA0FB6C96683E2076603D16683C230668916240FB2093AD01BC9F7D966F7D96683E1070FB6D06603CA6683C13066894E0283C6044D75B433C05F6689065E5DC38B54240833C966890A5DC3
        Else h=558B6C241085ED7E45568B74240C578B7C24148A078AC8C0E9044780F9090F97C2F6DA80E20702D1240F80C2303C090F97C1F6D980E10702C880C1308816884E0183C6024D75CC5FC606005E5DC38B542408C602005DC3
        VarSetCapacity(fun, StrLen(h) // 2)
        Loop % StrLen(h) // 2
            NumPut("0x" . SubStr(h, 2 * A_Index - 1, 2), fun, A_Index - 1, "Char")
        ptr := A_PtrSize ? "Ptr" : "UInt"
        DllCall("VirtualProtect", ptr, &fun, ptr, VarSetCapacity(fun), "UInt", 0x40, "UInt*", 0)
    }
    VarSetCapacity(hex, A_IsUnicode ? 4 * len + 2 : 2 * len + 1)
    DllCall(&fun, ptr, &hex, ptr, addr, "UInt", len, "CDecl")
    VarSetCapacity(hex, -1) ; update StrLen
    Return hex
}

It is based on Laszlo's fastest implementation and is optimized for speed.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 19th, 2010, 10:46 am 
Offline

Joined: August 12th, 2010, 1:56 pm
Posts: 3
hi
can u help me?
http://www.d3scene.com/forum/warcraft-3-hacks/42374-warcraft-3-memory-reading-dota-hero-level-where-address-my-hero-2.html#post327779
i have this advice to read some data from warcraft3 proccess
how it can be done with ur script?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 21st, 2010, 3:39 pm 
Offline

Joined: December 29th, 2009, 12:48 am
Posts: 43
TheGood wrote:
Here is a version of Bin2Hex which works on AHK_L x86/x64 ANSI/Unicode and vanilla AHK:

Code:
;By Laszlo
;http://www.autohotkey.com/forum/viewtopic.php?p=135522#135522
Bin2Hex(addr,len) {
    Static fun, ptr
    If (fun = "") {
        If A_IsUnicode
            If (A_PtrSize = 8)
                h=4533c94c8bd14585c07e63458bd86690440fb60248ffc2418bc9410fb6c0c0e8043c090fb6c00f97c14180e00f66f7d96683e1076603c8410fb6c06683c1304180f8096641890a418bc90f97c166f7d94983c2046683e1076603c86683c13049ffcb6641894afe75a76645890ac366448909c3
            Else h=558B6C241085ED7E5F568B74240C578B7C24148A078AC8C0E90447BA090000003AD11BD2F7DA66F7DA0FB6C96683E2076603D16683C230668916240FB2093AD01BC9F7D966F7D96683E1070FB6D06603CA6683C13066894E0283C6044D75B433C05F6689065E5DC38B54240833C966890A5DC3
        Else h=558B6C241085ED7E45568B74240C578B7C24148A078AC8C0E9044780F9090F97C2F6DA80E20702D1240F80C2303C090F97C1F6D980E10702C880C1308816884E0183C6024D75CC5FC606005E5DC38B542408C602005DC3
        VarSetCapacity(fun, StrLen(h) // 2)
        Loop % StrLen(h) // 2
            NumPut("0x" . SubStr(h, 2 * A_Index - 1, 2), fun, A_Index - 1, "Char")
        ptr := A_PtrSize ? "Ptr" : "UInt"
        DllCall("VirtualProtect", ptr, &fun, ptr, VarSetCapacity(fun), "UInt", 0x40, "UInt*", 0)
    }
    VarSetCapacity(hex, A_IsUnicode ? 4 * len + 2 : 2 * len + 1)
    DllCall(&fun, ptr, &hex, ptr, addr, "UInt", len, "CDecl")
    VarSetCapacity(hex, -1) ; update StrLen
    Return hex
}

It is based on Laszlo's fastest implementation and is optimized for speed.


Ah, thanks for this. I cant test it now, but if it's Laszlo it will be fine :wink:


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 ... 17, 18, 19, 20, 21, 22, 23, 24  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 18 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