FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
MemoryModule/example/DllLoader/DllLoaderLoader.cpp at master · attackgithub/MemoryModule · GitHub
attackgithub
MemoryModule
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
MemoryModule
/
example
/
DllLoader
/
DllLoaderLoader.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
64 lines (53 loc) · 1.24 KB
Breadcrumbs
MemoryModule
/
example
/
DllLoader
/
DllLoaderLoader.cpp
Copy path
File metadata and controls
64 lines (53 loc) · 1.24 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#
define
WIN32_LEAN_AND_MEAN
#
ifndef
_CRT_SECURE_NO_WARNINGS
#
define
_CRT_SECURE_NO_WARNINGS
#
endif
#
include
<
assert.h
>
#
include
<
windows.h
>
#
include
<
tchar.h
>
#
include
<
stdio.h
>
#
include
<
malloc.h
>
#
include
"
../../MemoryModule.h
"
#
define
EXE_FILE
TEXT
(
"
DllLoader.exe
"
)
int RunFromMemory(
void
)
{
FILE
*fp;
unsigned
char
*data=
NULL
;
long
size;
size_t
read;
HMEMORYMODULE
handle;
int
result = -
1
;
fp =
_tfopen
(
EXE_FILE
,
_T
(
"
rb
"
));
if
(fp ==
NULL
)
{
_tprintf
(
_T
(
"
Can't open executable
\"
%s
\"
.
"
),
EXE_FILE
);
goto
exit;
}
fseek
(fp,
0
,
SEEK_END
);
size =
ftell
(fp);
assert
(size >=
0
);
data = (
unsigned
char
*)
malloc
(size);
assert
(data !=
NULL
);
fseek
(fp,
0
,
SEEK_SET
);
read =
fread
(data,
1
, size, fp);
assert
(read ==
static_cast
<
size_t
>(size));
fclose
(fp);
handle =
MemoryLoadLibrary
(data, size);
if
(handle ==
NULL
)
{
_tprintf
(
_T
(
"
Can't load library from memory.
\n
"
));
goto
exit;
}
result =
MemoryCallEntryPoint
(handle);
if
(result <
0
) {
_tprintf
(
_T
(
"
Could not execute entry point: %d
\n
"
), result);
}
MemoryFreeLibrary
(handle);
exit:
free
(data);
return
result;
}
int
main
()
{
return
RunFromMemory
();
}
Back
|
FazBrowse Home
|
New Git URL