⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testdrv.cpp

📁 WMD驱动编程,本人收集整理的10多个例子和编程环境配置文档,特别是8139驱动,加了许多说明,并测试通过.
💻 CPP
字号:
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 1999 - 2000 Mark Roddy
//
//	Hollis Technology Solutions
//	94 Dow Road
//	Hollis, NH 03049
//	info@hollistech.com
//	www.hollistech.com
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// www.fsf.org
//
//
//
//	Synopsis: 
// 
//
//	Version Information:
//
//	$Header: /cpprun/sys/testDrv/testDrv.cpp 2     1/01/00 11:00p Markr $ 
//
///////////////////////////////////////////////////////////////////////////////

#include "htscpp.h"

CPP_DRIVER_ENTRY(PDRIVER_OBJECT DriverObject,
                 PUNICODE_STRING RegistryPath);

enum baseType { BIRD, PLANE, SUPERMAN };

class base {

public:
    base();
    virtual ~base();
    virtual baseType isa()=0;
};

class global : public base {

public:
    global(int x);
    global();
    virtual ~global();

    int getX();
    virtual baseType isa();

private:
    int m_x;
};


base::base() 
{
#if DBG
    DbgPrint("base: this %x\n", this);
#endif
}

base::~base()
{
#if DBG
    DbgPrint("~base: this %x\n", this);
#endif
}

global::global(int x)
{
#if DBG
    DbgPrint("global( %x): this %x\n", x, this);
#endif    
    m_x = x;
}

global::global()
{
#if DBG
    DbgPrint("global: this %x\n", this);
#endif    
    m_x = 0;
}

global::~global()
{
#if DBG
    DbgPrint("~global: this %x\n", this);
#endif    
    m_x = 0;
}

int global::getX()
{
#if DBG
    DbgPrint("global::getX m_x %x this %x\n", m_x, this);
#endif    
    return m_x;
}

baseType global::isa()
{
#if DBG
    DbgPrint("global::isa this %x\n", this);
#endif    
    return BIRD;
}

global one(2);

global two;

global other(3);

extern "C" void
testUnload(PDRIVER_OBJECT DriverObject);

CPP_DRIVER_ENTRY(PDRIVER_OBJECT DriverObject,
                 PUNICODE_STRING RegistryPath)
{
#if DBG
    DbgPrint("CPP_DRIVER_ENTRY\n");
#endif

    DriverObject->DriverUnload = testUnload;

    if (one.getX() != 2) {

        return STATUS_UNSUCCESSFUL;

    }

     if (two.getX() != 0) {

        return STATUS_UNSUCCESSFUL;

    }

    global * three = new('vrdT') global(4); // this is not global!

    if (!three) {
        //
        // allocation failure!
        //

        return STATUS_UNSUCCESSFUL;
    }

    if (other.getX() != 3) {

        return STATUS_UNSUCCESSFUL;

    }

    global four(4444);

    if (four.getX() != 4444) {

        delete three;

        return STATUS_UNSUCCESSFUL;

    }

    delete three;

    return STATUS_SUCCESS;

}

void
testUnload(PDRIVER_OBJECT DriverObject)
{
#if DBG
    DbgPrint("testUnload\n");
#endif

    return;
}

///////////////////////////////////////////////////////////////////////////////
// 
// Change History Log
//
// $Log: /cpprun/sys/testDrv/testDrv.cpp $
// 
// 2     1/01/00 11:00p Markr
// 
// 1     12/17/99 8:14a Markr
//
///////////////////////////////////////////////////////////////////////////////


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -