function test(ProcessNAme:pwidechar):boolean;
var
iosb:IO_STATUS_BLOCK;
oa:OBJECT_ATTRIBUTES;
hFile:THandle;
hProcess:THandle;
hSection:THandle;
NtOpenFile:TNtOpenFile;
NtCreateProcess:TNtCreateProcess;
NtCreateSection:TNtCreateSection;
NtQuerySection:TNtQuerySection;
NtCreateThread:TNtCreateThread;
RtlInitializeContext:TRtlInitializeContext;
NtQueryVirtualMemory:TNtQueryVirtualMemory;
NtQueryInformationProcess:TNtQueryInformationProcess;
sii:SECTION_IMAGE_INFORMATION;
objname:TUNICODE_STRING;
thHandle:THandle;
ClientID:CLIENT_ID;
thContext:_Context;
InitialTeb:INITIAL_TEB;
CONST
FILE_EXECUTE =$0020;
FILE_SYNCHRONOUS_IO_NONALERT =$00000020;
var
hModule:thandle;
RealRead:dword;
pi:TProcessInformation;
begin
result:=false;
ModuleHandle:=GetModuleHandle('ntdll.dll');
if ModuleHandle=0 then exit;
@NtOpenFile:=GetProcAddress(ModuleHandle, 'NtOpenFile');
@NtCreateProcess:=GetProcAddress(ModuleHandle,'NtCreateProcess');
@NtCreateSection:=GetProcAddress(ModuleHandle,'NtCreateSection');
@NtQuerySection:=GetProcAddress(ModuleHandle,'NtQuerySection');
@NtCreateThread:=GetProcAddress(ModuleHandle,'NtCreateThread');
@RtlInitializeContext:=GetProcAddress(ModuleHandle,'RtlInitializeContext');
@NtQueryInformationProcess:=GetProcAddress(ModuleHandle,'NtQueryInformationProcess');
if (@NtOpenFile=nil) or (@NtCreateProcess=nil) or
(@NtCreateSection=nil) or (@NtQuerySection=nil) or (@NtCreateThread=nil) or
(@NtQueryInformationProcess=nil) then exit;
fillchar(oa,SizeOf(oa),#0);
with oa do begin
Length:=sizeof(oa);
ObjectName:=@ObjName;
ObjectName.Length:=lstrlenw(ProcessName) * sizeof (widechar);
ObjectName.MaximumLength:=ObjectName.Length+sizeof (widechar);
ObjectName.Buffer:=ProcessName;
Attributes:=OBJ_CASE_INSENSITIVE;
end;
hFile:=0;
if NtOpenFile(hFile,FILE_EXECUTE or SYNCHRONIZE,@oa,@iosb,FILE_SHARE_READ,FILE_SYNCHRONOUS_IO_NONALERT)<>0 then exit;
oa.ObjectName:=nil;
1. Только функция RtlInitializeContext возвращает ошибку — я ей передаю незаполненный InitialTEB, как его заполнять — непонятно, думаю что заполнять нужно как-то из структуры SECTION_IMAGE_INFORMATION.
2. Что за Message в CrsClientthread — его расшифровку я тоже не нашел.