📄 w32-test.cpp
字号:
/* * w32-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. */ /* * w32-test.c is used to test the w32 syscall interface. */#include "stdafx.h"#include "w32syscall.h"__declspec(dllimport) __stdcall NtAcceptConnectPort(int param0, int param1, int param2, int param3, int param4, int param5); __declspec(dllimport) __stdcall NtAccessCheck(int param0, int param1, int param2, int param3, int param4, int param5, int param6, int param7); //print values of parameters for checkint _tmain(int argc, _TCHAR* argv[]){ int ret; long **ServerPortHandle, *NamedPortHandle; PLPC_MESSAGE LpcMessage; PLPC_SECTION_WRITE WriteMap; PLPC_SECTION_READ ReadMap; BOOLEAN AcceptIt; ServerPortHandle=(long **) malloc(sizeof(long *)); *ServerPortHandle=(long *)malloc(sizeof(long)); NamedPortHandle=(long *) malloc(sizeof(long)); LpcMessage=(PLPC_MESSAGE) malloc(sizeof(LPC_MESSAGE)); LpcMessage->ClientId.UniqueProcess=malloc(sizeof(long)); LpcMessage->ClientId.UniqueThread=malloc(sizeof(long)); WriteMap=(PLPC_SECTION_WRITE) malloc(sizeof(LPC_SECTION_WRITE)); WriteMap->SectionHandle=malloc(sizeof(long)); WriteMap->ViewBase=malloc(sizeof(long)); WriteMap->TargetViewBase=malloc(sizeof(long)); ReadMap=(PLPC_SECTION_READ) 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=(PSECURITY_DESCRIPTOR) malloc(sizeof(SECURITY_DESCRIPTOR)); SecurityDescriptor->Owner=malloc(sizeof(long)); SecurityDescriptor->Group=malloc(sizeof(long)); SecurityDescriptor->Sacl=(PACL) malloc(sizeof(ACL)); SecurityDescriptor->Dacl=(PACL) malloc(sizeof(ACL)); TokenHandle=(long *) malloc(sizeof(long)); GenericMapping=(PGENERIC_MAPPING) malloc(sizeof(GENERIC_MAPPING)); PrivilegeSet=(PPRIVILEGE_SET) malloc(sizeof(PRIVILEGE_SET)); ReturnLength=(unsigned long *) malloc(sizeof(unsigned long)); GrantedAccess=(unsigned long *) malloc(sizeof(unsigned long)); AccessStatus=(long *) 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 + -