Skip to content

Wrong Call To Find Out If CFG Is Enable #2

Description

@kapiushion

Good Research, Just 1 Observation / Correction . The call to

WinApiResolver winapi = WinApiResolver::GetInstance();

    if (winapi.LdrControlFlowGuardEnforced()) {

        return STATUS_ACCESS_DENIED;

    }

in ThreadSetExec Func , is completely Wrong. Beacuse LdrControlFlowGuardEnforced Checks if CFG is enable in the current process, not the foreign Process. i have not Check if this Works if the Target Process has CFG Enable, i guess It Does not, but if that is the case, you just must Figuere out if CFG is enable in the target process, not in the current one , since does not make much sense.

can be something simple, for example

BOOL IsCFG(

    HANDLE ProcHandle

) {

    EXTENDED_PROCESS_INFORMATION PcInfo = { 0 };

    NTSTATUS                     NtStatus   = STATUS_SUCCESS;



    PcInfo.ExtendedProcessInfo       = ProcessControlFlowGuardPolicy;

    PcInfo.ExtendedProcessInfoBuffer = 0;



    

    if ( ! NT_SUCCESS( NtStatus = NtQueryInformationProcess(

            ProcHandle,

            ProcessCookie | ProcessUserModeIOPL,

            &PcInfo,

            sizeof( PcInfo ),

            NULL )

    ) ) {

        printf( "NtQueryInformationProcess Failed => 0x%llx\n", NtStatus );

        return FALSE;

    }



    

    return (ULONG_PTR) PcInfo.ExtendedProcessInfoBuffer;

}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions