How would I convert a string like:
7aY#R5 z_ /+s79 (what is return from the registry) to its hex equivalent?:
1a,37,61,59,23,52,35,0c,7a,5f,20,17,2f,1e,1a,19,0e,2b,01,73,13,37,13,12,14,1a,15,39 (what regedit saves the above to)

It is a binary value I am grabbing from the registry and can't seem to figure it out.
Posted on 2003-03-17 19:35:47 by Gunner
Maybe it is encrypted...
Posted on 2003-03-17 21:11:21 by david
How would I convert a string like:
7aY#R5 z_ /+s79 (what is return from the registry) to its hex equivalent?:
You posted the answer in your next sentence (i.e. what regedit gave you).

Instead, you probably want to know how to interpret that data. This means learning how the registry is designed and where that particular string of bytes was obtained from the registry.

Quite a task. Have fun.

Raymond
Posted on 2003-03-17 22:26:37 by Raymond
I don't care if it is encrypted.

Don't want to learn how the registry was designed (know a lot about that as it is)

My question still remains... how do I convert to hex so I can save to file like regedit does when exporting a key.

I have to backup a reg key in my program and don't want to use AdjustTokenPrivileges (partly because I am unsure how to use it and also from reading, not all users will have the TOKEN_ADJUST_PRIVILEGES to use it) so I want to enumerate the keys and values and save to a file. Enumerating and saving to file is the easy part... saving the binary data is a bit differant because it has to be converted to hex and saved....
Posted on 2003-03-17 22:48:27 by Gunner
try to have a look at the Regdemo example in Masm32's Example7 folder.
Among other things, binary data is saved to registry and read again in the format you want to, I think.
Go check it out.

HTH, phueghy
Posted on 2003-03-18 04:17:28 by phueghy
Rob,

basically you read each byte and convert them one at a time to hex string notation.

dw2hex proc source:DWORD, lpBuffer:DWORD

This function will give you the result if you sign extend the byte to a dword and then chop off the 2 characters you want.

You could write a dedicated one that was a lot faster and smaller if you could be bothered.

Regards,

hutch@movsd.com

PS : you could also use the "HexDump proc lpString:DWORD,lnString:DWORD,lpbuffer:DWORD
" algo in the example code in MASM32 version 8. Its a bit overkill for what you are after but it will be more than fast enough. :tongue:
Posted on 2003-03-18 07:35:37 by hutch--
Maybe it's just me, but isn't the registry feeding you hex? Are you trying to convert it to ascii or what? Which brings the next question:
Are you trying to save the data to a .reg file that the user can then import into the registry? Or do you just want to save it so your program can backup the data itself?

Fake
Posted on 2003-03-18 08:32:11 by Fake51
Ahhhh, thank you. I knew it was simple but had a long day yesterday and brain wasn't working. Oh well..
I will also take a look at the HexDump.
Posted on 2003-03-18 08:32:12 by Gunner
hex2ascii:

push ebx
mov ebx,eax
ror ebx,04h
and bl,0fh
cmp bl,09h
ja $+07h
add bl,30h
jmp $+05h
add bl,37h
and al,0fh
cmp al,09h
ja $+06h
add al,30h
jmp $+04h
add al,37h
mov ah,bl
xchg ah,al
pop ebx
ret

This takes hex value in AL and converts upper nibble to ascii interpretation and places it in AH and the lower nibble in AL. An example of using it might be:

mov ecx,08h
mov al,
call hex2ascii
mov ,ax
inc esi
inc edi
inc edi
dec ecx
jnz $+06
Posted on 2003-03-19 08:58:33 by mrgone
Use a hex editor like ultraedit.
Posted on 2003-05-08 06:35:34 by chirbyji