Skip to content

Commit

Permalink
Merge pull request #14 from ntoskrnl7/fix/peb-teb
Browse files Browse the repository at this point in the history
Fix PEB, TEB
  • Loading branch information
ntoskrnl7 authored Aug 23, 2022
2 parents 8883233 + eadb396 commit 32f2abc
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
14 changes: 14 additions & 0 deletions include/Ldk/peb.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
#ifndef _LDK_PEB_
#define _LDK_PEB_

#include <winnt.h>
#include <minwindef.h>

#define RTL_USER_PROC_SECURE_PROCESS 0x80000000

typedef struct _RTL_USER_PROCESS_PARAMETERS {
ULONG MaximumLength;
ULONG Length;
ULONG Flags;
} RTL_USER_PROCESS_PARAMETERS, *PRTL_USER_PROCESS_PARAMETERS;

#define FLG_APPLICATION_VERIFIER 0x0100

typedef struct _LDK_PEB {
ULONG NtGlobalFlag;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
} LDK_PEB, *PLDK_PEB;

#endif // _LDK_PEB_
12 changes: 12 additions & 0 deletions include/Ldk/teb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#ifndef _LDK_TEB_
#define _LDK_TEB_

#include "peb.h"

typedef struct _LDK_TEB {
PLDK_PEB ProcessEnvironmentBlock;
} LDK_TEB, *PLDK_TEB;

#endif // _LDK_TEB_
5 changes: 2 additions & 3 deletions src/peb.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ typedef struct _RTL_USER_PROCESS_PARAMETERS {
typedef struct _LDK_PEB {

ULONG NtGlobalFlag;
PRTL_USER_PROCESS_PARAMETERS ProcessParameters;

PVOID ImageBaseAddress;
SIZE_T ImageBaseSize;

// \??\X:\~~~
ANSI_STRING FullPathName;

Expand All @@ -61,8 +62,6 @@ typedef struct _LDK_PEB {

LARGE_INTEGER CriticalSectionTimeout;

PRTL_USER_PROCESS_PARAMETERS ProcessParameters;

PDRIVER_OBJECT DriverObject;
UNICODE_STRING RegistryPath;

Expand Down
1 change: 1 addition & 0 deletions src/teb.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ LdkpCreateTeb (
ExFreeToNPagedLookasideList(&LdkpTebLookaside, Teb);
return NULL;
}
Teb->ProcessEnvironmentBlock = LdkCurrentPeb();
return Teb;
}

Expand Down
2 changes: 2 additions & 0 deletions src/teb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

typedef struct _LDK_TEB {

PLDK_PEB ProcessEnvironmentBlock;

EX_RUNDOWN_REF RundownProtect;

PETHREAD Thread;
Expand Down

0 comments on commit 32f2abc

Please sign in to comment.