阅读:1571回复:1
请斑竹和各路英豪帮我解决有关一个VxD例程 中的bug
我在调试下面这个 VxD实例时出现以下错误
.\dmach.cpp(38) : error C2248: 'hook' : cannot access public member declared in class 'VDMAChannel' .\dmach.cpp(47) : error C2248: 'physicalMask' : cannot access public member declared in class 'VDMAChannel' .\dmach.cpp(48) : error C2248: 'unhook' : cannot access public member declared in class 'VDMAChannel' 我不知时何原因,那位高手能帮俺解决这个讨厌的Bug,俺要好好谢谢这位高人!!。我把源程序附在下面 //DIOC.H #define DMASAMPL_DIOC_TRANSFER_DATA 101 typedef struct { PVOID Address; DWORD Count; } DMARegion; // DMACH.h - include file for VxD DMACH #include <vtoolscp.h> #define DEVICE_CLASS DmachDevice #define DMACH_DeviceID UNDEFINED_DEVICE_ID #define DMACH_Init_Order UNDEFINED_INIT_ORDER #define DMACH_Major 1 #define DMACH_Minor 0 class DmachDevice : public VDevice { public: virtual BOOL OnSysDynamicDeviceInit(); virtual BOOL OnSysDynamicDeviceExit(); virtual DWORD OnW32DeviceIoControl(PIOCTLPARAMS pDIOCParams); }; class DmachVM : public VVirtualMachine { public: DmachVM(VMHANDLE hVM); }; class DmachThread : public VThread { public: DmachThread(THREADHANDLE hThread); }; class DmachDMAChannel:VDMAChannel { public: DmachDMAChannel(); void handler(VMHANDLE hVM); }; // DMACH.cpp - main module for VxD DMACH #define DEVICE_MAIN #include "dmach.h" Declare_Virtual_Device(DMACH) #undef DEVICE_MAIN #include "dioc.h" static DmachDMAChannel *pDmasamplDMA=NULL; DmachVM::DmachVM(VMHANDLE hVM) : VVirtualMachine(hVM) {} DmachThread::DmachThread(THREADHANDLE hThread) : VThread(hThread) {} BOOL DmachDevice::OnSysDynamicDeviceInit() { return TRUE; } BOOL DmachDevice::OnSysDynamicDeviceExit() { return TRUE; } DWORD DmachDevice::OnW32DeviceIoControl(PIOCTLPARAMS pDIOCParams) { DMARegion *pDMARegion1; DWORD Lockable; DWORD ErrCode; PVOID PhysAddr; switch(pDIOCParams->dioc_IOCtlCode) { case DIOC_OPEN: pDmasamplDMA=new DmachDMAChannel; if(!pDmasamplDMA->hook()) { delete pDmasamplDMA; return -1; } break; case DIOC_CLOSEHANDLE: if(pDmasamplDMA) { pDmasamplDMA->physicalMask(TRUE); pDmasamplDMA->unhook(); delete pDmasamplDMA; } break; case DMASAMPL_DIOC_TRANSFER_DATA: if(!pDmasamplDMA) return -1; pDMARegion1=(DMARegion *)pDIOCParams->dioc_InBuf; if(pDmasamplDMA->lockRegion(pDMARegion1->Address,pDMARegion1->Count,0,Lockable,ErrCode,PhysAddr)) { pDmasamplDMA->setRegion(NULL,TRUE,pDMARegion1->Address,pDMARegion1->Count,PhysAddr); pDmasamplDMA->physicalUnmask(pDIOCParams->dioc_hvm,TRUE); } else { VDMABuffer DmasamplBuffer(pDMARegion1->Address,pDMARegion1->Count); if(!DmasamplBuffer.m_createError) { pDmasamplDMA->setRegion(&DmasamplBuffer,FALSE,pDMARegion1->Address,pDMARegion1->Count,DmasamplBuffer.m_physAddress); pDmasamplDMA->physicalUnmask(pDIOCParams->dioc_hvm,TRUE); DmasamplBuffer.copyFrom(pDMARegion1->Address,pDMARegion1->Count,0,ErrCode); } else return -1; } break; default: break; } return 0; } DmachDMAChannel::DmachDMAChannel():VDMAChannel(7) { } void DmachDMAChannel::handler(VMHANDLE hVM) { static WORD count=0; PVOID paddr; DWORD num; WORD mode; count++; dout<<"VM handle:"<<(DWORD)hVM<<endl; dout<<"DMA Channel 3 used counts:"<<count<<endl; getVirtualState(hVM,paddr,num,mode); dout<<"Region Addr:"<<(DWORD)paddr<<endl; dout<<"transfer Bytes:"<<num<<endl; dout<<"transfer Mode:"<<mode<<endl; } # DMACH.mak - makefile for VxD DMACH DEVICENAME = DMACH DYNAMIC = 1 FRAMEWORK = CPP DEBUG = 1 OBJECTS = dmach.OBJ !include $(VTOOLSD)\include\vtoolsd.mak !include $(VTOOLSD)\include\vxdtarg.mak dmach.OBJ: dmach.cpp dmach.h --- 革命还未成功,我还需努力! |
|
|
沙发#
发布于:2001-07-09 11:45
MSDN上的解释:
Compiler Error C2248 'member' : cannot access 'access' 'member' declared in class 'class' The specified private or protected member of a class, structure, or union was accessed. Tips This error can be caused by attempting to access a member that is declared as private or protected, or by accessing a public member of a base class that is inherited with private or protected access. The member should be accessed through a member function with public access or should be declared with public access. The following is an example of this error: class X { public: int m_pubMemb; void setPrivMemb( int i ) { m_privMemb = i; } protected: int m_protMemb; private: int m_privMemb; } x; class Y : X {} y; // default access to X is private void main() { x.m_pubMemb; // OK, m_pubMemb is public x.setPrivMemb( 0 ); // OK, uses public access function x.m_protMemb; // error, m_protMemb is protected x.m_privMemb; // error, m_privMemb is private y.m_pubMemb; // error, Y inherits X as private y.setPrivMemb( 0 ); // error, Y inherits X as private } -------------------------- 我们可以看到 class Y : X {} y; // default access to X is private Y继承X时,默认是private 所以你的代码中 class DmachDMAChannel:VDMAChannel 改成 class DmachDMAChannel: public VDMAChannel 应该就可以了 |
|