native application linking error

I am writing to OSR the first time. If I have written to a wrong address please guide me in proper direction.

I am compiling my first native application using WDK(C:\WinDDK\7600.16385.0) which is giving linking errors.

I am getting these errors when I am compiling and linking my native application in Checked Env. Using command:
Build -cfg
BUILD: Compile and Link for x86
BUILD: Loading c:\winddk\7600.16385.0\build.dat…
BUILD: Computing Include file dependencies:
BUILD: Start time: Sun Jan 30 17:59:59 2011
BUILD: Examining d:\anand\junkcode\natapp directory for files to compile.
d:\anand\junkcode\natapp Auto-cleaning queue for ‘root:x86chk’ (4 of 4 file(
s) removed)
Invalidating OACR warning log for ‘root:x86chk’
BUILD: Saving c:\winddk\7600.16385.0\build.dat…
BUILD: Compiling and Linking d:\anand\junkcode\natapp directory
Configuring OACR for ‘root:x86chk’ -
_NT_TARGET_VERSION SET TO WINXP
Compiling - entrypoint.c
Compiling - str.c
Compiling - file.c
Compiling - memory.c
Compiling - generating code…
1>errors in directory d:\anand\junkcode\natapp
1>NMAKE : fatal error U1073: don’t know how to make ‘\nt.lib’
1>nmake.exe /nologo BUILDMSG=Stop. -i BUILD_PASS=PASS2 LINKONLY=1 NOPASS0=1 MAKE
DIR_RELATIVE_TO_BASEDIR= failed - rc = 2

BUILD: Finish time: Sun Jan 30 18:00:01 2011
BUILD: Done

6 files compiled - 2 Errors - 1,116 LPS
--------------------------------------------------------------------------------------------------------
My makefile is like this
#
# Build using BUILD.EXE (Do not edit this section of this file, edit SOURCES)
#
MINIMUM_NT_TARGET_VERSION=0x501

!INCLUDE $(NTMAKEENV)\makefile.def
--------------------------------------------------------------------------------------------------------
My Sources is like this:
TARGETNAME=NatApp
TARGETPATH=obj
TARGETTYPE=PROGRAM

INCLUDES=$(BASEDIR)\inc\ddk

SOURCES=entrypoint.c str.c file.c memory.c
--------------------------------------------------------------------------------------------------------
I have added WLHBASE=C:\WinDDK\7600.16385.0 to my env variables

I had once compiled and linked successfully above source with IFSKit but not with WinDDK.

Thanks for your time.
-Anand

I also want to know if we can use win32 sdk and mfc dlls in native application, If not why? and if yes How? Can you point to some example of native app using win32 dll.

Thanks
-Anand

No, you cannot, because the win32 environment isn’t up and running when
native applications run.

Good luck,

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Tuesday, February 01, 2011 5:13 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] native application linking error

I also want to know if we can use win32 sdk and mfc dlls in native
application, If not why? and if yes How? Can you point to some example of
native app using win32 dll.

Thanks
-Anand


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

>I also want to know if we can use win32 sdk and mfc dlls in native application, If not why?

You cannot.

kernel32.dll is unable to be loaded to a native app. For instance, because some services in kernel32 require it to connect to csrss.exe via LPC, and csrss is not yet running when native app runs.

So are user32 and gdi32 - win32k.sys is not loaded yet.

So, in a native app, you can only use NtXxx, ZwXxx and RtlXxx (for heap, locks, and current directory stuff). I think ntdll.lib is present somewhere in the WDK, so you can link against it.

You can also write the standard C runtime functuions by wrapping them around the ntdll stuff.


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

Thanks for your reply, Maxim.

I was aware of win32 sub system being absent at that moment, but I read somewhere that Ntdll could be used, so was wondering if I can use other dlls as well.

But thanks a lot for explaining the reason so clearly.

Does anyone have a working sample of native application which compiles and links properly on WDK7 ? Or if you can guide to find it anywhere??

Thanks in advance.
-Anand

NTDLL is the interface to the ‘native’ subsystem; that’s why it can (has to
be, really) used.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Tuesday, February 01, 2011 9:27 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] native application linking error

Thanks for your reply, Maxim.

I was aware of win32 sub system being absent at that moment, but I read
somewhere that Ntdll could be used, so was wondering if I can use other dlls
as well.

But thanks a lot for explaining the reason so clearly.

Does anyone have a working sample of native application which compiles and
links properly on WDK7 ? Or if you can guide to find it anywhere??

Thanks in advance.
-Anand


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

xxxxx@hotmail.com wrote:

I am writing to OSR the first time. If I have written to a wrong address please guide me in proper direction.

I am compiling my first native application using WDK(C:\WinDDK\7600.16385.0) which is giving linking errors.

I am getting these errors when I am compiling and linking my native application in Checked Env. Using command:

1>errors in directory d:\anand\junkcode\natapp
1>NMAKE : fatal error U1073: don’t know how to make ‘\nt.lib’

I don’t see how this can be anything other than a bug in the WDK. In
the 7600 WDK, makefile.new is referring to environment variables
MINWIN_SDK_LIB_PATH and MINWIN_INC_PATH, and those variables are not
defined anywhere. That’s the problem here.

This builds fine in the 6001 WDK.

The OSR bug bash runs until midnight tonight…

As a workaround, you can do this when you open your build environment:
set MINWIN_SDK_LIB_PATH=%SDK_LIB_PATH%


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Ah, the joys of Makefile.new spelunking.

I concur.

You could also put it in your source files, so you wouldn’t have to do it
every time you opened a build window.

Wouldn’t be the strangest thing ever if the ability to build native
applications weren’t being thoroughly tested at this point.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Tuesday, February 01, 2011 1:05 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] native application linking error

xxxxx@hotmail.com wrote:

I am writing to OSR the first time. If I have written to a wrong address
please guide me in proper direction.

I am compiling my first native application using
WDK(C:\WinDDK\7600.16385.0) which is giving linking errors.



I am getting these errors when I am compiling and linking my native
application in Checked Env. Using command:

1>errors in directory d:\anand\junkcode\natapp
1>NMAKE : fatal error U1073: don’t know how to make ‘\nt.lib’

I don’t see how this can be anything other than a bug in the WDK. In
the 7600 WDK, makefile.new is referring to environment variables
MINWIN_SDK_LIB_PATH and MINWIN_INC_PATH, and those variables are not
defined anywhere. That’s the problem here.

This builds fine in the 6001 WDK.

The OSR bug bash runs until midnight tonight…

As a workaround, you can do this when you open your build environment:
set MINWIN_SDK_LIB_PATH=%SDK_LIB_PATH%


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer