On Sat, 8 Mar 2025, LIU Hao wrote:

> In our delayimp.c there's:
>
>    ```
>    static unsigned IndexFromPImgThunkData(PCImgThunkData
> pitdCur,PCImgThunkData pitdBase)
>    {
>      return (unsigned) (pitdCur - pitdBase);
>    }
>
>    // ... ...
>
>    FARPROC WINAPI __delayLoadHelper2(PCImgDelayDescr pidd,FARPROC
> *ppfnIATEntry)
>    {
>      // ... ...
>
>      unsigned iIAT, iINT;
>
>      // ... ...
>
>      iIAT = IndexFromPImgThunkData((PCImgThunkData)(ppfnIATEntry),idd.pIAT);
>      iINT = iIAT;
>
>      // ... ...
>    }
>    ```
>
> On a 64-bit system, this truncates the difference from `ppfnIATEntry` to
> `idd.pIAT` to 32 bits then zero-extend it back, which can cause trouble if the
> difference is negative.
>
> Because of the layout of `.didat` (and the mistaken `.idata`), at the moment
> the difference can't be negative. However I suggest we change this to

Woah, no, the ppfnIATEntry must be in the delay IAT for this DLL,
therefore it must be greater than the base address of the delay IAT for
this DLL.  If not, something is really wrong with the image.


_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to