Windows Hacking
Windows Hacking
Windows
Hacking
Getting into the window
Disclaimer
Dear readers,
This document is provided by VIEH Group for educational purposes
only. While we strive for accuracy and reliability, we make no
warranties or representations regarding the completeness, accuracy, or
usefulness of the information presented herein. Any reliance you place
on this document is at your own risk. VIEH Group shall not be liable
for any damages arising from the use of or reliance on this document.
We acknowledge and appreciate the contribution of the source person.
also,
This document is not created by a professional content writer so any
mistake and error is a part of great design
Scan QR:
I will spare you the rest of the history as we know how this game
played out. Today, Windows is the most used desktop and laptop OS
having a 76% share followed by Apple’s macOS at 16% and the remaining
ChromeOS and other Linux variants.
Like it or not Windows is the major player and throughout the years I
have focused on teaching Reverse Engineering in the Linux environment
so that we could focus on a more thinner and efficient development
and communication with the processor.
Today we begin our journey into the Win32API. This book will take
you step-by-step writing very simple Win32API’s in both x86 and x64
platforms in C and then reversing them both very carefully using the
world’s most popular Hey Rays IDA Free tool which is a stripped down
version of the IDA Pro tool used in more professional Reverse
Engineering environments.
Let’s begin...
Chapter 6: Directories
https://visualstudio.microsoft.com/downloads
Once installed, let’s create a new project and get started by following the
below steps.
Create a new project
Empty Project
Next
Project name: 0x0001-hello_world-x86
CHECK Place solution and project in the same directory
Create
RT CLICK on the 0x0001-hello_world-x86 in Solutions Explorer
Add
New Item…
main.asm
RT CLICK 0x0001-hello_world-x86
Build Dependencies
Build Customizations
CHECK masm
OK
RT CLICK on main.asm
Properties
Configuration Properties
General
Item Type: Microsoft Macro Assembler
OK
.686
.model flat, stdcall
.stack 4096
.data
msg_txt db"Hello World", 0
msg_caption db"Hello World App", 0
.code
main:
push0 ;UINT uType
leaeax, msg_caption;LPCSTR lpCaption pusheax
leaeax, msg_txt;LPCSTR lpText
pusheax
push0;HWND hWnd
callMessageBoxA@16
push0;UINT uExitCode
callExitProcess@4
end main
Congratulations! You just created your first hello world code in x86 Windows
Assembly. Time for cake!
Let’s take a moment and review. To begin we designate a .686 which means
enable the assembly of non-privileged instructions for the Pentium Pro+ style
architecture in 32-bit MASM.
(VISIT https://docs.microsoft.com/en-us/cpp/assembler/masm/dot-686?view=msvc-160)
Our second Win32API that we will call is the ExitProcess which simply exits
the application and frees up the operation to the Windows OS.
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-
processthreadsapi-exitprocess)
We see that the function is a void function which returns nothing and
has one param UINT uExitCode which simply retrieves the process’s
exit value.
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-
messageboxa)
We have 4 params here so we know we will have an @16 at the end of the
function.
The first param is HWND hWnd which is a handle to the owner of the window
of the message box to be created and in our case it is NULL meaning the
message box has no owner.
We then have the LPCSTR lpText which will display our text inside the
message box.
We then have the LPCSTR lpCaption which will be the caption text on the
message box.
Finally we have the UINT uType which is simply the combo of flags from the
table located in the docs. In our case it will be NULL.
Remember in stdcall we push the params in REVERSE order onto the stack
as you see in the code above.
At this point we can run our code by clicking on the green arrow next to the
Local Windows Debugger.
Select x64 to the right of Debug and the left of Local Windows Debugger menu bar
.data
msg_txt db 'Hello World', 0
msg_caption db 'Hello World App', 0
.code
main proc
sub rsp, 20h ;shadow stack
ret
main endp
end
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-
postquitmessage)
Congratulations! You just created your first hello world code in x64 Windows
Assembly. Time for cake, again!
Let’s take a moment and review. We first need to understand the x64 calling
convention.
The Microsoft x64 calling convention, fastcall, is what we use in x64. What we
see here under the Parameter passing section is by default, the x64 calling
convention passes the first four arguments to a function in registers. The
registers used for these arguments depend on the position and type of the
argument. Remaining arguments get pushed on the stack in right-to-left
order. The caller cleans up the stack after the call.
Integer valued arguments in the leftmost four positions are passed in left-to-
right order in RCX, RDX, R8, and R9, respectively. The fifth and higher
arguments are passed on the stack as previously described. All integer
arguments in registers are right-justified, so the callee can ignore the upper
bits of the register and access only the portion of the register necessary.
The shadow space is the mandatory 32 bytes (4x8 bytes) which we must
reserve for the called procedure. We provide 32 bytes on the stack before
calling. This space can be left uninitialized.
In this calling convention, arguments after the 4th are pushed on the stack,
which are on top of this shadow space (pushed before the 32 bytes).
We then setup and call our MessageBoxA Win32API again. We do not need
to review the params as we have handled this earlier in our x86 example.
At this point we can run our code by clicking on the green arrow next to the
Local Windows Debugger.
10
https://hex-rays.com/ida-free/#download
When The input file was linked with debug information modal pops up
select Yes as we will use the symbols in our reversing as we learn
the Win32API.
Immediately it shows the disassembly and drops us into the _main
function.
11
The first 48h is ascii. Let’s load up an ascii table and do some simple
investigation.
https://www.asciitable.com
Here we see 0x48 or 48h as H. This makes sense as our msg_caption begins
with a capital H.
We are currently in the IDA View-A tab. Let’s click on the 48h value and the
click on the Hex View-1 tab to the right of IDA View-A.
If we click back on the IDA View-A tab we can follow the same
procedure and as the above images indicate we can see our msg_txt
section as well following the same pattern.
Let’s his the esc button and go back to our _main function.
12
We see it load up our source code window which is quite handy as we can see
that it broke on the push 0 instruction.
Let’s ignore this window for now and click on the IDA View-EIP window to the
left.
Here we see a number of different windows. We see our Code window.
13
The next window is the Modules window which shows the application and
all of the respective .dll libs it is using. Like the registers
window you will need to scroll.
We then have our Stack view window which the top of the stack is
highlighted in blue. Like all of the others it is scrollable.
We have our Hex View-1 window where if you type g within the window you
can seek to that given memory address within the hex.
14
Let’s step through the code. Let’s enable the debugger menu.
Let’s click on the first blue icon with the two arrows to single-
step. Let’s single-step twice.
We are now about to execute the first push eax instruction. We see
msg_caption moved into eax. Before we step take note of the Stack
view window as well.
15
We see the msg_caption moved to the top of the stack as it was just pushed
from eax.
Take immediate note of the value in esp as that is the top of the stack.
16
Notice that the top of the stack, in this case 0x006ffdc0 holds the
value of 0 which was the LAST, most recent value pushed to the stack.
Remember that the STACK GROWS DOWN in memory. The value of ebp which
is the stack base pointer is HIGHER in memory as compared to esp.
Please write this down.
As we push more items onto the stack esp will continue to grow
DOWNWARD in memory and therefore the gap between ebp and esp grows
larger as esp is growing downward toward the heap until either call
occurs which will collapse the stack frame (ebp to esp) OR a pop
operation will pop the value in esp into whatever you are popping it
into and therefore moving esp UPWARD in memory.
At the +4 offset we see msg_txt which was the 2nd to the last thing
pushed onto the stack.
At the +8 offset we see msg_caption was the 3rd to the last thing
pushed onto the stack.
Finally at +12 or +0xc we see 0 which was the 4th to the last thing
pushed onto the stack.
We can step over the call to _MessageBoxA@16 and it will load our
modal window.
When we continue execution we will see our program run and we now
have a complete idea of how this simple programs works as we did a
complete dynamic reversing analysis on this binary.
17
Double-click on msg_caption.
We noticed in the last chapter that 0x48 begins the string as we know in the
ascii table that 0x48 is in fact ‘H’.
https://www.asciitable.com
18
48 61 63 6B 79 20 57 6F 72 6C 64 20 41 70 70 00
Click OK.
OK.
Click the green play button. We notice two warning windows which we can
ignore stating that the binary has changed.
We broke on our first break point. Let’s hit the play button again.
19
You could also take it a step further and hack the actual msg_txt if you so
chose.
This is the first of many small hacks. The purpose of this book it to take
SMALL steps. Take very careful analysis on exactly what is happening at the
assembly level and understanding have to have absolute control over the
process.
20
After loading Ida Free, click Go Work on your own and drag-and-drop
the 0x0001-hello_world-x64.exe into it.
When the Load a new file modal pops up click OK.
When The input file was linked with debug information modal pops up
select Yes as we will use the symbols in our reversing as we learn
the Win32API.
Immediately it shows the disassembly and drops us into the main
function.
Take note and re-read Chapter 2. Unlike x86 where we push params to
the stack we are moving the params into rcx, rdx, r8, r9. This is
how x64 handles their function calls at the Assembly level.
Let’s first examine what is inside msg_caption so the first step is
to double-click on the msg_caption text which will take us into the
.data section of the code.
21
https://www.asciitable.com
Here we see 0x48 or 48h as H. This makes sense as our msg_caption begins
with a capital H.
We are currently in the IDA View-A tab. Let’s click on the 48h value and the
click on the Hex View-1 tab to the right of IDA View-A.
If we click back on the IDA View-A tab we can follow the same
procedure and as the above images indicate we can see our msg_txt
section as well following the same pattern.
Let’s his the esc button and go back to our main function.
Let’s click on the mov r9, rax instruction and hit f2 to set a
breakpoint. You will notice a red box highlight that line.
When we click on the green play button next to Local Windows Debugger it
will then begin the debugging session.
22
Let’s click on the first blue icon with the two arrows to single- step. Let’s
single-step once.
We see the value of rax moved into r9 which holds the value of start. This is
the fourth param in reverse order.
We then load the effective address of msg_caption into r8 the third param
in reverse order after we step again.
We then load the effective address of msg_txt into rdx the second param
in reverse order after we step again.
23
24
Double-click on msg_caption.
We know from our prior chapters that 0x48 is ‘H’ and the other bytes are
the additional letters.
25
48 61 63 6B 79 20 57 6F 72 6C 64 20 41 70 70 00
Click OK.
OK.
Click the green play button. We notice two warning windows which we can
ignore stating that the binary has changed.
We broke on our first break point. Let’s hit the play button again.
26
#include <stdio.h>
#include <Windows.h>
int main(void)
{
BOOL bDir;
bDir = CreateDirectory(
L"C:\\mydir",
NULL
);
if (bDir == FALSE)
{
printf("CreateDirectory failed & error no %ul\n", GetLastError()); }
else
{
printf("CreateDirectory Success!\n");
}
bDir = RemoveDirectory(
L"C:\\mydir"
);
if (bDir == FALSE)
{
printf("RemoveDirectory failed & error no %ul\n", GetLastError()); }
else
{
printf("RemoveDirectory Success!\n");
}
27
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-
createdirectoryw)
We see we have two params which are lpPathName which is the path of
the directory to be created and lpSecurityAttributes which is a
pointer to a SECURITY_ATTRIBUTES structure. In our case we are just
using NULL.
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-
removedirectoryw)
CreateDirectory Success!
RemoveDirectory Success!
C:\Users\kevin\Documents\Hacking-Windows\0x0006-directories\0x0006-directories\Debug\0x0006-
directories.exe (process 10204) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging-
>Automatically close the console when debugging stops.
Press any key to close this window . . .
28
Since we have created a few projects together I assume you know what you
are doing in IDA at this point. If this process is unfamiliar to you please re-
read the prior chapters.
In the IDA View-A text view we first see our CreateDirectoryW function.
In our last chapter we reviewed the API in C. Here we first push the
lpSecurityAttributes param to the stack followed by the PathName
param and then we call the function.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
Here we see the first param of PathName and then the call.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
The flow of this series now that we have a basic familiarity with IDA
will be a simple reversing of the binary such that we continue to
reinforce how each Windows API looks like in both 32-bit and 64-bit
Assembly as this will help us get a firm grasp on what is going on
under the hood with any Windows binary.
29
There are TONS of good reversing resources out there however my aim is to
take SMALL Win32 API’s and reverse them step-by-step so that in the real
world when you are dealing with obfuscated Windows binaries which might
have dynamic resolution based on a complicated hash you will recognize
patters that you may not have without going through these exercises.
Taking time and getting your hands dirty on these small but digestible
exercises will help you master the domain!
30
In this chapter we will hack the directory name this will continue to build
our experience on custom hacking binaries.
43 00 3A 00 5C 00 6D 00 79 00 64 00 69 00 72 00
43 00 3A 00 5C 00 68 00 61 00 63 00 6b 00 79 00
Click OK.
Click OK.
Let’s set a breakpoint on the next instruction after the call to printf
indicating the CreateDirectory Success! Message.
31
Hooray! We have hacked our simple program and altered the creation of
the directory name.
As I have said before these are small bite-sized lessons that help you to
code, debug and hack in addition to researching each of the Win32API
functions so we have a mastery of the process.
32
Since we have created a few projects together I assume you know what you
are doing in IDA at this point. If this process is unfamiliar to you please re-
read the prior chapters.
In the IDA View-A text view we first see our CreateDirectoryW function.
Here we are simply putting the security attribute into edx, which is
0 and then we load the effective address of PathName into rcx and
call our function.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
Here we see the first param of PathName and then the call.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
33
43 00 3A 00 5C 00 6D 00 79 00 64 00 69 00 72 00
43 00 3A 00 5C 00 68 00 61 00 63 00 6b 00 79 00
Click OK.
Click OK.
Let’s set a breakpoint on the next instruction after the call to printf
indicating the CreateDirectory Success! Message.
34
Hooray! We have hacked our simple program and altered the creation of
the directory name.
35
#include <stdio.h>
#include <Windows.h>
int main(void)
{
BOOL bFile;
bFile = CopyFile(
L"C:\\temp\\test1.txt",
L"C:\\temp\\test2.txt",
TRUE
);
if (bFile == FALSE)
{
printf("CopyFile failed & error no %ul\n", GetLastError());
}
else
{
printf("CopyFile Success!\n");
}
return 0;
}
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-
copyfilew)
36
CopyFile Success!
C:\Users\kevin\Documents\Hacking-Windows\0x000b-copyfile\0x000b-copyfile\Debug\0x000b-
copyfile.exe (process 22464) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging-
>Automatically close the console when debugging stops.
Press any key to close this window . . .
37
the IDA View-A text view we first see our CopyFileW function.
Here we are simply pushing the bFailIfExists onto the stack followed by the
lpNewFileName and finally the lpExistingFileName.
BEFORE we run make sure we delete the file test2.txt within C:\temp so we
can proceed as if this was being run the first time.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
This was a very simple debug as I have to take the time again to clearly
state that our objective is to take SMALL steps so you can not get
overwhelmed and have a full appreciation for what is going on at every step
of these very popular Win32API calls.
38
In this chapter we will hack the directory name this will continue to build
our experience on custom hacking binaries.
32 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
33 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
Click OK.
39
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to CopyFileW.
Hooray! We have hacked our simple program and altered the new file
name.
40
the IDA View-A text view we first see our CopyFileW function.
BEFORE we run make sure we delete the file test2.txt within C:\temp
so we can proceed as if this was being run the first time.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
This was a very simple debug as I have to take the time again to
clearly state that our objective is to take SMALL steps so you can
not get overwhelmed and have a full appreciation for what is going on
at every step of these very popular Win32API calls.
41
In this chapter we will hack the directory name this will continue to build
our experience on custom hacking binaries.
32 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
33 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
Click OK.
42
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to CopyFileW.
Hooray! We have hacked our simple program and altered the new file
name.
43
#include <stdio.h>
#include <Windows.h>
int main(void)
{
BOOL bFile;
bFile = MoveFile(
L"C:\\temp\\test1.txt",
L"C:\\temp\\test2.txt"
);
if (bFile == FALSE)
{
printf("MoveFile failed and error no %ul\n", GetLastError());
}
else
{
printf("MoveFile Success!");
}
}
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-
movefilew)
44
MoveFile Success!
C:\Users\kevin\Documents\Hacking-Windows\0x0010-movefile\Debug\0x0010-movefile.exe (process
10480) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging-
>Automatically close the console when debugging stops.
Press any key to close this window . . .
45
Since we have created a few projects together I assume you know what you
are doing in IDA at this point. If this process is unfamiliar to you please re-
read the prior chapters.
Wait! What?
In our last chapter we reviewed the API in C. Here we first push the
lpNewFileName param to the stack followed by the lpExistingFileName
param and then we call the function.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
46
In this chapter we will hack the file name this will continue to build our
experience on custom hacking binaries.
32 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
33 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
Click OK.
Click OK.
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to _KERNEL32_NULL_THUNK_DATA.
47
Hooray! We have hacked our simple program and altered the new file
name.
48
the IDA View-A text view we first see our MoveFileW function.
Here we are simply putting the value of NewFileName into rdx and the
ExistingFileName into rcx.
BEFORE we run make sure we rename the file test2.txt to test1.txt within
C:\temp so we can proceed as if this was being run the first time.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
This was a very simple debug as I have to take the time again to clearly
state that our objective is to take SMALL steps so you can not get
overwhelmed and have a full appreciation for what is going on at every step
of these very popular Win32API calls.
49
In this chapter we will hack the file name this will continue to build our
experience on custom hacking binaries.
32 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
33 00 2E 00 74 00 78 00 74 00 00 00 00 00 00 00
Click OK.
50
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to CopyFileW.
Hooray! We have hacked our simple program and altered the new file
name.
51
#include <stdio.h>
#include <Windows.h>
int main(void)
{
HANDLE hFile;
hFile = CreateFile(
L"C:\\temp\\test.txt",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed and error no %ul\n", GetLastError());
}
else
{
printf("CreateFile Success!");
}
CloseHandle(hFile);
}
52
CreateFile Success!
C:\Users\kevin\Documents\Hacking-Windows\0x0011-createfile\0x0011-createfile\x64\Debug\0x0011-
createfile.exe (process 6488) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging-
>Automatically close the console when debugging stops.
Press any key to close this window . . .
53
Since we have created a few projects together I assume you know what you
are doing in IDA at this point. If this process is unfamiliar to you please re-
read the prior chapters.
In our last chapter we reviewed the API in C. If you are not familiar with
the parameters please review the last chapter.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
54
In this chapter we will hack the file name this will continue to
build our experience on custom hacking binaries.
74 00 65 00 73 00 74 00 2E 00 74 00 78 00 74
68 00 65 00 73 00 74 00 2E 00 74 00 78 00 74
Click OK.
OK.
55
Hooray! We have hacked our simple program and altered the new file
name.
56
the IDA View-A text view we first see our CreateFileW function.
BEFORE we run make sure we remove the file test.txt within C:\temp so we
can proceed as if this was being run the first time.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
This was a very simple debug as I have to take the time again to clearly
state that our objective is to take SMALL steps so you can not get
overwhelmed and have a full appreciation for what is going on at every step
of these very popular Win32API calls.
57
In this chapter we will hack the file name this will continue to
build our experience on custom hacking binaries.
74 00 65 00 73 00 74 00 2E 00 74 00 78 00 74 00
74 00 65 00 73 00 66 00 2E 00 74 00 78 00 74 00
Click OK.
58
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to CreateFileW.
Hooray! We have hacked our simple program and altered the new file
name.
59
#include <stdio.h>
#include <Windows.h>
int main(void)
{
HANDLE hFile;
BOOL bFile;
char lpBuffer[] = "Reversing is my life!";
DWORD nNumberOfBytesToWrite = strlen(lpBuffer);
DWORD lpNumberOfBytesWritten = 0;
hFile = CreateFile(
L"C:\\temp\\test.txt",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (hFile == INVALID_HANDLE_VALUE)
{
printf("CreateFile failed and error no %ul\n", GetLastError());
}
else
{
printf("CreateFile Success!\n");
}
bFile = WriteFile(
hFile,
60
CloseHandle(hFile);
}
(VISIT https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-
writefile)
CreateFile Success!
WriteFile Success!
C:\Users\kevin\Documents\Hacking-Windows\0x0012-writefile\0x0012-writefile\Debug\0x0012-
writefile.exe (process 7964) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging-
>Automatically close the console when debugging stops.
Press any key to close this window . . .
61
In our last chapter we reviewed the API in C. Here we first push the
lpOverlapped param to the stack followed by the
lpNumberOfBytesWritten param followed by the nNumberOfBytesToWrite
param followed by the lpBuffer param followed by the hFile param and
then we call the function.
Let’s set a breakpoint directly after the call and run the Local
Windows debugger.
NOTICE we see that our test.txt file has been created and populated
with, Reversing is my life!
62
In this chapter we will hack the file name this will continue to build our
experience on custom hacking binaries.
74 00 65 00 6D 00 70 00 5C 00 74 00 65 00 73 00
75 00 65 00 6D 00 70 00 5C 00 76 00 65 00 73 00
Click OK.
Click OK.
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to __imp__WriteFileW@20.
63
Hooray! We have hacked our simple program and altered the new file
name.
64
the IDA View-A text view we first see our WriteFile function.
Here we first putting the lpOverlapped param to the stack, an offset of rsp +
1a0 + dwCreationDisposition followed by the lpNumberOfBytesWritten
param into r9 followed by the nNumberOfBytesToWrite param into r8
followed by the lpBuffer param into rdx followed by the hFile param into rcx
and then we call the function.
BEFORE we run make sure we remove the file test.txt within C:\temp so we
can proceed as if this was being run the first time.
Let’s set a breakpoint directly after the call and run the Local Windows
debugger.
65
In this chapter we will hack the file name this will continue to build our
experience on custom hacking binaries.
74 00 65 00 73 00 74 00 2E 00 74 00 78 00 74 00
74 00 65 00 73 00 74 00 2E 00 66 00 78 00 74 00
Click OK.
Click OK.
Back in the IDA View0A tab, let’s set a breakpoint on the next
instruction after the call to CreateFileW.
66
Hooray! We have hacked our simple program and altered the new file
name.
I hope you have enjoyed this tutorial and have learned how to now take
any remaining Win32API function and reverse engineer it either in x86 or
x64.
Happy Hacking!
67
Jai Hind!
67