malware-dev/5-analyze-teb-struct/main.cpp
2023-11-03 16:58:05 +02:00

24 lines
467 B
C++

#include <windows.h>
#include <winternl.h>
#include <stdio.h>
#include <assert.h>
#define log(msg, ...) printf(msg "\n", ##__VA_ARGS__)
extern "C" {
extern PTEB getTEB(void);
extern DWORD CustomError(void);
}
int main() {
log("TEB: 0x%p", getTEB());
{
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 1337);
assert(process == NULL);
log("Real GetLastError: %ld", GetLastError());
log("Custom GetLastError: %ld", CustomError());
}
return 0;
}