Custom proxy missing null termination
Posted: Thu Feb 04, 2021 7:12 am
I tried to set a custom proxy using the hidden madExcept.ProxyServer property. In AnsiToGlobalUnicode inside TWinHttp.Create the proxy AnsiString is converted into a unicode string, but the null termination is missing. Suggest to include the null termination in the copy:
function AnsiToGlobalUnicode(const ansi: AnsiString) : pointer;
var us1 : UnicodeString;
begin
if ansi <> '' then begin
us1 := UnicodeString(ansi);
result := pointer(GlobalAlloc(LPTR, Length(us1) * 2 + 2));
Move(us1[1], result^, Length(us1) * 2 + 2);
end else
result := nil;
end;
I'm also having trouble using the automatic proxy. In madExcept.TWinHttp.SendRequest an attempt is first made to send the request without proxy. If the request fails and the error is not ERROR_WINHTTP_SECURE_FAILURE the proxy is setup and another attempt is made. The issue for me is that I get the error ERROR_WINHTTP_SECURE_FAILURE when a proxy is required. Could be the way our company network is setup with different security softwares and proxies... I can bypass this issue if I could set the proxy myself, but that fails too as described above.
function AnsiToGlobalUnicode(const ansi: AnsiString) : pointer;
var us1 : UnicodeString;
begin
if ansi <> '' then begin
us1 := UnicodeString(ansi);
result := pointer(GlobalAlloc(LPTR, Length(us1) * 2 + 2));
Move(us1[1], result^, Length(us1) * 2 + 2);
end else
result := nil;
end;
I'm also having trouble using the automatic proxy. In madExcept.TWinHttp.SendRequest an attempt is first made to send the request without proxy. If the request fails and the error is not ERROR_WINHTTP_SECURE_FAILURE the proxy is setup and another attempt is made. The issue for me is that I get the error ERROR_WINHTTP_SECURE_FAILURE when a proxy is required. Could be the way our company network is setup with different security softwares and proxies... I can bypass this issue if I could set the proxy myself, but that fails too as described above.