Forum > Windows
[SOLVED] WINAPI DhcpRequestParams works in 32-bit, but returns error 87in 64bit
tboege:
Solved in https://forum.lazarus.freepascal.org/index.php/topic,60922.msg457312.html#msg457312
Crosspost: This is almost identical to "Lazarus »Forum »Programming »Operating Systems »Windows »Getting error (87) when calling DhcpRequestParams"
I hope, that somebody in this subforum can help.
Crosscompile for 32-bit:
The code works fine: returnvalue from DhcpRequestParams is 0 - and the data in buffer and RecdParams.Params[0].Data is valid.
Compile for Target (Default) , ie 64 bit:
I get returnvalue from DhcpRequestParams "ERROR_INVALID_PARAMETER" (ie 87) and the data in buffer and RecdParams.Params[0].Data is NOT valid.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var Adaptername: PWCHAR; SendParams, RecdParams: DHCPCAPI_PARAMS_ARRAY; option15param: DHCPCAPI_PARAMS; buffer: LPBYTE; size, StatusI, StatusR, dwVersion: DWORD;begin Memo1.Lines.Add('========================='); size := 1024; GetMem(buffer, size); Adaptername := '{C90A9165-BE89-49AC-B79C-B2F6D5DF7B91}'; option15param.OptionId := OPTION_DOMAIN_NAME; option15param.IsVendor := False; option15param.Data := nil; option15param.nBytesData := 0; option15param.Flags := 0; RecdParams.nParams := 1; RecdParams.Params := @option15param; SendParams.Params := nil; SendParams.nParams := 0; StatusI := DhcpCApiInitialize(dwVersion); Memo1.Lines.Add('DhcpCApiInitialize: ' + IntToStr(StatusI)); StatusR := DhcpRequestParams(DHCPCAPI_REQUEST_SYNCHRONOUS, LPVOID(nil), Adaptername, nil, SendParams, RecdParams, buffer, @size, nil); Memo1.Lines.Add('DhcpRequestParams: ' + IntToStr(StatusR)); Memo1.Lines.Add(StrPas(PChar(buffer))); Memo1.Lines.Add(StrPas(PChar(RecdParams.Params[0].Data))); if StatusI = 0 then DhcpCApiCleanup(); FreeMem(buffer, size); end;
dseligo:
I tried your code and I get this for Win64/x86_64, Win32/i386 and (Default)/(Default):
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---=========================DhcpCApiInitialize: 0DhcpRequestParams: 0lanlan
Windows 11, Lazarus 2.2.4 (rev lazarus_2_2_4) FPC 3.2.2 x86_64-win64-win32/win64
Maybe you should initialize buffer after GetMem:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---FillChar(buffer^, size, 0);
dseligo:
Do you have correct GUID of your network adapter (connected to network)?
You can get it with:
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---netsh wlan show interfaces
or
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---netsh lan show interfaces
tboege:
Thank you for your efford. Out different results makes it really strange. I am running the same version of Lazarus/FPC.
I guess I have the right adaptername, since it works in Win32. The output of netsh lan show interfaces:
--- Code: --- S C:\WINDOWS\system32> netsh wlan show interfaces
There is 1 interface on the system:
Name : Wi-Fi
Description : Intel(R) Dual Band Wireless-AC 8265
GUID : c90a9165-be89-49ac-b79c-b2f6d5df7b91
Physical address : 34:41:5d:45:b4:10
Interface type : Primary
State : connected
SSID : nelson_5G
BSSID : d6:6e:0e:36:eb:1e
Network type : Infrastructure
Radio type : 802.11ac
Authentication : WPA2-Personal
Cipher : CCMP
Connection mode : Auto Connect
Band : 5 GHz
Channel : 44
Receive rate (Mbps) : 400
Transmit rate (Mbps) : 400
Signal : 91%
Profile : nelson_5G
Hosted network status : Not available
--- End code ---
Maybee I should another installation of Lazarus on virtual computer.
marcov:
Maybe DHCPCAPI_PARAMS_ARRAY isn't 64-bit proof ? where is this defined?
Keep in mind that Jedi units are generally not 64-bit proof !
Navigation
[0] Message Index
[#] Next page