#KMDF error

27 messages · Page 1 of 1 (latest)

rapid axle
#

code :

#include <ntifs.h>
#include <intrin.h>

#define MSR_VM_CR 0xC0010114         // MSR pour le contrôle de SVM (AMD-V)
#define MSR_VM_HSAVE_PA 0xC0010117   // MSR pour l'adresse de sauvegarde SVM

// Fonction pour vérifier si AMD-V (SVM) est activé
BOOLEAN IsSvmEnabled()
{
    // Lire le registre MSR_VM_CR
    ULONG64 msr = __readmsr(MSR_VM_CR);

    // Vérifie si le bit 4 (SVM_DISABLE) est désactivé
    if (!(msr & (1 << 4)))
    {
        KdPrint(("AMD-V (SVM) is enabled.\n"));
        return TRUE;
    }
    else
    {
        KdPrint(("Error: AMD-V (SVM) is disabled in the BIOS.\n"));
        return FALSE;
    }
}

// Fonction pour générer un ID aléatoire pour le CPU
ULONG64 GenerateRandomProcessorId()
{
    LARGE_INTEGER seed;
    KeQuerySystemTime(&seed);
    return seed.QuadPart ^ __rdtsc();
}

// Fonction principale du driver
extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
{
    UNREFERENCED_PARAMETER(RegistryPath);
    KdPrint(("*** DRIVER LOADED: AMD-V Spoofer Initialized ***\n"));

    // Vérification de SVM (AMD-V) via CPUID
    int cpuInfo[4] = { 0 };
    __cpuid(cpuInfo, 0x80000001);  // Leaf 0x80000001 contient les infos sur AMD-V

    if (!(cpuInfo[2] & (1 << 2)))  // Bit 2 d'ECX pour SVM
    {
        KdPrint(("Error: AMD-V (SVM) is not supported on this CPU.\n"));
        return STATUS_NOT_SUPPORTED;
    }

    // Vérifie si AMD-V est activé
    if (!IsSvmEnabled())
    {
        KdPrint(("Error: AMD-V (SVM) is supported but not enabled in BIOS.\n"));
        return STATUS_UNSUCCESSFUL;
    }

    // Simulation du spoofing en générant un ID aléatoire
    ULONG64 spoofedProcessorId = GenerateRandomProcessorId();
    KdPrint(("Spoofed ProcessorId: 0x%llX\n", spoofedProcessorId));

    // TODO : Étendre pour implémenter le spoof complet ici

    // Définir la fonction de déchargement du driver
    DriverObject->DriverUnload = [](PDRIVER_OBJECT DriverObject) {
        UNREFERENCED_PARAMETER(DriverObject);
        KdPrint(("*** DRIVER UNLOADED: AMD-V Spoofer Stopped ***\n"));
        };

    return STATUS_SUCCESS;
}

Hi, why is nothing displayed in the kernel logs?

keen cypress
#

What is the spoofer for?

#

Becuase I don't really think anyone will help with a kernel driver spoofer

#

tbh

rapid axle
# keen cypress tbh

no for now I'm just trying to make the driver work which doesn't give me any response..

brittle basinBOT
#

@rapid axle has reached level 1. GG!

keen cypress
rapid axle
#

code :

#include <ntifs.h>
#include <intrin.h>  // Pour __writemsr et __readmsr
#include <ntdef.h>

#define MSR_VM_HSAVE_PA 0xC0010117  // MSR pour l'adresse de sauvegarde SVM (AMD)
#define DRIVER_TAG 'SVMH'           // Tag pour les allocations mémoire

// Prototypes des fonctions
VOID InitializeSVM();
BOOLEAN CheckAMD_V();
VOID DriverUnload(PDRIVER_OBJECT DriverObject);

// Fonction pour vérifier la compatibilité AMD-V
BOOLEAN CheckAMD_V()
{
    int cpuInfo[4] = { 0 };
    __cpuid(cpuInfo, 0x80000001);  // Vérifie les fonctionnalités étendues du CPU

    if (cpuInfo[2] & (1 << 2))  // Bit 2 d'ECX : Support AMD-V
    {
        KdPrint(("AMD-V est supporté sur ce CPU.\n"));
        return TRUE;
    }
    else
    {
        KdPrint(("Erreur: AMD-V non supporté sur ce CPU.\n"));
        return FALSE;
    }
}

// Fonction pour initialiser et écrire dans MSR
VOID InitializeSVM()
{
    KdPrint(("Initialisation de l'hyperviseur AMD-V...\n"));

    // Vérification de la compatibilité AMD-V
    if (!CheckAMD_V())
    {
        KdPrint(("AMD-V non supporté. Abandon de l'initialisation.\n"));
        return;
    }

    // Allocation mémoire pour l'adresse HSAVE
    PVOID hsavePa = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, DRIVER_TAG);
    if (!hsavePa)
    {
        KdPrint(("Erreur: Échec d'allocation mémoire pour HSAVE.\n"));
        return;
    }

    KdPrint(("Mémoire allouée à l'adresse : 0x%llX\n", (ULONG64)hsavePa));

    // Écriture dans le MSR avec protection contre les exceptions
    __try
    {
        __writemsr(MSR_VM_HSAVE_PA, (ULONG64)hsavePa);
        KdPrint(("MSR_VM_HSAVE_PA initialisé avec succès à 0x%llX\n", (ULONG64)hsavePa));
    }
    __except (EXCEPTION_EXECUTE_HANDLER)
    {
        KdPrint(("Erreur: Écriture dans le MSR impossible. Nettoyage en cours...\n"));
        ExFreePoolWithTag(hsavePa, DRIVER_TAG);
        return;
    }

    KdPrint(("AMD-V Initialisé correctement.\n"));
}

// Fonction d'entrée du driver
extern "C" NTSTATUS DriverEntry(_In_ PDRIVER_OBJECT DriverObject, _In_ PUNICODE_STRING RegistryPath)
{
    UNREFERENCED_PARAMETER(RegistryPath);

    KdPrint(("Driver Chargé: Début de l'initialisation AMD-V...\n"));

    // Appel pour initialiser AMD-V
    InitializeSVM();

    // Configuration de la fonction de déchargement
    DriverObject->DriverUnload = DriverUnload;

    return STATUS_SUCCESS;
}

// Fonction de déchargement du driver
VOID DriverUnload(_In_ PDRIVER_OBJECT DriverObject)
{
    UNREFERENCED_PARAMETER(DriverObject);
    KdPrint(("Driver Déchargé: Nettoyage terminé.\n"));
}
keen cypress
#

I haven't used windbg like you are right there, but have you enabled kernel mode

#

Because I know in debug view you have to do that manually before you can see the kernel calls

keen cypress
#

seems to be the solution

#

This will give you read only access to the kernel

#

as the guy says in the video

rapid axle
keen cypress
#

maybe try to use something else like debug view

random latch
#

Please try to use Debug View X64

#

Also You might have to attach the driver to read the DbgPrint Statements for using the Kernel Debugger

#

For all and any DbgPrint Just use DebugView

rapid axle
keen cypress
#

Well then you are doing something very obviously wrong. Just look at my example that I sent you and then you can see how it should be build from the bottom up and also with a User interface if you would like