I red the first 9 tuts and they are great. I understood everything.
But now I don't understand very much at tut number 10. What is the resurce.h?I don't have it. What Dialog-Editor did he use?

Can anybody 'translate' the tut for use with Radasm?
There is an Dialog-Editor too, but I dont really know how to integrate the dialog in the prog and how to do the tut # 10 with Radasm.

Plz help :(
Posted on 2002-08-01 06:05:33 by Subby
> What is the resurce.h?

It's called "resource.h" and contains define's (equates) for some control names/"commands"
used by the resource compiler. It's just there to make a rc file human-readable :)

>I don't have it.


>What Dialog-Editor did he use?

Dunno. Maybe he wrote it off the top off his head :)
But you can use any resource editor. The one from
RadASM, ASMEdit, ResHack, Microsofts Free RC Editor, VisualC++ Resource Editor etc.
Searching google for "resource editor" might bring up some others.

>Can anybody 'translate' the tut for use with Radasm?

Just copy & paste the code and generate a RC file with the RadASM dialog editor.
Just give the controls the same ID's, else it wont work :)
Posted on 2002-08-01 06:30:53 by bazik
Hmm thought I did it that way, there weren't compiling errors, but I had to close the file per TaskManager cause nothing was shown.
(Yeah I used ShowWindow ;)

I think I'll try it again :)
Posted on 2002-08-01 06:41:46 by Subby
Post your code.
Posted on 2002-08-01 06:43:07 by bazik
Proggy.asm (Just Copy & Paste from Tut)

.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

ClassName db "DLGCLASS",0
MenuName db "MyMenu",0
DlgName db "MyDialog",0
AppName db "Our First Dialog Box",0
TestString db "Wow! I'm in an edit box now",0

hInstance HINSTANCE ?
CommandLine LPSTR ?
buffer db 512 dup(?)

IDC_EDIT equ 3000
IDC_BUTTON equ 3001
IDC_EXIT equ 3002
IDM_GETTEXT equ 32000
IDM_CLEAR equ 32001
IDM_EXIT equ 32002

invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax

WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,OFFSET MenuName
mov wc.lpszClassName,OFFSET ClassName
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateDialogParam,hInstance,ADDR DlgName,NULL,NULL,NULL
mov hDlg,eax
invoke ShowWindow, hDlg,SW_SHOWNORMAL
invoke UpdateWindow, hDlg
invoke GetDlgItem,hDlg,IDC_EDIT
invoke SetFocus,eax
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .IF (!eax)
invoke IsDialogMessage, hDlg, ADDR msg
.IF eax ==FALSE
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
mov eax,msg.wParam
WinMain endp

WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
invoke PostQuitMessage,NULL
mov eax,wParam
.IF lParam==0
invoke GetDlgItemText,hWnd,IDC_EDIT,ADDR buffer,512
invoke MessageBox,NULL,ADDR buffer,ADDR AppName,MB_OK
invoke SetDlgItemText,hWnd,IDC_EDIT,NULL
invoke DestroyWindow,hWnd
mov edx,wParam
shr edx,16
invoke SetDlgItemText,hWnd,IDC_EDIT,ADDR TestString
invoke SendMessage,hWnd,WM_COMMAND,IDM_EXIT,0
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
xor eax,eax
WndProc endp
end start


#include <Res\ProggyDlg.rc>

#define IDM_GETTEXT 32000
#define IDM_CLEAR 32001
#define IDM_EXIT 32003

POPUP "Test Controls"


#define MyDialog 1000
#define IDC_EXIT 3002
#define IDC_BUTTON 3001
#define IDC_EDIT 3000
MyDialog DIALOGEX 6,6,205,112
FONT 8,"MS Sans Serif"
STYLE 0x10CF0000
EXSTYLE 0x00000000
PUSHBUTTON "Exit",IDC_EXIT,140,81,60,15,NOT 0x00820000|0x50010000,0x00000000
PUSHBUTTON "Button",IDC_BUTTON,68,81,64,17,NOT 0x00820000|0x50010000,0x00000000
EDITTEXT IDC_EDIT,40,22,126,13,NOT 0x00820000|0x50010000,0x00000200

As I said:
It is compiled perfectly, but no Window is Shown when I run The Prog. Only can stop it with TaskManager
Posted on 2002-08-01 07:02:13 by Subby
It compiles without a prototype for your WndProc? :)
Posted on 2002-08-01 07:09:49 by bazik
Yeah, it does...

I never declare a proto for WndProc (as Icz do)
Posted on 2002-08-01 07:18:27 by Subby
Hmmm... its declared in Windows.inc then ;)

Anyway, I have no MASM here and just noticed that.
I will test it when I am back at home.
Posted on 2002-08-01 07:21:50 by bazik
nobody else got an idea? :(
Posted on 2002-08-01 10:30:03 by Subby
Just because a question isn't answered within 4 hours, it doesn't mean it isn't going to be answered. Have patience.

I (and I presume many others) have work/university/school to attend, and so we can't answer all questions straight away. Especially those that require more than a passing glance. I don't have a debugger here at work that I can use for instance...

Give it more time.

Posted on 2002-08-01 10:41:07 by Mirno

I didn't thought that it's such a big thing, because I did everything as in the tut. (excepted the Dialog)

Sorry for my impatient, but we got holidays, and I'm sitting here and can't go on :(
Posted on 2002-08-01 10:48:31 by Subby
Test for functions return values to see where it fails... or recheck your assembly code, get a good debugger like Ollydbg and try to debug your own code, or as Mirno said, have patience... but imho, learning to debug your code isn't useless. ;)
Posted on 2002-08-01 10:51:50 by JCP

What do you think about SoftIce?
Posted on 2002-08-01 10:56:35 by Subby
The Driver guys at work swear by it, but it costs a whole heap of money.

If you aren't doing really serious work, then its probably a sledgehammer to crack a nut. Go with something like Ollydbg until you're sure you need more from your debugger.

Posted on 2002-08-01 11:05:09 by Mirno
I agree with Mirno, I use OllyDBG. It is user-friendly and relatively simple to know how to use it unlike softice...
If you debug ring3 applications only0, you don't need anything more than Olly, which is free...
Sure, once you get used with softice it is much easier to use and productive (and you can type what you want, while Olly is a "click click" software... the access to some features would be faster by commands, sometimes...)
Posted on 2002-08-01 11:12:20 by JCP

Big thx for you Tipp!
OllyDBG is really very cool and easy to use :)

In SoftIce I got crazy ;)

BIG BIG thx :))
Posted on 2002-08-01 11:16:10 by Subby

PUSHBUTTON "Exit",IDC_EXIT,140,81,60,15,NOT 0x00820000|0x50010000,0x00000000
PUSHBUTTON "Button",IDC_BUTTON,68,81,64,17,NOT 0x00820000|0x50010000,0x00000000
EDITTEXT IDC_EDIT,40,22,126,13,NOT 0x00820000|0x50010000,0x00000200
What is this hex data? Aren't you suppose to use descriptive styles for readability? It's very hard to check whether you have the correct styles.

No, this is not the right time to say REAL MEN CODE IN HEX :grin:

Seriously, the reason why your app won't work because you define MyDialog as 1000 (Look at your .rc file). Now take a closer look at your .asm code
 invoke CreateDialogParam, hInstance, ADDR DlgName, NULL, NULL, NULL
You define DlgName as the name of your dialog in string but the definition in the .rc file is 1000(Number, Not A String). Try changing ADDR DlgName to 1000. If you want it as string remove the #define MyDialog 1000 in the .rc file and it should work.

One more thing, don't separate two different .rc files since my resource compiler won't work.

Don't forget to include resource.h, so that you can use descriptive styles.
Posted on 2002-08-01 11:30:56 by stryker
These rc files look generated by the Radasm dialog editor, which does "just" a conversion from his own format (.dlg) to classical rc files... without any style equates...
Posted on 2002-08-01 11:34:45 by JCP
Oh really? Since I don't use RadASM I didn't know that. :tongue:
Posted on 2002-08-01 11:37:37 by stryker