Skip to content

DetourFindPayload

Brian Gianforcaro edited this page Mar 6, 2021 · 8 revisions

DetourFindPayload

Return the address of the specified payload within a module.

Definition

_Writable_bytes_(*pcbData)
_Readable_bytes_(*pcbData)
_Success_(return != NULL)
PVOID DetourFindPayload(
    _In_opt_  HMODULE hModule,
    _In_      REFGUID rguid,
    _Out_opt_ DWORD  *pcbData
);

Parameters

hModule : Module holding the specified payload.

rguid : GUID of the specified payload.

pcbData : Variable to receive the size in bytes of the specified payload.

Return value

Pointer to the specified payload or NULL if the payload doesn't exist.

Error codes

The function sets one of the following error codes if it was unable to search the module for the target payload. The error code may be retrieved after the function has returned by calling GetLastError.

ERROR_BAD_EXE_FORMAT : The MZ header of specified module is invalid.

ERROR_EXE_MARKED_INVALID : The NT COFF header of the specified module is invalid.

ERROR_INVALID_EXE_SIGNATURE : The NT COFF header of the specified module has an invalid signature.

Remarks

DetourFindPayload returns the address of the specified payload within a module. Payloads can either be created at compile link time, see the Einst, or can be inserted it an existing binary using the DetourBinarySetPayload API.

For more information on binary editing with Detours and payloads, see Payloads and DLL Import Editing in the Detours Overview.

Related Samples

Einst, Tracebld.

Clone this wiki locally