使用Windows DDK编译时出错

发布于 2024-07-08 10:26:52 字数 1677 浏览 7 评论 0原文

请原谅我是 Windows DDK 的新手。

我创建了一个名为 test.cpp 的简单文件:

#include <windows.h>

#define BAD_ADDRESS 0xBAADF00D

int __cdecl main(int argc, char* args[])
{
    char* p =(char*)BAD_ADDRESS;
    *p='A';
    return 0;
}

在同一目录中,我创建了一个如下所示的 sources 文件:

TARGETNAME=test
TARGETTYPE=PROGRAM
TARGETPATH=obj

TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib 

SOURCES= test.cpp

以及一个如下所示的 makefile

#
# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
# file to this component.  This file merely indirects to the real make file
# that is shared by all the components of Windows
#
!INCLUDE $(NTMAKEENV)\makefile.def

启动 Windows XP 免费构建环境后,我浏览到包含三个文件(test.cpp、makefile 和源代码)的目录,然后运行以下命令:

F:\temp\debug\dir1>build -cZg

输出:

BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: Using 2 child processes
BUILD: Object root set to: ==> objfre_wxp_x86
BUILD: Compile and Link for i386
BUILD: Examining f:\temp\debug\dir1 directory for files to compile.
BUILD: Compiling (NoSync) f:\temp\debug\dir1 directory
1>Compiling - test.cpp for i386
BUILD: Compiling  f:\temp\debug\dir1 directory
BUILD: Linking f:\temp\debug\dir1 directory
1>Linking Executable - objfre_wxp_x86\i386\test.exe for i386
BUILD: Done

    2 files compiled
    1 executable built

问题是,当我运行创建的可执行文件 test.txt 时,会出现以下问题: exe 它说:

F:\temp\debug\dir1\objfre_wxp_x86\i386>test
The F:\temp\debug\dir1\objfre_wxp_x86\i386\test.exe application cannot be run in Win32 mode.

我在这里缺少什么?

Forgive me for being a complete newbie with Windows DDK.

I have create a simple file named test.cpp:

#include <windows.h>

#define BAD_ADDRESS 0xBAADF00D

int __cdecl main(int argc, char* args[])
{
    char* p =(char*)BAD_ADDRESS;
    *p='A';
    return 0;
}

In the same directory I created a sources file like this:

TARGETNAME=test
TARGETTYPE=PROGRAM
TARGETPATH=obj

TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib 

SOURCES= test.cpp

And a makefile like this:

#
# DO NOT EDIT THIS FILE!!!  Edit .\sources. if you want to add a new source
# file to this component.  This file merely indirects to the real make file
# that is shared by all the components of Windows
#
!INCLUDE $(NTMAKEENV)\makefile.def

After launching the Windows XP Free Build Environment I browse to the directory with the three files (test.cpp, makefile and sources) and run the following command:

F:\temp\debug\dir1>build -cZg

Which outputs:

BUILD: Adding /Y to COPYCMD so xcopy ops won't hang.
BUILD: Using 2 child processes
BUILD: Object root set to: ==> objfre_wxp_x86
BUILD: Compile and Link for i386
BUILD: Examining f:\temp\debug\dir1 directory for files to compile.
BUILD: Compiling (NoSync) f:\temp\debug\dir1 directory
1>Compiling - test.cpp for i386
BUILD: Compiling  f:\temp\debug\dir1 directory
BUILD: Linking f:\temp\debug\dir1 directory
1>Linking Executable - objfre_wxp_x86\i386\test.exe for i386
BUILD: Done

    2 files compiled
    1 executable built

The problem is that when I run the created executable test.exe it says:

F:\temp\debug\dir1\objfre_wxp_x86\i386>test
The F:\temp\debug\dir1\objfre_wxp_x86\i386\test.exe application cannot be run in Win32 mode.

What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风夜微凉 2024-07-15 10:26:52

您编译了一个“本机应用程序”而不是 win32 应用程序。 TARGET_TYPE 定义对此进行控制。

有关使用 DDK生成本机应用程序。

You have compiled a 'native application' rather than a win32 one. The TARGET_TYPE definition controls this.

See 'Inside Native Applications' for a discussion of using the DDK to generate a native application.

ヤ经典坏疍 2024-07-15 10:26:52

Rob Walker 解释了原因,但是 Kernel Mustard 解释了如何。

Rob Walker explains the why but Kernel Mustard explains the how.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文