Express ffi runtime dependency on windows

Previously, the win32-dir (v0.4.3) gem had a runtime dependency on ffi on
windows.

This commit adds ffi as a runtime dependency for puppet in preparation for
ffi-ing all the things. Note this doesn't change packaging since we already
bundle the ffi gem in the MSI.
Use FFI to manage pointers in the SID module

Previously, we were manipulating native pointers and making assumptions about
them, e.g. 32-bit pointer, maximum SID buffer size of 256 bytes.

Also the ConvertSidToStringSid takes a LPTSTR *StringSid out parameter as its
second argument. In other words, a pointer to a pointer to the first character
of the string. The function writes the address of the generated StringSid to
the address passed in. And we had to jump through some hoops to deference the
returned pointer (by copying the string to a local buffer using strncpy).

This commit changes the code to use FFI to manage pointers. This eliminates the
need for msvcrt buffer routines and results in more readable code:

   return pstr.read_pointer.read_string

Note that FFI::MemoryPointer are like smart pointers -- the memory they point
to is deleted when the pointer goes out of scope. Whereas FFI::Pointer assumes
someone else is managing the underlying memory. For example, sid_ptr_to_string
takes an address as a argument, so it wraps a plain FFI::Pointer around it.

We also specifically use the ANSI versions of the SID APIs, so that the
resulting strings are encoded as `Encoding.default_external`. Otherwise, if we
use the wide versions, and the data from this module is passed back to the
caller, and later used in ruby's File APIs, e.g.
File.join('a', 'b'.encode('UTF-16LE')), it would fail.
Use FFI to manage pointer in RootCerts module

Previously, we made assumptions about the layout of the CERT_CONTEXT structure,
specifically that PCERT_INFO (pointer to CERT_CONTEXT) was a 32-bit pointer,
and magically accessed the size of the returned structure as arr[2].

This commit uses FFI to define the layout of the CERT_CONTEXT structure, uses
named fields, e.g. [:cbCertEncoded], to access offsets within the structure,
and uses the FFI::Pointer#null? method to check for NULL pointer.

Note that we use FFI::Pointer and not MemoryPointer, because the
CertEnumCertificatesInStore function frees the previous CERT_CONTEXT, provided
it is not NULL.

Also in the motto of "don't stub what you don't own" it exercises the Win32
APIs to make the tests more meaningful.
Use FFI to manage pointers in Process module

Previously, we were passing a LPDWORD (pointer to DWORD) as a packed string,
and deferencing it by unpacking the string. This is a bit magical.

This commit changes it to use an FFI::MemoryPointer, which makes pointer
manipulations more explicit, e.g. exit_status.read_ulong

This commit also adds spec tests as there was none.
(Maint) Fix load order dependency

Previously, this module assumed Win32API had been loaded earlier.

This commit ensure this module requires the Win32API module before using it.
Use FFI to manage pointers to User module

Previously, we were packing and unpacking structures when calling Win32 APIs
when loading and unloading use profiles. We also made assumptions about the
size of pointers and structure offsets.

This commit uses FFI to manage pointers. It defines a SID structure, whose
total size can be computed as `sid.size`. It also defines a PROFILEINFO
structure, and assigns the lpServerName field to a managed pointer value:

    profile_info[:lpUserName] = FFI::MemoryPointer.from_string(user)

and passes a pointer to the structure when calling LoadUserProfileA. It also
accesses the "out" hProfile field within the structure:

    profile = profile_info[:hProfile]

which is much more explicit about what is going on.

Finally, FFI maps the :bool return type to ruby true/false, which makes the
code easier to check function return values, e.g. LogonUserA.
(Maint) Define module functions for Registry module

Previously, the registry module could not be tested without creating a wrapper
class in which to mix the module.

This commit declares each of the public methods with module_function so that
they can be called directly from the spec.
Use FFI to manage return values for File module

Previously, we relied on the ReplaceFileW API returning 0 (on failure) or
non-zero (on success).

This commit uses FFI to map the BOOL return type to :bool, so that it's a bit
more legible.

Also note that WideStrings are UTF-16LE encoded and may contain embedded null
bytes, so the :buffer_in type must be used in the FFI function declaration (as
oppsed to just :string).
(Maint) Fully qualify access to the GetLastError method

Not entirely sure why this was necessary, but it seemed to be load order
dependent.
(Maint) Include SID resolution code

Mixin the SID resolution code into the Windows file provider instead of
calling the module functions directly.
Fixup with user changes
Use FFI to manipulate Windows DACLs

Previously, we assumed 32-bit pointers on Windows, e.g. 0.chr * 4,
which works on x86 ruby, but will fail on x64. Additionally, we
performed manual pointer arthimetic, and manually packed and unpacked
structures, e.g. TOKEN_PRIVILEGE, which is a bit magical and hard to
understand.

This commit changes the module to use FFI. It makes use of the
following FFI features:

Passing a DWORD (32-bit unsigned long) pointer to a function and
reading the result:

    pflags = FFI::MemoryPointer.new(:ulong)
    GetVolumeInformationA(..., pflags, ...)
    pflags.read_ulong

Passing a pointer to a pointer to a function:

    ppsd = FFI::MemoryPointer.new(:pointer)
    FFI_GetSecurityInfo(..., ppsd, ...)
    yield ppdacl.read_pointer
    LocalFree(ppsd.read_pointer)

Note that `ppsd` is an FFI::MemoryPointer, so memory of what it points
to will be freed with `ppsd` is garbage collected. However,
`ppsd.read_pointer` is an unmanaged FFI::Pointer, referring to native
memory, and must be explicitly freed.

Given an address, wrap a structure around it, and manipulate its
fields:

    dacl_buf = ACL.new(pdacl)
    0.upto(dacl_buf[:aceCount] - 1) do |i|
       ...
    end

Create an unmanaged pointer at an offset to the start of a structure:

    FFI::Pointer.new(ace.pointer + ace.offset_of(:sid))

Nest structures and rely on FFI to pack the structure of size `tkp.size`:

    luid = LUID.new
    LookupPrivilegeValueA(..., luid.pointer)
    tkp = TOKEN_PRIVILEGES.new
    tkp[:count] = 1
    tkp[:privileges][0][:luid] = luid
    FFI_AdjustTokenPrivileges(..., tkp.pointer, tkp.size, ...)
WIP