wrong entry point

Hi dear all,
I’m using WDK to compile an executable with UMTYPE=windows directive
and provide an entry point WinMain . But linker complaint unresolved
external symbol _main referenced by ___mainCRTStartup error . It seems
build told linker the wrong entry point . To work arround I must set
UMENTRY=winmain . Is this a bug in build ? following is a dump of my
SOURCES file:
TARGETNAME=rcman
TARGETTYPE=PROGRAM
TARGETPATH=.
UMTYPE=windows
UMENTRY=winmain
USER_C_FLAGS=/EHa
USE_ATL=1
USE_WTL=1
USE_MSVCRT=1
INCLUDES=$(DDK_INC_PATH)
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\comctl32.lib
SOURCES= rcman.cpp \
rcman.rc
many thanks in advance

Did you name the function in your code ‘winmain’ v. ‘WinMain?’

mm

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of yushang
Sent: Sunday, June 20, 2010 5:28 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] wrong entry point

Hi dear all,
I’m using WDK to compile an executable with UMTYPE=windows directive and provide an entry point WinMain . But linker complaint unresolved external symbol _main referenced by ___mainCRTStartup error . It seems build told linker the wrong entry point . To work arround I must set UMENTRY=winmain . Is this a bug in build ? following is a dump of my SOURCES file:
TARGETNAME=rcman
TARGETTYPE=PROGRAM
TARGETPATH=.
UMTYPE=windows
UMENTRY=winmain
USER_C_FLAGS=/EHa
USE_ATL=1
USE_WTL=1
USE_MSVCRT=1
INCLUDES=$(DDK_INC_PATH)
TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\comctl32.lib
SOURCES= rcman.cpp \
rcman.rc
many thanks in advance


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

Yes. Should I name it winmain?

2010/6/20 M. M. O’Brien :
> Did you name the function in your code ‘winmain’ v. ‘WinMain?’

It should be named ‘WinMain.’

mm

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of yushang
Sent: Sunday, June 20, 2010 10:11 AM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

Yes. Should I name it winmain?

2010/6/20 M. M. O’Brien :
> Did you name the function in your code ‘winmain’ v. ‘WinMain?’


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 do name it WinMain . Any idea?

2010/6/21 M. M. O’Brien :
> It should be named ‘WinMain.’
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of yushang
> Sent: Sunday, June 20, 2010 10:11 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] wrong entry point
>
> Yes. Should I name it winmain?
>
> 2010/6/20 M. M. O’Brien :
>> Did you name the function in your code ‘winmain’ v. ‘WinMain?’
>
> —
> 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
>
>
> —
> 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
>

Not off the top of my head.

Sorry,

mm

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of yushang
Sent: Sunday, June 20, 2010 11:09 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

I do name it WinMain . Any idea?

2010/6/21 M. M. O’Brien :
> It should be named ‘WinMain.’
>
> mm
>
> -----Original Message-----
> From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of yushang
> Sent: Sunday, June 20, 2010 10:11 AM
> To: Windows System Software Devs Interest List
> Subject: Re: [ntdev] wrong entry point
>
> Yes. Should I name it winmain?
>
> 2010/6/20 M. M. O’Brien :
>> Did you name the function in your code ‘winmain’ v. ‘WinMain?’
>
> —
> 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
>
>
> —
> 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
>


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

Did you try looking at a sample in the wdk?

C:\WinDDK\7600.16385.0\src>findstr /s /i winmain *.c??
1394\vdev_hybrid\exe\wdf1394.c:WinMain (
1394\vdev_hybrid\exe\wdf1394.c:} // WinMain
^C
C:\WinDDK\7600.16385.0\src>type 1394\vdev_hybrid\exe\sources
TARGETNAME=WDF1394
TARGETTYPE=PROGRAM

USE_MSVCRT=1

INCLUDES=$(INCLUDES); \
…\inc; \
$(DDK_INC_PATH);

TARGETLIBS= $(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\setupapi.lib \
$(SDK_LIB_PATH)\user32.lib \

MSC_WARNING_LEVEL=/W4 /WX

SOURCES= 1394.c \
async.c \
debug.c \
isoch.c \
util.c \
wdf1394.c \
wdf1394.rc

UMTYPE=windows
UMENTRY=winmain

C_DEFINES=/DW32 /DWIN32

TARGET_DESTINATION=idw

MUI=0

MUI_COMMENT=LGNEXCLUDE_MOVE, moved from exclusion txt, owners have to contact MUICore to resolve

I think know what you mean . From linker help , if I just set
SUBSYSTEM , linker will pick a default entry point for me . In my case
it should be WinMainCRTStartup , which will call WinMain , but build
pass an extra entry point to linker which override the default one.
Following is part of my build log:

1>/subsystem:windows,5.01
1>/base:@D:\WinDDK\7600.16385.0\bin\coffbase.txt,usermode
1>/entry:mainCRTStartup

Which sample is entirely confusing of course. The entry point is ‘WinMain’,
while the specification in SOURCES is UMENTRY=winmain. If one just follows
along with this, everything works. On examination, why it works is a bit of
a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.

The WDK is a horrible user mode development environment.

Mark Roddy

On Mon, Jun 21, 2010 at 1:38 AM, wrote:

> Did you try looking at a sample in the wdk?
>
> C:\WinDDK\7600.16385.0\src>findstr /s /i winmain *.c??
> 1394\vdev_hybrid\exe\wdf1394.c:WinMain (
> 1394\vdev_hybrid\exe\wdf1394.c:} // WinMain
> ^C
> C:\WinDDK\7600.16385.0\src>type 1394\vdev_hybrid\exe\sources
> TARGETNAME=WDF1394
> TARGETTYPE=PROGRAM
>
> USE_MSVCRT=1
>
> INCLUDES=$(INCLUDES); <br>> …\inc; <br>> $(DDK_INC_PATH);
>
> TARGETLIBS= $(SDK_LIB_PATH)\kernel32.lib <br>> $(SDK_LIB_PATH)\setupapi.lib <br>> $(SDK_LIB_PATH)\user32.lib <br>>
> MSC_WARNING_LEVEL=/W4 /WX
>
> SOURCES= 1394.c <br>> async.c <br>> debug.c <br>> isoch.c <br>> util.c <br>> wdf1394.c <br>> wdf1394.rc
>
> UMTYPE=windows
> UMENTRY=winmain
>
> C_DEFINES=/DW32 /DWIN32
>
>
> TARGET_DESTINATION=idw
>
> MUI=0
>
> MUI_COMMENT=LGNEXCLUDE_MOVE, moved from exclusion txt, owners have to
> contact MUICore to resolve
>
>
>
> —
> 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
>

Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

thanks,
–rc

On Mon, Jun 21, 2010 at 10:38 AM, Mark Roddy wrote:
> Which sample is entirely confusing of course. The entry point is ‘WinMain’,
> while the specification in SOURCES is UMENTRY=winmain. If one just follows
> along with this, everything works. On examination, why it works is a bit of
> a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.
>
> The WDK is a horrible user mode development environment.
> Mark Roddy
>
>

Why should anyone have to do that in order to write a simple user mode app?

Mark Roddy

On Mon, Jun 21, 2010 at 12:05 PM, Rudra ठाकुर wrote:

> Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
> the mystery.
>
> thanks,
> --rc
>
>
> On Mon, Jun 21, 2010 at 10:38 AM, Mark Roddy wrote:
> > Which sample is entirely confusing of course. The entry point is
> ‘WinMain’,
> > while the specification in SOURCES is UMENTRY=winmain. If one just
> follows
> > along with this, everything works. On examination, why it works is a bit
> of
> > a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.
> >
> > The WDK is a horrible user mode development environment.
> > Mark Roddy
> >
> >
>
> —
> 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
>

This is a good question…

mm

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Monday, June 21, 2010 12:23 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

Why should anyone have to do that in order to write a simple user mode app?

Mark Roddy

On Mon, Jun 21, 2010 at 12:05 PM, Rudra ठाकुर wrote:

Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

thanks,
–rc

On Mon, Jun 21, 2010 at 10:38 AM, Mark Roddy wrote:
> Which sample is entirely confusing of course. The entry point is ‘WinMain’,
> while the specification in SOURCES is UMENTRY=winmain. If one just follows
> along with this, everything works. On examination, why it works is a bit of
> a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.
>
> The WDK is a horrible user mode development environment.
> Mark Roddy
>
>


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

— 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

…though he’s also correct…

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Monday, June 21, 2010 12:23 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

Why should anyone have to do that in order to write a simple user mode app?

Mark Roddy

On Mon, Jun 21, 2010 at 12:05 PM, Rudra ठाकुर wrote:

Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

thanks,
–rc

On Mon, Jun 21, 2010 at 10:38 AM, Mark Roddy wrote:
> Which sample is entirely confusing of course. The entry point is ‘WinMain’,
> while the specification in SOURCES is UMENTRY=winmain. If one just follows
> along with this, everything works. On examination, why it works is a bit of
> a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.
>
> The WDK is a horrible user mode development environment.
> Mark Roddy
>
>


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

— 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

yushang wrote:

Hi dear all,
I’m using WDK to compile an executable with UMTYPE=windows directive
and provide an entry point WinMain . But linker complaint unresolved
external symbol _main referenced by ___mainCRTStartup error . It seems
build told linker the wrong entry point . To work arround I must set
UMENTRY=winmain . Is this a bug in build ?

Difficult to say. If you have USE_MFC, then makefile.new automatically
sets UMENTRY to winmain. Without that, it leaves UMENTRY blank. Then,
when it goes to determine the actual entry point, if UMENTRY is blank,
it assumes your entry point is “main”, not WinMain.

Since there is a separate path for UMTYPE=console, I think you could
successfully argue that UMTYPE=windows should force UMENTRY=winmain.
(Which is, I think, the argument you were trying to make.) However, the
executive summary is that it does not, so you must do so explicitly.

And, after all, it’s only one additional line. If that’s the worst
makefile.new idiosyncrasy you encounter, count yourself lucky.


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

Rudra ठाकुर wrote:

Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

However, in all fairness, you have to be a black-belt makefile master in
order to do so. Makefile.new is almost 12,000 lines of magic. I *AM* a
black-belt makefile master, and it took me small integer minutes to
figure out why he was getting the wrong entry point.

And, as I said, I believe one could successfully argue that this is a
bug in makefile.new.


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

If that’s the worst makefile.new idiosyncrasy you encounter, count yourself lucky.

Hmm. Also quite true.

mm

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, June 21, 2010 12:47 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

yushang wrote:

Hi dear all,
I’m using WDK to compile an executable with UMTYPE=windows directive
and provide an entry point WinMain . But linker complaint unresolved
external symbol _main referenced by ___mainCRTStartup error . It seems
build told linker the wrong entry point . To work arround I must set
UMENTRY=winmain . Is this a bug in build ?

Difficult to say. If you have USE_MFC, then makefile.new automatically sets UMENTRY to winmain. Without that, it leaves UMENTRY blank. Then, when it goes to determine the actual entry point, if UMENTRY is blank, it assumes your entry point is “main”, not WinMain.

Since there is a separate path for UMTYPE=console, I think you could successfully argue that UMTYPE=windows should force UMENTRY=winmain.
(Which is, I think, the argument you were trying to make.) However, the executive summary is that it does not, so you must do so explicitly.

And, after all, it’s only one additional line. If that’s the worst makefile.new idiosyncrasy you encounter, count yourself lucky.


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

I am not aware that the WinDDK compilation environment comes with MFC. I find it insane that anyone would ever consider writing a user-level app using the raw Win32 API (that is, the Petzold intro-to-Windows model). In the great scheme of things, the cost of a low-end Visual Studio license (which is under US$1,000) would have such an impact on productivity by allowing the use of MFC that it would pay back the licensing cost in about 2 weeks. Note I am actually an MFC MVP. From my experience, creating a user-level app using the raw Win32 API is about as sensible as writing a user-level app in assembly code. Yes, there are people who write user apps in assembly code, but both their sanity and judgment are highly suspect. And there is no reason you would ever want to hire one of these people.
joe


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Mark Roddy
Sent: Monday, June 21, 2010 12:23 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

Why should anyone have to do that in order to write a simple user mode app?

Mark Roddy

On Mon, Jun 21, 2010 at 12:05 PM, Rudra ठाकुर wrote:
Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

thanks,
–rc

On Mon, Jun 21, 2010 at 10:38 AM, Mark Roddy wrote:
> Which sample is entirely confusing of course. The entry point is ‘WinMain’,
> while the specification in SOURCES is UMENTRY=winmain. If one just follows
> along with this, everything works. On examination, why it works is a bit of
> a mystery. It seems that ‘winmain’ is special code for ‘WinMain’.
>
> The WDK is a horrible user mode development environment.
> Mark Roddy
>
>

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

— 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

This message has been scanned for viruses and
dangerous content by http:</http:> MailScanner, and is
believed to be clean.

Joe Newcomer wrote:

I am not aware that the WinDDK compilation environment comes with MFC.

Yes, it does. It’s an older version (4.2), but still functional. It also comes with a couple of versions of ATL.

From my experience, creating a user-level app using the raw Win32 API is about as sensible as writing a user-level app in assembly code.

For any non-trivial application, I agree completely. Now, maybe we can get into a good pointless argument about MFC vs WTL. I’m a huge WTL fan – the model just makes more sense to me. It reminds me more of the Delphi VCL model, which was one of the best Windows GUI frameworks I’ve ever encountered.

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

*I* was hoping for a C++ versus C#, MFC + WTL versus .Net debate, myself.

Peter
OSR

To me, one of the great joys of working in Visual Studio is that I never,
ever, EVER have to look at a makefile. I not only had a black belt in
makefiles, I practically had the franchise on the dojos for this in my jobs
in the 1980s. And I have gratefully forgotten just about everything I once
knew about them.
joe

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Tim Roberts
Sent: Monday, June 21, 2010 12:50 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] wrong entry point

Rudra ??? wrote:

Please have a look in WINDDK\7600.16385.1\bin\makefile.new to solve
the mystery.

However, in all fairness, you have to be a black-belt makefile master in
order to do so. Makefile.new is almost 12,000 lines of magic. I *AM* a
black-belt makefile master, and it took me small integer minutes to
figure out why he was getting the wrong entry point.

And, as I said, I believe one could successfully argue that this is a
bug in makefile.new.


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


This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.