FASM、アセンブラ、WinAPIについて簡単に説明します
FASMとは何ですか?-これはアセンブラコンパイラ(フラットアセンブラ)です。
アセンブラとは何ですか?-これらはマシン命令です。つまり、プロセッサに対して何をするかを命令します。
Windows API / WinAPIとは何ですか?-これらはWindowsの機能であり、これらがないとWindowsで作業できません。
WinAPI関数は何をしますか?- 多くのこと:
ファイルの操作。
ウィンドウの操作、画像の描画、OpenGL、DirectX、GDIなど。
他のプロセスとの相互作用。
ポートの操作。
Windowsコンソールの操作
そして、さらに多くの興味深い機能。
なぜアセンブラが必要なのですか?
OSから3Dゲームまで、何でもできます。
アセンブラの長所は次のとおりです。
彼はとても速いです。
.
:
. ()
.
(FASM)?
FASM - https://flatassembler.net/
FASM Editor 2.0 - IDE FASM, fasmworld.ru (asmworld), : https://fasmworld.ru/content/files/tools/FEditor-v2.0.rar
OlyDbg - ollydbg.de: https://www.ollydbg.de/odbg201.zip
8.5MB.
( )
FASM- C:\\FASM\ , FASMEditor.
FASMEdit-a -, C:\\FASM Editor 2.0\
OlyDbg -, C:\\Users\****\Documents\FasmEditorProjects\
FASM Editor-a
.
FASM Editor .
"" ( ) -> "..."
"..." .
. .
"Hello world!" FASM
Fasm Editor "" -> "". , "Console"
, .
format PE Console ; FASM
entry start ; windows- .
include 'win32a.inc' ; FASM-
; .
section '.data' data readable writeable ;
hello db 'hello world!',0 ;
section '.code' code readable writeable executable ;
start: ;
invoke printf, hello ; printf
invoke getch ;
; .
invoke ExitProcess, 0 ; windows-
; ()
section '.idata' data import readable ;
library kernel, 'kernel32.dll',\ ; ,
msvcrt, 'msvcrt.dll'
import kernel,\
ExitProcess, 'ExitProcess'
import msvcrt,\
printf, 'printf',\
getch, '_getch'
, 3: 16, 18, 21 . ( , . )
.
:
2. ( 1, )
: ?
1 : "format PE Console" - FASM- , 1 , ( ).
PE - EXE , .
Console - , .
:
format MZ - EXE- MS-DOS
format PE - EXE- Windows, format PE GUI 4.0
format PE64 - EXE- Windows, 64 .
format PE GUI 4.0 - EXE- Windows, .
format PE Console - EXE- Windows, . ( )
format PE Native -
format PE DLL - DLL- Windows, .
format COFF - OBJ- Linux
format MS COFF -
format ELF - OBJ- gcc (Linux)
format ELF64 - OBJ- gcc (Linux), 64-bit
( ) format PE Console
;
. .
3 : entry start
windows- \ . "start" , .
5 : include 'win32a.inc'
, "win32a.inc" INCLUDE ( FASM). .
8 : section '.data' data readable writeable
, (), , .
"data" ( \\ - ) .
"readable writeable" - -.
'.data' -
10 : hello db 'hello world!',0
hello - , (, ), , , , , FASM , .
db - 1 . 1 .
'hello world!' - ASCII
",0" ? - 0 ( ), 0, . . .
12 : section '.code' code readable writeable executable
"code" - .
"executable" - , .
.
14 : start:
. . 3 start , . , entry
15 : invoke printf, hello
printf - \ . "hello"
, , .
- , - .
, invoke : ( 15 )
push hello
call [printf]
.
17 : invoke getch
getch - , .
20 : invoke ExitProcess, 0
ExitProcess - WinAPI , . , , , .
23 : section '.idata' data import readable
"import" - .
24-25 :
library kernel, 'kernel32.dll',\
msvcrt, 'msvcrt.dll'
"library" DLL ( , ).
DLL .
kernel - , .
: 'kernel32.dll'
- DLL .
\
.
:
library kernel, 'kernel32.dll',\
msvcrt, 'msvcrt.dll'
:
library kernel, 'kernel32.dll', msvcrt, 'msvcrt.dll'
1 1 .
27-28 :
import kernel,\
ExitProcess, 'ExitProcess'
import
- , DLL.
kernel
- DLL, .
ExitProcess
- , , . (WinAPI )
'ExitProcess'
-これは、DLLからロードされる関数の名前です。つまり、これはDLLに書き込まれる関数の名前です。
さらに、説明する価値はないと思います。すべてが明確なようです。
DLLライブラリとは何ですか?
DLL拡張子の付いたファイルです。このファイルには関数が含まれています(何でも)。これは通常のプログラムですが、ダブルクリックでは起動されませんが、プログラムの仮想メモリに読み込まれ、このDLLにある関数が呼び出されます。
まとめ
言語自体を知らなくても、コンパイラのマクロコマンドのみを使用して、アセンブラで記述できます。記事全体で、これpush hello
とcall [printf]
。の2つのアセンブラコマンドについてのみ説明しました。これが何を意味するのかは次の記事で説明します。