其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
mingw cross build wdm

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

 Windows NT will not load drivers that do not have a correct checksum.
You can apply this patch to binutils to solve the problem:

http://sources.redhat.com/ml/binutils/2002-01/msg00395.html

It writes a checksum to a PE image.

Alternatively you can search for a tool that will do the same and use it on
an image generated with MinGW.

Here is an example of a makefile that will generate a .sys file that Windows
NT will load (if ld has the checksum patch applied).


TOOLBASE = /usr/local/cross-tools/bin

GCC = $(TOOLBASE)/i386-mingw32msv-gcc
DLLTOOL = $(TOOLBASE)/i386-mingw32msv-dlltool

BASENAME = null

FULLNAME = $(BASENAME).sys
CFLAGS = -I../

OBJECTS = $(BASENAME).o

DDKLIBS = ntoskrnl.a

all: $(FULLNAME)

$(FULLNAME): $(OBJECTS)
$(GCC) -Wl,--base-file,base.tmp \
-Wl,--entry,_DriverEntry \
-nostartfiles -nostdlib \
-o junk.tmp \
$(OBJECTS) $(DDKLIBS)
$(DLLTOOL) --dllname $(FULLNAME) \
--base-file base.tmp \
--output-exp temp.exp
$(GCC) $(TARGET_LFLAGS) \
-Wl,--subsystem,native \
-Wl,--image-base,0x10000 \
-Wl,--file-alignment,0x1000 \
-Wl,--section-alignment,0x1000 \
-Wl,--entry,_DriverEntry \
-Wl,temp.exp \
-mdll -nostartfiles -nostdlib \
-o $(FULLNAME) \
$(OBJECTS) $(DDKLIBS)

%.o: %.c
$(GCC) $(CFLAGS) -c $< -o $@

///////////////////////////////////////////////////////////////////////////////////////////////

Is the use of DLLTOOL really needed ? I though ld could now generate the dll
relocation data automatically. Would this be enough:

$(FULLNAME): $(OBJECTS)
$(GCC) $(TARGET_LFLAGS) \
-Wl,--subsystem,native \
-Wl,--entry,_DriverEntry \
-shared -nostartfiles -nostdlib \
-o $(FULLNAME) \
$(OBJECTS) $(DDKLIBS)



相关文章

相关软件