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

📄 linux-test.c

📁 linux unified kernel test
💻 C
字号:
/* * linux-test.c * * Copyright (C) 2006  Insigme Co., Ltd * * Authors:  * - Decao Mao, Chenzhan Hu, Lixing Chu, Zhiqiang Jiao  * * This software has been developed while working on the Linux Unified Kernel * project (http://linux.insigma.com.cn) in the Insigma Reaserch Institute,   * which is a subdivision of Insigma Co., Ltd (http://www.insigma.com.cn). *  * The project is sponsored by Insigma Co., Ltd. * * The authors can be reached at linux@insigma.com.cn. * * This program is free software; you can redistribute it and/or modify it * under the terms of  the GNU General  Public License as published by the * Free Software Foundation; either version 2 of the  License, or (at your * option) any later version. * * Revision History: *   Jan 2006 - Created. */  /*  * linux-test.c is used to test the w32 syscall interface.  */  #include "w32syscall.h"#include <stdio.h>#include <stdlib.h>NtAcceptConnectPort(int param0, int param1, int param2, 		int param3, int param4, int param5){	__asm__(	"movl $0x0,%eax\n\t"	"lea 8(%ebp),%edx\n\t"	"int $0x2E\n\t"	);	//printf("vvv %08x",param0);}NtAccessCheck(int param0, int param1, int param2, int param3, 			  int param4, int param5, int param6, int param7){	__asm__(	"movl $0x1,%eax\n\t"	"lea 8(%ebp),%edx\n\t"	"int $0x2E\n\t"	);	//printf("vvv %p",&param0);	//printf("vvv %p",&param7);}/* print values of parameters for check */int main(){	int ret;		long **ServerPortHandle, *NamedPortHandle;	PLPC_MESSAGE LpcMessage;	PLPC_SECTION_WRITE WriteMap;	PLPC_SECTION_READ ReadMap;	BOOLEAN AcceptIt;		ServerPortHandle=malloc(sizeof(long *));	*ServerPortHandle=malloc(sizeof(long));	NamedPortHandle=malloc(sizeof(long));	LpcMessage=malloc(sizeof(LPC_MESSAGE));	LpcMessage->ClientId.UniqueProcess=malloc(sizeof(long));	LpcMessage->ClientId.UniqueThread=malloc(sizeof(long));	WriteMap=malloc(sizeof(LPC_SECTION_WRITE));	WriteMap->SectionHandle=malloc(sizeof(long));	WriteMap->ViewBase=malloc(sizeof(long));	WriteMap->TargetViewBase=malloc(sizeof(long));	ReadMap=malloc(sizeof(LPC_SECTION_READ));	ReadMap->ViewBase=malloc(sizeof(long));		**ServerPortHandle=1;	*NamedPortHandle=2;	LpcMessage->DataSize=31;    	LpcMessage->MessageSize=32;    	LpcMessage->MessageType=33;    	LpcMessage->VirtualRangesOffset=34;    	*((int *) LpcMessage->ClientId.UniqueProcess)=35;	*((int *) LpcMessage->ClientId.UniqueThread)=36;    	LpcMessage->MessageId=37;    	LpcMessage->SectionSize=38;	AcceptIt=4;	WriteMap->Length=51;    	*((int *) WriteMap->SectionHandle)=52;    	WriteMap->SectionOffset=53;    	WriteMap->ViewSize=54;    	*((int *) WriteMap->ViewBase)=55;    	*((int *) WriteMap->TargetViewBase)=56;	ReadMap->Length=61;	ReadMap->ViewSize=62;	*((int *) ReadMap->ViewBase)=63;			printf("test NtacceptConnectPort()\n");	ret=NtAcceptConnectPort((int) ServerPortHandle,(int) NamedPortHandle,(int ) LpcMessage,				(int) AcceptIt,(int) WriteMap,(int) ReadMap);	printf("return:%d\n-------------------\n",ret);	PSECURITY_DESCRIPTOR SecurityDescriptor;	PGENERIC_MAPPING GenericMapping;	PPRIVILEGE_SET PrivilegeSet;	unsigned long *GrantedAccess, *ReturnLength, DesiredAccess;	long *TokenHandle, *AccessStatus;	 		SecurityDescriptor=malloc(sizeof(SECURITY_DESCRIPTOR));	SecurityDescriptor->Owner=malloc(sizeof(long));	SecurityDescriptor->Group=malloc(sizeof(long));	SecurityDescriptor->Sacl=malloc(sizeof(ACL));	SecurityDescriptor->Dacl=malloc(sizeof(ACL));	TokenHandle=malloc(sizeof(long));	GenericMapping=malloc(sizeof(GENERIC_MAPPING));	PrivilegeSet=malloc(sizeof(PRIVILEGE_SET));	ReturnLength=malloc(sizeof(unsigned long));	GrantedAccess=malloc(sizeof(unsigned long));	AccessStatus=malloc(sizeof(long));		SecurityDescriptor->Revision=11;	SecurityDescriptor->Sbz1=12;	SecurityDescriptor->Control=13;	*((int *) SecurityDescriptor->Owner)=14;	*((int *) SecurityDescriptor->Group)=15;	SecurityDescriptor->Sacl->AclRevision=161;	SecurityDescriptor->Sacl->Sbz1=162;	SecurityDescriptor->Sacl->AclSize=163;	SecurityDescriptor->Sacl->AceCount=164;	SecurityDescriptor->Sacl->Sbz2=165;	SecurityDescriptor->Dacl->AclRevision=171;	SecurityDescriptor->Dacl->Sbz1=172;	SecurityDescriptor->Dacl->AclSize=173;	SecurityDescriptor->Dacl->AceCount=174;	SecurityDescriptor->Dacl->Sbz2=175;	*TokenHandle=2;	DesiredAccess=3;	GenericMapping->GenericRead=41;	GenericMapping->GenericWrite=42;	GenericMapping->GenericExecute=43;	GenericMapping->GenericAll=44;	PrivilegeSet->PrivilegeCount=51;	PrivilegeSet->Control=52;	PrivilegeSet->Privilege[0].Luid.LowPart=5311;	PrivilegeSet->Privilege[0].Luid.HighPart=5312;	PrivilegeSet->Privilege[0].Attributes=532;	*ReturnLength=6;	*GrantedAccess=7;	*AccessStatus=8;		printf("test NtAccessCheck()\n");	ret=NtAccessCheck((int) SecurityDescriptor,(int) TokenHandle,(int) DesiredAccess,(int) GenericMapping,			  (int) PrivilegeSet,(int) ReturnLength,(int) GrantedAccess,(int) AccessStatus);	printf("return:%d\n-------------------\n",ret);	return 0;}

⌨️ 快捷键说明

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