flat assembler
Message board for the users of flat assembler.

Index > Windows > REG_BINARY structure...

Author
Thread Post new topic Reply to topic
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
Image

This is 4 bytes per blocks: [unknown][x][y][width][height]

I need very help to regwrite binary type value. Before I known reg_sz and dword only " Image" Smile

And I could have problem to conversion data like CXSCREEN... to valid datas

Task is here:
Code:
        HKCU = HKEY_CURRENT_USER
        REGN = REG_OPTION_NON_VOLATILE

        invoke GetSystemMetrics,SM_CXSCREEN
        invoke wsprintf,@x,'%d',eax

        invoke GetSystemMetrics,SM_CYSCREEN
        sub eax,52 ; ommit taskbar size
        invoke wsprintf,@y,'%d',eax

        invoke RegCreateKeyEx,HKCU,'Software\Steinberg\Cubase SX',\
               NULL,NULL,REGN,KEY_WRITE,NULL,phkResult,NULL
        invoke RegSetValueEx,[phkResult],'Framewindow',NULL,REG_BINARY,????,???
        invoke RegCloseKey,[phkResult]

    

I very need it Embarassed Confused Very Happy

_________________
Memory=8388608


Last edited by semiono on 27 Aug 2010, 20:41; edited 3 times in total
Post 27 Aug 2010, 20:24
View user's profile Send private message ICQ Number Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
Try something like this:
Code:
         invoke  RegSetValueEx, [phkResult], RegValName, 0, REG_BINARY, <Address of data buffer>, <Length of the data>
           test    eax, eax
            jnz     .failed
             
            (...)
               
            RegValName db 'Framewindow', 0
    
Post 27 Aug 2010, 20:34
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
Is this valid the part of buffer format — invoke wsprintf,@x,'%d',eax ?
OK! I try it.
Post 27 Aug 2010, 20:38
View user's profile Send private message ICQ Number Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
Code:
        invoke GetSystemMetrics,SM_CXSCREEN
        ;invoke wsprintf,zzzz,'%u',eax
        invoke wsprintf,zzzz,'%x',eax
...
        invoke RegSetValueEx,[phkResult],'Framewindow',NULL,REG_BINARY,zzzz,4    

reg [34383000] 480h
reg [31313500] 1152
This should be little endian direction... Confused

http://msdn.microsoft.com/en-us/library/ms724884(v=VS.85).aspx
"REG_BINARY | Binary data in any form."
nothing about :\

How possible to format the buffer? Embarassed

--
invoke RegSetValueEx,[phkResult],'Framewindow',NULL,REG_BINARY,eax,4
Razz
Post 28 Aug 2010, 10:45
View user's profile Send private message ICQ Number Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
semiono wrote:
This should be little endian direction... Confused (...)
How possible to format the buffer? Embarassed
If you want to change endianness of your data you can use 'bswap' instruction. Try this code and observe (in a some debugger) how the eax content is changing:
Code:
mov     eax, 0x01020304
bswap        eax    
Wink
Post 28 Aug 2010, 10:53
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
I've do it! Yes!
Code:
section '.code' executable
start:
        xor eax,eax
        mov eax,18h
        mov [i],eax ; task bar size top
        invoke GetSystemMetrics,SM_CXSCREEN
        mov [x],eax
        invoke GetSystemMetrics,SM_CYSCREEN
        sub eax,52 ; ommit task bar size + bottom some size cosmetic
        mov [y],eax

        invoke RegCreateKeyEx,HKCU,'Software\Software\Steinberg\Cubase SX',NULL,NULL,REGN,KEY_WRITE,NULL,phkResult,NULL
        invoke RegSetValueEx,[phkResult],'Framewindow',NULL,REG_BINARY,!,20
        invoke RegCloseKey,[phkResult]
exit:
        invoke ExitProcess,NULL

section '.data' readable writable
        HKCU = HKEY_CURRENT_USER
        REGN = REG_OPTION_NON_VOLATILE
        ! dq NULL
        i dd ?
        x dd ?
        y dd ?
        phkResult dd ?
    


in registry 00 00 00 00 00 00 00 00 18 00 00 00 80 04 00 00 2c 03 00 00 (1152x812)

Please, examine me if code could has been hidden errors posible or code is not clean?


-------------------->8--
Big thanks, MHajduk! to following post >
"mov dword [i]" ))) i'm lame!


Last edited by semiono on 29 Aug 2010, 10:25; edited 8 times in total
Post 28 Aug 2010, 20:41
View user's profile Send private message ICQ Number Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6038
Location: Poland
MHajduk
semiono, checking return code (stored in the eax register) of the WinAPI functions is a good programming practice. Wink

I've made some minor corrections of your code Wink
Code:
format PE console

include 'win32ax.inc'

section '.code' code executable
 
start: 
        mov     dword [i], 18h ; task bar size top
 
        invoke       GetSystemMetrics, SM_CXSCREEN 
        test  eax, eax
        jz  failed
        
        mov       [x], eax
 
        invoke GetSystemMetrics, SM_CYSCREEN
       test    eax, eax
        jz  failed
 
        sub      eax, 52 ; omit task bar size + some cosmetic of the bottom size 
        mov [y], eax 

        invoke RegCreateKeyEx, HKCU, 'Software\Software\Steinberg\Cubase SX', NULL, NULL, REGN, KEY_WRITE,NULL, phkResult, NULL
        test   eax, eax
        jnz failed
        
        invoke    RegSetValueEx, [phkResult], 'Framewindow', NULL, REG_BINARY, !, 20
        test    eax, eax
        jnz failed
      
        invoke      RegCloseKey, [phkResult]
        test        eax, eax
        jnz failed
      
    jmp     exit
        
failed:
     stdcall ShowLastError, HWND_DESKTOP
  
exit: 
        invoke       ExitProcess, NULL 

; This procedure shows error messages in a human-readable form. Wink
;
proc   ShowLastError, hwnd

     locals
              Buffer dd ?
 endl

    push    ebx

     invoke  GetLastError

    lea     ebx, [Buffer]
       invoke  FormatMessage, FORMAT_MESSAGE_ALLOCATE_BUFFER + FORMAT_MESSAGE_FROM_SYSTEM, 0, eax, LANG_NEUTRAL, ebx, 0, 0
 invoke  MessageBox, [hwnd], [Buffer], NULL, MB_ICONERROR + MB_OK
            
    invoke  LocalFree, [Buffer]

     pop     ebx

     ret
endp


section '.data' data readable writable
 
        HKCU = HKEY_CURRENT_USER 
        REGN = REG_OPTION_NON_VOLATILE
        
        ! dq NULL 
        i dd ? 
        x dd ? 
        y dd ?
        
        phkResult dd ? 

.end start              
Post 28 Aug 2010, 21:39
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 176
Location: section '.code' executable
semiono
My first macro! Image
Code:
        macro rc r1,r2,r3,r4 {invoke RegSetValueEx,[phkResult],r1,NULL,r2,r3,r4}

        rc 'Code',REG_SZ,'59F0D04B31ADF0026C08E6041FD477284DA2910FDC11CDEB',48
        rc 'Current',REG_SZ,'Semiono',7
        rc 'Name',REG_DWORD,@00000001,4 ; @00000001 dd 0x00000001    

)))
Post 01 Sep 2010, 21:13
View user's profile Send private message ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.