![](/img/trans.png)
[英]Solving hid.lib “unresolved external symbol” linker errors in VC++
[英]Unresolved extenral symbol - VC++ Linker
我正在使用WDM构建简单的驱动程序。 (我安装了最新的WDK版本以及最新的Visual Studio 2017版本)。
问题是,在构建解决方案时,它只是不通过链接程序并返回错误2019( 如果您不熟悉该错误,请单击此处以了解更多信息 ),并且它说_DriverEntry @ 8是函数_GsDriverEntry @ 8中引用的未解析的外部符号,文件为BufferOverflowFastFailK.lib。
这是我编写函数签名的方式: NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath)
有人知道如何解决吗?
编辑:这是我的代码:
#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;
}
如果您正在使用驱动程序,则最好在标题中使用:
#ifdef __cplusplus
extern "C" {
#endif
NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath);
#ifdef __cplusplus
}
#endif
或只是extern "C" NTSTATUS DriverEntry(_In_ struct _DRIVER_OBJECT *DriverObject, _In_ PUNICODE_STRING RegistryPath);
如果这是唯一需要使用C调用约定和符号修饰符导出的函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.