none
Windows Embedded Compact 2013, Rebind adapter issue RRS feed

  • Question

  • Hello.

    I have installed Windows CE 2013 Update April 2020 and got some strange problem.

    When I try to set  a specific static IP  adapter loses all the address settings after I call IOCTL_NDIS_REBIND_ADAPTER IOCTL.

    #define WINCE_IOCTL_START 8
    #define IOCTL_NDIS_POWER_RESUME         _NDIS_CONTROL_CODE( WINCE_IOCTL_START+0, METHOD_OUT_DIRECT )
    #define IOCTL_NDIS_REGISTER_ADAPTER     _NDIS_CONTROL_CODE( WINCE_IOCTL_START+1, METHOD_OUT_DIRECT )
    #define IOCTL_NDIS_DEREGISTER_ADAPTER   _NDIS_CONTROL_CODE( WINCE_IOCTL_START+2, METHOD_OUT_DIRECT )
    #define IOCTL_NDIS_REBIND_ADAPTER       _NDIS_CONTROL_CODE( WINCE_IOCTL_START+3, METHOD_OUT_DIRECT )
    
    #define DD_NDIS_DEVICE_NAME TEXT("NDS0:")
    
    
    HANDLE NdisHandle;
    	NdisHandle = CreateFile(DD_NDIS_DEVICE_NAME, GENERIC_READ | GENERIC_WRITE,
    		FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
    		0, NULL);
    	if (NdisHandle == INVALID_HANDLE_VALUE) return FALSE;
    	if (DeviceIoControl(NdisHandle, IOCTL_NDIS_GET_ADAPTER_NAMES, NULL, 0, KN, sizeof(KN), &i, NULL)) {
    		//wcscpy(KN, L"PCI\\E1I1");
    	
    		NKDbgPrintfW(L"KN = %s\n\r",KN);
    		i = 0;
    		while (KN[i]) i++;
    		i++;
    		KN[i] = 0;
    		i++;
    		KN[i] = 0;
    		B = DeviceIoControl(NdisHandle, IOCTL_NDIS_REBIND_ADAPTER, KN, i*sizeof(wchar_t), NULL, 0, NULL, NULL);
    		if (B == FALSE) {
    			DWORD DD = GetLastError();
    			NKDbgPrintfW(L"Failed to IOCTL_NDIS_REBIND_ADAPTER err = %x\n\r",DD);
    			CloseHandle(NdisHandle);
    			return FALSE;
    		};
    	}
    	else {
    		NKDbgPrintfW(L"Failed to IOCTL_NDIS_GET_ADAPTER_NAMES\n\r");
    		CloseHandle(NdisHandle);
    		return FALSE;
    	};
    	CloseHandle(NdisHandle);


    I have found  simular question from Windows Embedded Compact 7 (https://social.msdn.microsoft.com/Forums/en-US/211d81ae-6115-4913-bbfa-55261356ac3c/windows-embedded-compact-7-update-45-march-2015-rebind-adapter-issue?forum=winembplatdev) and now I am trying to implement it. However this way is rather dirty.

    Is there any other way to change IP address programmly without rebinding adapter?

    P.S. The idea from the post about WinCE 7 (https://social.msdn.microsoft.com/Forums/en-US/211d81ae-6115-4913-bbfa-55261356ac3c/windows-embedded-compact-7-update-45-march-2015-rebind-adapter-issue?forum=winembplatdev)  has worked, so I think it is the same error.



    Sunday, May 3, 2020 7:10 AM

Answers

All replies