Protocol Handler Launcher

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

; Launches a Program when registered as a Protocol Handler
; The protocol is stripped from the argument (here hardcoded 7 digits "abcdef:")

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

.386
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive

include \MASM32\INCLUDE\windows.inc
include \MASM32\INCLUDE\kernel32.inc
include \MASM32\INCLUDE\shell32.inc
include \MASM32\INCLUDE\masm32.inc
include \masm32\macros\macros.asm

includelib \MASM32\LIB\kernel32.lib
includelib \MASM32\LIB\shell32.lib
includelib \MASM32\LIB\masm32.lib

Init PROTO
; #########################################################################

.data
open db "open",0
dir db 512 dup (0) ; buffer for command line
file db 1024 dup (0) ; buffer for the file to open
protocol db 64 dup (0) ; buffer for the Protocol Handler part

.code

start:

invoke GetCL,1,ADDR dir
invoke GetCL,2,ADDR file

mov edi, ptr$(protocol) ; put pointer to protocol
invoke ShellExecute,0,ADDR open,ADDR dir,ADDR file+7,NULL,SW_SHOW ; strip calldw:
invoke ExitProcess,eax

end start

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

Posted in IT