Hi all,

Okay I played with Hutch's dialog marcos, and butched up with some codes that did not use the api MultiByteToWideChar.



invoke VirtualAlloc,0,1024,MEM_COMMIT,PAGE_READWRITE
push eax
mov edi,eax
mov DWORD PTR[edi], DS_SETFONT or WS_OVERLAPPED or WS_SYSMENU or DS_CENTER
mov WORD PTR[edi+8], 0 ;Number of controls
mov WORD PTR[edi+10], 50 ;x
mov WORD PTR[edi+12], 50 ;y
mov WORD PTR[edi+14], 150 ;width
mov WORD PTR[edi+16], 80 ;height
add edi,22
mov ecx,15
lea esi,caption_
rep movsw
mov WORD PTR[edi], 10
add edi,2
mov ecx,14
lea esi,font_
rep movsw
pop edi
invoke CreateDialogIndirectParam,400000h,edi,0,ADDR dlgproc,0


Looking into the memory, the lpTemplate is the similar as hutch's

00134460 40 08 08 00 00 00 00 00 00 00 32 00 32 00 96 00 @.......2.2.?.
00134470 50 00 00 00 00 00 49 00 6E 00 70 00 75 00 74 00 P.....I.n.p.u.t.
00134480 20 00 70 00 61 00 73 00 73 00 77 00 6F 00 72 00 .p.a.s.s.w.o.r.
00134490 64 00 00 00 0A 00 4D 00 53 00 20 00 53 00 61 00 d.....M.S. .S.a.
001344A0 6E 00 73 00 20 00 53 00 65 00 72 00 69 00 66 00 n.s. .S.e.r.i.f.

00790000 40 08 08 00 00 00 00 00 00 00 32 00 32 00 96 00 @.......2.2.?.
00790010 50 00 00 00 00 00 49 00 6E 00 70 00 75 00 74 00 P.....I.n.p.u.t.
00790020 20 00 50 00 61 00 73 00 73 00 77 00 6F 00 72 00 .P.a.s.s.w.o.r.
00790030 64 00 00 00 0A 00 4D 00 53 00 20 00 53 00 61 00 d.....M.S. .S.a.
00790040 6E 00 73 00 20 00 53 00 65 00 72 00 69 00 66 00 n.s. .S.e.r.i.f.


Though the CreateDialogIndirectParamA returns the function as ERROR_SUCCESS and eax != 0, my dialog box does not appear. Anyone have any idea? However using hutch's marco, mine does appear.



004010BE |> 56 PUSH ESI
004010BF |. 57 PUSH EDI
004010C0 |. 68 00040000 PUSH 400 ; /MemSize = 400 (1024.)
004010C5 |. 6A 40 PUSH 40 ; |Flags = GPTR
004010C7 |. E8 B0000000 CALL <JMP.&kernel32.GlobalAlloc> ; \GlobalAlloc
004010CC |. 8BF0 MOV ESI,EAX
004010CE |. 8BFE MOV EDI,ESI
004010D0 |. C707 40080800 MOV DWORD PTR DS:[EDI],80840
004010D6 |. 66:C747 08 000>MOV WORD PTR DS:[EDI+8],0
004010DC |. 66:C747 0A 320>MOV WORD PTR DS:[EDI+A],32
004010E2 |. 66:C747 0C 320>MOV WORD PTR DS:[EDI+C],32
004010E8 |. 66:C747 0E 960>MOV WORD PTR DS:[EDI+E],96
004010EE |. 66:C747 10 500>MOV WORD PTR DS:[EDI+10],50
004010F4 |. 83C7 16 ADD EDI,16
004010F7 |. 6A 0F PUSH 0F ; /WideBufSize = F (15.)
004010F9 |. 57 PUSH EDI ; |WideCharBuf
004010FA |. 6A FF PUSH -1 ; |StringSize = FFFFFFFF (-1.)
004010FC |. 68 00304000 PUSH vodet.00403000 ; |StringToMap = "Input password"
00401101 |. 6A 01 PUSH 1 ; |Options = MB_PRECOMPOSED
00401103 |. 6A 00 PUSH 0 ; |CodePage = CP_ACP
00401105 |. E8 7E000000 CALL <JMP.&kernel32.MultiByteToWideChar> ; \MultiByteToWideChar
0040110A |. 83C7 1E ADD EDI,1E
0040110D |. 66:C707 0A00 MOV WORD PTR DS:[EDI],0A
00401112 |. 83C7 02 ADD EDI,2
00401115 |. 6A 0E PUSH 0E ; /WideBufSize = E (14.)
00401117 |. 57 PUSH EDI ; |WideCharBuf
00401118 |. 6A FF PUSH -1 ; |StringSize = FFFFFFFF (-1.)
0040111A |. 68 0F304000 PUSH vodet.0040300F ; |StringToMap = "MS Sans Serif"
0040111F |. 6A 01 PUSH 1 ; |Options = MB_PRECOMPOSED
00401121 |. 6A 00 PUSH 0 ; |CodePage = CP_ACP
00401123 |. E8 60000000 CALL <JMP.&kernel32.MultiByteToWideChar> ; \MultiByteToWideChar
00401128 |. 83C7 1C ADD EDI,1C
0040112B |. 6A 00 PUSH 0 ; /lParam = NULL
0040112D |. 68 50114000 PUSH vodet.00401150 ; |DlgProc = vodet.00401150
00401132 |. 6A 00 PUSH 0 ; |hOwner = NULL
00401134 |. 56 PUSH ESI ; |pTemplate
00401135 |. 68 00004000 PUSH vodet.00400000 ; |hInst = 00400000
0040113A |. E8 4F000000 CALL <JMP.&user32.DialogBoxIndirectParam>; \DialogBoxIndirectParamA
0040113F |. 50 PUSH EAX
00401140 |. 56 PUSH ESI ; /hMem
00401141 |. E8 3C000000 CALL <JMP.&kernel32.GlobalFree> ; \GlobalFree
00401146 |. 58 POP EAX
00401147 |. 5F POP EDI
00401148 |. 5E POP ESI


Anyone has any idea to solve my problem?
Posted on 2003-05-02 12:00:50 by roticv
I really dont understand what your trying to do here.. but i can point out that the "P" in "Password" from you unicode dump is different...

:grin: Now aint I usefull :grin:
:NaN:
Posted on 2003-05-02 21:11:56 by NaN
alignment problems?

improper setup?

Between DLGTEMPLATE and DLGITEMTEMPLATE structures, you need to DWORD align the memory.

see source below, oh and btw, I don't use hutch's macros. If you want me to explain the source, post below. :)

pmalign PROC lpMem:DWORD

mov eax, lpMem
add eax, 3
shr eax, 2
shl eax, 2
ret
pmalign ENDP
this one needs a pointer to a memory, the one you allocated.
after the DLGTEMPLATE...
2 bytes - Menu... 0 for no menu... -1 if you have the menu ID ... or wide
character string name of the menu
optional 2 bytes - ID for the menu if -1 above
2 bytes - classname(set to 0)
X bytes - title(wide character string for the title)
2 bytes - font size if DS_SETFONT is specified
X bytes - Font face if DS_SETFONT is specified(wide character string)

if cdit != 0 align here the continue with teh controls

DLGITEMTEMPLATE
....
try also using GetLastError and check what the system error code means.

tested on win2k sp3
Posted on 2003-05-03 01:58:32 by arkane
Have you tried using WS_VISIBLE?
Posted on 2003-05-03 05:49:21 by Jibz
Thanks, jibz. Solve my problem. The problem is with the flags. :)

Anyway Arkane, your marco is cute. But I still prefer rep movsw to copy the unicode fields. :alright:
Posted on 2003-05-04 01:03:30 by roticv