Calculando valores necessários
Duas informações críticas precisam ser calculados por rotina de auxiliar de atraso. Com esse fim, há duas funções embutidas em delayhlp.cpp para calcular essas informações.
O primeiro calcula o índice de importação atual em três tabelas diferentes (tabela de endereço (IAT) de importação de tabela, endereço (BIAT) de importação do limite, e a tabela de endereço desvinculada (UIAT) de importação).
O segundo conta o número das importações em um IAT válido.
// utility function for calculating the index of the current import
// for all the tables (INT, BIAT, UIAT, and IAT).
__inline unsigned
IndexFromPImgThunkData(PCImgThunkData pitdCur, PCImgThunkData pitdBase) {
return pitdCur - pitdBase;
}
// utility function for calculating the count of imports given the base
// of the IAT. NB: this only works on a valid IAT!
__inline unsigned
CountOfImports(PCImgThunkData pitdBase) {
unsigned cRet = 0;
PCImgThunkData pitd = pitdBase;
while (pitd->u1.Function) {
pitd++;
cRet++;
}
return cRet;
}