forked from hasherezade/pe_to_shellcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f4c9d9
commit 03e071d
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required ( VERSION 3.0 ) | ||
project (test_case2) | ||
|
||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT") | ||
include_directories ( include ) | ||
|
||
set (srcs | ||
main.cpp | ||
) | ||
|
||
set (hdrs | ||
) | ||
|
||
add_library ( ${PROJECT_NAME} SHARED ${hdrs} ${srcs} main.def) | ||
|
||
#install | ||
INSTALL( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT ${PROJECT_NAME} ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include <Windows.h> | ||
#include <iostream> | ||
|
||
#define TEST_NAME "Test Case 2" | ||
inline DWORD rotl32a(DWORD x, DWORD n) | ||
{ | ||
return (x << n) | (x >> (32 - n)); | ||
} | ||
|
||
inline char to_lower(char c) | ||
{ | ||
if (c >= 'A' && c <= 'Z') { | ||
c = c - 'A' + 'a'; | ||
} | ||
return c; | ||
} | ||
|
||
DWORD calc_checksum(BYTE *str, size_t buf_size, bool enable_tolower) | ||
{ | ||
if (str == NULL) return 0; | ||
|
||
DWORD checksum = 0; | ||
for (size_t i = 0; i < buf_size; i++) { | ||
checksum = rotl32a(checksum, 7); | ||
char c = str[i]; | ||
if (enable_tolower) { | ||
c = to_lower(c); | ||
} | ||
checksum ^= c; | ||
} | ||
return checksum; | ||
} | ||
|
||
int test_checksum1() | ||
{ | ||
char test1[] = "this is a test!"; | ||
DWORD checks = calc_checksum((BYTE*)test1, strlen(test1), true); | ||
std::cout << "Checks 1: " << std::hex << checks << std::endl; | ||
return checks; | ||
} | ||
|
||
BOOL WINAPI DllMain(HANDLE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | ||
{ | ||
std::cout << __FUNCTION__ << std::endl; | ||
switch (fdwReason) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
std::cout << TEST_NAME << " DLL loaded\n"; | ||
test_checksum1(); | ||
break; | ||
case DLL_THREAD_ATTACH: | ||
case DLL_THREAD_DETACH: | ||
case DLL_PROCESS_DETACH: | ||
std::cout << TEST_NAME << " DLL unloaded\n"; | ||
break; | ||
} | ||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
LIBRARY test_case2 |