How would I convert a string like:
7aY#R5z_ /+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.
7aY#R5z_ /+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.
Maybe it is encrypted...
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).
7aY#R5 z_ /+s79 (what is return from the registry) to its hex equivalent?:
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
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....
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....
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
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
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:
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:
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
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
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.
I will also take a look at the HexDump.
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
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
Use a hex editor like ultraedit.