flat assembler
Message board for the users of flat assembler.

Index > Windows > help: fix 64 bit code with issue

Author
Thread Post new topic Reply to topic
catafest



Joined: 05 Aug 2010
Posts: 120
catafest
According with this http://left404.com/2011/01/04/moving-x86-assembly-to-64-bit-x86-64/ I try to fix my source code.
My application try to create one interface for imput data.
Also, can you come with explication details?
This is the source code , can you tell me where I make mistakes?
Thank you very much . Regards.
Code:
format PE64 GUI 5.0
entry start
include 'WIN64A.inc'

section '.code' code readable executable

   WinMain:  
        invoke  GetModuleHandle,NULL
        mov     [wndclass.hInstance],rax
        invoke  LoadIcon,0,IDI_APPLICATION  
        mov     [wndclass.hIcon],rax
        invoke  LoadCursor,NULL,IDC_ARROW  
        mov     [wndclass.hCursor],rax
        invoke  RegisterClassEx,wndclass  

        invoke  CreateWindowEx,WS_EX_OVERLAPPEDWINDOW,szAppName,szAppName,\  
                  WS_OVERLAPPEDWINDOW+WS_VISIBLE,CW_USEDEFAULT,CW_USEDEFAULT,\  
                  CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,[wndclass.hInstance],NULL  
  .mainloop:   ;mainloop function
        invoke  GetMessage,msg,NULL,0,0  
        cmp     eax,0  
        jle     .finished  
        invoke  TranslateMessage,msg  
        invoke  DispatchMessage,msg  
        jmp     .mainloop  

  .finished:    ;exit function
        invoke  ExitProcess,[msg.wParam]
;draw graphic
proc DrawPixelArray hdc 
        ;pushad ;preserve all general purpose registers
        mov ebx,0 ;index base into each array  
        mov ecx,4 ; number of elements in each array  
 .RepeatMe:  
        ;push ecx ;windows ABI trashes ECX so we must preserve it
        push cdq
        invoke SetPixel,[hdc],[xarray+ebx],[yarray+ebx],0x00000000 ; paint black pixel at [x,y] 
        pop ecx ; now we restore it..  
        add ebx,4 ;next index is 4 bytes into the array  
        loop .RepeatMe  
        popad ;restore all general purpose registers  
        ret ;return to caller (proc macro cleans up params for us)  
endp  
;WindowProc function
proc WindowProc hwnd,umsg,wparam,lparam 
  local ps:PAINTSTRUCT  
        mov     rax,[umsg]
        cmp     eax,WM_PAINT  
        je      .wmpaint  
        cmp     eax,WM_DESTROY  
        je      .wmdestroy  
  .defwndproc:  
        invoke  DefWindowProc,[hwnd],[umsg],[wparam],[lparam]  
        jmp     .finish  
  .wmpaint:  
        lea     eax,[ps]  
        invoke  BeginPaint,[hwnd],eax  
        ;invoke  SetPixel,[ps.hdc],10,10,0x00000000 ; paint black pixel at [x,y] 
        stdcall DrawPixelArray,[ps.hdc] 
        lea     eax,[ps]  
        invoke  EndPaint,[hwnd],eax  
        jmp     .zfinish  
  .wmdestroy:  
        invoke  PostQuitMessage,0  
  .zfinish:  
        xor     eax,eax  
  .finish:  
        ret  
endp 

section '.data' data readable writeable  

  szAppName db 'Graphic input data from device',0

  wndclass WNDCLASSEX sizeof.WNDCLASSEX,CS_OWNDC,WindowProc,\  
    0,0,NULL,NULL,NULL,(COLOR_WINDOW+1),NULL,szAppName,NULL  

  msg MSG  
section '.data' data readable writeable 
xarray dd 0,1,2,3 ;x coordinates for 4 pixels
yarray dd 0,1,2,3 ;y coordinates for 4 pixels 
section '.idata' import data readable  

  library kernel32,'KERNEL32.DLL',\  
          user32,'USER32.DLL',\  
          gdi32,'GDI32.DLL'  

  include 'API\KERNEL32.INC'  
  include 'API\USER32.INC'  
  include 'API\GDI32.INC'     
Post 01 Mar 2015, 08:29
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
With 64-bit fastcall procedure entry you have to be aware of RCX, RDX, R8 and R9 upon procedure entry. You have to either spill them to the stack or use them directly.
Post 01 Mar 2015, 08:52
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 120
catafest
revolution wrote:
With 64-bit fastcall procedure entry you have to be aware of RCX, RDX, R8 and R9 upon procedure entry. You have to either spill them to the stack or use them directly.

this can be one good issue , indeed!
Some infos or example about how to do that .
... can you help me ?
Post 01 Mar 2015, 09:22
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
I know this isn't the right time, but I have to do this:

https://msdn.microsoft.com/en-us/library/7kcdt6fy.aspx?f=255&MSPPError=-2147217396
Post 01 Mar 2015, 12:49
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17270
Location: In your JS exploiting you and your system
revolution
catafest wrote:
Some infos or example about how to do that .
Perhaps this.

http://board.flatassembler.net/topic.php?p=169261#169261
Post 01 Mar 2015, 13:34
View user's profile Send private message Visit poster's website Reply with quote
catafest



Joined: 05 Aug 2010
Posts: 120
catafest
Thank you for help.

I will read all. Also If somebody want make better this project , just send me a mail.
This project I make will follow :
- create a gui for data;
- connect with usb to read data , data files, audio input or streams of data;
- parse data with specific functions;
The idea is to improuve day by day with users issue.
I know is many software and API to do this , but most of all need to learn something new.
Post 01 Mar 2015, 15:00
View user's profile Send private message Visit poster's website Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.