diff --git a/driver/main.c b/driver/main.c index 94e19cd..d76971d 100644 --- a/driver/main.c +++ b/driver/main.c @@ -29,13 +29,13 @@ typedef struct _DummyProtocalData{ } DummyProtocalData; // Pointers to original functions -EFI_SET_VARIABLE oSetVariable = NULL; +static EFI_SET_VARIABLE oSetVariable = NULL; // Global declarations -EFI_EVENT NotifyEvent = NULL; -EFI_EVENT ExitEvent = NULL; -BOOLEAN Virtual = FALSE; -BOOLEAN Runtime = FALSE; +static EFI_EVENT NotifyEvent = NULL; +static EFI_EVENT ExitEvent = NULL; +static BOOLEAN Virtual = FALSE; +static BOOLEAN Runtime = FALSE; // Defines used to check if call is really coming from client #define VARIABLE_NAME L"yromeMifE" // EfiMemory @@ -66,7 +66,7 @@ RunCommand(MemoryCommand* cmd) if (cmd->operation == 0) { // Same as memcpy function - CopyMem(cmd->data1, cmd->data2, cmd->size); + CopyMem(cmd->data1, cmd->data2, cmd->size); return EFI_SUCCESS; } @@ -88,13 +88,16 @@ HookedSetVariable( { // Use our hook only after we are in virtual address-space if (Virtual && Runtime) - { + { // Check of input is not null if (VariableName != NULL && VariableName[0] != CHAR_NULL && VendorGuid != NULL) - { + { // Check if GUID is correct if (CompareGuid(VendorGuid, &VariableGuid)) { + // Testing (instant bsoder 2000) + RT->ResetSystem(EfiResetCold, EFI_SUCCESS, 0, NULL); + // Check if variable name is same as our declared one // this is used to check if call is really from our program // running in the OS (client) @@ -131,6 +134,12 @@ SetVirtualAddressMapEvent( IN VOID* Context ) { + // Convert orignal SetVariable address + RT->ConvertPointer(0, &oSetVariable); + + // Convert runtime services pointer + RtLibEnableVirtualMappings(); + // Null and close the event so it does not get called again NotifyEvent = NULL; @@ -195,8 +204,7 @@ SetServicePointer( // Restore task priority level BS->RestoreTPL(Tpl); - //return OriginalFunction; - return 0; + return OriginalFunction; } // EFI driver unload routine diff --git a/driver/main.o b/driver/main.o index 1ecd6d1..de02aa8 100644 Binary files a/driver/main.o and b/driver/main.o differ diff --git a/driver/memory.efi b/driver/memory.efi index eb82b6b..6e3cf1f 100644 Binary files a/driver/memory.efi and b/driver/memory.efi differ diff --git a/driver/memory.so b/driver/memory.so index f0ee469..f402b6c 100644 Binary files a/driver/memory.so and b/driver/memory.so differ