flat assembler
Message board for the users of flat assembler.
Index
> Windows > very basic thunk - does not work on x64 |
Author |
|
revolution 28 Mar 2009, 14:03
And this is assembly related somehow?
Perhaps you meant to post in the heap? |
|||
28 Mar 2009, 14:03 |
|
wisepenguin 28 Mar 2009, 14:17
hello,
i will surely move it to the heap if thats the best place for it, but i thought the thunk code would classify it as assembly. thanks |
|||
28 Mar 2009, 14:17 |
|
comrade 29 Mar 2009, 03:06
This is assembly rleated because he is injected instructions into the program.
Those instructions are x86 instructions - the encodings on x86-64 are slightly different and mean different things. |
|||
29 Mar 2009, 03:06 |
|
revolution 29 Mar 2009, 04:41
comrade wrote: This is assembly rleated because he is injected instructions into the program. |
|||
29 Mar 2009, 04:41 |
|
wisepenguin 29 Mar 2009, 09:25
hello,
if a mod doesn't mind would they be able to move this to the heap, as heap may be a better place for this code ? i compiled the code with fasm 1.67.36 - using use32 for x86, and use64 for the x64 code. the code is in the comments above but i used Code: use64 mov rax, 1234567890abcdefh jmp rax for the 64bit version. i had a fresh look this morning and to my relief i have got the code working - although im quite ashamed i made such an obvious mistake. the byte order of the mov instruction was the wrong way around - i had the x64 prefix 2nd. the fix is Code: *pMov = 0xb848; with this now working, hopefully i can get the full thread class thunk working and be on my way to learning more about x64 architecture. have a good day ps. offtopic. comrade i liked your vc6 page. i too use vc6 to this day and much prefer it - its great. i also like the simple hex editor within it. i use vc6 on windows xp64. |
|||
29 Mar 2009, 09:25 |
|
vid 29 Mar 2009, 09:26
Quote: Pushing hex codes around is not assembly. Working with mnemonics and converting source code into binary is assembly. If that is your definition of "assembly", and this board should (except for Heap) should be assembly only, then it would be very limited scope. |
|||
29 Mar 2009, 09:26 |
|
revolution 29 Mar 2009, 10:30
vid wrote:
Now if there was some sort of _asm section (like some compilers support) with some assembly code being assembled then that would be different. Or even a separate assembly file that produces the hex codes (could be with display or something similar) then that would also be assembly. |
|||
29 Mar 2009, 10:30 |
|
vid 29 Mar 2009, 12:36
revolution: In my opinion, run-time generation of opcodes is related to assembly enough to remain here.
Wisepenguin: why don't you try using debugger and trace the code to see what fails? FDBG should work for you, |
|||
29 Mar 2009, 12:36 |
|
Tomasz Grysztar 29 Mar 2009, 12:42
vid wrote: revolution: In my opinion, run-time generation of opcodes is related to assembly enough to remain here. I support this point of view. Initially this forum was intended to be fasm-only, but now I think it's better for us to allow more wide machine-code related topics. |
|||
29 Mar 2009, 12:42 |
|
revolution 29 Mar 2009, 13:00
Hehe, okay I am overpowered by you two. I shall take my tail and put it between my legs and turn around.
|
|||
29 Mar 2009, 13:00 |
|
wisepenguin 29 Mar 2009, 13:26
hi vid,
wow - what a useful project. i simply didn't know or quite possibly forgot about FDBG. i ended up using NTSD all yesterday and stepping through it but was too blind to notice the error. however, this morning with fresh eyes i noticed the error was that i mixed up the byte order for the mov instruction and prefix. the correction is posted a few replies above. a big thanks to all of the FDBG contributors, and Tomasz for FASM. |
|||
29 Mar 2009, 13:26 |
|
ramguru 20 Jul 2009, 11:13
not so long time ago I've converted this thunk code to assembly in x64bit code:
Code: struct HM hWnd dq ? ; handle of control .. ends struct WndProcThunk RcxMov dw ? ; mov rcx, pThis RcxImm dq ? ; RaxMov dw ? ; mov rax, target RaxImm dq ? ; RaxJmp dw ? ; jmp rax ends proc DummyProc uses rsi, hWin, uMsg, wParam, lParam mov [hWin], rcx mov [uMsg], rdx mov [wParam], r8 mov [lParam], r9 ; allocate two structures for saving unique properties mov r10, sizeof.HM ; control properties add r10, sizeof.WndProcThunk ; thunk code invoke VirtualAlloc, 0, r10, MEM_COMMIT, PAGE_EXECUTE_READWRITE mov rcx, [hWin] mov [HM.hWnd + rax], rcx mov rsi, rax add rsi, sizeof.HM mov rcx, ContolProc mov WORD [rsi +0], 0B948h mov [rsi +2], rax mov WORD [rsi+10], 0B848h mov [rsi+12], rcx mov WORD [rsi+20], 0E0FFh invoke SetWindowLongPtr, [hWin], GWL_WNDPROC, rsi mov r9, [lParam] mov r8, [wParam] mov rdx, [uMsg] mov rcx, [hWin] call rsi ret endp proc ControlProc hWin, uMsg, wParam, lParam mov rbx, rcx ; now --> QWORD [HM.hwnd + rbx] - real control handle endp |
|||
20 Jul 2009, 11:13 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.