-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Straighten PE/COFF import tables in .EXEs
This is to try to reduce the number of false positives in the various antivirus programs. This may be a breaking change w.r.t. object/library files compiled with earlier versions of Smaller C (especially the ones involved in importing from DLLs). n2f still needs to be updated to support additional assembly directives, most notably for alignment.
- Loading branch information
Showing
47 changed files
with
330 additions
and
568 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file not shown.
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 |
---|---|---|
@@ -1,24 +1,45 @@ | ||
/* | ||
Copyright (c) 2014-2016, Alexey Frunze | ||
Copyright (c) 2014-2019, Alexey Frunze | ||
2-clause BSD license. | ||
*/ | ||
#ifdef _WINDOWS | ||
|
||
asm( | ||
"section .dll_import\n" | ||
"align 4\n" | ||
"dd 0\n" // make sure the section isn't empty | ||
"global __dll_imports\n" | ||
"__dll_imports:" | ||
); | ||
" section .dll_import write align=4\n" | ||
" dd 0\n" | ||
" global __dll_imports\n" | ||
" __dll_imports:\n" | ||
|
||
// The dll imports table (section .dll_imports) will reside between | ||
// sections .dll_import and .dll_imports_trailer due to alphabetic | ||
// ordering of sections by the linker | ||
// .dll_import0_<dll> sections follow. | ||
|
||
asm( | ||
"section .dll_imports_trailer\n" | ||
"dd 0, 0, 0, 0, 0" | ||
" section .dll_import1 write align=4\n" | ||
" dd 0, 0, 0, 0, 0\n" | ||
|
||
// Pairs of sections follow: | ||
// .dll_import2_<dll> | ||
// .dll_import2_<dll>_trailer | ||
|
||
// .dll_import3_<dll> sections follow. | ||
// .dll_import4_<dll> sections follow. | ||
|
||
" section .dll_imports_end write align=4\n" | ||
" global __dll_imports_end\n" | ||
" __dll_imports_end:\n" | ||
" dd 0\n" | ||
|
||
" section .dll_iat write align=4\n" | ||
" dd 0\n" | ||
" global __dll_iats\n" | ||
" __dll_iats:\n" | ||
|
||
// Pairs of sections follow: | ||
// .dll_iat2_<dll> | ||
// .dll_iat2_<dll>_trailer | ||
|
||
" section .dll_iats_end write align=4\n" | ||
" global __dll_iats_end\n" | ||
" __dll_iats_end:\n" | ||
" dd 0\n" | ||
); | ||
|
||
#endif // _WINDOWS |
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,29 @@ | ||
/* | ||
Copyright (c) 2019, Alexey Frunze | ||
2-clause BSD license. | ||
*/ | ||
|
||
// Before including this file define DLL and FXN, e.g.: | ||
// | ||
// #define DLL "kernel32" | ||
// #define FXN "ExitProcess" | ||
// #include "../dimports.h" | ||
|
||
asm( | ||
" section .dll_import2_" DLL " write align=4\n" | ||
" dd _hint_" FXN "\n" | ||
|
||
" section .dll_import3_" DLL " write align=2\n" | ||
" _hint_" FXN ":\n" | ||
" db 0, 0, \"" FXN "\", 0\n" | ||
" align 2, db 0\n" | ||
|
||
" section .dll_iat2_" DLL " write align=4\n" | ||
" global __imp__" FXN "\n" | ||
" __imp__" FXN ":\n" | ||
" dd _hint_" FXN "\n" | ||
|
||
" section .data\n" | ||
" extern __" DLL "_dll__\n" | ||
" dd __" DLL "_dll__\n" // pull DLL.c | ||
); |
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
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
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
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
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
Oops, something went wrong.