We use the entropy function formalism introduced by A. Sen to obtain the entropy of $AdS_{2}times S^{d-2}$ extremal and static black holes in four and five dimensions, with higher derivative terms of a general type. Starting from a generalized Einstein--Maxwell action with nonzero cosmological constant, we examine all possible scalar invariants that can be formed from the complete set of Riemann invariants (up to order 10 in derivatives). The resulting entropies show the deviation from the well known Bekenstein--Hawking area law $S=A/4G$ for Einsteins gravity up to second order derivatives.