I'm trying to call a function WinHttpGetIEProxyConfigForCurrentUserto get automatically discovered configuration IE proxy. It takes an inout struct parameter as per the documentation . I am using the following code:
func GetProxySettings() {
winhttp, _ := syscall.LoadLibrary("winhttp.dll")
getIEProxy, _ := syscall.GetProcAddress(winhttp, "WinHttpGetIEProxyConfigForCurrentUser")
settings := new(WINHTTP_CURRENT_USER_IE_PROXY_CONFIG)
var nargs uintptr = 1
ret, _, callErr := syscall.Syscall(uintptr(getIEProxy), nargs, uintptr(unsafe.Pointer(&settings)), 0, 0)
fmt.Println(ret, callErr)
if settings != nil {
fmt.Println(settings.fAutoDetect)
fmt.Println(settings.lpszAutoConfigUrl)
fmt.Println(settings.lpszProxy)
fmt.Println(settings.lpszProxyBypass)
}
}
type WINHTTP_CURRENT_USER_IE_PROXY_CONFIG struct {
fAutoDetect bool
lpszAutoConfigUrl string
lpszProxy string
lpszProxyBypass string
}
It seems that the call is successful, settingsnot zero, but as soon as I receive it, I get a panic. Here's the conclusion:
1 The operation completed successfully.
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x1 pc=0x4d2bb4]
source
share