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

📄 w32syscall.c

📁 linux unified kernel test
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * w32syscall.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. */  /*  * w32syscall.c is a part of win32 module, handles win32 system call.  * It also includes the W32 syscall function table and other data structures   * (from ReactOS)  */#include "w32syscall.h"#include <linux/kernel.h>#include <linux/module.h>#include <asm/uaccess.h>#include <asm/linkage.h>#include "sysmap.h"void OutputBinary(unsigned char * byteArray,int byteArrayLen);__attribute__((regparm(0)))NTSTATUS STDCALLNtAcceptConnectPort (PHANDLE 		ServerPortHandle,		     HANDLE		NamedPortHandle,		     PLPC_MESSAGE	LpcMessage,		     BOOLEAN		AcceptIt,		     PLPC_SECTION_WRITE	WriteMap,		     PLPC_SECTION_READ	ReadMap){	/*	 * print all the values of parameters	 */// 	char *addr;// 	asm("mov %%esi,%0":"=r"(addr):);// 	printk("old esp = %p\n",addr);// 	printk("ServerPortHandle addr = %p\n",&ServerPortHandle);// 	printk("NamedPortHandle addr = %p\n",&NamedPortHandle);// 	printk("LpcMessage addr = %p\n",&LpcMessage);// 	printk("AcceptIt addr = %p\n",&AcceptIt);// 	printk("WriteMap addr = %p\n",&WriteMap);// 	printk("ReadMap add =%p\n",&ReadMap);		//OutputBinary((unsigned char *)&ServerPortHandle,24);	printk("NtAcceptConnectPort parameters:\n");/*	printk("ServerPortHandle p %p\n",&ServerPortHandle);*/		printk("ServerPortHandle %p \n",ServerPortHandle); 	if (unlikely(!access_ok(VERIFY_READ, ServerPortHandle, sizeof(int)))) 		return -EFAULT; 	if (unlikely(!access_ok(VERIFY_READ, *ServerPortHandle, sizeof(int)))) 		return -EFAULT;	printk("%d\n",*((int *) *ServerPortHandle));	if (unlikely(!access_ok(VERIFY_WRITE, NamedPortHandle, sizeof(int))))		return -EFAULT;	printk("%d\n",*((int *) NamedPortHandle));	if (unlikely(!access_ok(VERIFY_WRITE, LpcMessage, sizeof(LPC_MESSAGE))))		return -EFAULT;	printk("%d\t%d\t%d\t%d\t%d,%d\t%lu,%lu\n",		LpcMessage->DataSize,		LpcMessage->MessageSize,		LpcMessage->MessageType,		LpcMessage->VirtualRangesOffset,		*((int *) LpcMessage->ClientId.UniqueProcess),		*((int *) LpcMessage->ClientId.UniqueThread),		LpcMessage->MessageId,		LpcMessage->SectionSize);	printk("%d\n",AcceptIt);	if (unlikely(!access_ok(VERIFY_WRITE, WriteMap, sizeof(LPC_SECTION_WRITE))))		return -EFAULT;	printk("%lu\t%d\t%lu\t%lu\t%d\t%d\n",		WriteMap->Length,		*((int *) WriteMap->SectionHandle),		WriteMap->SectionOffset,		WriteMap->ViewSize,		*((int *) WriteMap->ViewBase),		*((int *) WriteMap->TargetViewBase));	if (unlikely(!access_ok(VERIFY_WRITE, ReadMap, sizeof(LPC_SECTION_READ))))		return -EFAULT;	printk("%lu\t%lu\t%d\n",		ReadMap->Length,		ReadMap->ViewSize,		*((int *) ReadMap->ViewBase));			return (STATUS_SUCCESS);}__attribute__((regparm(0)))NTSTATUS STDCALLNtAccessCheck(IN  PSECURITY_DESCRIPTOR 	SecurityDescriptor,	      IN  HANDLE 		TokenHandle,	      IN  ACCESS_MASK 		DesiredAccess,	      IN  PGENERIC_MAPPING 	GenericMapping,	      OUT PPRIVILEGE_SET 	PrivilegeSet,	      OUT PULONG 		ReturnLength,	      OUT PACCESS_MASK 		GrantedAccess,	      OUT PNTSTATUS 		AccessStatus){	/*	 * print all the parameters	 */		printk("SecurityDescriptor addr  = %p\n",&SecurityDescriptor);	printk("SecurityDescriptor = %p\n",SecurityDescriptor);	printk("AccessStatus = %p\n",&AccessStatus);		printk("NtAccessCheck parameters:\n"); 	if (unlikely(!access_ok(VERIFY_WRITE, SecurityDescriptor, sizeof(SECURITY_DESCRIPTOR)))) 		return -1;	printk("%d\t%d\t%d\t%d\t%d\t%d,%d,%d,%d,%d\t%d,%d,%d,%d,%d\n",		SecurityDescriptor->Revision,		SecurityDescriptor->Sbz1,		SecurityDescriptor->Control,		*((int *) SecurityDescriptor->Owner),		*((int *) SecurityDescriptor->Group),		SecurityDescriptor->Sacl->AclRevision,		SecurityDescriptor->Sacl->Sbz1,		SecurityDescriptor->Sacl->AclSize,		SecurityDescriptor->Sacl->AceCount,		SecurityDescriptor->Sacl->Sbz2,		SecurityDescriptor->Dacl->AclRevision,		SecurityDescriptor->Dacl->Sbz1,		SecurityDescriptor->Dacl->AclSize,		SecurityDescriptor->Dacl->AceCount,		SecurityDescriptor->Dacl->Sbz2); 	if (unlikely(!access_ok(VERIFY_WRITE, TokenHandle, sizeof(int)))) 		return -2;	printk("%d\n",*((int *) TokenHandle));	printk("%lu\n",DesiredAccess); 	if (unlikely(!access_ok(VERIFY_WRITE, GenericMapping, sizeof(GENERIC_MAPPING)))) 		return -3;	printk("%lu\t%lu\t%lu\t%lu\n",		GenericMapping->GenericRead,		GenericMapping->GenericWrite,		GenericMapping->GenericExecute,		GenericMapping->GenericAll); 	if (unlikely(!access_ok(VERIFY_WRITE, PrivilegeSet, sizeof(PRIVILEGE_SET)))) 		return -4;	printk("%lu\t%lu\t%lu,%lu,%lu\n",		PrivilegeSet->PrivilegeCount,		PrivilegeSet->Control,		PrivilegeSet->Privilege[0].Luid.LowPart,		PrivilegeSet->Privilege[0].Luid.HighPart,		PrivilegeSet->Privilege[0].Attributes); 	if (unlikely(!access_ok(VERIFY_WRITE, ReturnLength, sizeof(ULONG)))) 		return -5;	printk("%lu\n",*ReturnLength); 	if (unlikely(!access_ok(VERIFY_WRITE, GrantedAccess, sizeof(ACCESS_MASK )))) 		return -6;	printk("%lu\n",*GrantedAccess); 	if (unlikely(!access_ok(VERIFY_WRITE, AccessStatus, sizeof(NTSTATUS)))) 		return -7;	printk("%lu\n",*AccessStatus);		  	return (STATUS_SUCCESS);}
#define DbgPrint printk
#define MAX_TEMP 100
void OutputBinary(unsigned char * byteArray,int byteArrayLen)
{
	unsigned long offset;
	int    i, j, k;

	DbgPrint("Date size is : %2d byte\n",(unsigned int)byteArrayLen);
	if (byteArrayLen <= 0 )
	{
		return;
	}
	i = 0;
	offset = 0;
	for (k = byteArrayLen/16; k>0; k--, offset += 16)
	{
		DbgPrint("%""08X  ",(unsigned int)offset);
		for ( j = 0; j < 16; j++, i++ )
		{
			if ( j == 7 )
			{
				DbgPrint("%""02X-",byteArray[i]);
			}
			else
			{
				DbgPrint("%""02X ",byteArray[i]);
			}
		}
		DbgPrint("   ");
		i -= 16;
		for ( j = 0; j < 16; j++, i++ )
		{
			if ((byteArray[i] >= ' ') && (byteArray[i] < 255 ))
			{
				DbgPrint("%c",byteArray[i]); 
			}
			else
			{
				DbgPrint("."); 
			}
		}
		DbgPrint("\n");
		if((offset!=0) && (((offset/16+1)%8)==0))
		{
			DbgPrint("\n");
		}
	}  /* end of for */
	k = byteArrayLen - i;
	if (k <= 0)
	{
		return;
	}
	DbgPrint("%""08X ",(unsigned int)offset);
	for (j = 0 ; j < k; j++, i++)
	{
		if (j == 8)
		{
			DbgPrint("-%""02X", byteArray[i]);
		}
		else
		{
			DbgPrint(" %""02X", byteArray[i]);
		}
	}
	i -= k;
	for ( j = 16 - k; j > 0; j-- )
	{
		DbgPrint("   ");
	}
	DbgPrint("    ");
	for ( j = 0; j < k; j++, i++ )
	{
		if ((byteArray[i] >= ' ') && ( byteArray[i] <= 255 ))
		{
			DbgPrint("%c", byteArray[i]); 
		}
		else
		{
			DbgPrint("."); 
		}
	}
	DbgPrint("\n");
	return;

⌨️ 快捷键说明

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