Jump to content
Tuts 4 You

Whats wrong with this ASM code?


Keygen_Dr.

Recommended Posts

Posted (edited)

What's wrong with this ASM code... I'm using, Negatory Assembly Studio...

Error;

Generating Code...
Linking...
Link failed
		   .486									   ;  creating 32bit code
.model flat, stdcall ; 32 bit memory mode
option casemap : none ;
;*******************************************************************************
**************************
;******************************************** INCLUDES ***************************************************
;*******************************************************************************
**************************
include windows.inc
include gdi32.inc
include user32.inc
include kernel32.inc
include Comctl32.inc
include comdlg32.inc
include shell32.inc
include oleaut32.inc
;*******************************************************************************
**************************
;******************************************** INCLUDELIBS ************************************************
;*******************************************************************************
**************************
includelib gdi32.lib
includelib user32.lib
includelib kernel32.lib
includelib Comctl32.lib
includelib comdlg32.lib
includelib shell32.lib
includelib oleaut32.lib
;*******************************************************************************
**************************
;******************************************** FUNC MACRO *************************************************
;*******************************************************************************
**************************
FUNC MACRO parameters:VARARG
invoke parameters
EXITM <eax>
ENDM include dialogs.inc dlgproc PROTO :DWORD,:DWORD,:DWORD,:DWORD;*******************************************************************************
**************************
;******************************************** DATA? ******************************************************
;*******************************************************************************
**************************
.data?
hInstance dd ?;*******************************************************************************
**************************
;******************************************** DATA? ******************************************************
;*******************************************************************************
************************** .data
MsgBoxText db "Really? :(",0
MsgBoxCaption db "This project is not working...",0;*******************************************************************************
*************************
;******************************************** CONST ******************************************************
;*******************************************************************************
************************** .const
NULL equ 0;*******************************************************************************
**************************
;******************************************** CODE *******************************************************
;*******************************************************************************
**************************
.code
start: mov hInstance, FUNC(GetModuleHandle,NULL)
invoke MessageBoxA, NULL, ADDR MsgBoxText, ADDR MsgBoxCaption, 0
call main
invoke ExitProcess, eax;---------------------------
;---------- main -----------
;--------------------------- main proc
Dialog "Dialog Project", \ ;caption
"MS Sans Serif",10, \ ;font, pointsize
WS_OVERLAPPED or \ ;styles for
WS_SYSMENU or DS_CENTER, \ ;window
2, \ ;number of controls ---: button + text
50,50,150,80, \ ;x y co-ordinates
1024 ;memory buffer size
DlgButton "Close",WS_TABSTOP,48,40,50,15,IDCANCEL
DlgStatic "Dialog Project",SS_CENTER,2,20,140,9,100
CallModalDialog hInstance,0,dlgproc,NULL
ret
main endp;---------------------------
;---------- dlgproc --------
;---------------------------
dlgproc proc hWin:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD .if uMsg == WM_INITDIALOG
invoke SendMessage,hWin,WM_SETICON,1
FUNC(LoadIcon,NULL,IDI_ASTERISK) .elseif uMsg == WM_COMMAND
.if wParam == IDCANCEL
jmp quit_dialog
.endif .elseif uMsg == WM_CLOSE
quit_dialog:
invoke EndDialog,hWin,0
.endif xor eax,eax
ret dlgproc endp end start
Edited by Keygen_Dr.
Posted
Dialog	"Dialog Project", \						;caption
"MS Sans Serif",10, \ ;font, pointsize
WS_OVERLAPPED or \ ;styles for
WS_SYSMENU or DS_CENTER, \ ;window
2, \ ;number of controls ---: button + text
50,50,150,80, \ ;x y co-ordinates
1024 ;memory buffer size

Not sure if your assembler will be the same (i mean, this is MASM code after all, can't see it being any different). but the comments in this part are making the line too long, if you want the comments, either use Tab (rather than Space) to separate the comments from the code, or remove the comments from the lines for the dialog and have another copy of the entire dialog template commented out either above or below it. Another way to avoid problems it to have it all on a single line

:

Dialog		"Dialog Project","MS Sans Serif",10,WS_OVERLAPPED or WS_SYSMENU or DS_CENTER,2,50,50,150,80,1024

Also:

invoke SendMessage,hWin,WM_SETICON,1
FUNC(LoadIcon,NULL,IDI_ASTERISK)

needs a comma after the "1" to make it a single line, otherwise the assembler thinks it is two separate lines, i've also placed it on a single line:

  invoke SendMessage,hWin,WM_SETICON,1,FUNC(LoadIcon,NULL,IDI_ASTERISK)

Compiled fine now. I'd also recommend using an IDE which displays the actual error messages from ML.exe/Link.exe, that way you can track down what is wrong and how you can fix it. (IE: Google searching error code/message, rather than only having a message saying that it coudnt assemble/link your code.)

HR,

Ghandi

Posted

Wow, it worked, ghandi! Thanks for answering quickly. :)

It gave me a headache hehe :D ...

Posted (edited)

Yep, I got same error: "line too long".

Edited by alaphate
Posted

;) No problems mate.

HR,

Ghandi

Posted (edited)

normally the compiler should show in which line is an error. and not just "...failed"

Edited by diablo2oo2
Posted (edited)
normally the compiler should show in which line is an error. and not just "...failed"

I'm using this compiler.Assembly Studio!.

I think it's really old, that's why it can't say anything about the error. And it really sucks. But i found some video tutorials with that program. I'm afraid to switch it to another one. Cuz i'm really a newbie at coding in assembly.

But maybe you can tell me a good compiler that can say where is the error. It would be really nice...

But as i said before, i'm really newbie, i learned somethings from this software, if there will be so many differents in writing the codes. It would be really bad. :)

gihandi said that use and IDE, but i don't know how to :(

Edited by Keygen_Dr.
Posted (edited)

Error:

;*******************************************************************************

**************************

I'm using?

RadASM

http://www.radasm.com/resed/

post-41139-1240721474_thumb.jpg

Edited by by:70

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...