Skip to content

Commit

Permalink
Add more comments to fake_code_signer.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
banister committed Dec 14, 2017
1 parent 4005673 commit d9f208b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/fake_code_signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ def sign
raise "input and output files must be different!"
end

# Below we access an instance of the IMAGE_DATA_DIRECTORY struct.
# This instance is called IMAGE_DIRECTORY_ENTRY_SECURITY and it contains information about the digital signature
# see: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680305(v=vs.85).aspx

# write the offset (address) of the digital signature to the security header (VirtualAddress field)
@image[pe_header.security_offset, 4] = raw_bytes(@image.size + @padding)

# write the size of the digital signature to the security header (Size field)
@image[pe_header.security_offset + 4, 4] = raw_bytes(FAKE_SIG.size)

# append the "digital signature" to the end of the executable, complete with padding
@image << padding_string << FAKE_SIG

File.binwrite(@output, @image)
Expand Down

0 comments on commit d9f208b

Please sign in to comment.