Re: Dll in Native( Boot time ) and Win32 (normal) mode

native DLLs I believe can call only the NativeAPIs, use that as a starting
point…

On Thu, Aug 20, 2009 at 5:10 PM, wrote:

> Hi All,
>
> I want to build a common dll which could works in both Native( Boot time )
> and Win32 (normal) modes. But I am not sure not how to build such dll, could
> someone please help in building such dll.
>
>
>
> —
> 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
>



- amitr0

Yeah, you are right?, native dlls can use only NativeAPIs, I am taking care of that part. But problem is I don’t know how to build the dll which can be used in both modes( Native and Win32 )
–Anil

I don’t understand what you mean. You can call that DLL from a WIN32
app, we do it all the time at OSR.

–Mark
OSR, Open Systems Resource, Inc.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, August 20, 2009 9:41 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Re: Dll in Native( Boot time ) and Win32 (normal)
mode

Yeah, you are right?, native dlls can use only NativeAPIs, I am taking
care of that part. But problem is I don’t know how to build the dll
which can be used in both modes( Native and Win32 )
–Anil


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

Typically what is done in this case is that the core functionality that you want to expose is refactored into a lib and you create 2 DLLs that consume the lib but then import from drifferent APIs

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Thursday, August 20, 2009 6:40 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Re: Dll in Native( Boot time ) and Win32 (normal) mode

Yeah, you are right?, native dlls can use only NativeAPIs, I am taking care of that part. But problem is I don’t know how to build the dll which can be used in both modes( Native and Win32 )
–Anil


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 actually experimenting with native application for one project requirement. I built a native application with WDK and executed that with success. I thought to have a dll which implements core functionality and which I can call from Native app and Win32 App as well, but than when I try to build (compile/link) WDK linker gives me following error.

1>errors in directory d:\diskdefregment\applications\testdll
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_dllmain.obj) : e
rror LNK2019: unresolved external symbol xxxxx@4 refe
renced in function __DllMainCRTStartupForGS@12
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.obj) : e
rror LNK2019: unresolved external symbol xxxxx@4 refere
nced in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.obj) : e
rror LNK2019: unresolved external symbol xxxxx@0 referenced in fun
ction ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.obj) : e
rror LNK2019: unresolved external symbol xxxxx@0 referenced
in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.obj) : e
rror LNK2019: unresolved external symbol xxxxx@0 referenced
in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.obj) : e
rror LNK2019: unresolved external symbol xxxxx@4 refere
nced in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\objchk_wxp_x86\i386\commdll.dll : error
LNK1120: 6 unresolved externals

My source file is

TARGETNAME=CommDll
TARGETTYPE=DYNLINK

TARGETLIBS=$(DDK_LIB_PATH)\ntdll.lib

UMENTRY=DllMain
SOURCES= Test.c

Any suggestions?

Thanks
Anil

I’ve never used DLLMain in a native DLL, so I can’t help you with that
one, our sources file is

send debug objects to the objd dir

CHECKED_ALT_DIR=1
USE_NTDLL=1

if required, specify where libcmt can be found

MSVCDIR=E:\DevStudio\VC

TARGETNAME=ntapi
TARGETTYPE=DYNLINK
DLLBASE=0x2000000

TARGETLIBS=$(DDK_LIB_PATH)\kernel32.lib \
$(DDK_LIB_PATH)\ntdll.lib

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

SOURCES=…\queryLinks.cpp \
…\createFile.cpp \
…\fsctrl.cpp \
…\queryVol.cpp \
…\resource.rc \
…\mapfile.cpp \
…\event.cpp \
…\devioctrl.cpp \
…\setfile.cpp

C_DEFINES=-DUNICODE $(C_DEFINES) -DNTAPILIBBUILD

NTTARGETFILE0=version

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@gmail.com
Sent: Thursday, August 20, 2009 10:01 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Re: Dll in Native( Boot time ) and Win32 (normal)
mode

I am actually experimenting with native application for one project
requirement. I built a native application with WDK and executed that
with success. I thought to have a dll which implements core
functionality and which I can call from Native app and Win32 App as
well, but than when I try to build (compile/link) WDK linker gives me
following error.

1>errors in directory d:\diskdefregment\applications\testdll
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_dllmain.
obj) : e
rror LNK2019: unresolved external symbol
xxxxx@4 refe
renced in function __DllMainCRTStartupForGS@12
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.
obj) : e
rror LNK2019: unresolved external symbol
xxxxx@4 refere
nced in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.
obj) : e
rror LNK2019: unresolved external symbol __imp__GetTickCount@0
referenced in fun
ction ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.
obj) : e
rror LNK2019: unresolved external symbol __imp__GetCurrentThreadId@0
referenced
in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.
obj) : e
rror LNK2019: unresolved external symbol __imp__GetCurrentProcessId@0
referenced
in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\bufferoverflowu.lib(gs_support.
obj) : e
rror LNK2019: unresolved external symbol
xxxxx@4 refere
nced in function ___security_init_cookie
1>d:\diskdefregment\applications\testdll\objchk_wxp_x86\i386\commdll.dll
: error
LNK1120: 6 unresolved externals

My source file is

TARGETNAME=CommDll
TARGETTYPE=DYNLINK

TARGETLIBS=$(DDK_LIB_PATH)\ntdll.lib

UMENTRY=DllMain
SOURCES= Test.c

Any suggestions?

Thanks
Anil


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 think all you have to do in your case (judging by the linker errors) is to add the -GS- option to the cl command line to stop using security checks. How you do this in BUILD, I’m not really sure.

Good luck,

mm

xxxxx@evitechnology.com wrote:

I think all you have to do in your case (judging by the linker errors) is to add the -GS- option to the cl command line to stop using security checks. How you do this in BUILD, I’m not really sure.

This should do it:
BUFFER_OVERFLOW_CHECKS = 0


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

And there you have it.

Thanks, Tim.

mm

Thanks Tim,
I am able to build dll with BUFFER_OVERFLOW_CHECKS = 0.

Thanks
Anil