The documentation for this code is directly from Microsofts pe-format documentation.