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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
[BITS 64]
;==========================================================================================================================================================================================================
; HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER HEADER
;==========================================================================================================================================================================================================
;{
%define i32 dword
%define i64 qword
[extern CreateCompatibleBitmap]
[extern CreateCompatibleDC ]
[extern CreateWindowExA ]
[extern RegisterClassA ]
[extern DefWindowProcA ]
[extern PeekMessageA ]
[extern SelectObject ]
[extern BitBlt ]
[extern GetDC ]
;}
; WinAPI site = https://msdn.microsoft.com/en-us/library/windows/desktop/hh920508(v=vs.85).aspx
;==========================================================================================================================================================================================================
; END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER END_HEADER
;==========================================================================================================================================================================================================
;==========================================================================================================================================================================================================
; CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE CODE
;==========================================================================================================================================================================================================
[section .code]
;{
start:
;{
mov [instance ], rcx
mov [prev_instance], rdx
mov [cmd_line ], r8
mov [cmd_show ], r9d
; Set personalize resolution
mov [int_length], i32 1203
mov [int_width ], i32 899
call init_windows
.l1:
;{
call windows_event
;}
cmp [quit], i32 0
je .l1
ret
;}
;}
;==========================================================================================================================================================================================================
; END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE END_CODE
;==========================================================================================================================================================================================================
;==========================================================================================================================================================================================================
; FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION FUNCTION
;==========================================================================================================================================================================================================
[section .code]
;{
init_windows:
;{
;=============================================================================================.
; void init_windows (void)
; Purpose : Initiate Window
; Input : None
; Output : Screen
; Data :
[section .data]
;{
.title_windows: db "HackEngine x64", 0
.class_name: db "Classe 1", 0
.icon_program dq 0
.windows_class: times 18 dd 0
;}
[section .code]
;=============================================================================================.
;{
sub rsp, 96 + 32
;{
mov [rsp + 96 + 0], r8
mov [rsp + 96 + 8], r9
mov [rsp + 96 + 16], r10
mov [rsp + 96 + 24], r11
; RegisterClass(&windows_class);
mov rcx, .windows_class
mov i32 [rcx + 0], CS_HREDRAW | CS_VREDRAW ; .style
mov i64 [rcx + 8], windows_procedure ; .lpfnWndProc
mov i32 [rcx + 16], 0 ; .cbClsExtra
mov i32 [rcx + 20], 0 ; .cbWndExtra
mov rax, [instance] ; .hInstance
mov [rcx + 24], rax ; .hInstance
mov rax, [.icon_program] ; .hIcon
mov [rcx + 32], rax ; .hIcon
mov i64 [rcx + 40], 0 ; .hCursor
mov i64 [rcx + 48], 0 ; .hbrBackground
mov i64 [rcx + 56], 0 ; .lpszMenuName
mov i64 [rcx + 64], .class_name ; .lpszClassName
call RegisterClassA
; CreateWindow("Classe 1", "3D engine(HackOS)", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
; CW_USEDEFAULT, CW_USEDEFAULT, LENGTH, WIDTH, NULL, NULL, instance, NULL);
xor rcx , rcx
mov rdx , .class_name ; .lpClassName
mov r8 , .title_windows ; .lpWindowName
mov r9d , WS_OVERLAPPEDWINDOW | WS_VISIBLE ; .dwStyle
mov i32 [rsp + 32], CW_USEDEFAULT ; .x
mov i32 [rsp + 40], CW_USEDEFAULT ; .y
mov eax, [int_length] ; .nWidth
mov [rsp + 48], eax ; .nWidth
mov eax, [int_width] ; .nHeight
mov [rsp + 56], eax ; .nHeight
mov i64 [rsp + 64], 0 ; .hWndParent
mov i64 [rsp + 72], 0 ; .hMenu
mov rax, [instance] ; .hInstance
mov [rsp + 80], rax ; .hInstance
mov i64 [rsp + 88], 0 ; .lpParam
call CreateWindowExA
mov [windows_handle], rax
; GetDC(windows_handle);
mov rcx, rax
call GetDC
mov [device_context_screen], rax
; CreateCompatibleBitmap(device_context_screen, LENGTH, WIDTH);
mov rcx, rax
mov edx, [int_length]
mov r8d, [int_width]
call CreateCompatibleBitmap
mov [texture], rax
; CreateCompatibleDC(device_context_screen);
mov rcx, [device_context_screen]
call CreateCompatibleDC
mov [device_context_texture], rax
; SelectObject(device_context_texture, texture);
mov rcx, [device_context_texture]
mov rdx, [texture]
call SelectObject
mov r8 , [rsp + 96 + 0]
mov r9 , [rsp + 96 + 8]
mov r10, [rsp + 96 + 16]
mov r11, [rsp + 96 + 24]
;}
add rsp, 96 + 32
;}
;=============================================================================================.
; / init_windows
;=============================================================================================.
ret
;}
windows_event:
;{
;=============================================================================================.
; void windows_event()
; Purpose : Manage windows event
; Input : NONE
; Output : NONE
; Data :
[section .data]
.event: times 12 dd 0
[section .code]
;=============================================================================================.
;{
sub rsp, 40 + 32
;{
mov [rsp + 40 + 0], r8
mov [rsp + 40 + 8], r9
mov [rsp + 40 + 16], r10
mov [rsp + 40 + 24], r11
; Bool PeekMessage(LPMSG lpMsg, HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax, UINT wRemoveMsg)
mov rcx , .event
mov rdx , [windows_handle]
xor r8d , r8d
xor r9d , r9d
mov [rsp + 32], i32(PM_REMOVE)
call PeekMessageA
; windows_procedure(windows_handle, event.message, event.wParam, event.lParam)
mov rcx, [windows_handle]
mov edx, [.event + 8] ; event.message
mov r8 , [.event + 16] ; event.wParam
mov r9 , [.event + 24] ; event.lParam
call windows_procedure
mov r8 , [rsp + 40 + 0]
mov r9 , [rsp + 40 + 8]
mov r10, [rsp + 40 + 16]
mov r11, [rsp + 40 + 24]
;}
add rsp, 40 + 32
;}
;=============================================================================================.
; / windows_event
;=============================================================================================.
ret
;}
windows_procedure:
;{
;=============================================================================================.
; void windows_procedure(windows_handle, event.message, event.wParam, event.lParam)
; Purpose : Processes all messages sent or posted to all windows of the class
; Input : parameter 1(windows_handle): rcx
; parameter 2(message): edx
; parameter 3(word_param_msg): r8
; parameter 4(long_param_msg): r9
; Output : NONE
; Data :
[section .data]
;{
_long_param_msg: dd 0, 0 ; LOWORD(long_param_msg), HIWORD(long_param_msg)
_word_param_msg: dd 0, 0 ; LOWORD(word_param_msg), HIWORD(word_param_msg)
long_param_msg dq 0
word_param_msg dq 0
.prev_coord_mouse: dd 0, 0 ; x, y
dd 0, 0
.coord_mouse: dd 0, 0 ; x, y
dd 0, 0
.message dd 0
;}
[section .code]
;=============================================================================================.
;{
sub rsp, 40 + 32
;{
mov [rsp + 40 + 0], r8
mov [rsp + 40 + 8], r9
mov [rsp + 40 + 16], r10
mov [rsp + 40 + 24], r11
mov [windows_handle], rcx
mov [.message ], edx
mov [word_param_msg], r8
mov [long_param_msg], r9
; DefWindowProc(windows_handle, message, wParam, lParam);
mov rcx, [windows_handle]
mov edx, [.message ]
mov r8 , [word_param_msg]
mov r9 , [long_param_msg]
; Switch first or 2nd instruction for get windowed or full screen
call DefWindowProcA
; mov rax, 1
mov r8 , [rsp + 40 + 0]
mov r9 , [rsp + 40 + 8]
mov r10, [rsp + 40 + 16]
mov r11, [rsp + 40 + 24]
;}
add rsp, 40 + 32
;}
;=============================================================================================.
; / windows_procedure
;=============================================================================================.
ret
;}
;}
;==========================================================================================================================================================================================================
; END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION END_FUNCTION
;==========================================================================================================================================================================================================
;==========================================================================================================================================================================================================
; DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA DATA
;==========================================================================================================================================================================================================
[section .data]
;{
quit dd 0
int_length dd 0
int_width dd 0
instance dq 0
prev_instance dq 0
cmd_line dq 0
cmd_show dd 0
texture dq 0
paint_struct: times 18 dd 0
device_context_screen dq 0
device_context_texture dq 0
windows_handle dq 0
;}
;==========================================================================================================================================================================================================
; END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA END_DATA
;========================================================================================================================================================================================================== |
Partager