flat assembler
Message board for the users of flat assembler.

Index > Windows > XP update stoped code working

Author
Thread Post new topic Reply to topic
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
First i would like to point out, i do not do alot of windows programming, but i written some basic code for user input.
Which worked fine, untill i did a windows (XP home) update, then all that happened was there was a empty window.
Here is some of the code that stops work (or disapears as in it just came up as a empty windows box).
Code:
format PE GUI 4.0
entry start

include '%include%\win32a.inc'

section '.data' data readable writeable

  _title db 'Win32 program template',0
  _class db 'FASMWIN32',0
  _class_cb db 'COMBOBOX',0
   _class_cb1 db 'COMBOBOX1',0

  mainhwnd dd ?
  hinstance dd ?

  hwnd_cb dd ?

  msg MSG
  wc WNDCLASS

section '.code' code readable executable

  start:
      invoke  GetModuleHandle,0
   mov     [hinstance],eax
     invoke  LoadIcon,0,IDI_APPLICATION
  mov     [wc.hIcon],eax
      invoke  LoadCursor,0,IDC_ARROW
      mov     [wc.hCursor],eax
    mov     [wc.style],0
        mov     [wc.lpfnWndProc],WindowProc
 mov     [wc.cbClsExtra],0
   mov     [wc.cbWndExtra],0
   mov     eax,[hinstance]
     mov     [wc.hInstance],eax
  mov     [wc.hbrBackground],COLOR_BTNFACE+1
  mov     [wc.lpszMenuName],0
 mov     [wc.lpszClassName],_class
   invoke  RegisterClass,wc
    invoke  CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,192,192,NULL,NULL,[hinstance],NULL
 mov     [mainhwnd],eax
  msg_loop:
   invoke  GetMessage,msg,NULL,0,0
     or      eax,eax
     jz      end_loop
    invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
 jmp     msg_loop
  end_loop:
 invoke  ExitProcess,[msg.wParam]

proc WindowProc, hwnd,wmsg,wparam,lparam
    push    ebx esi edi
 cmp     [wmsg],WM_CREATE
    je      wmcreate
    cmp     [wmsg],WM_DESTROY
   je      wmdestroy
  defwndproc:
      invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
       jmp     finish
  wmcreate:
   ;invoke  CreateWindowEx,0,_class_cb,0,WS_CHILD+WS_VISIBLE+CBS_DROPDOWNLIST,16,40,130,125,[hwnd],0,[hinstance],0
     ;mov     [hwnd_cb],eax
      stdcall create_control,hwnd_cb,_class_cb,0,WS_CHILD+WS_VISIBLE+CBS_DROPDOWNLIST+CBS_SORT,[hwnd],16,40,155,100,1005
  invoke  SendMessage,[hwnd_cb],CB_ADDSTRING,0,_class
 invoke  SendMessage,[hwnd_cb],CB_ADDSTRING,0,_class_cb
      invoke  SendMessage,[hwnd_cb],CB_SETCURSEL,0,0
      invoke  SetFocus,[hwnd_cb]
       ; invoke  SendMessage,[hwnd_cb],CB_GETCURSEL  ,0,0  ;this code test the  get selected string in combo box
       ; cmp  eax,0                              ;it returns the index starting at 0
       ; jne  @f
       ; invoke  SendMessage,[hwnd_cb],CB_ADDSTRING,0,_class_cb1
@@:
   xor     eax,eax
     jmp     finish
  wmdestroy:
  invoke  PostQuitMessage,0
   xor     eax,eax
  finish:
    pop     edi esi ebx
 ret
endp

proc create_control,handle,_class_name,_caption,style,parent,x,y,w,h,control_id
  push    ebx esi edi
 invoke  CreateWindowEx,0,[_class_name],[_caption],[style],[x],[y],[w],[h],[parent],0,[hinstance],[control_id]
       mov     ecx,[handle]
        mov     [ecx],eax
   ;invoke  SendMessage,eax,WM_SETFONT,[hFont],0
       pop     edi esi ebx
 ret
endp

section '.idata' import data readable writeable

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

  include '\api\kernel32.inc'
  include '\api\user32.inc'

;;;;;;;;;; This adds vista style to app COOL ;;;;;;;;;;;;;;;;;;;;;
section '.rsrc' resource data readable

  directory RT_MANIFEST, manifest
   resource manifest, 1, LANG_NEUTRAL, xpstyle

resdata xpstyle
   file 'winxpstyle32.xml'
  endres

    


I had lots of code that did the same basic thing and they all were the same, but the funny thing is the only peace of code that did work was if it had this in it
Code:
;======= DoFileOpen =======;
proc DoFileOpen, hwnd
;invoke DestroyWindow, [hwnd]
       mov     edi,ofn
     mov     eax,0
       mov     ecx,10
      stosd
       mov     [ofn.lStructSize], sizeof.OPENFILENAME 
     mov     eax, [hwnd] 
        mov     [ofn.hwndOwner], eax 
       mov     [ofn.lpstrFilter], lpstrFilter 
     mov     [ofn.lpstrFile], szFileName 
        mov     [ofn.nMaxFile], MAX_PATH 
   mov     [ofn.Flags], OFN_FILEMUSTEXIST+OFN_PATHMUSTEXIST+OFN_HIDEREADONLY
   mov     [ofn.lpstrDefExt], lpstrDefExt 
     invoke  GetOpenFileName, ofn 
       or      eax, eax 
   jz      .FinishFile
 ;invoke  SetWindowText, [hwnd], szFileName
  invoke SendMessage,[hwndBox1],CB_ADDSTRING,0,szFileName
      invoke SendMessage,eax,WM_SETFONT,[hFont],TRUE
     ;invoke SetFocus,[hwndBox1]
 invoke SendMessage,[hwndBox1],CB_SETCURSEL,0,0

    .FinishFile:
  ;invoke SendMessage,eax,WM_SETFONT,[hFont],TRUE
     ret 
endp 
    

If i add that code then they work again even if i do not call it.
I have used sys restore to go back and they work OK.
Anyone have any idea ?.
Post 19 Mar 2009, 18:47
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Try both one at a time:
* Replace your import section with this:
Code:
section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
          user32,'USER32.DLL',\
          comctl32,'COMCTL32.DLL'

  include '\api\kernel32.inc'
  include '\api\user32.inc'
  include '\api\COMCTL32.INC'
  alfa = InitCommonControls ; Or call the function on code instead of relaying on the undocumented fact that the function only returns without doing nothing (but don't remove the reference, otherwise the DLL won't be imported)
    

* Remove the XML manifest
Post 19 Mar 2009, 19:14
View user's profile Send private message 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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.