简体   繁体   English

typedef c ++的编译器错误

[英]Compiler errors with typedef c++

I'm currently working on meshing together some declarations for ntdll functions from various exploit-db files in order to create a keylogger (educationally).我目前正在努力将来自各种漏洞利用数据库文件的 ntdll 函数的一些声明结合在一起,以创建一个键盘记录器(教育)。 I tried searching around on here, and the general web.我试着在这里和一般的网络上搜索。 I couldn't find anything similar enough to where I could understand how to use it to fix my issue.我找不到任何与我可以理解如何使用它来解决我的问题相似的东西。 I apologize if there's a duplicate, I couldn't find anything related.如果有重复,我很抱歉,我找不到任何相关的内容。

I put these in a header file, and when trying to compile them I get all sorts of errors related to the typedefs within the header, I get error messages mentioning decltype, and I'll admit I can't seem to understand it at all.我把这些放在一个头文件中,当我试图编译它们时,我得到了与头中 typedefs 相关的各种错误,我收到了提到 decltype 的错误消息,我承认我似乎根本无法理解它. I've never really messed with header stuff or with decltype, I searched around, but still can't really understand it.我从来没有真正弄乱过头文件或 decltype,我四处搜索,但仍然无法真正理解它。 The errors occur with this:出现以下错误:

typedef (NTSTATUS) (WINAPI *LPFUN_NtCreateThreadEx)
(
    OUT PHANDLE hThread,
    IN ACCESS_MASK DesiredAccess,
    IN LPVOID ObjectAttributes,
    IN HANDLE ProcessHandle,
    IN LPTHREAD_START_ROUTINE lpStartAddress,
    IN LPVOID lpParameter,
    IN BOOL CreateSuspended,
    IN DWORD StackZeroBits,
    IN DWORD SizeOfStackCommit,
    IN DWORD SizeOfStackReserve,
    OUT LPVOID lpBytesBuffer
);

typedef NTSTATUS(NTAPI *lNtAllocVirtMem)(
    IN  HANDLE  ProcessHandle,
    IN  PVOID   *BaseAddress,
    IN  PULONG  ZeroBits,
    IN  PSIZE_T RegionSize,
    IN  ULONG   AllocationType,
    IN  ULONG   Protect
);

The other error in the main.cpp is: (sorry about the long line) main.cpp 中的另一个错误是:(抱歉排长了)

lNtAllocVirtMem pNtAllocateVirtualMemory=(lNtAllocVirtMem)GetProcAddress(LoadLibaryA("ntdll.dll"),"NtAllocateVirtualMemory");

My errors are(I get a double of both):我的错误是(我得到了两个):

error: expected primary-expression before '__attribute__'
error: typedef 'NTSTATUS' is initialized (use decltype instead)

I would like to know how to solve these (as I plan on adding more), and more importantly, how can I make sure I don't get these from here on out?我想知道如何解决这些问题(因为我计划添加更多内容),更重要的是,我如何确保我不会从这里得到这些?

The type NTSTATUS is defined in the Windows SDK header file winternl.h : NTSTATUS类型在 Windows SDK 头文件Winternl.h 中定义

typedef _Return_type_success_(return >= 0) LONG NTSTATUS;

You need to include that header file instead of trying to define NTSTATUS yourself.您需要包含该头文件,而不是尝试自己定义NTSTATUS The SDK provided definition differs in two ways: 1 It contains SAL annotations that allow you do run static code analysis. SDK 提供的定义在两个方面有所不同: 1它包含允许您运行静态代码分析的 SAL 注释。 2 It provides the correct alias, irrespective of platform. 2它提供正确的别名,与平台无关。 It should be a 32-bit integer value on both x86 and x64 platforms.在 x86 和 x64 平台上,它应该是一个 32 位整数值。 long may be longer than that. long可能比这更长。

The answer was incredibly simple.答案非常简单。 To the header I added:我在标题中添加了:

typedef long NTSTATUS;

It seems to have compiled correctly, and one of the functions works fine from my understanding.它似乎已正确编译,根据我的理解,其中一个功能运行良好。 I thank those who helped for sending me on the right thought process and in the right direction a TON :).我感谢那些帮助我进行正确思考过程和正确方向的人 TON :)。

Edit: By using visual studios, i have access to winternl.h, where NTSTATUS is properly defined, my original answer is not a solution.编辑:通过使用视觉工作室,我可以访问 Winternl.h,其中正确定义了 NTSTATUS,我的原始答案不是解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM