I started out driver development, however I followed some tutorials I met online here and I am trying to compile my driver into a simple .sys file.
The code looks like this:
#include <ntddk.h>
#include <wdf.h>
#define UNREFERENCED_PARAMETER(P) (P)
VOID DriverUnload(PDRIVER_OBJECT driver)
{
DbgPrint("first:HelloWorld End!");
}
NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pUnicodeString)
{
DbgPrint("first:HelloWorld Begin!");
pDriverObject->DriverUnload = DriverUnload;
return STATUS_SUCCESS;
}
Rather than compile, I get this very funny error:
Error C2220 warning treated as error - no 'object' file generated MyHelloWorldDriver C:\Users\****\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
I am lost as I dont know where else to seek answers from. I have checked and checked all and I get this funny error which happens to work fine on other versions of Visual studio. If I remove the warnings, I don't see it to have a worry, it compiles fine and does not send any errors to my screen, why is this so?
I am using Visual studio 2019, what could I apparently be missing ??
PS
The warnings I get look like this
Error (active) E1097 unknown attribute "no_init_all" MyHelloWorldDriver C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\km\ntddk.h 372
Error (active) E1097 unknown attribute "no_init_all" MyHelloWorldDriver C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\km\ntddk.h 1093
Warning MSB8038 Spectre mitigation is enabled but Spectre mitigated libraries are not found. Verify that the Visual Studio Workload includes the Spectre mitigated libraries. See https://aka.ms/Ofhn4c for more information. MyHelloWorldDriver C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets 422
Error C2220 warning treated as error - no 'object' file generated MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
Warning C4566 character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252) MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 7
Warning C4100 'driver': unreferenced formal parameter MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 5
Warning C4566 character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252) MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 12
Warning C4100 'pUnicodeString': unreferenced formal parameter MyHelloWorldDriver C:\Users\***\source\repos\MyHelloWorldDriver\MyHelloWorldDriver\main.c 10
!
character is different from!
. – Marlomarlon