[QUOTE=Narue]Welcome! What assembler are you using? Are you working directly with the Win32 API for assembly GUI applications or are you actually doing something fun?
I am using Masm for straight assembly API like them good old DOS days. :-)
Right now I am struggling with this code.
Thanks. I have the SDK, but it's a little cryptic.
There is a problem with one/both RegCloseKey statements.
Maybe:
1. Their order should be reversed
2. Something else is needed in the code
What I want Ollydbg to do is go to my breakpoints and stop so I can see what's going on.
Then go one instruction at a time. This computer F-keys does their own thing.
; creatsub.asm Create a subkey of an existing registry key
; Help from AsmER,
; SLOW and EASY with this code !!!
.386
.MODEL FLAT, STDCALL
OPTION CASEMAP: NONE
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\advapi32.inc
include \masm32\macros\macros.asm
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\advapi32.lib
.DATA
APPKey BYTE "Marzipan", 0
SecondKey BYTE "basement", 0
Opened_Key BYTE "Registry Key sucessfully opened.",0
No_Key BYTE "Registry Key not present!",0
Key_Closed BYTE "Sub_Key creation suceeded.",0
Problem BYTE "Problem closing Registry Key !",0
Sample BYTE "Sample",0 ; title of message box
.DATA?
RegH PHKEY ? ; Handle for registry key DON'T use ADDR with these!
SubRegKey PHKEY ?
.CODE
Start:
jmp Next
Fill db "db eax",0
Next:
invoke RegOpenKey, HKEY_CURRENT_USER, ADDR APPKey, ADDR RegH ;to get handle of already created
;registry key.
.IF EAX == ERROR_SUCCESS
invoke MessageBox, 0, ADDR Opened_Key, ADDR Sample,MB_ICONINFORMATION
.ELSE
invoke MessageBox, 0, ADDR No_Key, ADDR Sample,MB_ICONINFORMATION
invoke ExitProcess, 0 ; exit, we have a problem
.ENDIF
invoke RegCreateKey, RegH, ADDR SecondKey, SubRegKey ;to create or open
;already existing sub reg. key
invoke RegCloseKey, RegH ; close handle for reg. key
int 3
invoke RegCloseKey, SubRegKey ; close handle for reg. key
int 3
.IF EAX == ERROR_SUCCESS
invoke MessageBox, 0, ADDR Key_Closed, ADDR Sample,MB_ICONINFORMATION
.ELSE ; something's amiss
invoke MessageBox, 0, ADDR Problem, ADDR Sample,MB_ICONINFORMATION
.ENDIF
invoke ExitProcess, 0
END Start