Aracılığıyla paylaş


Arama kuralları, parametreleri ve dönüş türü

Yardımcısı yordam 's prototip gibidir:

FARPROC WINAPI __delayLoadHelper2( 
   PCImgDelayDescr pidd,
   FARPROC * ppfnIATEntry
);

Burada:

  • pidd
    A const bir ImgDelayDescr işaretçisine (bkz. delayimp.h) uzaklıklar çeşitli alma ile ilgili verileri, bağlama bilgileri için bir zaman damgası ve tanımlayıcı içeriği hakkında daha fazla bilgi sağlayan öznitelikler kümesi içeren.Şu anda yalnızca bir öznitelik tanımlayıcısı adreslerinde (karşıt olarak sanal adresler) göreli sanal adresleri gösterir dlattrRva vardır.

    Bkz: yapısı ve sabit değer tanımları PCImgDelayDescr yapı tanımı.

  • ppfnIATEntry
    Gecikme yük yuvasında bir işaretçi adresi tablosu (içe aktarılan işlev adresi ile güncelleştirilecek IAT) içe aktarın.Yardımcısı yordam bu konumuna döndürme aynı değeri depolaması gerekir.

Beklenen dönüş değerleri

İşlev başarılı olursa, alınan işlevinin adresini döndürür.

İşlev başarısız olursa, bir özel durum oluşturur ve 0 döndürür.Üç tür özel durumlar yükseltilebilir:

  • Olur ve geçersiz parametre öznitelikleri pidd belirtilen doğru değildir.

  • LoadLibrary belirtilen dll dosyalarının başarısız oldu.

  • Hata GetProcAddress.

Bu özel durumlarý iþlemek için sizin sorumluluğunuzdur.

Notlar

Yardımcı işlev çağırma kuralı olan __stdcall.Dönüş değeri türü ilgili, değil farproc kullanılır.Bu işlev, c bağlantı vardır.

Bildirim kanca kullanılacak yardımcı alışkanlık istemediğiniz sürece gecikme yük Yardımcısı dönüş değeri içinde geçirilen işlev işaretçisi konumda depolanması gerekir.Bu durumda, kodunuzu dönmek için uygun işlev işaretçisi bulmak için sorumludur.Linker sonra oluşturur thunk kodu alma gerçek hedefi olarak, dönüş değerini alır ve doğrudan atlar.

Örnek

Aşağıdaki kod, bir basit kanca işlevi uygulamak gösterilmiştir.

FARPROC WINAPI delayHook(unsigned dliNotify, PDelayLoadInfo pdli)
{
    switch (dliNotify) {
        case dliStartProcessing :

            // If you want to return control to the helper, return 0.
            // Otherwise, return a pointer to a FARPROC helper function
            // that will be used instead, thereby bypassing the rest 
            // of the helper.

            break;

        case dliNotePreLoadLibrary :

            // If you want to return control to the helper, return 0.
            // Otherwise, return your own HMODULE to be used by the 
            // helper instead of having it call LoadLibrary itself.

            break;

        case dliNotePreGetProcAddress :

            // If you want to return control to the helper, return 0.
            // If you choose you may supply your own FARPROC function 
            // address and bypass the helper's call to GetProcAddress.

            break;

        case dliFailLoadLib : 

            // LoadLibrary failed.
            // If you don't want to handle this failure yourself, return 0.
            // In this case the helper will raise an exception 
            // (ERROR_MOD_NOT_FOUND) and exit.
            // If you want to handle the failure by loading an alternate 
            // DLL (for example), then return the HMODULE for 
            // the alternate DLL. The helper will continue execution with 
            // this alternate DLL and attempt to find the
            // requested entrypoint via GetProcAddress.

            break;

        case dliFailGetProc :

            // GetProcAddress failed.
            // If you don't want to handle this failure yourself, return 0.
            // In this case the helper will raise an exception 
            // (ERROR_PROC_NOT_FOUND) and exit.
            // If you choose you may handle the failure by returning 
            // an alternate FARPROC function address.


            break;

        case dliNoteEndProcessing : 

            // This notification is called after all processing is done. 
            // There is no opportunity for modifying the helper's behavior
            // at this point except by longjmp()/throw()/RaiseException. 
            // No return value is processed.

            break;

        default :

            return NULL;
    }

    return NULL;
}

/* 
and then at global scope somewhere
PfnDliHook __pfnDliNotifyHook2 = delayHook;
*/

Ayrıca bkz.

Başvuru

Yardımcı işlevini anlama