since i use RegOpenKeyExW, i've this problem :
if the code are this :
All work fine. but if i put :
in this case, RegOpenKeyExW return some strange value.
In fact i can't declare DB value (like text) BEFORE KeyName.
If it's DD value, it's OK.
I've declared RegOpenKeyExW as :
RegOpenKeyExW PROTO WINAPI :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
What's wrong?
I'm under win2k (nt5).
if the code are this :
.586p
.Model Flat, StdCall
option casemap:none
include ..\INC\windows.inc
include ..\INC\perso01.inc
includelib kernel32.lib
includelib user32.lib
includelib advapi32.lib
.DATA
KeyName db 'S', 0, 'o', 0, 'f', 0, 't', 0, 'w', 0, 'a', 0, 'r', 0, 'e', 0, "\", 0, 'M', 0, 'y', 0, 'K', 0, 'e', 0, 'y', 0, "\", 0,0,0
hKey dd 0
.CODE
Main:
invoke RegOpenKeyExW, HKEY_LOCAL_MACHINE, addr KeyName, 0, KEY_QUERY_VALUE, addr hKey
cmp eax,ERROR_SUCCESS
jz @ok
ret
@ok :
invoke MessageBoxA, 0, 0, 0, 0
ret
end Main
All work fine. but if i put :
.DATA
someByteHere db 0 ; [COLOR=red]<< HERE[/COLOR]
KeyName db 'S', 0, 'o', 0, 'f', 0, 't', 0, 'w', 0, 'a', 0, 'r', 0, 'e', 0, "\", 0, 'M', 0, 'y', 0, 'K', 0, 'e', 0, 'y', 0, "\", 0,0,0
hKey dd 0
in this case, RegOpenKeyExW return some strange value.
In fact i can't declare DB value (like text) BEFORE KeyName.
If it's DD value, it's OK.
I've declared RegOpenKeyExW as :
RegOpenKeyExW PROTO WINAPI :DWORD, :DWORD, :DWORD, :DWORD, :DWORD
What's wrong?
I'm under win2k (nt5).
I think it has something to do with alignment. I've meet the same thing many times and I have fixed it like this:
So the align keyword does the magic.
If somebody knows why this happens and how the align really fixes this it would be nice to know.
Sami
.DATA
someByteHere db 0 ; << HERE
align
KeyName db 'S', 0, 'o', 0, 'f', 0, 't', 0, 'w', 0, 'a', 0, 'r', 0, 'e', 0, "\", 0, 'M', 0, 'y', 0, 'K', 0, 'e', 0, 'y', 0, "\", 0,0,0
hKey dd 0
So the align keyword does the magic.
If somebody knows why this happens and how the align really fixes this it would be nice to know.
Sami
hi
pentium processors can easily access memory locations that are 32-bit aligned. i.e memory locations that are divisible by 4.
otherwise they have to do a little jugling up b4 they can access those location, which, if not anything else, slows down the program.
"align" probebly aligns the next location to a 32-bit boundry location.
some compiler do that for u.
it is a good idea to do that specially in case of structures. e.g in C u can do something like the following:
#pragma pack(x)
where x is the number of bytes.
e.g #pragma pack(4) mean 32-bit packing(default)
that mean every member of the structure will start from a 32-bit aligned location. u can check if out by defining a structure and then taking sizeof() that structure.
regards,
goto
pentium processors can easily access memory locations that are 32-bit aligned. i.e memory locations that are divisible by 4.
otherwise they have to do a little jugling up b4 they can access those location, which, if not anything else, slows down the program.
"align" probebly aligns the next location to a 32-bit boundry location.
some compiler do that for u.
it is a good idea to do that specially in case of structures. e.g in C u can do something like the following:
#pragma pack(x)
where x is the number of bytes.
e.g #pragma pack(4) mean 32-bit packing(default)
that mean every member of the structure will start from a 32-bit aligned location. u can check if out by defining a structure and then taking sizeof() that structure.
regards,
goto
thx it work :alright: