flat assembler
Message board for the users of flat assembler.

Index > Windows > ieSwitchImage win32 console completed,source code included:)

Author
Thread Post new topic Reply to topic
vbVeryBeginner



Joined: 15 Aug 2004
Posts: 884
Location: \\world\asia\malaysia
vbVeryBeginner
hi,
i just finished coding the win32 console version of ieSwitchImage.
feel free to take a glance at it :p and suggest improvement :)

i guess this code is usefull particularly for those (like me) who just
step their foot inside the world of win32 asm.

this application won't be completed (or might take long time instead of 4 days ) if
without the help from the nice guys in this board, i wish to take this chance to
express my thanks to people like privalov, vortex, tommy, pelaillo, decard, roticv
for their excellent "after-download" support :) and those who have help directly
or indirectly :)

to: vortex,
i change your code a bit, coz i need color :p

Code:
;sorry if incompatible or ugly displayed, i am in tab 5 mode :p
;--------------------------------------------------------------
format PE console 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable
      HWND_BROADCAST          equ     0FFFFh
      WM_SETTINGCHANGE        equ     1Ah
 SMTO_ABORTIFHUNG        equ     2h
  
    crlf                    db      13,10,0
     
    conTitle                db      'IE Switch Image Utility - Win32 Console Mode',0
  conTitleLine    db      '--------------------------------------------',13,10,0
    conColor                dd      ?
   conHandleOut    dd      ?
   conHandleIn     dd      ?
   conReturn               dd      ?
   conBuffer:  times 2 db 0
        conBufferRead   dd      ?
   
    regHandle               dd      ?
   regKeySub               db      'Software\Microsoft\Internet Explorer\Main',0
  regItem         db      'Display Inline Images',0
 regItemType     dd      ?
   regItemBuffer   dd      4
   regItemValue:       times 4 db 0
        regItemTonggle  dd      ?               ;to store address of ieShowYes or ieShowNo

      ieShowYes               db      'yes',0
   ieShowNo                db      'no',0
    
    ieLbl0          db      'Current Show Image Status : ',0
      ieLbl1          db      'Press ',0
        ieLbl2          db      '[ spacebar ]',0
  ieLbl3          db      ' to tonggle image shows/hides or',13,10,'others keys to exit : ',0
 
section '.code' code readable executable
      start:
          ; +-----------------------+
         ; | set the console title |
         ; +-----------------------+
         invoke  SetConsoleTitle,conTitle
            ; +------------------------+
                ; | set the console handle |
                ; +------------------------+
                invoke  GetStdHandle,STD_OUTPUT_HANDLE
                              mov     [conHandleOut],eax
          invoke  GetStdHandle,STD_INPUT_HANDLE
                               mov     [conHandleIn],eax
           ; +--------------------------------------------------------------------------------+
                ; | open registry and check HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer |
             ; | \Main\Display Inline Images                                                                                  |
                ; +--------------------------------------------------------------------------------+
                invoke  RegOpenKey,HKEY_CURRENT_USER,regKeySub,regHandle
            invoke  RegQueryValueEx,[regHandle],regItem,0,regItemType,regItemValue,regItemBuffer
                                call    ie_header
           invoke  lstrcmpi,ieShowYes,regItemValue
                             cmp     eax,0
                               je      ie_color_yes
                                jmp     ie_color_no
         
                            ie_color_yes:
                                                   mov     [conColor],159
                                                      lea     eax,[ieShowNo]                  ;tonggle value
                                                      mov     [regItemTonggle],eax
                                        stdcall console_write,ieShowYes
                                                     jmp     ie_color

                                ie_color_no:
                                                    mov     [conColor],207
                                                      lea     eax,[ieShowYes]         ;tonggle value
                                                      mov     [regItemTonggle],eax
                                        stdcall console_write,ieShowNo

                          ie_color:
                                                       mov     [conColor],7
                                        stdcall console_write,crlf
                                  stdcall console_write,ieLbl1
                                                        mov     [conColor],47
                                       stdcall console_write,ieLbl2
                                                        mov     [conColor],7
                                        stdcall console_write,ieLbl3
                ; +--------------------------------------------------------------+
          ; | we will need to wait for user keyboard [spacebar] input here |
          ; +--------------------------------------------------------------+
          invoke  SetConsoleMode,[conHandleIn],0
              invoke  ReadConsole,[conHandleIn],conBuffer,1,conBufferRead,0
               stdcall console_write,conBuffer
                             cmp     byte [conBuffer],32                     ;whether the pressed key is spacebar
                                je      reg_tonggle
 
    ; +-----------------------------+
   ; | Program Execution Ends Here |
   ; +-----------------------------+
   exit:
           invoke  RegCloseKey,[regHandle]
             invoke  ExitProcess,0
       
    ie_header:
              stdcall console_write,crlf
                          mov     [conColor],143
              stdcall console_write,conTitle
              stdcall console_write,crlf
          stdcall console_write,conTitleLine
                          mov     [conColor],7
                stdcall console_write,ieLbl0
                ret
 
    reg_tonggle:
            mov             [regItemType],1
             invoke  lstrlen,[regItemTonggle]
            invoke  RegSetValueEx,[regHandle],regItem,0,[regItemType],[regItemTonggle],eax
              invoke  SendMessageTimeout,HWND_BROADCAST,WM_SETTINGCHANGE,0,regKeySub,SMTO_ABORTIFHUNG,1000,0
                              jmp     exit
        
    proc    console_prinst,txt
                          txtBuffer       dd      ?
                           txtLength       dd      ?
                   enter
                               invoke  lstrlen,[txt]
                                               mov     [txtLength],eax
                                             lea     eax,[txtBuffer]
                             invoke  WriteFile,[conHandleOut],[txt],[txtLength],eax,NULL
                                         mov     eax,[txtBuffer]
                     return
      endp
        
    proc console_write,txt
              enter
                       invoke  SetConsoleTextAttribute,[conHandleOut],[conColor]
                   invoke  lstrlen,[txt]
                       invoke  WriteConsole,[conHandleOut],[txt],eax,conReturn,0
           return
      endp

section '.idata' import data readable writeable
       library kernel32,'KERNEL32.DLL',\
                        advapi32,'ADVAPI32.DLL',\
                        user32,'USER32.DLL'
       
    import  kernel32,\
                 lstrlen,                                        'lstrlenA',\
                     lstrcmpi,                                       'lstrcmpiA',\
                    SetConsoleTitle,                        'SetConsoleTitleA',\
                     SetConsoleTextAttribute,                'SetConsoleTextAttribute',\
                      GetStdHandle,                           'GetStdHandle',\
                 WriteConsole,                           'WriteConsoleA',\
                        ReadConsole,                            'ReadConsoleA',\
                 SetConsoleMode,                 'SetConsoleMode',\
                       ExitProcess,                            'ExitProcess'
                     
    import  advapi32,\
                 RegOpenKey,                             'RegOpenKeyA',\
                  RegQueryValueEx,                        'RegQueryValueExA',\
                     RegSetValueEx,                          'RegSetValueExA',\
                       RegCloseKey,                            'RegCloseKey'
     
    import  user32,\
                   SendMessageTimeout,                     'SendMessageTimeoutA'                 
    


sincerely,
vbVeryBeginner, d(:))b
http://sulaiman.thefreebizhost.com


Description:
Download
Filename: e1.asm
Filesize: 4.9 KB
Downloaded: 107 Time(s)

Post 20 Aug 2004, 16:50
View user's profile Send private message Visit poster's website 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 GitHub, YouTube, Twitter.

Website powered by rwasa.