Howdy
I am making a goofy program just so I can send a WM_SETTEXT message to things like the start button and such. Here's my problem: instead of hardcoding the handle of the start button (which would only work until Explorer is closed) I want to be able to just enter the handle into a textbox and click a button to send the WM_SETTEXT to the handle I entered. Here's what I have so far:


LOCAL Handle:DWORD
..........

invoke GetDlgItemInt,hWin,600,Handle,FALSE
invoke SendMessage,Handle,WM_SETTEXT,0,ADDR SpoofText

As you probably guessed it doesn't work, but I don't know what else to do. Any suggestions? Thanks.
Posted on 2004-09-25 12:32:29 by yo|dude|mon
You'll probably want to get the value from the editbox as text, and use an ascii->hex routine...
Posted on 2004-09-25 12:51:10 by f0dder
what i would do is this:

make the string uppercase, check for invalid characters, if everything is okay then check character by character: if '0' <= c <= '9' or 'A' <= c <= 'F', if 0...9 substract '0' from c, if 'A' ... 'F' substract ('A'-10') from it, and or it to a certain register that you'll shift for each new character.

but, as many things, it can be done easier i guess, or even with some fancy API.
Posted on 2004-09-25 12:52:42 by lifewire
something along these lines:
; __fastcall str2dword(IN char* number)

;
; IN
; eax = ptr to string
; OUT
; eax = dword
;
; esi is preserved.
;

str2dword:
push esi
xchg eax,esi
sub eax,eax
cdq
push 10
pop ecx
@@convert:
mov dl,[esi]
sub dl,'0'
add eax,edx
inc esi
cmp byte ptr [esi],dh
jz @@end
push edx
mul ecx
pop edx
jmp @@convert
@@end:
pop esi
ret


i made it fastcall so HLLs can call it as well. this will assume that the buffer is all numeric, so you would need to do some checks beforehand. hope this helps.
Posted on 2004-09-25 13:46:51 by Drocon
I guess I dug too deep on this question. I just don't understand a bit of it. Thanks for your help anyway.
Posted on 2004-09-25 23:21:25 by yo|dude|mon
there is an HEX TEXT 2 DWORD function in the masm32 lib (htodw)
Posted on 2004-09-26 02:52:06 by greenant
Setting the start button text won't do you much good, since it uses a bitmap.
But you can convert from an ASCII representation of a hexadecimal number to binary like this:


push esi
mov esi,[Text]
xor eax,eax
cdq
getnbrl:
lodsb
sub al,48
jb nbrerror
cmp al,10
jb under10
sub al,17
and al,223
under10:
cmp al,16
jae nbrerror
shr edx,4
add edx,eax
jmp getnbrl
nbrerror:
xchg edx,eax
pop esi
ret
Posted on 2004-09-26 05:17:29 by Sephiroth3
I just used greenant's idea about that MASM function, which is easier to use. One thing I do not understand is using those brackets. For instance, sephiroth's code has


mov esi, [Text]

Let's just say I had a string named "Buf". When I say


mov esi, [Buf]

the compiler says "Invalid instruction operands." ??
Thanks for all your help guys I think I'll get the hang of it soon.

PS: On an unrelated note, what are logical ANDs, ORs, NOTs, and XORs?

PPS: The start button isn't a bitmap because I changed the text with a WM_SETTEXT a few minutes ago.
Posted on 2004-09-26 19:39:51 by yo|dude|mon
I just used greenant's idea about that MASM function, which is easier to use. One thing I do not understand is using those brackets. For instance, sephiroth's code has


mov esi, [Text]

Let's just say I had a string named "Buf". When I say


mov esi, [Buf]

the compiler says "Invalid instruction operands." ??
Thanks for all your help guys I think I'll get the hang of it soon.

you need to specify the size of data to move if you want to move some part of string:



somestring db "abcdefg"
mov esi, dword ptr [somestring]

but that's even not the case, as 'mov esi, ' in Sephiroth3 example loads a string pointer located in Text variable into esi.

PS: On an unrelated note, what are logical ANDs, ORs, NOTs, and XORs?

you better read some assembly introduction books. like AOA.
Posted on 2004-09-26 20:40:01 by arafel
Take a look at

http://www.win32asmcommunity.net/phpwiki/index.php/BitOperations
Posted on 2004-09-27 06:50:35 by roticv
Hi, why not use FindWindow to get the handle of the start button at runtime. See the example at : http://win32assembly.online.fr/Win32Api1.htm#tq2

Thomas Antony 8)
Posted on 2004-10-01 10:23:44 by thomasantony
Thomas,
Thanks for trying to help, but I already did that and the program changed something else that was a button and had the text as "Start".
Posted on 2004-10-01 15:02:25 by yo|dude|mon