format PE console use32 entry start include win32a inc -----DATA-----

 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
format PE console
use32
entry start
include 'win32a.inc'
;-----DATA-----;
filen db 'test.txt',0
Handle dd ?
lenz dd ?
buffer db "TEST.txt",0dh,0ah
bufSize = ($-buffer)
buf db 1024 dup(?)
bytesWritten dw ?
res dd ?
std_handle dd 0
;-----DATA-----;
;-----WORK-----;
start:
;-----WORK-----;
invoke GetStdHandle,STD_OUTPUT_HANDLE
mov [std_handle],eax
invoke CreateFile,filen,\ ; filename
GENERIC_WRITE,\ ; for write
FILE_SHARE_READ,\ ; Enables subsequent open operations on a file or device to request read access.
0,\ ; NULL
CREATE_ALWAYS,\ ; Creates a new file, always.Тобишь пишет поверх ,если тот существет
FILE_ATTRIBUTE_NORMAL,\ ; Без атрибутов.
0 ; тэмпл.
Push eax
pop [Handle]
invoke WriteFile,\ ; write text to file
[Handle],\ ; file handle
buffer,\ ; buffer pointer
bufSize,\ ; number of bytes to write
bytesWritten,\ ; number of bytes written
0 ; overlapped execution flag
invoke ReadFile,\
[Handle],\
buf,\
1024,\
1024,\
0
invoke lstrlen,buf
push eax
pop [lenz]
invoke WriteConsole,[std_handle],buf,[lenz],res,NULL
invoke CloseHandle,Handle
call [ExitProcess]
;-----SHIT-----;
data import
library kernel32,'KERNEL32.DLL',\
user32, 'USER32.DLL'
include 'api\kernel32.inc'
include 'api\user32.inc'
end data
;-----SHIT-----;