From 378fc27075e3662da68a3a8053aa7d4b3aa4ea94 Mon Sep 17 00:00:00 2001 From: KnicKnic Date: Sun, 18 Aug 2019 00:23:19 -0700 Subject: [PATCH] rename exposed functions --- native-powershell | 2 +- pkg/powershell/powershell.cpp | 4 ++-- pkg/powershell/powershell.go | 20 ++++++++++---------- pkg/powershell/powershellobjects.go | 10 +++++----- pkg/powershell/runspace.go | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/native-powershell b/native-powershell index bfa0dab..f0bcdaf 160000 --- a/native-powershell +++ b/native-powershell @@ -1 +1 @@ -Subproject commit bfa0dabe5ba6999412f3a31d91bcc87bc7f46861 +Subproject commit f0bcdaf258d0d9089e243137e52230d5a71bc25f diff --git a/pkg/powershell/powershell.cpp b/pkg/powershell/powershell.cpp index 49fde30..f7d3c75 100644 --- a/pkg/powershell/powershell.cpp +++ b/pkg/powershell/powershell.cpp @@ -25,7 +25,7 @@ void FreeWrapper(void *ptr) } void InitLibraryHelper(){ - InitLibrary(MallocWrapper, free); + NativePowerShell_InitLibrary(MallocWrapper, free); } void * MallocCopyGeneric(const void * input, unsigned long long byteCount ){ @@ -69,7 +69,7 @@ NativePowerShell_RunspaceHandle CreateRunspaceHelper(unsigned long long context, if(useCommand == 0){ commandPtr = nullptr; } - return CreateRunspace((void*)context, commandPtr, loggerPtr); + return NativePowerShell_CreateRunspace((void*)context, commandPtr, loggerPtr); // return CreateRunspace(nullptr, Command, Logger); } diff --git a/pkg/powershell/powershell.go b/pkg/powershell/powershell.go index bb6175b..d0dceb2 100644 --- a/pkg/powershell/powershell.go +++ b/pkg/powershell/powershell.go @@ -38,18 +38,18 @@ func (runspace Runspace) createCommand() psCommand { currentCommand := currentlyInvoking[len(currentlyInvoking)-1] return currentCommand.createNested() } - return psCommand{C.CreatePowershell(runspace.handle), runspace.runspaceContext} + return psCommand{C.NativePowerShell_CreatePowerShell(runspace.handle), runspace.runspaceContext} } // createNested a nested powershell command func (command psCommand) createNested() psCommand { - return psCommand{C.CreatePowershellNested(command.handle), command.context} + return psCommand{C.NativePowerShell_CreatePowerShellNested(command.handle), command.context} } // Close and free a psCommand // , call on all objects even those that are Invoked func (command psCommand) Close() { - C.DeletePowershell(command.handle) + C.NativePowerShell_DeletePowershell(command.handle) } func boolToCChar(b bool) C.char { @@ -66,7 +66,7 @@ func (command psCommand) AddCommand(commandlet string, useLocalScope bool) { ptrwchar := unsafe.Pointer(cs) localScope := boolToCChar(useLocalScope) - _ = C.AddCommandSpecifyScope(command.handle, (*C.wchar_t)(ptrwchar), localScope) + _ = C.NativePowerShell_AddCommandSpecifyScope(command.handle, (*C.wchar_t)(ptrwchar), localScope) } // AddScript to an existing powershell command @@ -76,7 +76,7 @@ func (command psCommand) AddScript(script string, useLocalScope bool) { ptrwchar := unsafe.Pointer(cs) localScope := boolToCChar(useLocalScope) - _ = C.AddScriptSpecifyScope(command.handle, (*C.wchar_t)(ptrwchar), localScope) + _ = C.NativePowerShell_AddScriptSpecifyScope(command.handle, (*C.wchar_t)(ptrwchar), localScope) } // AddArgumentString add a string argument to an existing powershell command @@ -85,12 +85,12 @@ func (command psCommand) AddArgumentString(argument string) { ptrwchar := unsafe.Pointer(cs) - _ = C.AddArgument(command.handle, (*C.wchar_t)(ptrwchar)) + _ = C.NativePowerShell_AddArgument(command.handle, (*C.wchar_t)(ptrwchar)) } // AddArgument add a Object argument to an existing powershell command func (command psCommand) AddArgument(object Object) { - _ = C.AddPSObjectArgument(command.handle, object.handle) + _ = C.NativePowerShell_AddPSObjectArgument(command.handle, object.handle) } // AddParameterString add a string with a parameter name to an existing powershell command @@ -100,7 +100,7 @@ func (command psCommand) AddParameterString(paramName string, paramValue string) cValue, _ := windows.UTF16PtrFromString(paramValue) ptrValue := unsafe.Pointer(cValue) - _ = C.AddParameterString(command.handle, (*C.wchar_t)(ptrName), (*C.wchar_t)(ptrValue)) + _ = C.NativePowerShell_AddParameterString(command.handle, (*C.wchar_t)(ptrName), (*C.wchar_t)(ptrValue)) } // AddParameter add a Object with a parameter name to an existing powershell command @@ -109,7 +109,7 @@ func (command psCommand) AddParameter(paramName string, object Object) { cName, _ := windows.UTF16PtrFromString(paramName) ptrName := unsafe.Pointer(cName) - _ = C.AddParameterObject(command.handle, (*C.wchar_t)(ptrName), object.handle) + _ = C.NativePowerShell_AddParameterObject(command.handle, (*C.wchar_t)(ptrName), object.handle) } func (command psCommand) completeInvoke() { @@ -127,7 +127,7 @@ func (command psCommand) Invoke() *InvokeResults { var count C.uint command.context.invoking = append(command.context.invoking, command) defer command.completeInvoke() - exception := C.InvokeCommand(command.handle, &objects, &count) + exception := C.NativePowerShell_InvokeCommand(command.handle, &objects, &count) return makeInvokeResults(objects, count, exception) } diff --git a/pkg/powershell/powershellobjects.go b/pkg/powershell/powershellobjects.go index be71a8a..c6e47de 100644 --- a/pkg/powershell/powershellobjects.go +++ b/pkg/powershell/powershellobjects.go @@ -46,7 +46,7 @@ func (obj Object) toCHandle() C.NativePowerShell_PowerShellObject { // // Needs to be called for every object returned from AddRef func (obj Object) Close() { - C.ClosePowerShellObject(obj.toCHandle()) + C.NativePowerShell_ClosePowerShellObject(obj.toCHandle()) } // AddRef returns a new Object that has to also be called Close on @@ -54,13 +54,13 @@ func (obj Object) Close() { // This is useful in Callback processing, as those NativePowerShell_PowerShellObjects are auto closed, and to keep // a reference after the function returns use AddRef func (obj Object) AddRef() Object { - handle := C.AddPSObjectHandle(obj.toCHandle()) + handle := C.NativePowerShell_AddPSObjectHandle(obj.toCHandle()) return makePowerShellObject(handle) } // IsNull returns true if the backing powershell object is null func (obj Object) IsNull() bool { - return C.IsPSObjectNullptr(obj.toCHandle()) == 1 + return C.NativePowerShell_IsPSObjectNullptr(obj.toCHandle()) == 1 } // Type returns the (System.Object).GetType().ToString() function @@ -71,7 +71,7 @@ func (obj Object) Type() string { return "nullptr" } - var str *C.wchar_t = C.GetPSObjectType(obj.toCHandle()) + var str *C.wchar_t = C.NativePowerShell_GetPSObjectType(obj.toCHandle()) defer C.FreeWrapper(unsafe.Pointer(str)) return makeString(str) } @@ -84,7 +84,7 @@ func (obj Object) ToString() string { return "nullptr" } - var str *C.wchar_t = C.GetPSObjectToString(obj.toCHandle()) + var str *C.wchar_t = C.NativePowerShell_GetPSObjectToString(obj.toCHandle()) defer C.FreeWrapper(unsafe.Pointer(str)) return makeString(str) } diff --git a/pkg/powershell/runspace.go b/pkg/powershell/runspace.go index f3ea122..b4cf0a5 100644 --- a/pkg/powershell/runspace.go +++ b/pkg/powershell/runspace.go @@ -81,5 +81,5 @@ func CreateRunspace(loggerCallback logger.Simple, callback CallbackHolder) Runsp // Close and free a Runspace func (runspace Runspace) Close() { deleteRunspaceContextLookup(runspace.contextLookup) - C.DeleteRunspace(runspace.handle) + C.NativePowerShell_DeleteRunspace(runspace.handle) }