Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing functions from iphlpapi.dll #134

Open
2 tasks
armed opened this issue Dec 20, 2024 · 5 comments
Open
2 tasks

Missing functions from iphlpapi.dll #134

armed opened this issue Dec 20, 2024 · 5 comments

Comments

@armed
Copy link

armed commented Dec 20, 2024

Hello, just discovered this tool. Its great.

  • YY-Thunks version: 1.1.5-Beta2.

Report By YY.Depends.Analyzer (Target:5.1.2600-x86)

iphlpapi.dll

  • CancelMibChangeNotify2
    • Supported OS: 6.0.6000, 6.1.7600, 6.2.9200, 6.3.9600
    • Ref Module: .\libp2p-test.exe
  • NotifyIpInterfaceChange
    • Supported OS: 6.0.6000, 6.1.7600, 6.2.9200, 6.3.9600
    • Ref Module: .\libp2p-test.exe
@armed
Copy link
Author

armed commented Dec 23, 2024

I added those two functions to Iphlpapi.hpp and rebuild the project.

#if (YY_Thunks_Target < __WindowsNT6)
    __DEFINE_THUNK(
        iphlpapi,
        8,
        NETIO_STATUS,
        NETIOAPI_API_,
        CancelMibChangeNotify2,
        _In_ HANDLE notificationHandle
    )
    {
        if (const auto _pfnCancelMibChangeNotify2 = try_get_CancelMibChangeNotify2())
        {
            return _pfnCancelMibChangeNotify2(notificationHandle);
        }
        return STATUS_NOT_IMPLEMENTED;
    }
#endif

#if (YY_Thunks_Target < __WindowsNT6)
    __DEFINE_THUNK(
        iphlpapi,
        8,
        NETIO_STATUS,
        NETIOAPI_API_,
        NotifyIpInterfaceChange,
        _In_ ADDRESS_FAMILY family,
        _In_ PIPINTERFACE_CHANGE_CALLBACK callback,
        _In_opt_ PVOID callerContext,
        _In_ BOOLEAN initialNotification,
        _Out_ HANDLE* notificationHandle
    )
    {
        if (const auto _pfnNotifyIpInterfaceChange = try_get_NotifyIpInterfaceChange())
        {
            return _pfnNotifyIpInterfaceChange(family, callback, callerContext, initialNotification, notificationHandle);
        }
        return NO_ERROR;
    }
#endif
}

Then I'm trying to build my simple rust project pointing to a patched YY-Thunk and getting this error:

 note: windows.0.52.0.lib(iphlpapi.dll) : error LNK2005: _NotifyIpInterfaceChange@20 already defined in YY_Thunks_for_WinXP.obj␍
          windows.0.52.0.lib(iphlpapi.dll) : error LNK2005: _CancelMibChangeNotify2@4 already defined in YY_Thunks_for_WinXP.obj␍
          C:\Users\artem\code\k42\libp2p-tests\target\i686-pc-windows-msvc\release\deps\libp2p_test.exe : fatal error LNK1169: one or more multiply defined symbols found␍

It wasn't failing with non patched version during build/link, but failed during runtime on windows xp.
So what could be the reason of this duplicate linker error? Did I setup incorrect msvc env?

thanks

@mingkuang-Chuyu
Copy link
Collaborator

@armed Update like this

    __DEFINE_THUNK(
        iphlpapi,
        4,
        NETIO_STATUS,
        NETIOAPI_API_,
        CancelMibChangeNotify2,
        _In_ HANDLE notificationHandle
    )


    __DEFINE_THUNK(
        iphlpapi,
        20,
        NETIO_STATUS,
        NETIOAPI_API_,
        NotifyIpInterfaceChange,
        _In_ ADDRESS_FAMILY family,
        _In_ PIPINTERFACE_CHANGE_CALLBACK callback,
        _In_opt_ PVOID callerContext,
        _In_ BOOLEAN initialNotification,
        _Out_ HANDLE* notificationHandle
    )

@armed
Copy link
Author

armed commented Dec 27, 2024

@mingkuang-Chuyu thanks, what those 4 and 20 sizes mean? Where I can look them up for future patches?

@mingkuang-Chuyu
Copy link
Collaborator

@mingkuang-Chuyu thanks, what those 4 and 20 sizes mean? Where I can look them up for future patches?

this is x86 __stdcall ABI.
: )

@armed
Copy link
Author

armed commented Dec 27, 2024

Ok got ya, those numbers are stack sizes. Initially I thought that it is a return type size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants