This commit is contained in:
vxunderground 2021-06-03 18:31:21 -05:00 зафіксовано GitHub
джерело 31e1ae3a4c
коміт 6959eb869c
Не вдалося знайти GPG ключ що відповідає даному підпису
Ідентифікатор GPG ключа: 4AEE18F83AFDEB23

@ -1,29 +1,26 @@
#include <windows.h>
/*
DEFINITIONS FOR TEB MUST BE PRESENT
*/
PTEB GetTeb(VOID)
{
#if defined(_WIN64)
return (PTEB)__readgsqword(0x30);
#elif define(_WIN32)
return (PTEB)__readfsdword(0x18);
#endif
}
GetLastErrorAlt function
Summary:
Custom implementation of GetLastError. Relevant for malware dev, eliminates the need to dynamically resolve GetLastError from kernel32.dll
Parameters:
N/A
Return value:
The return value is the calling thread's last-error code.
Remarks:
This function requires the TEB structure to be defined, GetTeb function must also be present. Both are present in WINAPI-TRICKS
Author:
smelly__vx | June 3rd, 2021
*/
DWORD GetLastErrorAlt(VOID)
{
PTEB Teb = (PTEB)GetTeb();
return Teb->LastErrorValue;
}
INT main(VOID)
{
DWORD dwError;
dwError = GetLastErrorAlt();
return ERROR_SUCCESS;
}