Hey guys,
I am in the middle of programming a thing that allows you to view the names of users online for another program (lets take for example ICQ). It will read out the names of the user that comes online, his # etc. What I can't figure out is how to convert the hex string that his name is stored in into an actual read out of his name (his name being displayed in a text box). Can anyone help me with this? I have tried before but have failed to suceed. I want it to display his name not the hex strings please take note of that. Examples would be a lot of help.

Posted on 2002-06-24 16:04:10 by resistance_is_futile
Well if I understand you correctly, you could just use wsprintf. I'm sure there are at least a couple of examples in the masm32 examples folders. It's a pretty straight forward api though. Also, look in the masm32.lib help file for the dwToA or whatever that function is called. There're several of those conversion type functions in there.
Posted on 2002-06-24 16:50:46 by Will
:grin: thx found the command I needed heh and it was right in front of my face.
Posted on 2002-06-24 17:08:58 by resistance_is_futile
how exactly would I invoke all of that? lol I kinda found an example in masm32 package but it was changing colors to rgb values. I think I know how but im not sure. would this be correct?

clearbuffer PROTO :DWORD
<the usual stuff here>
WndProc proc hWin :DWORD,
uMsg :DWORD,
wParam :DWORD,
lParam :DWORD

LOCAL buffer1[128]:BYTE <-----I want to change this so it holds more then a byte
LOCAL buffer2[128]:BYTE<----same as first one


.elseif uMsg == WM_COMMAND
.if wParam == 1001 <---the button I use to pick up the names

invoke clearbuffer, ADDR buffer1
invoke clearbuffer, ADDR buffer2

invoke dw2hex, color, ADDR buffer2<---this is from the example im not sure where to go from here
Then I used to know how to make this appear inside a box but i kinda got rusty on my skills lol.

If someone can help me fix this current code so it reads the hex string at a certain start code then shows it in a text box I would be VERY greatful lol.
Posted on 2002-06-24 22:44:56 by resistance_is_futile
I don't know If I answered your main question(First Post) but here's a sample code I did:

INCLUDE \masm32\INCLUDE\windows.inc
INCLUDE \masm32\INCLUDE\kernel32.inc
INCLUDE \masm32\INCLUDE\user32.inc
INCLUDELIB \masm32\lib\user32.lib
INCLUDELIB \masm32\lib\kernel32.lib
INCLUDE \masm32\INCLUDE\masm32.inc
INCLUDELIB \masm32\lib\masm32.lib


HexString DB "48656C6C6F20437275656C20576F726C64", 0 ;"Hello Cruel World"


HexBuffer DB 3 DUP(?)
TxtBuffer DB 1024 DUP(?)


HexStr2TxtStr PROC USES ebx esi edi lpszHexString:DWORD, lpszTextBuffer:DWORD, szHexBuffer:DWORD

mov ebx, szHexBuffer
xor eax, eax
mov esi, lpszHexString
xor ecx, ecx
mov edi, lpszTextBuffer


mov ax, WORD PTR [esi+ecx*2]
mov WORD PTR [ebx], ax
push ecx
invoke htodw, ebx
pop ecx
mov WORD PTR [edi+ecx], ax
inc ecx
cmp BYTE PTR [esi+ecx*2+1], 0
jne @B


HexStr2TxtStr ENDP

invoke HexStr2TxtStr, OFFSET HexString, OFFSET TxtBuffer, OFFSET HexBuffer
invoke MessageBox, 0, OFFSET TxtBuffer, 0, 0
invoke ExitProcess,NULL
END START[/size]
Is this what your looking for? :)
Posted on 2002-06-24 23:34:20 by stryker
lol kinda I will try it out and see..
Posted on 2002-06-25 00:04:25 by resistance_is_futile

I don't know If I answered your main question(First Post) but here's a sample code I did:

Thanks now I can use this to decode that thread a while back :) Wrote my own, but it kinda crapped out if the buffer was too big... I'll try yours..

Posted on 2002-06-25 08:03:21 by Sliver
okay its kinda like that and that almost had me actually understanding it lol but I wanna get the hex string from a certain memory address (such as 00378954 just an example). Would I put that address in the HexString line under data? I dont think I would because I only want to get a certain number of bytes from the whole hex string (like the last few ex. 00 00 00 00 00 45 67 32 87 FF just an example but I would like to get the last few 45, 67, 32, 87, and FF and convert them into ascii then display it in a text box thus displaying the name of whoever is currently online with the target program) not the whole string of data. Also would I refer to the text box with its id or name? heh I know its a simple question but I just barely started programming again and am a little rusty.
Posted on 2002-06-25 13:20:50 by resistance_is_futile
comeon!! Please help me dont give up now! lol :grin:
Posted on 2002-06-25 22:07:16 by resistance_is_futile
I would suggest to parse the hex string into a buffer before feeding it on the HexStr2TxtStr. There are a lot of factors here to consider, I cannot pinpoint each of them since your the one who knew the format. Just some pointers here:
    [*]on this example 00 00 00 00 00 45 67 32 87 FF are you sure this is the total size of the hex string? (I think not)
    [*]What's the data after FF? Is it a terminating 0?
    [*]How would I know the end of a hex string ?
    [*]after FF it could be any data, how would I know it?There are a lot of ways to tackle this problem, it's just that there are a lot of factors to consider.

    If the data after FF is 0 then this would be easy. Just load the address to any register, scan your way until you hit a hex value > 0, start copying this data into a buffer, continue scanning while copying until you hit another 0, stop here. Feed it into HexStr2TextStr...

    If the there is no terminating 0 after FF, you must know the size of the hex string. Start at the end of the hex string, copying it into the buffer and scan your way to the start of the hex string until you hit a value == 0. Stop here. Then feed into HexStr2TextStr... Then use a string reverse algo.
Posted on 2002-06-25 22:52:02 by stryker
okay this is how far I am in converting hex to ascii. I think I need to use a different function other than dwtoa.

.elseif wParam == 1001
invoke ReadProcessMemory,gameprocess,addr urnameaddy,addr buffer1,10,NULL
invoke dwtoa,buffer1,ADDR buffer2
invoke SetDlgItemText,hWin,IDC_STC1,addr buffer2

what that does is if the button is pushed (1001 is its ID) then it invokes ReadProcessMemory on a memory address that stores my name (in hex) and stores it in buffer1 (which is set up in my data? section to hold 64 characters so it shouldnt be a problem of space in the buffer). Then I invoke dwtoa (DWORD TO ASCII) and it takes the hex values from buffer1, changes them to ascii, then stores them in buffer2 and reads it out in a dialog box (IDC_STC1). This is the PROC I use for dwtoa.

dwtoa PROC dwValue:DWORD, lpBuffer:DWORD

wsprintf equ <wsprintfA>

fMtStrinG db "%lu",0

invoke wsprintf,lpBuffer,ADDR fMtStrinG,dwValue

dwtoa endp

this is in the same .asm file as all the coding only at the bottom (just before the start endp)

and my .data? section looks like this (i dont think the problem is here)

buffer1 db 64 dup(?)
buffer2 db 64 dup(?)

Okay now for the problem part lol. What I get when I run it is an error message. And I have looked through this and havent found a problem and it assemble right (no errors found in my code) so Im wondering if Im just using the wrong function call. Any help on this would be alot of help.
Regards RIF
Posted on 2002-06-27 23:03:55 by resistance_is_futile
You mean your app crashed ??? You should try this code in between calls, so you'll know what function screwed up.

invoke MessageBox, 0, 0, 0, 0
Place this between ReadProcessMemory and your dwtoa, if the messagebox shows up and an error occurs move this code inbetween dwtoa and SetDlgItemText. Wherever you placed the MessageBox code and you don't see the MessageBox popping up or the MessageBox pops up after the error, the function call before the MessageBox code is the culprit. Run this in a debugger to fully understand what's going on your data.

Also I suspect there is something wrong on your dwtoa routine. You should try printing out buffer1 before converting it. Try reading a small portion in memory like 1 byte at a time instead of 10 ... Try using a loop while reading 1 byte after 1 byte, printing each byte on a message box or printing it in a textbox ... debug it in small ways don't do everything in one whack.
Posted on 2002-06-28 10:19:35 by stryker