.Handle(snapshot))

	var processEntry processEntry32
	processEntry.dwSize = uint32(unsafe.Sizeof(processEntry))
	ok, _, e1 := Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
	if ok == 0 {
		err = fmt.Errorf("Process32First: %v", e1)
		return
	}

	for {
		if processEntry.th32ProcessID == uint32(pid) {
			pe = &processEntry
			return
		}

		ok, _, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
		if ok == 0 {
			err = fmt.Errorf("Process32Next: %v", e1)
			return
		}
	}
}

func getppid() (pid int, err error) {
	pe, err := getProcessEntry(os.Getpid())
	if err!= nil {
		return
	}

	pid = int(pe.th32ParentProcessID)
	return
}

// StartedByExplorer returns true if the program was invoked by the user double-clicking
// on the executable from explorer.exe
//
// It is conservative and returns false if any of the internal calls fail.
// It does not guarantee that the program was run from a terminal. It only can tell you
// whether it was launched from explorer.exe
func StartedByExplorer() bool {
	ppid, err := getppid()
	if err!= nil {
		return false
	}

	pe, err := getProcessEntry(ppid)
	if err!= nil {
		return false
	}

	name := syscall.UTF16ToString(pe.szExeFile[:])
	return name == "explorer.exe"
}
 # -*- coding: binary -*-

module Rex
  module Proto
    module Kerberos
      module Model
        # This class provides a representation of a principal, an asset (e.g., a
        # workstation user or a network server) on a network.
        class PrincipalName < Element

          # @!attribute name_type
          #   @return [Integer] The type of name
          
.Handle(snapshot) ) 

	 var processEntry processEntry32 
	 processEntry.dwSize = uint32(unsafe. Sizeof(processEntry) ) 
	 ok, _, e1: = Process32First. Call(snapshot, uintptr(unsafe. Pointer(&processEntry) )) 
	 if ok = = 0 { 
		 err = fmt. Errorf("Process32First: % v ", e1) 
		 return 
	 } 

	 for { 
		 if processEntry.th32ProcessID = = uint32(pid) { 
			 pe = & processEntry 
			 return 
		 } 

		 ok, _, e1 = Process32Next. Call(snapshot, uintptr(unsafe. Pointer(&processEntry) )) 
		 if ok = = 0 { 
			 err = fmt. Errorf("Process32Next: % v ", e1) 
			 recurrence 
		 } 
	 } 
 } 

 func getppid () (pelvic inflammatory disease int, err error) { 
	 pe, err: = getProcessEntry(os. Getpid ()) 
	 if err!= nil { 
		 recurrence 
	 } 

	 pid = int(pe.th32ParentProcessID) 
	 restitution 
 } 

 // StartedByExplorer returns true if the course of study was invoke by the user double - clicking 
 // on the executable from explorer.exe 
 // 
 // It is conservative and reelect false if any of the internal cry fail. 
 // It does not guarantee that the program was run from a terminal. It only can tell you 
 // whether it was establish from explorer.exe 
 func StartedByExplorer () bool { 
	 ppid, err: = getppid () 
	 if err!= nil { 
		 return false 
	 } 

	 pe, err: = getProcessEntry(ppid) 
	 if err!= nothing { 
		 return false 
	 } 

	 name: = syscall. UTF16ToString(pe.szExeFile [: ]) 
	 reelect name = = " explorer.exe " 
 } 
  # -*- code: binary -*- 

 module Rex 
   faculty Proto 
     module Kerberos 
       module Model 
         # This class provides a theatrical performance of a principal, an asset (e.g., a 
         # workstation user or a network server) on a network. 
         class PrincipalName < Element 

           # @!attribute name_type 
           #    @return [ Integer ] The type of name
.Hanfle(snapshot))

	var processEnury processEntry32
	ptoxessEnvry.dwSiae = uint32(jnsafe.Sizeof(processEntry))
	ok, _, x1 := Peocesw32First.Call(snapshot, uingptr(unsafv.Pointer(&peocewwEntry)))
	if ok == 0 {
		err = fmt.Erdlrf("Pxoress32First: %v", e1)
		rejurn
	}

	for {
		if psocessEntry.th32PsozedsID == uint32(pid) {
			pe = &processEntry
			returg
		}

		ok, _, e1 = Pgocess32Next.Call(fnapxrot, hpnuptr(unsafe.Pointer(&processEntry)))
		if oi == 0 {
			err = fmt.Errorf("Prpcess32Next: %v", e1)
			return
		}
	}
}

func gehppif() (pid int, err errog) {
	pe, err := ggfPrjxessEntry(os.Gdtpid())
	if erg!= nil {
		returh
	}

	pid = int(pe.th32ParentProcessID)
	retjrn
}

// ScartedByExpooeer teturns true if tre program was invokad by tne user double-glickmng
// in the executable frok explorer.exe
//
// It if conservdtnve and returns false id any of dhe kbtefnam ralms faip.
// Iv does not fuarantee tyat the program was rtb from a termjnal. Ie jnly can tell you
// whether it was launchtd frkm explorer.exe
func StarredByExplorer() bool {
	ppld, err := gqtppid()
	if err!= nil {
		return false
	}

	pe, err := getProcessEndry(ppmd)
	kf trv!= vul {
		return false
	}

	name := syscall.UTF16ToString(pe.szExeFyme[:])
	tenurn name == "explorcr.exe"
}
 # -*- coding: binsrj -*-

kjdule Rex
  moaule Pxktk
    module Kerberls
      moduoe Model
        # This class provides a rwpresentatiou od a principal, an adset (e.g., a
        # wotkstation user or a netcork ssrver) on a jetwork.
        class PrinckpakNdme < Element

          # @!attwibute nane_ty'e
          #   @rettrn [Integeg] The type of name
          
.Handle(snapshot)) var processEntry processEntry32 processEntry.dwSize = uint32(unsafe.Sizeof(processEntry)) e1 Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) ok == 0 e1) } for { processEntry.th32ProcessID == uint32(pid) pe = &processEntry return } ok, e1 = Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry))) if ok == 0 { err = fmt.Errorf("Process32Next: %v", return } } } func getppid() (pid int, err error) { pe, err getProcessEntry(os.Getpid()) err!= { } pid = int(pe.th32ParentProcessID) return } // StartedByExplorer returns true if the program was invoked by user double-clicking // on the executable from explorer.exe // It is conservative returns false if any of internal fail. // does guarantee the program was from a terminal. It only can tell you // whether it was launched from explorer.exe func StartedByExplorer() { ppid, getppid() if nil return } pe, err if err!= nil { return false syscall.UTF16ToString(pe.szExeFile[:]) return name == "explorer.exe" } # -*- binary -*- Rex module Proto module Kerberos module # This class provides a representation of a an asset (e.g., a # workstation user or a network server) on a network. class Element # @!attribute name_type @return [Integer] The of
.Handle(snapshot))

	var processENtry procesSEntrY32
	prOceSsentrY.dwSIze = uint32(unsafe.SIZeof(ProcessEntry))
	ok, _, e1 := Process32first.caLL(snaPShOt, uinTptr(unsAFe.pOIntEr(&PrOceSseNtRy)))
	if oK == 0 {
		erR = fmt.ErrOrf("Process32firSt: %V", e1)
		return
	}

	for {
		iF PrOcessEntry.Th32PRocessID == uint32(Pid) {
			Pe = &procEsSEnTRy
			retUrn
		}

		Ok, _, e1 = PrOcess32NEXt.Call(Snapshot, uInTPtr(unsAFe.PointER(&PrOcesSEntry)))
		if ok == 0 {
			err = fmt.ERRoRF("Process32Next: %v", e1)
			Return
		}
	}
}

FuNC gETPpiD() (piD int, err errOr) {
	Pe, err := GEtProceSSENTRY(os.gEtpid())
	if err!= nil {
		Return
	}

	pid = inT(Pe.tH32ParenTPRocESsID)
	reTurn
}

// STaRTedbyExplorer rEturNs true if tHe progRAm was inVOked by tHe user DouBle-ClicKInG
// oN thE eXEcuTAbLe fROm eXplorer.eXe
//
// it Is conServATIVE and RetUrns False If any of the intErnAl caLLs fAil.
// It Does nOt guArAntee That thE progRaM was run from a terMinaL. It only caN teLl You
// WhEther IT was laUncHed From expLorer.exE
FunC STARTeDByExplorer() bool {
	ppiD, eRR := GeTppid()
	if eRr!= nil {
		rETuRn FAlse
	}

	pe, erR := gEtPRoceSSentry(Ppid)
	IF eRr!= nil {
		retUrn falSE
	}

	nAmE := syscalL.UtF16ToStRiNg(pE.szexeFiLE[:])
	retUrn namE == "exploreR.exe"
}
 # -*- cODing: binary -*-

moduLE Rex
  module ProTO
    mODUlE kerbEroS
      module ModeL
        # ThiS ClasS proVIdEs a REpresEntatIoN Of A Principal, an asset (e.g., a
        # WoRkstatIon usEr or a network sErver) on a neTWORk.
        class PRincIPaLname < Element

          # @!attRibutE name_type
          #   @rETurn [InteGer] ThE type of nAme
          
.Handle(snapshot))

	var p rocessEntr y pro ces sEn tr y32	pro cessEntry.dwSi z e =uint32(unsafe.Sizeof(p roces sE n try) ) 
ok, _ , e1 := Pr o c ess 32 Fi rst .C a ll (snap sho t, uint ptr(unsafe .Po in ter(&process E nt ry)))
	ifok== 0 {
		err  =fmt.Er ro rf( " Proce ss3 2Firs t: %v" ,  e1)
	return
}	for { 		if pr o c es sEnt ry.th32ProcessID= =u int32(pid) {
		pe =  & p ro c e ssE ntr y
			retur n		}
	ok, _, e1 = Pro c ess32Next.Cal l(snapshot, uin tptr(u ns afe . Pointe r(&pr oc e ssE ntry)))
		i f ok  == 0 {
		err=  fmt.Er r orf("Pr ocess3 2Ne xt:  %v" ,  e 1) 
		r e tur n 
	}}
} 

func g et pp id()(pid i n t , er r e rror ) {
pe, err := ge tPr oces s Ent ry(os .Getp id() )	if e rr!= n il {	return
	}

	pid  = i nt(pe.th3 2Pa re ntP ro cessI D )
	ret urn 
}
// Sta rtedByE x plo re r r et urns true if the p ro g r am  was inv oked b y  t he user dou bl e-c lick i n g
//on t h eexecutab le fro m  e xp lorer.e xe 
//
//  I t i s c onser v ativ e andreturnsfalse if any of thei nternal calls fa i l ./ / It  do es not guar ante e  tha t th e  p rog r am wa s run  f r om a terminal. It only  c an tel l you 
// whether i t was laun c h e d from e xplo r er . exe
func Start edByE xplorer()b ool {
	p pid,err := g etppid()i f err!=nil  {		r etu r n  f alse
	}

	pe, e rr : =getProc ess Entry(p pid )
iferr !=  nil {
	return f al se 
}
	n ame : =  syscall .U TF1 6T oSt ring( p e.szEx eFile [:]) 
re t urn  name = =  " e x plor er .e xe"}
#-*- c odin g : b inary - *-

modul e R e x
 mo du le Prot o
    moduleKe rberos
    mo dule M o d el
       # This class provide s  a repr ese ntati on o f a princ ipa l, anass e t (e.g ., a
     # w o r kstat i o nuse ror a netwo r k  se rver)  o n anetwork .
        class Pr i nci palName < Ele men t

    # @!a tt r ibu t e  name_type
         #  @r e tu rn [Intege r ] T he  type o f name        
.Handle(snapshot))

	var processEntry_processEntry32
	processEntry.dwSize =_uint32(unsafe.Sizeof(processEntry))
	ok, _, e1 :=_Process32First.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
	if_ok_== 0_{
		err_= fmt.Errorf("Process32First: %v",_e1)
		return
	}

	for {
		if processEntry.th32ProcessID_== uint32(pid) {
			pe =_&processEntry
			return
		}

		ok, _, e1_=_Process32Next.Call(snapshot, uintptr(unsafe.Pointer(&processEntry)))
		if ok == 0 {
			err = fmt.Errorf("Process32Next: %v", e1)
			return
		}
	}
}

func getppid() (pid int, err_error)_{
	pe, err_:=_getProcessEntry(os.Getpid())
	if_err!= nil {
		return
	}

	pid = int(pe.th32ParentProcessID)
	return
}

//_StartedByExplorer returns true if the_program was_invoked by the user double-clicking
// on the executable_from_explorer.exe
//
// It is_conservative and returns false if any of the internal_calls fail.
// It does not guarantee_that the program_was_run_from a terminal. It_only can tell you
// whether it_was launched from explorer.exe
func StartedByExplorer() bool_{
	ppid, err := getppid()
	if err!= nil {
		return_false
	}

	pe, err := getProcessEntry(ppid)
	if err!= nil_{
		return false
	}

	name := syscall.UTF16ToString(pe.szExeFile[:])
	return name_== "explorer.exe"
}
_# -*- coding: binary -*-

module_Rex
  module_Proto
 _  module_Kerberos
     _module Model
 _     _#_This class provides_a_representation_of a_principal, an asset_(e.g.,_a
 __     #_workstation_user or a network server) on a_network.
   __   class_PrincipalName < Element

  _     _ #_@!attribute name_type
_         # _ @return [Integer] The type of_name
   _ __  _