flat assembler
Message board for the users of flat assembler.

Index > Windows > struct LPSHELLEXECUTEINFO

Author
Thread Post new topic Reply to topic
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
Quote:
typedef struct _SHELLEXECUTEINFO {
DWORD cbSize; // dw ?
ULONG fMask; // What??? Very Happy
HWND hwnd; // dd ?
LPCTSTR lpVerb; // NULL, edit, etc.
LPCTSTR lpFile; // null terminated aka db 'la-la',0
LPCTSTR lpParameters; // OK!
LPCTSTR lpDirectory; // NULL, etc.
int nShow; // SW_SHOW
HINSTANCE hInstApp; // dd ?
LPVOID lpIDList; // Shocked
LPCTSTR lpClass; // GUID Rolling Eyes
HKEY hkeyClass; // ...
DWORD dwHotKey; // NULL ?
union {
HANDLE hIcon;
HANDLE hMonitor;
} DUMMYUNIONNAME;
// Who is this? Razz ???
HANDLE hProcess;
} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;


Please, example it for me? Embarassed
Symply i need ShellExecuteEx with delay for terminate a console application...

_________________
Windows 9, FL Studio 19
Post 09 Sep 2010, 12:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 18847
Location: In your JS exploiting you and your system
revolution
Everything is a dword sized value
Post 09 Sep 2010, 12:54
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
very formidably function labyrinth...
i see some examples in a web with regiser manipulation with is the structure
i'm hands up!
Smile
Post 09 Sep 2010, 20:58
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3489
Location: vpcmipstrm
bitRAKE
Code:
struc SHELLEXECUTEINFO {
  .:
  .cbSize       dd ?
  .fMask        dd ?
  .hwnd         dd ?
  .lpVerb       dd ?
  .lpFile       dd ?
  .lpParameters dd ?
  .lpDirectory  dd ?
  .nShow        dd ?
  .hInstApp     dd ?
  .lpIDList     dd ?
  .lpClass      dd ?
  .hkeyClass    dd ?
  .dwHotKey     dd ?
  label .hIcon dword
  .hMonitor     dd ?
  .hProcess     dd ?
  .. = $ - .
}    
...and slightly different for PE64 - all the handles and pointers become DQ's? Also, .nShow probably has a dword following it for padding.
Post 10 Sep 2010, 07:03
View user's profile Send private message Visit poster's website Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
link
What is different of fasm ?

Code:
LOCAL sei:SHELLEXECUTEINFO
    
    INVOKE RtlZeroMemory, ADDR sei, SIZEOF sei
    mov sei.cbSize, SIZEOF SHELLEXECUTEINFO
    mov eax, hWnd
    mov sei.hwnd, eax
    mov sei.fMask, SEE_MASK_FLAG_DDEWAIT OR SEE_MASK_FLAG_NO_UI
    mov eax, CTXT("runas")
    mov sei.lpVerb, eax
    mov eax, pFilename
    mov sei.lpFile, eax
    mov eax, pParameters 
    mov sei.lpParameters, eax
    mov sei.nShow, SW_SHOWNORMAL
    INVOKE ShellExecuteEx, ADDR sei
la-la-la-...    


SIZEOF sei - Shocked $-sei ?

I don't need directly this example but i should need somthing about ShellExecuteEx() exampe. Smile
Post 14 Sep 2010, 16:10
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3489
Location: vpcmipstrm
bitRAKE
Please send money to my paypal account ( bitRAKE _ gmail.com ): I need help buying my next computer. Thank you.
Code:
format PE GUI 4.0
include 'win32ax.inc'

.data

SEE_MASK_DEFAULT                = 0x00000000
SEE_MASK_CLASSNAME              = 0x00000001
SEE_MASK_CLASSKEY               = 0x00000003
SEE_MASK_IDLIST                 = 0x00000004
SEE_MASK_INVOKEIDLIST           = 0x0000000C
SEE_MASK_ICON                   = 0x00000010
SEE_MASK_HOTKEY                 = 0x00000020
SEE_MASK_NOCLOSEPROCESS         = 0x00000040
SEE_MASK_CONNECTNETDRV          = 0x00000080
SEE_MASK_NOASYNC                = 0x00000100
SEE_MASK_FLAG_DDEWAIT           = 0x00000100
SEE_MASK_DOENVSUBST             = 0x00000200
SEE_MASK_FLAG_NO_UI             = 0x00000400
SEE_MASK_UNICODE                = 0x00004000
SEE_MASK_NO_CONSOLE             = 0x00008000
SEE_MASK_ASYNCOK                = 0x00100000
SEE_MASK_HMONITOR               = 0x00200000
SEE_MASK_NOZONECHECKS           = 0x00800000
SEE_MASK_NOQUERYCLASSSTORE      = 0x01000000
SEE_MASK_WAITFORINPUTIDLE       = 0x02000000
SEE_MASK_FLAG_LOG_USAGE         = 0x04000000

struc SHELLEXECUTEINFO {
  .:
  .cbSize       dd ?
  .fMask        dd ? 
  .hwnd         dd ? 
  .lpVerb       dd ? 
  .lpFile       dd ? 
  .lpParameters dd ? 
  .lpDirectory  dd ? 
  .nShow        dd ? 
  .hInstApp     dd ? 
  .lpIDList     dd ? 
  .lpClass      dd ? 
  .hkeyClass    dd ? 
  .dwHotKey     dd ? 
  label .hIcon dword 
  .hMonitor     dd ? 
  .hProcess     dd ? 
  .. = $ - . 

  ; Requests the OS to run the executable elevated.
  ; Returns TRUE if successful, or FALSE otherwise.
  ; If FALSE then return error information in edx
  macro .RunElevated hWnd*,pFilename*,pParameters* \{
    \local ..okay
    invoke RtlZeroMemory,.,..
    mov [.cbSize],..
    mov [.hwnd],hWnd
    mov [.fMask],SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI
    mov [.lpVerb],_runas
    mov [.lpFile],pFilename
    mov [.lpParameters],pParameters
    mov [.nShow],SW_SHOWNORMAL
    invoke ShellExecuteEx,.
    test eax,eax
    jnz ..okay
    invoke GetLastError
    mov edx, eax
    xor eax, eax
    ..okay:
  \}
}

  _runas   db 'runas',0
  _notepad db 'notepad.exe',0
  _test    db 'w32.semiono.asm',0

  align 4

  sei SHELLEXECUTEINFO

.code

start:

  sei.RunElevated 0,_notepad,_test

  invoke  ExitProcess,0

.end start    
...you need to post your code because mine is working well. Very Happy
Post 14 Sep 2010, 17:47
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
semiono,

Didn't you notice «..= $ - .» line? sei.. is your SIZEOF SHELLEXECUTEINFO.

Using struct macro instead can be easier (it supports union too and defines sizeof.struct name).
Post 14 Sep 2010, 17:51
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
This is really grand step for me to understand all about ms api to go himself. Very Happy
I don't have job, and not have money because i'm lazzy

bitRAKE, what your computer is last? Cool
if you come we can drink beer

Thanks to all good people! I'm sorrii Very Happy Embarassed
Post 14 Sep 2010, 18:52
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3489
Location: vpcmipstrm
bitRAKE
Learning assembler and English = not so lazy. Very Happy

Trying to confuse you with this line:
Code:
invoke RtlZeroMemory,.,..    
Laughing (x86 braille)
Post 14 Sep 2010, 19:45
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
bitRAKE,

brainfasm? Wink
Post 14 Sep 2010, 20:03
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
i found code in google and copypast it,
i not understand this thing ))
Smile

_________________
Windows 9, FL Studio 19
Post 14 Sep 2010, 20:25
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
Code:
include '%fasm%/win64ax.inc'
section '.code' executable
start:
        sub rsp,8

        invoke RtlZeroMemory,sei,MAX_PATH ; b = $ - sei

        mov [sei.cbSize],MAX_PATH
        mov [sei.fMask],NULL
        mov [sei.hwnd],NULL
        mov [sei.lpVerb],NULL
        mov [sei.lpFile],a
        mov [sei.lpParameters],NULL
        mov [sei.nShow],SW_NORMAL
        mov [sei.hInstApp],NULL

        invoke ShellExecuteEx,sei
        cmp eax,NULL
        jnz exit

        invoke MessageBoxTimeout,HWND_DESKTOP,'','',MB_TOPMOST,LANG_NEUTRAL,5000
exit:
        invoke ExitProcess,NULL

section '.data' readable writeable

        a db 'notepad.exe',NULL

        b = $ - sei

struct SHELLEXECUTEINFO

        cbSize dd NULL
        fMask dd NULL
        hwnd dd NULL
        lpVerb dd NULL
        lpFile dd NULL
        lpParameters dd NULL
        lpDirectory dd NULL
        nShow dd NULL
        hInstApp dd NULL
        lpIDList dd NULL
        lpClass dd NULL
        hkeyClass dd NULL
        dwHotKey dd NULL
        label .hIcon dword
        hMonitor dd NULL
        hProcess dd NULL
ends
        sei SHELLEXECUTEINFO

section '.idata' import readable

        library kernel32,'KERNEL32.DLL',shell32,'SHELL32.DLL',user32,'USER32.DLL'
        include '%fasm%/api/kernel32.inc'
        include '%fasm%/api/shell32.inc'
        include '%fasm%/api/user32.inc'    


I'll be back Very Happy

Why my interpretation bitRAKE's code do not work? Fully quiet!
RtlZeroMemory - something wrong here. I can't it.
b = $ - sei - nothing happen

_________________
Windows 9, FL Studio 19
Post 16 Aug 2022, 14:18
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 3489
Location: vpcmipstrm
bitRAKE
When you do 'b = $ - sei', $ is equal to sei. Very Happy

In 64-bit all the pointers and handles need to be promoted to 64-bit.
Post 16 Aug 2022, 19:04
View user's profile Send private message Visit poster's website Reply with quote
Hrstka



Joined: 05 May 2008
Posts: 35
Location: Czech republic
Hrstka
For 64-bit you need to make some changes like this:
Code:
format PE64 GUI
entry start
include 'win64a.inc'

section '.code' code readable executable
start:
        sub rsp,8
        invoke RtlZeroMemory,sei,SEI_SIZE

        mov [sei.cbSize],SEI_SIZE
        ; cannot move 64-bit value directly to memory, need to use a register
        mov rax,a
        mov [sei.lpFile],rax
        mov [sei.nShow],SW_SHOWNORMAL
        invoke ShellExecuteEx,sei

        cmp rax,NULL
        jnz exit

        invoke MessageBoxTimeout,HWND_DESKTOP,message,title,MB_TOPMOST,LANG_NEUTRAL,5000
exit:
        invoke ExitProcess,NULL

section '.data' data readable writeable

struc SHELLEXECUTEINFO64 {
  .cbSize       dd ?
  .fMask        dd ?
  .hwnd         dq ?
  .lpVerb       dq ?
  .lpFile       dq ?
  .lpParameters dq ?
  .lpDirectory  dq ?
  .nShow        dd ?, ?
  .hInstApp     dq ?
  .lpIDList     dq ?
  .lpClass      dq ?
  .hkeyClass    dq ?
  .dwHotKey     dd ?, ?
  label .hIcon qword 
  .hMonitor     dq ?
  .hProcess     dq ?
}

  a db 'notepad.exe',NULL
  title db 'Error',NULL
  message db 'Something went wrong',NULL

  align 16
  sei SHELLEXECUTEINFO64
  SEI_SIZE = $-sei

section '.idata' import data readable writeable

  library kernel ,'KERNEL32.DLL',\
          shell, 'SHELL32.DLL',\
          user, 'USER32.DLL'

  import kernel,\
         ExitProcess,'ExitProcess',\
         RtlZeroMemory,'RtlZeroMemory'

  import shell,\
         ShellExecuteEx,'ShellExecuteExA'

  import user,\
         MessageBoxTimeout,'MessageBoxTimeoutA'

section '.reloc' fixups data readable discardable    
Post 17 Aug 2022, 11:33
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
Code:
include '%fasm%/win64ax.inc'
section '.code' executable
start:
        sub rsp,8

        invoke RtlZeroMemory,sei,SEI_SIZE

        mov [sei.cbSize],SEI_SIZE
        mov [sei.lpFile],a

        invoke ShellExecuteEx,sei
        cmp eax,NULL
        jnz exit

        invoke MessageBoxTimeout,HWND_DESKTOP,'','',MB_TOPMOST,LANG_NEUTRAL,1000
exit:
        invoke ExitProcess,NULL

section '.data' readable

        a db 'calc.exe',NULL

section '.data' readable writeable

struct SHELLEXECUTEINFO

        cbSize dd NULL
        fMask dd NULL
        hwnd dq NULL
        lpVerb dq NULL
        lpFile dq NULL
        lpParameters dq NULL
        lpDirectory dq NULL
        nShow dd NULL,NULL
        hInstApp dq NULL
        lpIDList dq NULL
        lpClass dq NULL
        hkeyClass dq NULL
        dwHotKey dd NULL,NULL
        label .hIcon qword
        hMonitor dq NULL
        hProcess dq NULL
ends
        align 16
        sei SHELLEXECUTEINFO
        SEI_SIZE = $ - sei

section '.idata' import readable

        library kernel32,'KERNEL32.DLL',shell32,'SHELL32.DLL',user32,'USER32.DLL'
        include '%fasm%/api/kernel32.inc'
        include '%fasm%/api/shell32.inc'
        include '%fasm%/api/user32.inc'
    


Fully work! Thank you, Hrstka!

Quote:

; cannot move 64-bit value directly to memory, need to use a register
mov rax,a
mov [sei.lpFile],rax

Maybe you right. I move it direct but no problem)
My problem has been that SEI_SIZE must follow strong after structure.
And sometime ago I meet this like dword/qword but in structure it depend by every personal parameter.
nShow dword lpClass quord etc. Thanx!
Post 17 Aug 2022, 19:46
View user's profile Send private message Reply with quote
semiono



Joined: 31 Aug 2007
Posts: 181
Location: section '.code' executable
semiono
Quote:

When you do 'b = $ - sei', $ is equal to sei.


SEI_SIZE Very Happy
Post 17 Aug 2022, 20:09
View user's profile Send private message 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.