Reputation: 15
I'm using WDM to build a simple driver. (I have the latest WDK version and also the latest Visual Studio 2017 version installed).
The problem is that when it comes to building the solution, it just doesn't pass the linker and returns error 2019 (click here to read more about it if you're not familiar with the error) and it says _DriverEntry@8 is an unresolved external symbol referenced in function _GsDriverEntry@8 and the file is BufferOverflowFastFailK.lib.
Here is how I wrote my function's signature: NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath)
Does somebody know how to fix it?
EDIT: Here is my code:
#include "ntddk.h"
UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\deviceone");
UNICODE_STRING SymLinkName = RTL_CONSTANT_STRING(L"\\??\\deviceonelink");
PDEVICE_OBJECT DeviceObject = NULL;
void Unload(PDRIVER_OBJECT DriverObject) {
IoDeleteSymbolicLink(&SymLinkName);
IoDeleteDevice(DeviceObject);
KdPrint(("Driver unloaded"));
}
NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath) {
NTSTATUS status;
DriverObject->DriverUnload = Unload;
status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &DeviceObject);
if (!NT_SUCCESS(status)) {
KdPrint(("Couldn't create device"));
return status;
}
status = IoCreateSymbolicLink(&SymLinkName, &DeviceName);
if (!NT_SUCCESS(status)) {
KdPrint(("Failed to create symbolic link"));
IoDeleteDevice(DeviceObject);
return status;
}
KdPrint(("Driver has been loaded"));
return status;
}
Upvotes: 0
Views: 352
Reputation: 8284
if you're working with drivers it might be best to use in your headers:
#ifdef __cplusplus
extern "C" {
#endif
NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath);
#ifdef __cplusplus
}
#endif
or just extern "C" NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath);
if this is the only function you need to export with the C calling convention and symbol decoration.
Upvotes: 1