How is the encoding of extraNonce done in the genesis block?
Looks like you're misinterpreting the code.

CBigNum is just a class that stores numbers. CBigNum(4) simply stores the number 4, and CBigNum(SHA256(block)) would store the hash of a block as a number (after all, SHA256 gives us numbers). CBigNum does what it says: it stores a big number. As it has a function that exports the number as big endian, it's useful here, and the Bitcoin source will often use it to concatenate numbers in a data stream.

Let's take a quick look at the genesis block's script, without looking at the code. Please open the relevant wiki page: Script

04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73


Part of this can be interpreted as :

04 -&gt; PUSH 4  bytes (FFFF001D)
01 -&gt; PUSH 1  byte  (04)
45 -&gt; PUSH 69 bytes (The Times 03/Jan/2009 Chancellor on brink of second bailout for banks)