How C + + calls NT functions statically in R3

Source: Internet
Author: User

The original text was first published in Baidu Space 2010-02-22.

1, put ntapi.h, ntdll.lib in a directory, and then set the tool---------Project and Solution--vc++ Directory--Include the file, the new directory is set in the file, and then set the library file, the new directory is set in the file.
The settings above are unified to make it easy for new projects to be used later, and if you want to set up individual items, follow these steps:
Put ntapi.h, ntdll.lib in a directory, right-click on the project--property--c/c++--general--Additional include directory--set the directory path just now, in the linker--general--Additional library directory set just the directory path, in the linker--input-- Additional dependency Settings ntdll.lib.
2, the new header file ABC.h, the contents are as follows:
#ifndef abc_h__
#define ABC_H__
#ifndef Cplusplus
extern "C"
#endif
#include "ntapi.h"
#pragma comment (lib, "Ntdll.lib")
#endif//abc_h__
3, put abc.h in and ntapi.h the same directory, so you can call the NT function statically, using the following example:
#include "stdafx.h"
#include "iostream"
#include "windows.h"
#include "abc.h"
int _tmain (int argc, _tchar* argv[])
{
int pid;
std::cout<< "Please input pid:";
std::cin>>pid;
HANDLE kk=openprocess (0X1F0FFF, false,pid);
NTSTATUS nstatus = ntterminateprocess(kk,0);
std::cin>>pid;
return 0;
}

How C + + calls NT functions statically in R3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.