News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SHGetValue dillema

Started by Ksbunker, April 04, 2008, 05:01:55 AM

Previous topic - Next topic

Ksbunker

I cannot see a single error yet this fails to execute. Debugger says error lies inside the SHGetValue() in shlwapi.dll. Exact error message is below the snippet.

    .486
    .model flat, stdcall
    option casemap:none   ; case sensitive

; ####################################################

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\advapi32.inc ; needed for Registry functions
    include \masm32\include\shlwapi.inc

    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\advapi32.lib  ; needed for Registry functions
includelib \masm32\lib\shlwapi.lib

.const

MAXLENGTH equ 256

.data

Directory db "\SOFTWARE\Macromedia\FlashPlayerActiveX", 0
Value db "Path", 0
bSize dd 0
Buffer db MAXLENGTH dup(0)

.code

start:

mov bSize, SIZEOF Buffer
Invoke SHGetValue, HKEY_LOCAL_MACHINE, ADDR Directory, ADDR Value, REG_SZ, ADDR Buffer, bSize
Invoke MessageBox, 0, ADDR Buffer, 0, 0
Invoke ExitProcess, 0

end start


77F70CC7   8B07             MOV EAX,DWORD PTR DS:[EDI]    <----BREAKS HERE!
77F70CC9   8945 20          MOV DWORD PTR SS:[EBP+20],EAX
77F70CCC   8B5D 14          MOV EBX,DWORD PTR SS:[EBP+14]
77F70CCF   68 200DF777      PUSH shlwapi.77F70D20                    ; UNICODE "SHRegGetValueA"
77F70CD4   57               PUSH EDI
77F70CD5   FF75 1C          PUSH DWORD PTR SS:[EBP+1C]
77F70CD8   53               PUSH EBX
77F70CD9   FF75 08          PUSH DWORD PTR SS:[EBP+8]
77F70CDC   E8 2235FFFF      CALL shlwapi.77F64203


With error break (77F70CC7);

DS:[00000100]=???
EAX=00000000

Whats wrong?


sinsi

Looks like all params except the first need to be pointers
Quote
DWORD SHGetValue(
    HKEY hkey,
    LPCTSTR pszSubKey,
    LPCTSTR pszValue,
    LPDWORD pdwType,
    LPVOID pvData,
    LPDWORD pcbData
);


.const

MAXLENGTH equ 256

.data

Directory db "\SOFTWARE\Macromedia\FlashPlayerActiveX", 0
Value db "Path", 0
bSize dd 0
Buffer db MAXLENGTH dup(0)
dwType dd REG_SZ
.code

start:

mov bSize, SIZEOF Buffer
Invoke SHGetValue, HKEY_LOCAL_MACHINE, ADDR Directory, ADDR Value, ADDR dwType, ADDR Buffer, ADDR bSize


untested, because I am lazy...
Light travels faster than sound, that's why some people seem bright until you hear them.

arroso

http://msdn2.microsoft.com/en-us/library/bb773495(VS.85).aspx

hkey
    A handle to the currently open key, or any of the following predefined values.

    HKEY_CLASSES_ROOT
    HKEY_CURRENT_CONFIG
    HKEY_CURRENT_USER
    HKEY_DYN_DATA (MicrosoftWindows95 only)
    HKEY_LOCAL_MACHINE
    HKEY_PERFORMANCE_DATA (Microsoft Windows NTonly)
    HKEY_USERS