-----------------------------------------------
                            LARGE_INTEGER ARGUMENT
                                 January 2017
                 -----------------------------------------------
                                    CCB



1. THE LARGE_INTEGER STRUCTURE:

     typedef union _LARGE_INTEGER {
       struct {
         DWORD LowPart;
         LONG  HighPart;
       };
       struct {
         DWORD LowPart;
         LONG  HighPart;
       } u;
       LONGLONG QuadPart;
     } LARGE_INTEGER, *PLARGE_INTEGER;

     BOOL WINAPI SetFilePointerEx(
       _In_       HANDLE hFile,
       _In_       LARGE_INTEGER liDistanceToMove,
       _Out_opt_  PLARGE_INTEGER lpNewFilePointer,
       _In_       DWORD dwMoveMethod
     );


2. REFERENCE CODE:

     In x86, a LARGE_INTEGER argument is 2 arguments: u.LowPart and u.HighPart.

     For example, we can write the following code to call SetFilePointerEx:

     ; SetFilePointerEx PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD (5 arguments)
     push dword ptr dwMoveMethod
     push dword ptr lpNewFilePointer
     push dword ptr liDistanceToMove.HighPart
     push dword ptr liDistanceToMove.LowPart
     push dword ptr hFile
     call SetFilePointerEx

     In x64, a LARGE_INTEGER argument is 1 argument: u.

     For example, we can write the following code to call SetFilePointerEx:

     ; PROTO64 external,SetFilePointerEx, :QWORD,:QWORD,:QWORD,:QWORD (4 arguments)
     mov rcx, qword ptr hFile
     mov rdx, qword ptr liDistanceToMove
     mov r8, qword ptr lpNewFilePointer
     mov r9, qword ptr dwMoveMethod
     call SetFilePointerEx

     The following code is incorrectly in x64:

     ; incorrectly code (5 arguments?)
     mov rcx, qword ptr hFile
     mov edx, dword ptr liDistanceToMove.LowPart
     mov r8d, dword ptr liDistanceToMove.HighPart
     mov r9, qword ptr lpNewFilePointer
     mov rax, qword ptr dwMoveMethod
     mov qword ptr [rsp+20h],rax
     call SetFilePointerEx


3. REFERENCE WINDOWS APIS:

     SetFilePointerEx(_In_ HANDLE hFile, _In_ LARGE_INTEGER liDistanceToMove, _Out_opt_ PLARGE_INTEGER lpNewFilePointer, _In_ DWORD dwMoveMethod);
     CoRevokeInitializeSpy(_In_ ULARGE_INTEGER uliCookie);


4. REFERENCE COM INTERFACES:

     HRESULT ILockBytes::ReadAt([in] ULARGE_INTEGER ulOffset, [in] void *pv, [in] ULONG cb, [out] ULONG *pcbRead);
     HRESULT ILockBytes::WriteAt([in] ULARGE_INTEGER ulOffset, [in] void const *pv, [in] ULONG cb, [out] ULONG *pcbWritten);
     HRESULT ILockBytes::SetSize([in] ULARGE_INTEGER cb);
     HRESULT ILockBytes::LockRegion([in] ULARGE_INTEGER libOffset, [in] ULARGE_INTEGER cb, [in] DWORD dwLockType);
     HRESULT ILockBytes::UnlockRegion([in] ULARGE_INTEGER libOffset, [in] ULARGE_INTEGER cb, [in] DWORD dwLockType);

     HRESULT IStream::Seek([in] LARGE_INTEGER dlibMove, [in] DWORD dwOrigin, [out] ULARGE_INTEGER *plibNewPosition);
     HRESULT IStream::SetSize([in] ULARGE_INTEGER libNewSize);
     HRESULT IStream::CopyTo([in, unique] IStream *pstm, [in] ULARGE_INTEGER cb, [out] ULARGE_INTEGER *pcbRead, [out] ULARGE_INTEGER *pcbWritten);
     HRESULT IStream::LockRegion([in] ULARGE_INTEGER libOffset, [in] ULARGE_INTEGER cb, [in] DWORD dwLockType);
     HRESULT IStream::UnlockRegion([in] ULARGE_INTEGER libOffset, [in] ULARGE_INTEGER cb, [in] DWORD dwLockType);


5. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please e-mail to ccb2000@163.com.