コード例 #1
0
ファイル: main.c プロジェクト: jamella/VBoxHardenedLoader
/*
* TsmiLoadParameters
*
* Purpose:
*
* Read parameters from registry.
*
*/
NTSTATUS TsmiLoadParameters(
    VOID
)
{
    UCHAR                           cond = 0;
    PKEY_VALUE_PARTIAL_INFORMATION  tmpChains;
    HANDLE                          hKey = NULL;
    NTSTATUS                        status = STATUS_UNSUCCESSFUL;
    UNICODE_STRING                  uStr;
    OBJECT_ATTRIBUTES               ObjectAttributes;
    ULONG                           ChainsLength;

    RtlInitUnicodeString(&uStr, TSUGUMI_PARAMS);
    InitializeObjectAttributes(&ObjectAttributes, &uStr, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);

    status = ZwOpenKey(&hKey, KEY_READ, &ObjectAttributes);
    if (!NT_SUCCESS(status))
        return status;

    do {

#ifdef _DEBUGMSG
        DbgPrint("[TSMI] TsmiLoadParameters(%ws)\n", DDname);
#endif
        ChainsLength = 0;
        tmpChains = NULL;
        RtlInitUnicodeString(&uStr, DDname);
        status = TsmiReadPatchChains(hKey, &uStr, &tmpChains, &ChainsLength);
        if (NT_SUCCESS(status)) {
            if (tmpChains != NULL) {
                TsmiCopyPatchChainsData(&PatchChains_VBoxDD, tmpChains, ChainsLength);
                ExFreePoolWithTag(tmpChains, TSUGUMI_TAG);
            }
        }

#ifdef _DEBUGMSG
        DbgPrint("[TSMI] TsmiLoadParameters(%ws)\n", VMMname);
#endif
        ChainsLength = 0;
        tmpChains = NULL;
        RtlInitUnicodeString(&uStr, VMMname);
        status = TsmiReadPatchChains(hKey, &uStr, &tmpChains, &ChainsLength);
        if (NT_SUCCESS(status)) {
            if (tmpChains != NULL) {
                TsmiCopyPatchChainsData(&PatchChains_VBoxVMM, tmpChains, ChainsLength);
                ExFreePoolWithTag(tmpChains, TSUGUMI_TAG);
            }
        }

    } while (cond);

    ZwClose(hKey);
    hKey = NULL;

#ifdef _DEBUGMSG
    DbgPrint("[TSMI] TsmiLoadParameters=%lx\n", status);
#endif
    return status;
}
コード例 #2
0
ファイル: main.c プロジェクト: CM44/VBoxHardenedLoader
/*
* TsmiLoadParameters
*
* Purpose:
*
* Read parameters from registry.
*
*/
NTSTATUS TsmiLoadParameters(
    VOID
)
{
    UCHAR                cond = 0;
    HANDLE               hKey = NULL;
    NTSTATUS             status = STATUS_UNSUCCESSFUL;
    UNICODE_STRING       uStr;
    OBJECT_ATTRIBUTES    ObjectAttributes;
    VBOX_PATCH           tempPatch;

    PAGED_CODE();

    RtlInitUnicodeString(&uStr, TSUGUMI_PARAMS);
    InitializeObjectAttributes(&ObjectAttributes, &uStr, OBJ_KERNEL_HANDLE | OBJ_CASE_INSENSITIVE, NULL, NULL);

    status = ZwOpenKey(&hKey, KEY_READ, &ObjectAttributes);
    if (!NT_SUCCESS(status))
        return status;

    do {
        tempPatch.Chains = NULL;
        tempPatch.ChainsLength = 0;

        RtlInitUnicodeString(&uStr, DDname);
        status = TsmiReadPatchChains(hKey, &uStr, &tempPatch);
        if (NT_SUCCESS(status)) {
            TsmiCopyPatchChainsData(&tempPatch, &g_VBoxDD);
        }
        else {
            // VBoxDD must be always patched so return error if no patch data found.
            status = STATUS_UNSUCCESSFUL;
            break;
        }

    } while (cond);

    ZwClose(hKey);
    return status;
}