I built my driver using Visual Studio 2008 without any problems. The IntelliSense feature is very handy to develop with. We had Jerry Lozano come on-site to work here (he?s the author of a Windows device driver book) to give a class. He had a wizard that could plug in to Visual Studio that sets it up for building drivers.
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Gary G. Little
Sent: Thursday, February 25, 2010 10:27 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] RE: [ntdev] LNK2001 error unresolved external symbol?
And just how are you building things? Are you using the Visual Studio IDE, building it just like you would an application? If so, you are wrong. You need to open a sanctioned WDK build environment and either run BLD or BUILD. BLD is a macro wrapping BUILD so you will still run build. Using BUILD, unmodified Toaster source files and SOURCES will build a SYS file.
An alternative is to download DDKBUILD.bat from either OsrOnline or Hollistech.com, and create a makefile project in VS.
Gary G. Little
H (952) 223-1349
C (952) 454-4629
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Thomas Mann
Sent: Thursday, February 25, 2010 11:16 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] LNK2001 error unresolved external symbol?
Hi!
I'm new to driverprogramming.
I'm using Visual Studio 2008 with the VisualDDK Extension.
WDK,installed is WDK 7600.16385.0.
OS is Windows 7 Professional
I decided to start off using the simple Toaster example shipped with the WDK-installation.
(I got this ideal from reading a Paper)
I wrote the code while reading it.
I sort of need a working example,I can edit, before i start digging deeper and try to understand it a little bit more.
Problem is that I get the following errors(1 beeing caused by it's precessors),which I can't resolve.
Fehler 1 error LNK2001: unresolved external symbol _WdfFunctions toaster.obj Toaster
Fehler 2 error LNK2001: unresolved external symbol _WdfDriverGlobals toaster.obj Toaster
Fehler 3 fatal error LNK1120: 2 unresolved externals e:\windriver\toaster\toaster\objchk_win7_x86\i386\Toaster.sys Toaster
I appended the sourcecode as Zipfile.
I hope someone can tell me what isn't working and why.
I really am eager to learn but every theory is grey without practice, so I need this to pick it up from here.
sincerly
Thomas
P.s.:Since the emailinglist isn't accepting attachments, I'll append them in this Email:
Toaster.c
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
PURPOSE.
Module Name:
Toaster.c
Abstract:
This is a simple form of function driver for toaster device. The driver
doesn't handle any PnP and Power events because the framework provides
default behavior for those events. This driver has enough support to
allow an user application (toast/notify.exe) to open the device
interface registered by the driver and send read, write or ioctl requests.
Environment:
Kernel mode
--*/
#include "Toaster.h"
#ifdef ALLOC_PRAGMA
#pragma alloc_text (INIT, DriverEntry)
#pragma alloc_text (PAGE, ToasterEvtDeviceAdd)
#pragma alloc_text (PAGE, ToasterEvtIoRead)
#pragma alloc_text (PAGE, ToasterEvtIoWrite)
#pragma alloc_text (PAGE, ToasterEvtIoDeviceControl)
#endif
NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject,IN PUNICODE_STRING RegistryPath){
NTSTATUS status = STATUS_SUCCESS;
WDF_DRIVER_CONFIG config;
KdPrint(("Toaster Function Driver Sample - Driver Framework Edition.\n"));
KdPrint(("Built %s $s\n",DATE,TIME));
WDF_DRI VER_CONFIG_INIT(&config,ToasterEvtDeviceAdd);
status = WdfDriverCreate(
DriverObject,
RegistryPath,
WDF_NO_OBJECT_ATTRIBUTES,
&config,
WDF_NO_HANDLE);
if(!NT_SUCCESS(status)){
KdP rint(("WdfDriverCreate failed with status 0x%x\n",status));
}
return status;
}
NTSTATUS ToasterEvtDeviceAdd(IN WDFDRIVER Driver,IN PWDFDEVICE_INIT DeviceInit){
NTSTATUS status = STATUS_SUCCESS;
PFDO_DATA fdoData;
WDF_IO_QUEUE_CONFIG queueConfig;
WDF_OBJECT_ATTRIBUTES fdoAttributes;
WDFDEVICE hDevice;
WDFQUEUE queue;
UNREFERENCED_PARAMETER(Driver);
PAGED_CODE();
KdPrint(("ToasterEvtDeviceAdd\n"));
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&fdoAttributes,FDO_DATA);
status = WdfDeviceCreate(&DeviceInit, &fdoAttributes, &hDevice);
if(!NT_SUCCESS(status)){
KdPrint(("WdfDeviceCreate f ailed with status code 0x%x\n",status));
return status;
}
fdoData = ToasterFdoGetData(hDevice);
status = WdfDeviceCreateDeviceInterface(hDevice,
(LPGUID) &GUID_DEVINTERFACE_TOASTER,
NULL);
if(!NT_SUCCESS(status)){
KdPrint(("WdfDeviceCreateInterface failed 0x%x\n",status));
return status;
}
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&queueConfig, WdfIoQueueDispatchParallel);
queueConfig.EvtIoRead = ToasterEvtIoRead;
queueConfig.EvtIoWrite = ToasterEvtIoWrite;
queueConfig.EvtIoDeviceControl = ToasterEvtIoDeviceControl;
status = WdfIoQueueCreate(hDevice,
&queueConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&queue);
if(!NT_SUCCESS(status)){
KdPrint(("WdfIoQueueCreate failed 0x%x\n",st atus));
return status;
}
return status;
}
VOID ToasterEvtIoRead(WDFQUEUE Queue,WDFREQUEST Request,size_t Length){
NTSTATUS status;
ULONG_PTR bytesCopied = 0;
WDFMEMORY memory;
UNREFERENCED_PARAMETER(Queue);
UNREFERENCED_PARAMETER(Length);
PAGED_CODE();
KdPrint(("ToasterEvtIoRead:Request: 0x%p, Queue: 0x%p\n",Request,Queue));
status = WdfRequestRetrieveOutputMemory(Request,&memory);
if(NT_SUCCESS(status)){
}
WdfRequestCompleteWithInformation(Request,status,bytesCopied);
}
VOID ToasterEvtIoWrite(WDFQUEUE Queue,WDFREQUEST Request,size_t Length){
NTSTATUS status;
ULONG_PTR bytesWritten = 0;
WDFMEMORY memory;
UNREFERENCED_PARAMETER(Queue);
UNREFERENCED_PARAMETER(Length);
KdPrint(("ToasterEvtIoWrite.Request:0x%p,Queue:0x%p\n",Request,Queue));
PAGED_CODE();
status = WdfRequestRetrieveInputMemory(Request,&memory);
if(NT_SUCCESS(status)){
bytesWritten = Length;
}
WdfRequestCompleteWithInformation(Request,status,bytesWritten);
}
VOID ToasterEvtIoDeviceControl(
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t OutputBufferLength,
IN size_t InputBufferLength,
IN ULONG IoControlCode
)
{
NTSTATUS status = STATUS_SUCCESS;
UNREFERENCED_PARAMETER(Queue);
UNREFER ENCED_PARAMETER(OutputBufferLength);
UNREFERENCED_PARAMETER(InputBufferLength);
KdPrint(("ToasterEvtIoDeviceControl called\n"));
PAGED_CODE();
switch(IoControlCode){
default:
status = STATUS_INVALID_DEVICE_REQUEST;
}
WdfRequestCompleteWithInformation(Request,status,(LONG_PTR) 0);
}
Toaster.h
/*++
Copyright (c) 1990-2000 Microsoft Corporation All Rights Reserved
Module Name:
Toaster.h
Abstract:
Header file for the toaster driver modules.
Environment:
Kernel mode
--*/
#if !defined(TOASTER_H)
#define TOASTER_H
#include<ntddk.h>
#include<..\wdf\kmdf\1.9\wdf.h>
#defi ne NTSTRSAFE_LIB
#include<ntstrsafe.h>
#include<wmilib.h>
#include<initguid.h>
#include"driver.h"
#include"public.h"
#define TOASTER_POOL_TAG (ULONG) 'saoT'
#define MOFRESOURCENAME L"ToasterWMI"
//
// The device extension for the device object
//
typedef struct FDO_DATA
{
WDFWMIINSTANCE WmiDeviceArrivalEvent;
BOOLEAN WmiPowerDeviceEnableRegistered;
TOASTER_INTERFACE_STANDARD BusInterface;
} FDO_DATA, *PFDO_DATA;
WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(FDO_DATA, ToasterFdoGetData)
//
// Connector Types
//
#define TOASTER_WMI_STD_I8042 0
#define TOASTER_WMI_STD_SERIAL 1
#define TOASTER_WMI_STD_PARALEL 2
#define TOASTER_WMI_STD_USB 3
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD ToasterEvtDeviceAdd;
EVT_WDF_DEVICE_CONTEXT_CLEANUP ToasterEvtDeviceContextCleanup;
EVT_WDF_DEVICE_D0_ENTRY ToasterEvtDeviceD0Entry;
EVT_WDF_DEVICE_D0_EXIT ToasterEvtDeviceD0Exit;
EVT_WDF_DEVICE_PREPARE_HARDWARE ToasterEvtDevicePrepareHardware;
EVT_WDF_DEVICE_RELEASE_HARDWARE ToasterEvtDeviceReleaseHardware;
EVT_WDF_DEVICE_SELF_MANAGED_IO_INIT ToasterEvtDeviceSelfManagedIoInit;
//
// Io events callbacks.
//
EVT_WDF_IO_QUEUE_IO_READ ToasterEvtIoRead;
EVT_WDF_IO_QUEUE_IO_WRITE ToasterEvtIoWrite;
EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL ToasterEvtIoDeviceControl;
EVT_WDF_DEVICE_FILE_CREATE ToasterEvtDeviceFileCreate;
EVT_WDF_FILE_CLOSE ToasterEvtFileClose;
NTSTATUS
ToasterWmiRegistration(
in WDFDEVICE Device
);
//
// Power events callbacks
//
EVT_WDF_DEVICE_ARM_WAKE_FROM_S0 ToasterEvtDeviceArmWakeFromS0;
EVT_WDF_DEVICE_ARM_WAKE_FROM_SX ToasterEvtDeviceArmWakeFromSx;
EVT_WDF_DEVICE_DISARM_WAKE_FROM_S0 ToasterEvtDe viceDisarmWakeFromS0;
EVT_WDF_DEVICE_DISARM_WAKE_FROM_SX ToasterEvtDeviceDisarmWakeFromSx;
EVT_WDF_DEVICE_WAKE_FROM_S0_TRIGGERED ToasterEvtDeviceWakeFromS0Triggered;
EVT_WDF_DEVICE_WAKE_FROM_SX_TRIGGERED ToasterEvtDeviceWakeFromSxTriggered;
PCHAR
DbgDevicePowerString(
IN WDF_POWER_DEVICE_STATE Type
);
//
// WMI event callbacks
//
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE EvtWmiInstanceStdDeviceDataQueryInstance;
EVT_WDF_WMI_INSTANCE_QUERY_INSTANCE EvtWmiInstanceToasterControlQueryInstance;
EVT_WDF_WMI_INSTANCE_SET_INSTANCE EvtWmiInstanceStdDeviceDataSetInstance;
EVT_WDF_WMI_INSTANCE_SET_INSTANCE EvtWmiInstanceToasterControlSetInstance;
EVT_WDF_WMI_INSTANCE_SET_ITEM EvtWmiInstanceToasterControlSetItem;
EVT_WDF_WMI_INSTANCE_SET_ITEM EvtWmiInstanceStdDeviceDataSetItem;
EVT_WDF_WMI_INSTANCE_EXECUTE_METHOD EvtWmiInstanceToasterControlExecuteMethod;
NTSTATUS
ToasterFireArrivalEvent(
in WDFDEVICE Device
);
#endif // TOASTER_H
---------------------------
driver.h and public.h are manually added to my project and weren't altered in this process.
Internet Explorer 8 - schneller, einfacher & sicherer Browsenhttp:
---
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
OSR Seminars – OSR
To unsubscribe, visit the List Server section of OSR Online at ListServer/Forum
Information from ESET Smart Security, version of virus signature database 4895 (20100225)
The message was checked by ESET Smart Security.
http://www.eset.com
Information from ESET Smart Security, version of virus signature database 4895 (20100225) __________
The message was checked by ESET Smart Security.
http://www.eset.com
---
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
OSR Seminars – OSR
To unsubscribe, visit the List Server section of OSR Online at ListServer/Forum</http:></initguid.h></wmilib.h></ntstrsafe.h></ntddk.h>