Ejemplo n.º 1
0
CInvHead::~CInvHead()
{
	m_pInvDet = NULL;
	
	//释放链表空间
    DelList(); 
}
Ejemplo n.º 2
0
/*++
* @method: DelAllLists
*
* @description: Deletes all lists
*
* @input: None
*
* @output: NTSTATUS
*
*--*/
NTSTATUS DelAllLists()
{
    NTSTATUS retVal = STATUS_UNSUCCESSFUL;
    __try
    {
        retVal = DelList( eProcList );
        retVal = DelList( eDllList );
        retVal = DelList( eDrvList );
        retVal = DelList( eSsdtList );
    }
    __except( EXCEPTION_EXECUTE_HANDLER )
    {
        retVal = STATUS_UNSUCCESSFUL;
        DbgPrint( "Exception caught in DelAllLists()" );
    }
    return retVal;
}
Ejemplo n.º 3
0
int main(int argc, const char * argv[]) {
    int a[10] = {1,3,9,8,4,2,5,0,7.6};
    int b[4] = {2,2,3};
    int c[4] = {1,3,3,4};
    SeqList list;//这个怎么直接全部赋值

    fillList(&list, a, 10);
    
    printf("获取位置:%d\n",Locate(list, 2));//按内容查找
    
    printf("插入:%s\n",InsList(&list,2,10)==1?"OK":"ERROR");//插入
    
    int delement;
    printf("删除:%s,删除的元素:%d\n",DelList(&list,3,&delement)==1?"ok":"ERROR",delement);//删除
    
    
    SeqList list1,list2,list3;
    
    fillList(&list1,b,3);
    fillList(&list2,c,4);
    
    mergeList(&list1,&list2,&list3);//合并两个非递减有序线性表
    printf("合并后的list:%d\n",list3.elem[7]);
    
    printf("---------%s---------\n","链表");
    
    //----------链表-------
    
    LinkList L;
    InitList(&L);
    
    //CreateFromHead(L);
    CreateFormTail(&L);
    
    Node *p = Get(L, 2);
    printf("链表的第2个节点:%c\n",p->data);
    
    
    Node *pp = Located(L,'2');
    printf("key是2的节点:%c\n",pp->data);
    
    printf("链表的长度是:%d\n",ListLength(L));
    
    InseList(L,1,'5');
    printf("插入后的链表长度:%d,首节点:%c\n",ListLength(L),Get(L, 1)->data);
    
    char tem;
    DellList(L,1,&tem);
    printf("链表长度%d,删除链表元素:%c\n",ListLength(L),tem);
    
    LinkList Lb = L;
    printf("合并后的长度%d\n",ListLength(MergeLinkList(L,Lb)));
    return 0;
}
Ejemplo n.º 4
0
    bool Data::DelEntry(const Data& entry)
    {
	if(!IsList())
	    throw Error::Invalid("DelEntry(int)","Not a list");

	bool already_exist;
	size_t pos=KeyLookup(entry,already_exist);

	if(!already_exist)
	    return false;

	DelList(pos);

	return true;
    }
Ejemplo n.º 5
0
void Change(SeqList *L)
{
    int i=0,j=1;
    while(j<=L->last)
    {
        if(L->elem[i]==L->elem[j])
            DelList(L,j);
        else
        {
            i++;
            j++;
        }
    }

}
Ejemplo n.º 6
0
UnitType& UnitType::operator=(const UnitType &ref)
{
	//判断自赋值
	if(this == &ref)
		return *this;
    //调用基类赋值
	//释放堆内存
	DelList();
	m_symbolList.RemoveAll();
	//重新分配堆内存
	CloneList(ref.m_symbolList);
	//赋值
   	m_nID = ref.m_nID;
	m_strID = ref.m_strID;
	m_strName = ref.m_strName;
	m_strCurSymbol = ref.m_strCurSymbol;
	m_strStdSymbol = ref.m_strStdSymbol;
	return *this;
}
Ejemplo n.º 7
0
BOOL TShareDlg::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl)
{
	switch (wID)
	{
	case IDOK:		EndDialog(TRUE); break;
	case IDCANCEL:	EndDialog(FALSE); break;

	case FILE_BUTTON:
		{
			int	i = shareInfo->fileCnt;
			if (FileAddDlg(this, shareMng, shareInfo, cfg))
				for (i; i < shareInfo->fileCnt; i++)
					AddList(i);
		}
		break;

	case FOLDER_BUTTON:
		if (BrowseDirDlg(this, GetLoadStrU8(IDS_FOLDERATTACH), cfg->lastOpenDir, cfg->lastOpenDir))
		{
			if (shareMng->AddFileShare(shareInfo, cfg->lastOpenDir))
			{
				AddList(shareInfo->fileCnt -1);
				cfg->WriteRegistry(CFG_GENERAL);
			}
		}
		break;

	case DEL_BUTTON:
		{
			for (int i=shareInfo->fileCnt-1; i >= 0; i--)
			{
				if (!shareListView.IsSelected(i)) continue;

				DelList(i);
			}
		}
		break;

	default: break;
	}
	return	TRUE;
}
Ejemplo n.º 8
0
bool CTopnReportList::triggerSlot(WObject *sender, const WSlot_ *slot, void **args)
{
  if (slot == slots_ + 0) {
    sender_ = sender;    FastGenReport();
    return true;
  }
  if (slot == slots_ + 1) {
    sender_ = sender;    Translate();
    return true;
  }
  if (slot == slots_ + 2) {
    sender_ = sender;    ExChange();
    return true;
  }
  if (slot == slots_ + 3) {
    sender_ = sender;    SelAll();
    return true;
  }
  if (slot == slots_ + 4) {
    sender_ = sender;    SelNone();
    return true;
  }
  if (slot == slots_ + 5) {
    sender_ = sender;    SelInvert();
    return true;
  }
  if (slot == slots_ + 6) {
    sender_ = sender;    BeforeDelList();
    return true;
  }
  if (slot == slots_ + 7) {
    sender_ = sender;    DelList();
    return true;
  }
  if (slot == slots_ + 8) {
    sender_ = sender;    ReturnMainTopnReport();
    return true;
  }
  return WContainerWidget::triggerSlot(sender, slot, args);
}
Ejemplo n.º 9
0
BOOL TShareStatDlg::EvCommand(WORD wNotifyCode, WORD wID, LPARAM hWndCtl)
{
	switch (wID)
	{
	case IDOK:		EndDialog(TRUE); break;
	case IDCANCEL:	EndDialog(FALSE); break;
	case DEL_BUTTON:
		{
			for (int i=shareListView.GetItemCount()-1; i >= 0; i--)
			{
				if (!shareListView.IsSelected(i))	continue;
				DelList(i);
			}
			SetAllList();
		}
		break;
	case MODIFY_CHECK:
		cfg->fileTransOpt = SendDlgItemMessage(MODIFY_CHECK, BM_GETCHECK, 0, 0) ? FT_STRICTDATE : 0;
		cfg->WriteRegistry(CFG_GENERAL);
		break;
	default: break;
	}
	return	TRUE;
}
Ejemplo n.º 10
0
UnitType::~UnitType()
{
	DelList();
}
Ejemplo n.º 11
0
INT32 CInvHead::Load()
{
	DBG_ENTER("CInvHead::Load");
	DBG_PRINT(("进入CInvHead::Load函数"));
	
	//释放链表所占空间
	DelList();
	
	//查询INV_HEAD表
	CTable::Requery();
	INT32 returnVal = LoadOneRecord();
	
	if (returnVal == SQLITE_OK)
	{    
        DBG_PRINT(("NO, %d", m_no));
		DBG_PRINT(("m_fpdm, %s", m_fpdm.c_str()));
		DBG_PRINT(("m_fphm, %d", m_fphm));
		DBG_PRINT(("m_kprq, %lu", m_kprq));
		DBG_PRINT(("m_kpsj, %lu", m_kpsj));
		DBG_PRINT(("m_kplx, %d", m_kplx));
		
		DBG_PRINT(("m_kphjje, %lld", m_kphjje));
		DBG_PRINT(("m_yfphm, %d", m_yfphm));
		
		DBG_PRINT(("m_fkdw, %s", m_fkdw.c_str()));
		DBG_PRINT(("m_payerCode, %s", m_payerCode.c_str()));
		DBG_PRINT(("m_sky, %s", m_sky.c_str()));
		//		DBG_PRINT(("m_skyid, %u", m_skyid));
		DBG_PRINT(("m_fwm, %s", m_fwm.c_str()));
		
		// 	    DBG_PRINT(("m_ptype, %d", m_ptype));
		//DBG_NPRINT_HEX(m_fCode, 8);	    
		DBG_PRINT(("m_sphsl, %d", m_sphsl));
		DBG_PRINT(("BACKUP1, %s", m_backup1.c_str()));
		// 		DBG_PRINT(("BACKUP2, %s", m_backup2.c_str()));
		//		DBG_PRINT(("BACKUP3, %s", m_backup3.c_str()));
		
	}
	else if (returnVal == SQLITE_DONE)
	{
		DBG_PRINT((" CInvHead has no matched record! errorcode: %d", returnVal));
		return returnVal;
	}
	else
	{
		DBG_PRINT(("errorcode: %d", returnVal));
		return returnVal;
	}
	
	m_kpje = m_kphjje - m_kpse;
	
	//查询INV_DET表
	INT8 chFilter[256];
	memset((void *)chFilter, 0x00, sizeof(chFilter));
	sprintf(chFilter, "where FPDM = '%s' and FPHM = %u", m_fpdm.c_str(), m_fphm);
	DBG_PRINT(("chFilter = %s", chFilter));
	m_pInvDet->m_filter = chFilter;
	m_pInvDet->Requery();
	
	INT32 errorcode = m_pInvDet->MoveFirst();	
	if (errorcode != SQLITE_ROW) 
	{
		if ((errorcode == SQLITE_DONE)&&(m_sphsl==0)) //没有明细
		{
			m_pInvDet->MoveEnd();
			return SQLITE_OK;
		}
		else
		{
			DBG_PRINT(("errorcode: %d", errorcode));
			m_pInvDet->MoveEnd();
			return errorcode; //可能返回SQLITE_DONE,或其它错误码
		}	
	}
	
	CInvDet *p;
	while (errorcode == SQLITE_ROW)
	{
		//		p = new CInvDet;
		p = p->GetNewInvDet();//从静态数组获取一个可用的CInvDet对象
		
		p->m_no = m_pInvDet->m_no;
		p->m_fpdm = m_pInvDet->m_fpdm;
		p->m_fphm = m_pInvDet->m_fphm;
		
		p->m_kprq = m_pInvDet->m_kprq;
		p->m_kpsj = m_pInvDet->m_kpsj;
		p->m_kplx = m_pInvDet->m_kplx;
		
		p->m_sphxh = m_pInvDet->m_sphxh;
		p->m_spbm = m_pInvDet->m_spbm;
		p->m_spmc = m_pInvDet->m_spmc;
		p->m_spdj = m_pInvDet->m_spdj;
		p->m_spsl = m_pInvDet->m_spsl;
		p->m_spje = m_pInvDet->m_spje;
		p->m_spdw = m_pInvDet->m_spdw;
		
		p->m_sl = m_pInvDet->m_sl;
		p->m_spse = m_pInvDet->m_spse;
		p->m_property = m_pInvDet->m_property;
		p->m_dj = m_pInvDet->m_dj;
		p->m_je = m_pInvDet->m_je;
		
		InsertNode(p);	//插入节点	
		DBG_PRINT(("============================"));
		DBG_PRINT(("NO, %d", m_pInvDet->m_no));
		DBG_PRINT(("m_fpdm, %s", m_pInvDet->m_fpdm.c_str()));
		DBG_PRINT(("m_fphm, %d", m_pInvDet->m_fphm));
		DBG_PRINT(("m_sphxh, %d", m_pInvDet->m_sphxh));
		DBG_PRINT(("m_kprq, %lu", m_pInvDet->m_kprq));
		DBG_PRINT(("m_kpsj, %lu", m_pInvDet->m_kpsj));
		
		DBG_PRINT(("m_spbm, %s", m_pInvDet->m_spbm.c_str()));
		DBG_PRINT(("m_spmc, %s", m_pInvDet->m_spmc.c_str()));
		
		DBG_PRINT(("m_spdj, %f", m_pInvDet->m_spdj));
		DBG_PRINT(("m_spsl, %f", m_pInvDet->m_spsl));
		DBG_PRINT(("m_spje, %lld", m_pInvDet->m_spje));
		DBG_PRINT(("m_spse, %lld", m_pInvDet->m_spse));
		DBG_PRINT(("m_spdw, %s", m_pInvDet->m_spdw.c_str()));
		
		//	DBG_PRINT(("PRICE, %u", m_pInvDet->m_dpNo)); 	    	     
		errorcode = m_pInvDet->MoveNext();
	}
	
	m_pInvDet->MoveEnd();
	//m_db->MutexUnlock();
	
	
	if (errorcode==SQLITE_DONE) 
	{
		DBG_PRINT(("退出CInvHead::Load函数"));
		return SQLITE_OK;
	}
	
	DBG_PRINT(("退出CInvHead::Load函数"));
	return errorcode;
}
Ejemplo n.º 12
0
static void TestList()
{
	uint i, a;
	Thing S, T, U, W, X;
	Thing things[MAXCOUNT];
	List L;
	a=-93;
	W = Word(a);
	
	CommentLine("Test List");

	L = NewList(); /* insert and empty list */
	DelList(L); /* delete an empty list */

	/* insert into a list, delete a list make sure thing is ok */
	L = NewList();
	ListIns(L, W);
	DelList(L);
	assert(a == IntWord(W));

	L = NewList();
	for (i=0; i<MAXCOUNT; i++)
	{
		T = Word(i);
		things[i]=T;
		//printf("made: >>%s<<\n", ThingToString(T));
		ListIns(L, T);
	}
	//asm("int3");
	String s1, s2;
	for (i=0; i<MAXCOUNT; i++)
	{
		// seperate assignments are NECESSARY because if i assign
		// inline with strcmp(ThingToString ... ) they will never 
		// get deleted and it will be a memory leak!!
		s1 = ThingToString(things[i]);
		s2 = ThingToString(ListGet(L, things[i]));
		assert(strcmp(s1, s2)==0);
		/*
		if (strcmp(s1, s2) != 0)
		{
			
			printf("*** no match\n");
			printf("%s ",ThingToString(things[i]));
			printf("!= %s\n", ThingToString(ListGet(L, things[i])));
		}
		*/
		DelStr(s1); // sigh, there is no real way around this.
		DelStr(s2); 
	}
	DelList(L);
	fflush(stdout);

	/* S, T, X are unused */
	L = NewList();
	S = Word(-64);
	U = Word(64);
	ListIns(L, S);  // memory leak but these are just tests.
	T = Word(-64);
	assert(SameThing(S, T));
	assert(SameThing(S, U) == false);

	X = ListRm(L, T);
	DelList(L);

	/* X is unused */
	L = NewList();
	for (i = 0; i < MAXCOUNT; i++) 
	{
		W = Word(i);
		ListIns(L, W);
	}
	assert(GetListSize(L) == MAXCOUNT);
	 
	a = GetListSize(L);

	for (i = 0; i < MAXCOUNT; i++) 
	{
		a -= 1;
		W = Word(i);
		assert(i == IntWord(ListRm(L, W)));
		assert(GetListSize(L) == a);
		//printf("a: %d, size: %d\n", a, GetListSize(L));
	}
	DelList(L);

	L = NewList();
	assert(SameThing(S, W) == false);
	ListIns(L, T);
	i = GetListSize(L);
	X = ListRm(L, T);
	assert(GetListSize(L) == (i - 1));
	assert(SameThing(X, T) == true);
	/* check to make sure it's not in there anymore */
	assert(ListRm(L, T) == NULL);


	for (i = 0; i < MAXCOUNT; i++) { ListIns(L, T); }

	assert(GetListSize(L) == MAXCOUNT);

	for (i = 0; i < MAXCOUNT; i++) 
	{ 
		X = ListRm (L, T); 
		assert(X != NULL);
	}
	assert(GetListSize(L) == 0);
	assert(ListRm(L, T) == NULL);

	DelList(L);
	/* these are the only ones we actually made new */
	/* W is a, S is -64, T= -64 */
	DelThing(S);
	DelThing(T);
	DelThing(U);
	DelThing(W);

	printf("Done TestList()\n");
}
Ejemplo n.º 13
0
/*++
* @method: InitList
*
* @description: Initialize list head of specified type
*
* @input: eListType eTypeOfList
*
* @output: NTSTATUS
*
*--*/
NTSTATUS InitList( eListType eTypeOfList )
{
    NTSTATUS retVal = STATUS_UNSUCCESSFUL;
    __try
    {
        // Allocate list entry head
        PLIST_ENTRY pHead = NULL;

        // Delete list if it is present already
        DelList( eTypeOfList );

        pHead = ExAllocatePoolWithTag( NonPagedPool,
                                       sizeof( LIST_ENTRY ),
                                       ARKITLISTTAG );

        // Free the old head and save new pointer based on type of list
        switch( eTypeOfList )
        {
        case eProcList:
            {
                if( MmIsAddressValid( g_lstArray.pProcListHead ) )
                {
                    ExFreePool( g_lstArray.pProcListHead );
                }
                g_lstArray.pProcListHead = pHead;
            }
            break;

        case eDllList:
            {
                if( MmIsAddressValid( g_lstArray.pDllListHead ) )
                {
                    ExFreePool( g_lstArray.pDllListHead );
                }
                g_lstArray.pDllListHead = pHead;
            }
            break;

        case eDrvList:
            {
                if( MmIsAddressValid( g_lstArray.pDrvListHead ) )
                {
                    ExFreePool( g_lstArray.pDrvListHead );
                }
                g_lstArray.pDrvListHead = pHead;
            }
            break;

        case eSsdtList:
            {
                if( MmIsAddressValid( g_lstArray.pSsdtListHead ) )
                {
                    ExFreePool( g_lstArray.pSsdtListHead );
                }
                g_lstArray.pSsdtListHead = pHead;
            }
            break;

        default:
            {
                pHead = NULL;
                retVal = STATUS_UNSUCCESSFUL;
            }
            break;
        }

        // Initialize list head
        if( pHead )
        {
            RtlZeroMemory( pHead, sizeof( LIST_ENTRY ) );
            InitializeListHead( pHead );
            retVal = STATUS_SUCCESS;
        }
    }
    __except( EXCEPTION_EXECUTE_HANDLER )
    {
        DbgPrint( "Exception caught in InitList()" );
        retVal = STATUS_UNSUCCESSFUL;
    }
    return retVal;
}
Ejemplo n.º 14
0
/*++
* @method: DrvDispatch
*
* @description: IOCTL dispatch routine
*
* @input: IN PDEVICE_OBJECT pDevice, IN PIRP pIrp
*
* @output: NTSTATUS
*
*--*/
NTSTATUS DrvDispatch( IN PDEVICE_OBJECT pDevice, IN PIRP pIrp )
{
    NTSTATUS retVal = STATUS_UNSUCCESSFUL;
    
    __try
    {
        UINT nIndex = 0;
        DWORD dwInBuffSize = 0;
        DWORD dwOutBuffSize = 0;
        PIO_STACK_LOCATION pIoStackIrp = NULL;

        if( MmIsAddressValid( pIrp ) )
        {
            pIoStackIrp = IoGetCurrentIrpStackLocation( pIrp );
        }

        if( MmIsAddressValid( pIoStackIrp ) )
        {
            dwInBuffSize = pIoStackIrp->Parameters.DeviceIoControl.InputBufferLength;
            dwOutBuffSize = pIoStackIrp->Parameters.DeviceIoControl.OutputBufferLength;
        }

        switch( pIoStackIrp->Parameters.DeviceIoControl.IoControlCode )
        {
        case IOCTL_OS_VER_INFO:
            {
                // Set OS and SP versions got from usermode, in our globals
                PMYOSVERINFO pOSVerInfo = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pOSVerInfo ) )
                {
                    if( STATUS_SUCCESS == InitGlobals( pOSVerInfo ) )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwInBuffSize;
                    }
                }
            }
            break;

        case IOCTL_GET_DATA_CNT:
            {
                // Get the count of items requested by usermode
                PARKDATACOUNT pArkDataCout = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pArkDataCout ) )
                {
                    switch( pArkDataCout->typeOfArkData )
                    {
                    case eArkDataProcList:
                        {
                            // Get the count of running processes
                            pArkDataCout->dataCount = ScanAndGetProcessCount();
                        }
                        break;

                    case eArkDataDllList:
                        {
                            // Get the count of DLLs
                            pArkDataCout->dataCount = ScanAndGetDllCount( pArkDataCout->miscData );
                        }
                        break;

                    case eArkDataDriverList:
                        {
                            // Get the count of loaded drivers
                            pArkDataCout->dataCount = ScanAndGetDriverCount();
                        }
                        break;

                    case eArkDataSsdtList:
                        {
                            // Get the count of SSDT hooks
                            pArkDataCout->dataCount = ScanAndGetSSDTHooksCount();
                        }
                        break;

                    default:
                        {
                            pArkDataCout->dataCount = 0;
                        }
                        break;
                    }

                    // Set the IO status based on count of items
                    if( pArkDataCout->dataCount > 0 )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = sizeof( ARKDATACOUNT );
                    }
                }
            }
            break;

        case IOCTL_GET_PROCESS:
            {
                // Copy all processes info from our internal list to usermode array
                PARKPROCESS pArkProcData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pArkProcData ) && VALIDATE_LIST_BUFF_SIZE( dwOutBuffSize, ARKPROCESS, eProcList ) )
                {
                    PPROCLISTENTRY pProcListEntry = NULL;
                    while( STATUS_SUCCESS == GetListEntry( eProcList, nIndex, &pProcListEntry ) )
                    {
                        if( MmIsAddressValid( pProcListEntry ) )
                        {
                            pArkProcData[nIndex].procId = pProcListEntry->dwPID;
                            RtlStringCchCopyA( pArkProcData[nIndex].procName, ARKITLIB_STR_LEN, pProcListEntry->szProcName );
                            ++nIndex;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if( nIndex > 0 )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }
                // Free our internal process list
                DelList( eProcList );
            }
            break;

        case IOCTL_GET_DLLS:
            {
                // Copy all DLLs info from our internal list to usermode array
                PARKDLL pArkDllData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pArkDllData ) && VALIDATE_LIST_BUFF_SIZE( dwOutBuffSize, ARKDLL, eDllList ) )
                {
                    PDLLLISTENTRY pDllListEntry = NULL;
                    while( STATUS_SUCCESS == GetListEntry( eDllList, nIndex, &pDllListEntry ) )
                    {
                        if( MmIsAddressValid( pDllListEntry ) )
                        {
                            pArkDllData[nIndex].baseAddr = pDllListEntry->dwBase;
                            RtlStringCchCopyA( pArkDllData[nIndex].dllName, ARKITLIB_STR_LEN, pDllListEntry->szDllName );
                            ++nIndex;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if( nIndex > 0 )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }
                // Free our internal DLL list
                DelList( eDllList );
            }
            break;

        case IOCTL_GET_DRIVERS:
            {
                // Copy all drivers info from our internal list to usermode array
                PARKDRIVER pArkDrvData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pArkDrvData ) && VALIDATE_LIST_BUFF_SIZE( dwOutBuffSize, ARKDRIVER, eDrvList ) )
                {
                    PDRIVERLISTENTRY pDrvListEntry = NULL;
                    while( STATUS_SUCCESS == GetListEntry( eDrvList, nIndex, &pDrvListEntry ) )
                    {
                        if( MmIsAddressValid( pDrvListEntry ) )
                        {
                            pArkDrvData[nIndex].baseAddr = pDrvListEntry->dwBase;
                            pArkDrvData[nIndex].endAddr = pDrvListEntry->dwEnd;
                            pArkDrvData[nIndex].entryPoint = pDrvListEntry->dwEntryPoint;
                            RtlStringCchCopyA( pArkDrvData[nIndex].driverName, ARKITLIB_STR_LEN, pDrvListEntry->szDrvName );
                            ++nIndex;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if( nIndex > 0 )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }
                // Free our internal driver list
                DelList( eDrvList );
            }
            break;

        case IOCTL_GET_SSDTHOOKS:
            {
                // Copy all SSDT hooks info from our internal list to usermode array
                PARKSSDTHOOK pArkSsdtData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pArkSsdtData ) && VALIDATE_LIST_BUFF_SIZE( dwOutBuffSize, ARKSSDTHOOK, eSsdtList ) )
                {
                    PSSDTHOOKLISTENTRY pSsdtListEntry = NULL;
                    while( STATUS_SUCCESS == GetListEntry( eSsdtList, nIndex, &pSsdtListEntry ) )
                    {
                        if( MmIsAddressValid( pSsdtListEntry ) )
                        {
                            pArkSsdtData[nIndex].unSsdtIndex = pSsdtListEntry->unIndex;
                            pArkSsdtData[nIndex].baseAddr = pSsdtListEntry->dwBase;
                            pArkSsdtData[nIndex].endAddr = pSsdtListEntry->dwEnd;
                            pArkSsdtData[nIndex].hookAddr = pSsdtListEntry->dwHookAddr;
                            RtlStringCchCopyA( pArkSsdtData[nIndex].driverName, ARKITLIB_STR_LEN, pSsdtListEntry->szDrvName );
                            ++nIndex;
                        }
                        else
                        {
                            break;
                        }
                    }

                    if( nIndex > 0 )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }
                // Free our internal driver and SSDT list
                DelList( eDrvList );
                DelList( eSsdtList );
            }
            break;

        case IOCTL_GET_SYSENTERHOOK:
            {
                // Copy sysenter hook data to usermode buffer
                PARKSYSENTERHOOK pSysenterHookData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pSysenterHookData ) )
                {
                    if( ScanAndGetSysenterHook( pSysenterHookData ) )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }

                // Free driver list
                DelList( eDrvList );
            }
            break;

        case IOCTL_GET_KINLINEHOOK:
            {
                PARKINLINEHOOK pKernelFuncData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pKernelFuncData ) )
                {
                    if( ScanFunctionInlineHook( pKernelFuncData ) )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwOutBuffSize;
                    }
                }
            }
            break;

        case IOCTL_NT_API_INFO:
            {
                PARKNTAPI pNtApiData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pNtApiData ) )
                {
                    if( STATUS_SUCCESS == InitNtApiData( pNtApiData ) )
                    {
                        retVal = STATUS_SUCCESS;
                        pIrp->IoStatus.Information = dwInBuffSize;
                    }
                }
            }
            break;

        case IOCTL_FIX_ISSUES:
            {
                PARKFIX pFixData = pIrp->AssociatedIrp.SystemBuffer;
                if( MmIsAddressValid( pFixData ) )
                {
                    switch( pFixData->eType )
                    {
                    case eArkKillProcess:
                        {
                            PDWORD pdwPid = (PDWORD)(pFixData->cFixData);
                            if( KillProcess( pdwPid ) )
                            {
                                retVal = STATUS_SUCCESS;
                            }
                        }
                        break;

                    case eArkFixSsdtHook:
                        {
                            PARKFIXSSDT pFixSsdtHookData = (PARKFIXSSDT)(pFixData->cFixData);
                            if( FixSSDTHook( pFixSsdtHookData ) )
                            {
                                retVal = STATUS_SUCCESS;
                            }
                        }
                        break;

                    case eArkFixInlineHook:
                        {
                            PARKFIXINLINEHOOK pFixInlineHook = (PARKFIXINLINEHOOK)(pFixData->cFixData);
                            if( FixInlineHook( pFixInlineHook ) )
                            {
                                retVal = STATUS_SUCCESS;
                            }
                        }
                        break;
                    }

                    if( STATUS_SUCCESS == retVal )
                    {
                        pIrp->IoStatus.Information = dwInBuffSize;
                    }
                }
            }
            break;

        default:
            {
                retVal = STATUS_UNSUCCESSFUL;
                pIrp->IoStatus.Information = 0;
            }
            break;
        }
        pIrp->IoStatus.Status = retVal;
        IoCompleteRequest( pIrp, IO_NO_INCREMENT );
    }
    __except( EXCEPTION_EXECUTE_HANDLER )
    {
        retVal = STATUS_UNSUCCESSFUL;
        DbgPrint( "Exception caught in DrvDispatch()" );
    }
    return retVal;
}
Ejemplo n.º 15
0
Archivo: Lista.cpp Proyecto: lcion/gocl
/*********************************************************************
* Description:
*   
* Revision:
* 2000-02-23 luci 1.0 New
**********************************************************************/
void Lista::InitLst(){
	if(head)
		DelList(head);
	head = NULL;
}
Ejemplo n.º 16
0
Archivo: Lista.cpp Proyecto: lcion/gocl
/*********************************************************************
* Description:
*   
* Revision:
* 2000-02-23 luci 1.0 New
**********************************************************************/
void Lista::DelList(Node *sblist){
	if(sblist->next) DelList(sblist->next);
	delete sblist->strnID;
	delete sblist;
}