windows - 编译没有 kernel32.lib 的 c 程序时出现链接错误
问题描述
我想创建只使用 ntdll 并对其使用安全检查的应用程序。但是当我删除 kernel32.lib 或取消选中“从父级或项目默认值继承”时,我在构建项目时会出现链接错误。 链接错误
#include <Windows.h>
#include <processthreadsapi.h>
#include <vcruntime.h>
ULONG WINAPI NtGetCurrentProcessorNumber(void);
void main()
{
int a = 2;
int b = 5;
int sum = a + b;
int Number = NtGetCurrentProcessorNumber();
while (1)
{
}
}
void NtProcessStartup(PVOID DriverObject, PVOID RegistryPath)
{
__security_init_cookie();
//__security_check_cookie();
main();
}
这是一个本机项目,当我在编译器设置中删除“安全检查”开关并删除“__security_init_cookie”功能时工作正常。这个项目链接到 ntdll.lib
谁能帮我?
解决方案
当您使用安全检查时,__security_xx
功能会链接到您的模块。链接器错误表示gs_support.obj
(__security_xx
函数所在的位置)、需要QueryPerformanceCounter
和其他列出的函数。QueryPerformanceCounter
驻留在 kernel32中,因此在使用安全检查时需要与它链接。
推荐阅读
- asp.net-core - 为什么 Ctrl+C 不停止通用主机?
- c# - 从动态队列 RabbitMQ 读取数据
- python - 在python中使用selenium搜索电子邮件地址并在没有结果时返回信息失败
- docker - 主体反序列化失败(提供的身份无效:x509:证书已过期或尚未生效)
- ios - 在Objective C中添加二维数组的对角线
- python - 具有(单个)最大分区大小的星形和条形
- javascript - 道具更改时反应组件不重新渲染
- python-2.7 - P4Python 在删除客户端时遇到问题 - [错误]:要删除客户端,请先删除所有挂起的更改
- python - 如何将代码中的值与单独文本文档中的值进行比较?
- java - Map.merge .. 不能从静态上下文中引用非静态方法