TRANSCRIPTEnglish

Making A Kernel Cheat - Part 3/3 - Drawing ESP

17m 47s4,091 words619 segmentsEnglish

FULL TRANSCRIPT

0:00

thank you guys so much for 10 000

0:01

subscribers i genuinely didn't even

0:03

think i would actually hit that number

0:05

when i was around seven to eight

0:06

thousand

0:07

on discord i made my name next video at

0:09

10k because i thought

0:11

i'm never gonna hit that so i'm just

0:12

gonna like quit youtube and that's it

0:14

here we are you guys actually kept

0:16

subscribing even though i haven't

0:17

uploaded a

0:18

proper video for like almost a year we

0:20

still hit 10 000 subscribers and thank

0:22

you so much um

0:24

it really means a lot it shows me that

0:25

you guys actually enjoy my videos

0:27

if you have any video ideas leave a

0:29

comment down below once again

0:31

thank you so much for 10 000 subscribers

0:33

i'm really grateful for it it means a

0:35

lot enjoy this video

0:36

what's going on guys this is going to be

0:38

the last episode of the kernel series

0:39

we're basically just going to draw esp

0:41

from our kernel driver we're just going

0:42

to implement

0:43

uh the win gdi functions in our driver

0:46

so basically a quick rundown on wingdi

0:48

it stands for windows graphics driver

0:50

interface so it's just a programming

0:52

interface core operating system

0:53

component

0:54

and it lets you just output to your

0:55

screen so what can we use that for we

0:57

can draw lines curves boxes and text

0:59

in this video we're focusing on the

1:01

boxes but you can follow the same steps

1:03

in this video to implement draw text

1:05

or lines or whatever you want drawing a

1:07

box so in user mode you can just use the

1:09

function

1:10

frame rec and that's going to basically

1:11

just draw a box on your screen

1:13

now we can't exactly call this function

1:15

from our kernel driver so how we're

1:16

going to do it well we're going to look

1:17

at what this function actually does and

1:19

this is from react os

1:21

and as you can see all this function

1:23

does is it selects the brush that you

1:24

want to use to draw and then it calls

1:27

this function pad blt to draw the

1:29

rectangle the first thing it does is it

1:30

saves

1:31

the current brush before drawing and

1:33

then once it's done drawing with the

1:34

brush you want

1:35

it sets it back to the old brush so next

1:37

thing we need to do is just look at

1:39

these functions here select object and

1:41

pad blt

1:42

and see if we can call them from the

1:44

kernel a way we can do this

1:45

is shout out to this guy no idea how to

1:48

say his name but i'm just going to say

1:49

guru we're going to look at

1:51

the windows syscalls now i usually use

1:53

his website but it's down at the moment

1:55

so

1:55

i'm going to use this github now this

1:57

might look a little familiar we did use

1:58

this in part one when we were looking

2:00

for a function to hook but now we're

2:02

just looking at functions to

2:03

export and call so what this is is it's

2:06

just

2:06

a bunch of syscalls from the win32k

2:09

driver

2:10

and the reason we're interested in this

2:11

one is because it stores a bunch of the

2:13

graphics cisco's

2:14

for the gdi so what we can do is we can

2:15

just control f and

2:17

look for the functions that we're

2:18

interested in i was looking at get dc

2:20

before don't worry about that before we

2:21

get into this i just want to say head

2:23

over to my patreon

2:25

it'll be linked below patreon.com null

2:27

terminator five dollars a month you get

2:29

access to the source code from

2:31

this video and all the other videos on

2:33

my channel and

2:34

recently i've been uploading the

2:36

compiled files as well

2:37

so for the kernel cheat tutorial for

2:39

part one and two you can just have

2:40

access to the files straight away

2:42

you can check out the code as well

2:44

you'll have all the source code so this

2:45

is all you've got to do just search

2:46

the function you want to look at and

2:49

then just react os and it'll pop up here

2:52

so here's the code for frame rack the

2:54

first function i want to look at

2:56

is select object now i don't really care

2:58

about this line because i'm just going

2:59

to delete this line but

3:00

we do need this one because we need to

3:01

set it to the brush that we want

3:03

so it takes in the hdc which is a

3:06

handle to the device context and it

3:08

takes in the

3:09

object that you want to select okay

3:12

now what this function does is it just

3:14

has a switch case and it just looks for

3:16

which

3:17

type of object you're trying to select

3:19

but in this case

3:20

since we're just implementing frame

3:22

rates we're trying to select a brush so

3:24

let's see what would happen so it does

3:26

checks what handle type it is it's not a

3:28

region type not a bitmap it's a brush

3:30

type and of course this function select

3:31

brush

3:32

so let's just do this function so this

3:34

one is a bit more specific

3:35

nice takes in htc and a brush which is

3:38

exactly what we want so we'd probably

3:39

just want to call this function anyway

3:41

but

3:41

let's look at the syscalls and check if

3:44

select object is in there and uh it's

3:46

not in here so

3:47

let's look at select brush

3:50

okay so select brush is in here so that

3:53

means we can

3:54

export it and call it from our kernel

3:55

driver next function we're going to need

3:57

is this thing pat blt so same as select

4:00

object we're just going to check if it's

4:01

in here

4:02

and if it is then we can just call it

4:04

directly otherwise

4:05

oh it isn't here so we can export um

4:08

select

4:09

not select object we can export select

4:10

brush and replace

4:12

select object with select brush because

4:13

it's doing the same thing and then we

4:15

can just

4:15

export pat blt as well to do this part

4:18

so let's um implement this in the code

4:19

i'm using the same project from

4:21

part one and two i just downloaded this

4:23

from my patreon because i'm pretty sure

4:25

i've lost the original project but

4:26

anyway i'm just having a quick

4:28

look through here and there's a couple

4:29

things i want to change um

4:31

i don't know why i did this not equal

4:33

default it should

4:35

be something like this

4:38

i'm not even doing else ifs i'm just

4:40

doing if statements it could do

4:42

three operations in one call which is

4:44

not

4:45

how it's designed it's meant to be one

4:46

operation per call so i'm just going to

4:48

add the else fcr to make it safer

4:50

because you don't really want to just

4:52

request the base but then it ends up

4:54

writing some random bit of memory or

4:56

whatnot anyway all right great

4:57

so how do we actually implement this

4:59

into our code and export these functions

5:01

so all you want to do is let's start

5:03

with select brush so you just copy this

5:04

part here paste it into the code and you

5:06

want to just add a bit so you want to

5:07

say type def

5:08

i don't think that matters do this this

5:12

and then you want to add a semicolon

5:13

right there man and that's it so now we

5:15

have a typedef

5:16

for the function we had another function

5:18

pad blt so copy this

5:22

i'm pretty sure this is x y

5:25

width high yeah so i'm pretty sure

5:27

that's right and then the last one the

5:28

word cool no okay

5:30

so we're just going to do the same thing

5:31

type dev and get rid of this

5:34

okay great so we need to export another

5:35

function to actually get the device

5:37

context and the way you do it in user

5:39

mode is with

5:40

get dc so first thing we want to check

5:42

is if there's just a kernel function we

5:43

can export that does it for us

5:45

but if there isn't then that's when you

5:46

want to go in react os look at the user

5:49

mode function

5:49

and see what kernel functions it calls

5:52

and you're going to have to basically

5:53

just replicate

5:54

the user mode function in kernel right

5:55

and call the functions it's calling

5:57

by exporting those specific functions

5:59

luckily there's a syscall that we can

6:01

just

6:01

export and call so it's going to be

6:03

enter user get dc

6:05

so this is it in react os i clicked on

6:07

it just to get this side here that we

6:08

can just copy and paste

6:10

and we're just gonna have to do this

6:11

type def thing again

6:17

just like that so we have select brush

6:19

uh pad blt

6:21

and get dc let's see if we need any

6:24

more okay yeah so we're going to need to

6:26

create the brush as well which doesn't

6:28

show up here but

6:29

it requires a brush as a parameter so

6:31

the way you do it in windy eyes you just

6:33

create brush so i'm just going to search

6:35

create first i'm going to search brush

6:36

so i don't know what it's called exactly

6:38

so i'm just going to go through all of

6:39

these

6:40

and there we go so we see create solid

6:42

brush which is just the kernel

6:44

uh syscall that we can export so since

6:46

we can export it i'm

6:48

going to search it in react os um this

6:50

one

6:51

and then we just copy this

6:56

i'm sorry if this is a little all over

6:57

the place i usually have like a second

6:59

monitor

7:00

to keep me on track with like notes and

7:02

stuff i don't have that anymore

7:04

and i'm kind of just doing this on the

7:06

fly so we got select brush

7:08

pad blt get dc create brush let's just

7:12

triple check make sure we're not missing

7:13

any other function so we can get the dc

7:16

the rectangle is just uh we create our

7:18

own rectangle

7:19

we can create the brush we can select

7:21

the brush and we can draw the actual

7:22

rectangle okay

7:23

i think that's it so it returns an int

7:27

and it takes this so i'm just honestly

7:30

just gonna oh my god now i'm just gonna

7:31

add the function in this namespace here

7:33

so i'm gonna copy that uh

7:34

do the um get rid of this there you go

7:36

dude copy that again go down here paste

7:38

it

7:38

add this all right cool now we can just

7:40

paste this code into here

7:42

we're going to add our own parameter

7:44

here for the thickness delete this line

7:46

replace select object with select brush

7:49

replace

7:49

pad blt with nt pad blt and lastly

7:52

replace the one with

7:54

the thickness parameter and there we go

7:56

our own frame wrecked function

7:57

the video you just been watching was

7:58

recorded a week ago after that point i

8:00

kind of ran into some problems when i

8:02

was trying to get this to work but i've

8:03

solved those issues it's a week later

8:05

and i'm going to finish off the video

8:06

the functional

8:07

hooking for some reason when you hook

8:09

that function and then you open like

8:10

google chrome it blue screens your

8:12

computer but the way i fix it is just by

8:14

hooking a different function everything

8:15

else is the same you just change the

8:17

function name here you can copy the one

8:18

i'm using here it'll work perfectly fine

8:20

it also comes up in the

8:21

syscall table that we've been using here

8:23

i'm pretty sure these

8:25

other functions around it will work as

8:26

well they're very similar so that fixes

8:28

the blue screen

8:29

next problem for some reason win32k

8:31

doesn't come up in this

8:33

module list so we're gonna have to make

8:34

another module export function

8:36

that can actually find the base address

8:38

of the win32k modules

8:40

so we need to make a function that's

8:41

going to get a

8:43

routine address and it takes in the

8:45

routine name that's going to be a really

8:46

short function

8:47

we need a unicode string and we're

8:49

basically just going to convert

8:50

the parameter into a unicode string and

8:53

we're converting it to a unicode so that

8:55

we can pass

8:56

that into this function here and that'll

8:58

work so that's the function there

8:59

next we're going to pretty much make a

9:01

new version of this function here so i'm

9:03

going to copy this paste it and this

9:05

needs to be

9:05

a wsdr again well we can delete all this

9:08

if you want more information on what i'm

9:09

about to do here

9:11

you can check out this grade right up

9:12

here there's two different write-ups

9:14

this first one has a bunch of

9:15

information on a lot of windows

9:17

internals and other things like that

9:18

i'll link it in the description we're

9:20

looking at how to get kernel module

9:21

addresses so the method we've been using

9:23

is similar to this

9:24

method that he puts here the query

9:26

system information method but this

9:27

wasn't working for me

9:28

because win32k wasn't coming up for me

9:31

it says

9:32

i it works for him but it wasn't working

9:34

i just switched over to another method

9:36

down here

9:37

which is the ps loaded modulus method uh

9:39

we're going to be doing it a similar way

9:40

to this but i just wanted to give credit

9:42

to this guy because this is where i

9:44

learned about this this second write up

9:45

here goes into a lot more detail if you

9:47

really want to understand what's

9:49

happening so this gives a nice

9:50

visualization of the module list and it

9:52

also goes into depth with the kernel

9:54

debugging okay great so let's start

9:55

putting it into code first thing we're

9:57

going to need

9:57

is module list and we're going to get it

9:59

using a little function that we coded

10:01

up here and we want to say es loaded

10:05

module list awesome so that's how you

10:06

get the module list i'm going to quickly

10:08

check if that pointer is valid

10:10

now that we have the list how do we

10:12

actually traverse it so basically the

10:13

way we're going to loop this is going to

10:15

look a little different if you haven't

10:17

worked with doubly linked lists before

10:18

we're basically just going to say

10:20

while we're not at the end of the list

10:22

just go to the next link in the list so

10:24

we're going to create a new variable

10:25

here it's going to be a place entry and

10:27

that's going to be the link and we're

10:28

going to start at the top of the list

10:29

and we want to say while it's not the

10:31

bottom of the list it's going to be b

10:33

link

10:33

equal the next element in the list right

10:35

but while we're not at the bottom

10:37

keep going through the list so now that

10:38

we're in the list okay that's going to

10:40

be the entry

10:41

and we want to use containing record at

10:44

link

10:44

it's going to be a data table entry and

10:46

we want to do the first

10:47

field so this one right here just like

10:51

that now that we have the entry we can

10:52

check

10:53

if it's the right module we're going to

10:54

need another unicode string here

10:56

and it's going to be the module name and

10:58

we're going to be comparing the entry

11:00

based dll name so that's going to be the

11:02

module name right with the one we're

11:03

looking for

11:05

and we want it to be case sensitive so

11:07

if they match we're returning the base

11:08

address

11:08

oh so if the base is valid we're going

11:11

to export the routine

11:13

pass the base and then the routine name

11:15

we're looking for

11:16

otherwise if the dll base is null now

11:18

that we have these export functions that

11:20

we can use head over to our hook.cpt

11:23

i've already got the just recorded this

11:25

by the way my computer crashed and i

11:27

lost the recording

11:28

so i'm doing it again so some of the

11:29

code is still here but we're going to

11:31

have to create the

11:32

function variables right using the type

11:34

defs that we created earlier

11:36

and you just want to set it to null

11:38

initially here i guess just pause the

11:40

video and copy this out

11:41

but what we're going to do is we're

11:42

going to actually use the export

11:44

functions

11:44

in our call kernel function here so this

11:47

is where we set the hook and because

11:48

this only runs one gonna put this code

11:50

in here as well because we only want it

11:52

to run one so we can set our function

11:54

addresses now the way we're going to do

11:55

this

11:56

is by setting the function address

11:59

we want to type cast the return of our

12:01

function that we just created

12:03

so it gets the module export and you

12:04

want to make sure you're passing a wstr

12:06

so it uses the right function because if

12:08

you don't use this l here it's going to

12:10

go to the other

12:11

version here so you see we have two

12:12

versions with the same name so make sure

12:14

that's a wstr

12:15

or select brush it's in win32k full if

12:18

you want to know which module it's in

12:20

you can just use winddbg you can load

12:22

win32k

12:23

full and win 32k base and then search

12:26

for whatever function you're looking for

12:28

so if you're looking for select brush

12:30

you just search select brush in win dbg

12:32

and it'll tell you which module it's in

12:34

it'll be something like this

12:35

formation mark and then like select

12:37

brush or whatever the function name is

12:39

that's going to be the module editing

12:40

and then we want to put the routine name

12:42

which is going to be like this

12:43

with nt at the start i think so now we

12:45

need to do this exact same thing with

12:47

all the other functions i'm just going

12:48

to edit that for you

12:49

this is create solid brush at blt get dc

12:53

release dc and delete object app so i

12:56

just realized i i've added these two

12:58

functions here

12:59

um when i was fixing the code so i think

13:01

you guys wouldn't won't have these type

13:03

devs here so i'll show you guys the type

13:04

devs

13:05

you can go on react os search these

13:08

functions here if you want to get the

13:09

function definitions like that or just

13:11

pause the video and copy these two type

13:13

devs here these are the type def for the

13:15

two function so we're gonna need these

13:16

two functions

13:17

um to release the hdc our device context

13:21

handle and this is going to be

13:22

to delete the handle to the brush that

13:25

we create

13:25

now we can use them in our hook we just

13:27

scroll down here and we're going to add

13:29

another

13:30

if statement and we're going to say if

13:31

we want to draw a box we're going to use

13:33

these functions here

13:34

so we're going to need a new boolean and

13:35

some ins in our struct here so you want

13:37

to add a boolean

13:39

raw box and you want to add

13:42

rgb x y width height and thickness

13:45

as in and we're going to need these to

13:47

draw the actual box the first thing

13:49

we're going to have to do is get the htc

13:51

using our exported function and we pass

13:54

null in there so that we get

13:55

the device context for the whole screen

13:57

the entire monitor so we can draw

13:59

anywhere we want

14:00

i'm going to quickly check if this

14:02

handle is valid and if it's not and

14:04

unsuccessful

14:05

next we need uh the brush we're going to

14:07

use create solid brush you want to pass

14:09

rgb which is a macro this is defined

14:11

in wingdi.h so make sure you include

14:14

that

14:15

it's got r g b and it's from zero to two

14:18

five okay so we wanna pass our

14:20

instructions for r

14:21

g and b and then you wanna pass knob

14:24

once again i'm going to check if the

14:25

brush is a valid handle just like that

14:27

now we can actually draw the rectangle

14:29

oh well we actually need to create the

14:30

rectangle first and that's going to be

14:32

the x

14:32

y the x plus the width and then it's the

14:35

y plus the height now we can call frame

14:37

rect

14:38

as hdc plus the rectangle the brush and

14:41

the thickness

14:41

but now we've drawn the rectangle just

14:43

need to release the hdc and the brush

14:45

and we do this using the new exports

14:48

that we've added

14:48

and you want to pass brush for the

14:50

delete object app and that's it

14:52

that should be it for the driver now we

14:54

want to head over to the user mode

14:56

program and we need to create a function

14:58

to draw the box so

14:59

it's going to be the same as these other

15:01

functions that we have here going to be

15:02

called draw box and it's going to take

15:04

uh

15:04

quite a few parameters going to take the

15:06

x y width height

15:07

thickness r e and b we don't need

15:10

these two don't need these two either

15:13

also i forgot to mention

15:14

um since we changed the struct we need

15:16

to copy it and

15:17

paste it into the user mode one you want

15:19

to make sure that the struct

15:21

is the exact same in the user mode

15:23

program and the driver you also want to

15:24

make sure in the user mode

15:26

program that you change the function

15:28

name as well otherwise it's not going to

15:30

work you're going to make sure this

15:31

function name matches

15:32

the one in the driver and up here okay

15:34

great so the struct matches the function

15:37

matches now we need to

15:38

change these other function calls here

15:40

anytime you add a new

15:42

boolean you need to make sure that

15:43

you're setting that boolean to false in

15:45

all the other function calls so we've

15:47

created the draw box boolean and you

15:48

want to make sure you're setting it to

15:49

false so i'm going to copy this and you

15:51

want to paste it

15:52

in all of the functions i've already

15:54

done it because like i said before i or

15:56

just recorded this

15:57

but the mp4 got corrupted so i have to

15:59

record it again but you just want to

16:00

make sure you're pasting it in all the

16:01

other functions and of course in the

16:03

draw box function

16:04

you want to set it to true and set all

16:06

the other ones to false we'll have to

16:08

set some more instructions here so we

16:09

have the x y with height

16:10

etc the x y width height

16:14

r e b so we're setting the x y i forgot

16:17

the thickness

16:18

good thing i'm double checking out and

16:19

you want to make sure you do the

16:20

thickness now

16:21

down in main i'm just doing a while loop

16:23

and i'm calling dropbox

16:25

5050 size of 50 50 thickness of two

16:29

and it's red i'm going to build this and

16:31

let's hope it works now to map the

16:33

driver i'm using kd mapper google

16:35

kd mapper it's the first link credits to

16:38

the cruise for maintaining this and

16:40

updating it

16:41

adding a bunch of features apparently

16:42

this works on from 1607

16:45

to windows 11. there shouldn't be any

16:47

problems you guys should be able to run

16:48

this download the code and compile it

16:50

and copy the exe over to the directory

16:52

okay great so i'm going to map the

16:53

driver just by dragging and dropping it

16:55

onto kdmapper so we've mapped the driver

16:57

now i'm going to run the user mode

16:59

exe and hopefully it'll draw a box in

17:01

the top left corner and there we go

17:03

you can see it's throwing a box it's on

17:04

top of everything it'll be on top of

17:06

games as well

17:06

i know this is probably a little

17:08

underwhelming just drawing a box in the

17:10

corner of my screen like i said earlier

17:12

this isn't just

17:13

boxes you can follow the same steps in

17:15

this video by going to react os and

17:17

looking up function definition

17:19

and the code for the functions and

17:21

implementing them in your drive and

17:22

specifically you can do this with draw

17:24

tech and you can also do it with a

17:25

function called fill rec to draw filled

17:28

rectangles for like health bars and

17:29

stuff

17:30

anyways here's a clip of my talk of

17:31

cheat that uses this exact same drawing

17:33

method

17:34

um in that one i have implemented draw

17:35

text and fill rec hopefully you guys can

17:37

do that yourselves

17:38

thank you so much for watching once

17:40

again thank you so much for 10 000

17:41

subscribers leave a like

17:42

subscribe okay great goodbye

UNLOCK MORE

Sign up free to access premium features

INTERACTIVE VIEWER

Watch the video with synced subtitles, adjustable overlay, and full playback control.

SIGN UP FREE TO UNLOCK

AI SUMMARY

Get an instant AI-generated summary of the video content, key points, and takeaways.

SIGN UP FREE TO UNLOCK

TRANSLATE

Translate the transcript to 100+ languages with one click. Download in any format.

SIGN UP FREE TO UNLOCK

MIND MAP

Visualize the transcript as an interactive mind map. Understand structure at a glance.

SIGN UP FREE TO UNLOCK

CHAT WITH TRANSCRIPT

Ask questions about the video content. Get answers powered by AI directly from the transcript.

SIGN UP FREE TO UNLOCK

GET MORE FROM YOUR TRANSCRIPTS

Sign up for free and unlock interactive viewer, AI summaries, translations, mind maps, and more. No credit card required.