导入系统功能(windows-ntsystem.dll)以供内联汇编使用 [英] Import a system function (windows - ntsystem.dll) for use in inline assembly

查看:70
本文介绍了导入系统功能(windows-ntsystem.dll)以供内联汇编使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要运行以下代码:

asm
 push eax
 mov eax, esp
 push 0
 push 4
 ...
 call NtQueryInformationThread
 ...
end;

但是我收到错误消息NtQueryInformationThread是
未声明的标识符:'NtQueryInformationThread' 。

But I get the error message that NtQueryInformationThread is "Undeclared identifier: 'NtQueryInformationThread'".

可以帮我声明一下吗?
预先感谢。

Can you please help me declare it? Thanks in advance.

推荐答案

您缺少的是,您需要使程序从 ntdll.dll 。而且,您不需要 asm ,您真的应该避免使用它,因为它会使您的程序难以维护。

What you are missing is that you need to make your program import the function from ntdll.dll. What's more you don't need asm for this and you really should avoid using it because it will make your program hard to maintain.

您可以像导入任何其他Windows API函数一样导入该函数:

You can import the function just like any other Windows API function:

function NtQueryInformationThread(
    ThreadHandle: THandle;
    ThreadInformationClass: THREADINFOCLASS;
    ThreadInformation: Pointer;
    ThreadInformationLength: ULONG;
    ReturnLength: PULONG
): NTSTATUS; stdcall; external 'ntdll.dll';

您也将需要几个类型声明:

You will need a couple of type declarations too:

type
  NTSTATUS = LONG;
  THREADINFOCLASS = DWORD;

这篇关于导入系统功能(windows-ntsystem.dll)以供内联汇编使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆