none
LNK4257 linking object not compiled with /KERNEL ; image may not run. VS2015. x86 (Win32) Only. RRS feed

  • Question

  • I am moving some drivers from the Widows 7 DDK and Windows 8.1 DDK to the Windows 10 WDK and VS2015.

    I am unable to build one of the drivers for Win32 (x86). This is true for all of the targets (Windows 7, Windows 8.1 and Windows 10).

    The same driver builds just fine for x64 on all three targets.

    This driver code is .cpp files (though I am not using any C++ features).

    This driver needs to link to Win32k.lib.

    Win32k.lib(guard_support.obj) : warning LNK4257: object file was not compiled for kernel mode; the image might not run

    I understand what this message means but I do not understand how this is possible?

    Any help is appreciated.

    Monday, January 11, 2016 2:59 PM

Answers

  • I was building the Windows 7 drivers with the windows 7 DDK.

    I was building the Windows 8.1 Drivers with the Windows 8.1 DDK and Visual Studio 2013
    so yes, this compiled correctly using the Win8.1 WDK and building it with an MSBuild (vcxproj) project.

    I was attempting to let the Visual Studio 2015 create the projects for me.
    The problem seems to centered around when I let it use the GsDriverEntry@8 driver entry and
    the $(KernalBufferOverflowLib). I am now not using GsDriverEntry, $(KernalBufferOverflowLib)
    and it builds and runs.

    It simply seems strange to me that:
    1.) When my target is x64, GsDriverEntry and $(KernalBufferOverflowLib) there is no warning for
    all three operating systems (Windows 7, Windows 8.1 and Windows 10). They all build.
    2.)  When my target is x86, GsDriverEntry@8 and $(KernalBufferOverflowLib) all three operating
    systems (Windows 7, Windows 8.1 and Windows 10) produce the same warning. They do not build.

    Thanks.

    Tuesday, January 12, 2016 4:35 PM

All replies

  • It's a WDM / GDI driver (mirror driver / remote display driver).

    If I build without it (Win32k.lib) I get unresolved externals (EngCreateRectRgn, EngDeleteRgn,.....)

    EngDeleteRgn

    Monday, January 11, 2016 6:40 PM
  • Then try to disable this warning...

    Monday, January 11, 2016 6:44 PM
  • you can't disable the warning. did this compile correctly using the Win8.1 WDK and building it with an MSBuild (vcxproj) project? or were you building this with the win7 wdk? the win7 wdk didn't have the /kernel flag, it was added for win8. Windows builds all kernel mode drivers with /kernel, so win32k.lib should be compatible with the flag

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Monday, January 11, 2016 7:47 PM
  • I was building the Windows 7 drivers with the windows 7 DDK.

    I was building the Windows 8.1 Drivers with the Windows 8.1 DDK and Visual Studio 2013
    so yes, this compiled correctly using the Win8.1 WDK and building it with an MSBuild (vcxproj) project.

    I was attempting to let the Visual Studio 2015 create the projects for me.
    The problem seems to centered around when I let it use the GsDriverEntry@8 driver entry and
    the $(KernalBufferOverflowLib). I am now not using GsDriverEntry, $(KernalBufferOverflowLib)
    and it builds and runs.

    It simply seems strange to me that:
    1.) When my target is x64, GsDriverEntry and $(KernalBufferOverflowLib) there is no warning for
    all three operating systems (Windows 7, Windows 8.1 and Windows 10). They all build.
    2.)  When my target is x86, GsDriverEntry@8 and $(KernalBufferOverflowLib) all three operating
    systems (Windows 7, Windows 8.1 and Windows 10) produce the same warning. They do not build.

    Thanks.

    Tuesday, January 12, 2016 4:35 PM