提问人:zvqle 提问时间:11/3/2023 更新时间:11/3/2023 访问量:90
我想使用 Windows NTAPI 启动一个进程,但它一直出错,错误代码为 c0000033
I Want to start a process using the Windows NTAPI, but it keeps erroring with error code c0000033
问:
我想学习适用于 Windows 的本机 API,所以我决定使用它创建一个进程,它编译没有问题,但是当我运行它时,它给了我一个错误代码 c0000033,检查后,它说这意味着它找不到文件。但文件在目录中
这是项目的代码
#include <Windows.h>
#include <winternl.h>
#include <tchar.h>
#include <stdio.h>
typedef NTSTATUS(NTAPI *PNtCreateProcess)(
_Out_ PHANDLE ProcessHandle,
_In_ ACCESS_MASK DesiredAccess,
_In_opt_ POBJECT_ATTRIBUTES ObjectAttributes,
_In_ HANDLE ParentProcess,
_In_ BOOLEAN InheritObjectTable,
_In_opt_ HANDLE SectionHandle,
_In_opt_ HANDLE DebugPort,
_In_opt_ HANDLE TokenHandle
);
int main() {
HMODULE ntdll = GetModuleHandleW(L"ntdll.dll");
if(!ntdll){
wprintf(L"Failed Getting Handle!\n");
return 0;
}
PNtCreateProcess NtCreateProcess = (PNtCreateProcess)GetProcAddress(ntdll, "NtCreateProcess");
if(!NtCreateProcess){
wprintf(L"Failed Getting Function From NTDLL!\n");
return 0;
}
UNICODE_STRING applicationPath;
RtlInitUnicodeString(&applicationPath, L"C:\\WINDOWS\\NOTEPAD.EXE");
for (int i = 0; i < applicationPath.Length / sizeof(WCHAR); i++) {
wprintf(L"%c", applicationPath.Buffer[i]);
}
wprintf(L"\n");
OBJECT_ATTRIBUTES objectAt;
InitializeObjectAttributes(&objectAt, &applicationPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
CLIENT_ID clientId;
PROCESS_BASIC_INFORMATION pbi;
NTSTATUS status = NtCreateProcess(&clientId.UniqueProcess, PROCESS_ALL_ACCESS, &objectAt, GetCurrentProcess(), FALSE, NULL, NULL, NULL);
if (NT_ERROR(status))
wprintf(L"Error Creating Process!: %x\n", status);
return
status = NtQueryInformationProcess(clientId.UniqueProcess, ProcessBasicInformation, &pbi, sizeof(pbi), NULL);
if(NT_ERROR(status)){
wprintf(L"failed creating process\n");
return 0;
}
return 0;
答: 暂无答案
评论
return
;
return
语句,没有终止符;”
- 以及缺少大括号。return
if (NT_ERROR(status)) wprintf(L"Error Creating Process!: %x\n", status); return
{}
if
if
wprintf()
return
status = NtQueryInformationProcess(...)
status
return
status = NtQueryInformationProcess(...)
"C:\\WINDOWS\\NOTEPAD.EXE"
==>STATUS_OBJECT_NAME_INVALID