编译使用命令如下:
>>>g++ criticalproc.cpp
报错F:\criticalproc.cpp:8:18: error: typedef 'NTSTATUS' is initialized (use decltype instead)
typedef NTSTATUS(NTAPI *_NtSetInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
^
F:\criticalproc.cpp:8:18: error: expected primary-expression before 'attribute'
typedef NTSTATUS(NTAPI *_NtSetInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
^
F:\criticalproc.cpp:9:18: error: typedef 'NTSTATUS' is initialized (use decltype instead)
typedef NTSTATUS(NTAPI *_NtQueryInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength OPTIONAL);
^
F:\criticalproc.cpp:9:18: error: expected primary-expression before 'attribute'
typedef NTSTATUS(NTAPI *_NtQueryInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength OPTIONAL);
^
F:\criticalproc.cpp: In function 'BOOL CallNtSetInformationProcess(HANDLE, ULONG)':
F:\criticalproc.cpp:30:2: error: '_NtSetInformationProcess' was not declared in this scope
_NtSetInformationProcess NtSetInformationProcess = (_NtSetInformationProcess)GetProcAddress(GetModuleHandleA("NtDll.dll"), "NtSetInformationProcess");
^~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:31:7: error: 'NtSetInformationProcess' was not declared in this scope
if (!NtSetInformationProcess)
^~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:35:40: error: 'PROCESS_INFORMATION_CLASS' was not declared in this scope
if(NtSetInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, &Flag, sizeof(ULONG))<0)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:35:113: error: 'NtSetInformationProcess' was not declared in this scope
if(NtSetInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, &Flag, sizeof(ULONG))<0)
^
F:\criticalproc.cpp: In function 'BOOL CallNtQueryInformationProcess(HANDLE, PULONG)':
F:\criticalproc.cpp:41:2: error: '_NtQueryInformationProcess' was not declared in this scope
_NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("NtDll.dll"), "NtQueryInformationProcess");
^~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:42:7: error: 'NtQueryInformationProcess' was not declared in this scope
if (!NtQueryInformationProcess)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:46:42: error: 'PROCESS_INFORMATION_CLASS' was not declared in this scope
if(NtQueryInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, pFlag, sizeof(ULONG), NULL)<0)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:46:121: error: 'NtQueryInformationProcess' was not declared in this scope
if(NtQueryInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, pFlag, sizeof(ULONG), NULL)<0)
^
F:\criticalproc.cpp: In function 'void print_help()':
F:\criticalproc.cpp:67:19: error: converting to execution character set: Illegal byte sequence
fwprintf(stderr, L"用法:CriticalProc.exe [/n imagename] [/p [pid]] [/t] [/f] [/q]\n\n
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'void print_err(LPCWSTR, DWORD, LPCWSTR)':
F:\criticalproc.cpp:92:10: error: converting to execution character set: Illegal byte sequence
wprintf(L"%s失败!原因:%s\n", lpWhere, (LPCWSTR)lpMsgBuf);
^~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'HRESULT ParseCommandLine(int, char**, DWORD*, PBOOL, PBOOL)':
F:\criticalproc.cpp:104:44: error: 'towlower' was not declared in this scope
switch (towlower(argv[index][1]))
^
F:\criticalproc.cpp:112:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"查找指定进程失败。可能是您指定了多个进程。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:122:36: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_INVALID_DATA, L"请核对您的输入。");
^~~~~~~~~~~~~~~
F:\criticalproc.cpp:122:73: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_INVALID_DATA, L"请核对您的输入。");
^~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:129:35: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_BAD_LENGTH, L"请将进程名控制在1512个字符之间。");
^~~~~~~~~~~~~~~
F:\criticalproc.cpp:129:70: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_BAD_LENGTH, L"请将进程名控制在1512个字符之间。");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:136:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"查找指定进程失败。可能是您指定了多个进程。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:148:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"指定关键度失败。可能是您指定了多个关键度。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:157:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"指定关键度失败。可能是您指定了多个关键度。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'int main(int, char**)':
F:\criticalproc.cpp:185:10: error: converting to execution character set: Illegal byte sequence
wprintf(L"CriticalProc v1.0 by 旮沓曼_gt428\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:191:26: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"获取调试特权", GetLastError(), L"请尝试以管理员身份运行!");
^~~~~~~~~~~~~~~
F:\criticalproc.cpp:191:59: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"获取调试特权", GetLastError(), L"请尝试以管理员身份运行!");
^~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:194:49: error: converting to execution character set: Illegal byte sequence
if(hProcess == INVALID_HANDLE_VALUE) print_err(L"打开进程", GetLastError(), L"请尝试管理员身份运行!");
^~~~~~~~~~~
F:\criticalproc.cpp:194:78: error: converting to execution character set: Illegal byte sequence
if(hProcess == INVALID_HANDLE_VALUE) print_err(L"打开进程", GetLastError(), L"请尝试管理员身份运行!");
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:198:27: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"设置关键进程时", GetLastError(), NULL);
^~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:204:27: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"询问进程关键度时", GetLastError(), NULL);
^~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:205:16: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:205:49: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~
F:\criticalproc.cpp:205:61: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~
这是为啥啊?
编译使用命令如下:
>>>g++ criticalproc.cpp
报错F:\criticalproc.cpp:8:18: error: typedef 'NTSTATUS' is initialized (use decltype instead)
typedef NTSTATUS(NTAPI *_NtSetInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
^
F:\criticalproc.cpp:8:18: error: expected primary-expression before 'attribute'
typedef NTSTATUS(NTAPI *_NtSetInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength);
^
F:\criticalproc.cpp:9:18: error: typedef 'NTSTATUS' is initialized (use decltype instead)
typedef NTSTATUS(NTAPI *_NtQueryInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength OPTIONAL);
^
F:\criticalproc.cpp:9:18: error: expected primary-expression before 'attribute'
typedef NTSTATUS(NTAPI *_NtQueryInformationProcess)(HANDLE ProcessHandle, PROCESS_INFORMATION_CLASS ProcessInformationClass, PVOID ProcessInformation, ULONG ProcessInformationLength, PULONG ReturnLength OPTIONAL);
^
F:\criticalproc.cpp: In function 'BOOL CallNtSetInformationProcess(HANDLE, ULONG)':
F:\criticalproc.cpp:30:2: error: '_NtSetInformationProcess' was not declared in this scope
_NtSetInformationProcess NtSetInformationProcess = (_NtSetInformationProcess)GetProcAddress(GetModuleHandleA("NtDll.dll"), "NtSetInformationProcess");
^~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:31:7: error: 'NtSetInformationProcess' was not declared in this scope
if (!NtSetInformationProcess)
^~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:35:40: error: 'PROCESS_INFORMATION_CLASS' was not declared in this scope
if(NtSetInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, &Flag, sizeof(ULONG))<0)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:35:113: error: 'NtSetInformationProcess' was not declared in this scope
if(NtSetInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, &Flag, sizeof(ULONG))<0)
^
F:\criticalproc.cpp: In function 'BOOL CallNtQueryInformationProcess(HANDLE, PULONG)':
F:\criticalproc.cpp:41:2: error: '_NtQueryInformationProcess' was not declared in this scope
_NtQueryInformationProcess NtQueryInformationProcess = (_NtQueryInformationProcess)GetProcAddress(GetModuleHandleA("NtDll.dll"), "NtQueryInformationProcess");
^~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:42:7: error: 'NtQueryInformationProcess' was not declared in this scope
if (!NtQueryInformationProcess)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:46:42: error: 'PROCESS_INFORMATION_CLASS' was not declared in this scope
if(NtQueryInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, pFlag, sizeof(ULONG), NULL)<0)
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:46:121: error: 'NtQueryInformationProcess' was not declared in this scope
if(NtQueryInformationProcess(hProcess, (PROCESS_INFORMATION_CLASS)ProcessBreakOnTermination, pFlag, sizeof(ULONG), NULL)<0)
^
F:\criticalproc.cpp: In function 'void print_help()':
F:\criticalproc.cpp:67:19: error: converting to execution character set: Illegal byte sequence
fwprintf(stderr, L"用法:CriticalProc.exe [/n imagename] [/p [pid]] [/t] [/f] [/q]\n\n
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'void print_err(LPCWSTR, DWORD, LPCWSTR)':
F:\criticalproc.cpp:92:10: error: converting to execution character set: Illegal byte sequence
wprintf(L"%s失败!原因:%s\n", lpWhere, (LPCWSTR)lpMsgBuf);
^~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'HRESULT ParseCommandLine(int, char**, DWORD*, PBOOL, PBOOL)':
F:\criticalproc.cpp:104:44: error: 'towlower' was not declared in this scope
switch (towlower(argv[index][1]))
^
F:\criticalproc.cpp:112:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"查找指定进程失败。可能是您指定了多个进程。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:122:36: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_INVALID_DATA, L"请核对您的输入。");
^~~~~~~~~~~~~~~
F:\criticalproc.cpp:122:73: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_INVALID_DATA, L"请核对您的输入。");
^~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:129:35: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_BAD_LENGTH, L"请将进程名控制在1
512个字符之间。");512个字符之间。");^~~~~~~~~~~~~~~
F:\criticalproc.cpp:129:70: error: converting to execution character set: Illegal byte sequence
print_err(L"查找指定进程", ERROR_BAD_LENGTH, L"请将进程名控制在1
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:136:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"查找指定进程失败。可能是您指定了多个进程。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:148:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"指定关键度失败。可能是您指定了多个关键度。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:157:27: error: converting to execution character set: Illegal byte sequence
wprintf(L"指定关键度失败。可能是您指定了多个关键度。请核对您的输入。\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp: In function 'int main(int, char**)':
F:\criticalproc.cpp:185:10: error: converting to execution character set: Illegal byte sequence
wprintf(L"CriticalProc v1.0 by 旮沓曼_gt428\n");
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:191:26: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"获取调试特权", GetLastError(), L"请尝试以管理员身份运行!");
^~~~~~~~~~~~~~~
F:\criticalproc.cpp:191:59: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"获取调试特权", GetLastError(), L"请尝试以管理员身份运行!");
^~~~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:194:49: error: converting to execution character set: Illegal byte sequence
if(hProcess == INVALID_HANDLE_VALUE) print_err(L"打开进程", GetLastError(), L"请尝试管理员身份运行!");
^~~~~~~~~~~
F:\criticalproc.cpp:194:78: error: converting to execution character set: Illegal byte sequence
if(hProcess == INVALID_HANDLE_VALUE) print_err(L"打开进程", GetLastError(), L"请尝试管理员身份运行!");
^~~~~~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:198:27: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"设置关键进程时", GetLastError(), NULL);
^~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:204:27: error: converting to execution character set: Illegal byte sequence
if(!fSuccess) print_err(L"询问进程关键度时", GetLastError(), NULL);
^~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:205:16: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~~~~~~~~~~~
F:\criticalproc.cpp:205:49: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~
F:\criticalproc.cpp:205:61: error: converting to execution character set: Illegal byte sequence
else wprintf(L"指定的进程为%s。\n", bCritical?L"关键进程":L"普通进程");
^~~~~~~~~~~
这是为啥啊?