I write simple windows x64 applicaiton on assembler (create window and show it). But when I init WNDCLASSEX structure, I`ve got incorrect pointer to WndProc function.
invoke WndProc1, 0,0,0,0 ; for testing purposes. Its fails here, of course
mov wc.cbSize, sizeof WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
; or CS_BYTEALIGNWINDOW
; mov rbx, OFFSET WndProc1
lea rbx, [WndProc1]
mov wc.lpfnWndProc, rbx
I view my code in dissasembler from studio and got strange result:
invoke WndProc1, 0,0,0,0
00007FF6AB941066 xor ecx,ecx
00007FF6AB941068 xor edx,edx
00007FF6AB94106A xor r8d,r8d
00007FF6AB94106D xor r9d,r9d
00007FF6AB941070 call WndProc1 (07FF6AB9411F5h)
mov wc.cbSize, sizeof WNDCLASSEX
00007FF6AB941075 mov dword ptr [wc (07FF6AB944472h)],50h
mov wc.style, CS_HREDRAW or CS_VREDRAW
00007FF6AB94107F mov dword ptr [wc+4h (07FF6AB944476h)],3
; or CS_BYTEALIGNWINDOW
; mov rbx, OFFSET WndProc1
lea rbx, [WndProc1]
00007FF6AB941089 lea rbx,[WndProc1 (07FF6AB941014h)]
mov wc.lpfnWndProc, rbx
Call to function: call WndProc1 (07FF6AB9411F5h)
Get function pointer with LEA or mov: lea rbx,[WndProc1 (07FF6AB941014h)]
I try to use mov rbx, OFFSET WndProc1
- not working same way.
I add testptr dq 0
before WndProc1 in code and lea rbx, [testptr+8]
got right result.
What I doing wrong?
I use visual studio 2022, ml64 and headers from masm64.
I view 'incorrect' address with debugger and get this:
00007FF61115100A jmp mousemove (07FF61115120Bh)
00007FF61115100F jmp timer (07FF6111511FDh)
00007FF611151014 jmp WndProc1 (07FF61115121Fh)
00007FF611151019 jmp main (07FF611151050h)
Its a jump table to my function!