以下代码尝试使用 NtOpenFile 生成文件句柄:
HANDLE spawnFileHandle(){
HANDLE ret;
IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes;
ObjectAttributes.SecurityDescriptor=0;
ObjectAttributes.SecurityQualityOfService=0;
ObjectAttributes.RootDirectory=0;
ObjectAttributes.Attributes=0;
ObjectAttributes.Length=sizeof(OBJECT_ATTRIBUTES);
WCHAR stringBuffer[5048];
UNICODE_STRING string;
string.Buffer = stringBuffer;
lstrcpyW(stringBuffer, L"\\??\\");
lstrcatW(stringBuffer, EXEPath);
string.Length = lstrlenW(stringBuffer)*2; // Edit after comment.
string.MaximumLength = 5048;
ObjectAttributes.ObjectName=&string;
NTSTATUS error=origZwOpenFile(&ret, FILE_READ_DATA, &ObjectAttributes, &IoStatusBlock, FILE_SHARE_READ, 0);
printf("huh %ls %x", stringBuffer, error);
return ret;
}
但它总是返回 STATUS_OBJECT_NAME_INVALID,例如:
编辑:[HBIP] - 因为我偏执而隐藏 -.-
EXE path : C:\Users\n00b\Desktop\[HBIP]\Debug\[HBIP].exe
huh \??\C:\Users\n00b\Desktop\[HBIP]\Debug\[HBIP].exe c0000033
Spawned Handle : cccccccc
可能是什么原因 ?