flat assembler
Message board for the users of flat assembler.

Index > Windows > Different Looks ResEd/FASM .rsrc

Author
Thread Post new topic Reply to topic
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus 26 Mar 2007, 12:36
Hey guys,

I have this tiny problem: Take a look at the added screenshot and it's description.

I have no clue why they are different! Confused I basically copied the attributes of the controls and dialog box into FASM, and it looks nearly the same, but it's slightly different as you can see.

Thanks in advance,
Daedalus

Here are the:
Screenshot (http://daedalus.ubergeek.nl/asm/DialogBoxDifference.png) (31KB, 1280x1024)
.rc file (http://daedalus.ubergeek.nl/asm/xxloxx.rc) (forgive the name, hehe)
.asm file (http://daedalus.ubergeek.nl/asm/DialogBox.ASM)
Post 26 Mar 2007, 12:36
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Mar 2007, 13:05
http://board.flatassembler.net/topic.php?t=3256 But for some reason I can't get your app work with the XML, it silently dies when I add it but probably I did something wrong.
Post 26 Mar 2007, 13:05
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus 26 Mar 2007, 14:48
Did you call InitCommonControlsEx?
Post 26 Mar 2007, 14:48
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Mar 2007, 15:15
That was!

I added InitCommonControls it to import table and then I added "dummy = InitCommonControls" (to force inclusion to the import table) instead of calling it and worked. Well, I see the app as always but that is because I have disabled the WinXP style and I can't use it because my Windows instalation is very reduced Razz (used nliteos)
Post 26 Mar 2007, 15:15
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus 26 Mar 2007, 15:17
Code:
;Program:        Dialog Boxing
;Author:         Clockowl
;Description:    Me playing with the dialogboxes.

format PE GUI 4.0
entry start

include 'win32a.inc'

section '.data' data readable writeable
  checkthis db 1Fh
  IDKEY              = 101
  IDNAME             = 102
  IDGEN              = 103
  IDEXIT             = 104
  ID_ICONERROR       = 201
  errmsg  db  'An error has occured, shutting down'
  errcap  db  'w00ps!'

section '.code' code readable executable

  start:
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc, 0
        or      eax,eax
        jz      exit
  exit:
        invoke  ExitProcess,0

proc DialogProc hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      wminitdialog
        cmp     [msg],WM_COMMAND
        je      wmcommand
        cmp     [msg],WM_CLOSE
        je      wmclose
        xor     eax,eax
        jmp     finish
  wminitdialog:
        invoke  InitCommonControls
        test    eax, eax
        jz      error
        jmp     processed
  wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + IDEXIT
        je      wmclose
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        jmp     processed
  wmclose:
        invoke  EndDialog,[hwnddlg], 0
  processed:
        mov     eax, 1
  error:
        invoke MessageBox,HWND_DESKTOP,errmsg,errcap,ID_ICONERROR+MB_OK
        jmp    wmclose
  finish:
        pop     edi esi ebx
        ret

endp

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL',\
          comctl,'COMCTL32.DLL'

  import  kernel,\
          GetModuleHandle,'GetModuleHandleA',\
          ExitProcess,'ExitProcess'

  import  user,\
          DialogBoxParam,'DialogBoxParamA',\
          GetDlgItemText,'GetDlgItemTextA',\
          MessageBox,'MessageBoxA',\
          EndDialog,'EndDialog'

  import  comctl,\
          InitCommonControls,'InitCommonControls'

section  '.rsrc' resource data readable
;macro dialog label,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize

directory RT_DIALOG,dialogs,\
          24,manifests

resource manifest,\
         1,LANG_ENGLISH+SUBLANG_DEFAULT,manifest

resdata man
         db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',13,10
         db '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',13,10
         db '<assemblyIdentity name="x.x.x" processorArchitecture="x86" version="5.1.0.0" type="win32"/> ',13,10
         db '<description>no</description>',13,10
         db '<dependency>',13,10
         db '<dependentAssembly>',13,10
         db '<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" />',13,10
         db '</dependentAssembly>',13,10
         db '</dependency>',13,10
         db '</assembly>',13,10
endres

  ;directory RT_DIALOG,dialogs

resource dialogs,\
         37, LANG_ENGLISH+SUBLANG_DEFAULT,mydialog

  dialog mydialog,'Clockowl - First KeyGens',6,5,242,66,10C00800h,00000088h
    dialogitem 'EDIT','Enter your desired username',IDNAME,4,5,230,15,10800101h
    dialogitem 'EDIT','Hit generate to generate a key',IDKEY,4,25,230,15,10000901h
    dialogitem 'BUTTON','&Generate',IDGEN,152,46,82,13,50010000h
    dialogitem 'BUTTON','E&xit',IDEXIT,4,46,82,13,50010000h
  enddialog
    


Ugh, same thing, doesn't launch! Confused

Hey, nice! Thanks a lot, I'll check it for changes in a moment, but hey, it works. Cool

One more little thing: The borders around the edit boxes? Any chance?

Again, thanks.


Last edited by Daedalus on 26 Mar 2007, 15:27; edited 1 time in total
Post 26 Mar 2007, 15:17
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Mar 2007, 15:21
This one gets opened on my PC
Code:
;Program:        Dialog Boxing
;Author:         Clockowl
;Description:    Me playing with the dialogboxes.

format PE GUI 4.0
entry start

include 'win32ax.inc'

section '.data' data readable writeable
  checkthis db 1Fh
  IDKEY  = 101
  IDNAME = 102
  IDGEN  = 103
  IDEXIT = 104

section '.code' code readable executable

  start: dummy = InitCommonControls
        invoke  GetModuleHandle,0
        invoke  DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc, 0
        or      eax,eax
        jz      exit
  exit:
        invoke  ExitProcess,0

proc DialogProc hwnddlg,msg,wparam,lparam
        push    ebx esi edi
        cmp     [msg],WM_INITDIALOG
        je      wminitdialog
        cmp     [msg],WM_COMMAND
        je      wmcommand
        cmp     [msg],WM_CLOSE
        je      wmclose
        xor     eax,eax
        jmp     finish
  wminitdialog:
        jmp     processed
  wmcommand:
        cmp     [wparam],BN_CLICKED shl 16 + IDEXIT
        je      wmclose
        cmp     [wparam],BN_CLICKED shl 16 + IDOK
        jmp     processed
  wmclose:
        invoke  EndDialog,[hwnddlg], 0
  processed:
        mov     eax, 1
  finish:
        pop     edi esi ebx
        ret

endp

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          comctl,'COMCTL32.DLL',\
          user,'USER32.DLL'

  import  kernel,\
          GetModuleHandle,'GetModuleHandleA',\
          ExitProcess,'ExitProcess'

  import  user,\
          DialogBoxParam,'DialogBoxParamA',\
          GetDlgItemText,'GetDlgItemTextA',\
          MessageBox,'MessageBoxA',\
          EndDialog,'EndDialog'

  import comctl,\
         InitCommonControls,'InitCommonControls'

section  '.rsrc' resource data readable
;macro dialog label,title,x,y,cx,cy,style,exstyle,menu,fontname,fontsize

  directory 24,manifest,\
            RT_DIALOG,dialogs

  resource manifest,\
         1,LANG_ENGLISH+SUBLANG_DEFAULT,man

  resource dialogs,\
           37, LANG_ENGLISH+SUBLANG_DEFAULT,mydialog

  dialog mydialog,'Clockowl - First KeyGens',6,5,242,66,10C00800h,00000088h
    dialogitem 'EDIT','Enter your desired username',IDNAME,4,5,230,15,10800101h
    dialogitem 'EDIT','Hit generate to generate a key',IDKEY,4,25,230,15,10000901h
    dialogitem 'BUTTON','&Generate',IDGEN,152,46,82,13,50010000h
    dialogitem 'BUTTON','E&xit',IDEXIT,4,46,82,13,50010000h
  enddialog

resdata man
  db '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>',\
     '<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">',\
     ' <assemblyIdentity version="1.0.0.0" processorArchitecture="X86" name="CompanyName.ProductName.YourApp" type="win32"/>',\
     ' <description>First KeyGen</description>',\
     ' <dependency>',\
     '  <dependentAssembly>',\
     '   <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="X86" publicKeyToken="6595b64144ccf1df" language="*"/>',\
     '  </dependentAssembly>',\
     ' </dependency>',\
     '</assembly>'
endres    
Post 26 Mar 2007, 15:21
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus 26 Mar 2007, 15:30
What does the line
Code:
dummy = InitCommonControls
    


do? (besides calling InitCommonControls)

Shouldn't this give an undefined symbol error since you didn't define dummy? is it predefined? "Forces it in the import table"? I know what the import table is, how does this force it in?

Thanks again,
Post 26 Mar 2007, 15:30
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Mar 2007, 15:53
I did that because the macros that build the import table doesn't add the API functions that you don't use and if there is no remain any function from the DLL to import then the DLL is also discarded from the table and for that reason COMCTL32.DLL doesn't get loaded. The assembler has no way to declare an assembly-time variable so the first time you use it you have to asign a value to it (e.g. you can't do "a = a + 1" the first time). Doing "dummy = InitCommonControls" is just to mark InitCommonControls as a used label and since the import macros includes only used APIs, it gets included even if I never call it, it's enough to make any use of the label to get it included in the import table.

The reason of why I don't call InitCommonControls is because it does nothing, is just provided to allow programs to import COMCTL32.DLL, but the real initializations occurs on DLL load.
Post 26 Mar 2007, 15:53
View user's profile Send private message Reply with quote
Daedalus



Joined: 25 Mar 2007
Posts: 52
Daedalus 26 Mar 2007, 16:24
Ah okay.

Learned a lot from this little adventure!

One itty bitty thing remains:
What happened to the little boarders around the EDITs?

Obviously the thing is in XP style now, great, but it isn't exactly the same. Confused

Ouch! Foul me, forgot to update my xStyle! Thanks a lot LocoDelAssembly!
Post 26 Mar 2007, 16:24
View user's profile Send private message MSN 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.