Usage of CreateProcessA() winapi in go language

-1

the structure of CreateProcessA is as follows:

BOOL CreateProcessA(
  LPCSTR                lpApplicationName,
  LPSTR                 lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL                  bInheritHandles,
  DWORD                 dwCreationFlags,
  LPVOID                lpEnvironment,
  LPCSTR                lpCurrentDirectory,
  LPSTARTUPINFOA        lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation
);

I am curious to as how I can emulate/interact with this winapi inside Go. This is what I've attempted to no avail:

package main

import (
    "syscall"
    "unsafe"
)

func main() {
    proc := []byte("C:\\Windows\\System32\\calc.exe")
    CREATE_SUSPENDED := uintptr(0x00000004)
    kernel32 := syscall.MustLoadDLL("kernel32.dll")
    cproca := kernel32.MustFindProc("CreateProcessA")
    cproca.Call(uintptr(unsafe.Pointer(&proc[0])), 0, 0, 0, 0, CREATE_SUSPENDED, 0, 0, 0, 0)   
}

I can't seem to figure out how to create the STARTUPINFO and PROCESS_INFORMATION structures. I am trying to start calc.exe in suspended state. Examples of creating processes in C++ can be found here: Creating Processes (Microsoft Docs)

go
winapi
system-calls
createprocess
asked on Stack Overflow Feb 11, 2020 by secdev1l • edited Feb 11, 2020 by secdev1l

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0