Hello everybody,
here are my sources for the SMTP project.
I am having a lot of trouble porting it from c/c++ to masm.
maybe some hints?
Internet is text based i believe after reading rfc 1225 and others.
They give me a real indept knowledge.
anyway look at the source, the asm part is not working fully.
In fact i need a little help i think.
Porting from c to asm is hard for me.
I am happy with the NOP statements, i used them to mark code and function sections in the
cPP file so it is much easy`r to read after the c++ compiler spits out the asm file.
c/c++ and asm source included.
I hope that this is portable to assembler. (need some advice)
Thats what i am working at now.
Any advice is welkome.
Bye
[attachment deleted by admin]
Marco1974,
First thing I would do is make a simple prog that can connect to a smtp server using sockets.
Once you can connect the rest is about what to send and receive over the connection.
Some code here might help you: www.jamesladdcode.com
There are other tutorials and examples in asm for using sockets. Id start with some of these
rather than translate C/C++.
Let me know how you go.
You are right,
But the reasson for (compiler example) for compiling with assembly code:
-bcc32 /c /B smtpc.pp (/B) gives smtp.asm.
is that i had written some code that AUTOMATICLY Fills in the STANDARD mail.domain.com
This code is more a sort of project to LEARN about ALL the INTERNET protocols.
I downloaded the PDF and TXT versions of ALL RFC (requist for comments) 70 and 80 MB.
So i can UNDERSTAND how things work.
at www.rfc.editor.org or something like that u can download all the rfc`s in pdf and txt format.
I am so glad the rfc editors did such a good job.
I also DELETED all the smtp code from BEAGLE. Its dangerous code and i already have coded a partial working version of a SMTP mailer in asm.
It will be posted here when the bugs are sorted out.
IF someone has any idea to create a SMTP-SERVER (MS DID) so u dont need mail.domain.org , let me know!
If u use THIS c code u see what i mean.
Quote
struct servent * sp = ::getservbyname("smtp", "tcp");
//if (sp == NULL)
//LogTextToFile("getservbyname error");
m_sockADDR.sin_port = sp->s_port; //PORT
m_Hostent=gethostbyname(sp->s_name); //"mail.zeelandnet.nl");
m_sockADDR.sin_addr.s_addr=*((unsigned long *) m_Hostent->h_addr);
i=connect(m_SOCKET,(struct sockaddr *) &m_sockADDR,sizeof(m_sockADDR));
This code ( i am porting it to asm) does not need the Client/User to fill in his mail server!
It finds the smtp service.
Its fun exploring this protocol.
Happy coding,
Marco
I tried to run your sample but have problem with this statement...
m_Hostent=gethostbyname(sp->s_name); //"mail.zeelandnet.nl");
...during run time it cancels because of Unhandled Exception: Access Violation.
I have no idea what is problem.
Ok here is a NEW smtp project in c/c++.
It works for me.
It mails from my desktop --> hotmail mail account.
Its heavy NOP`ED becouse i use bcc32 /c /B source.cpp
See the zip.
Happy coding,
marco
[attachment deleted by admin]
Quote from: marco1974 on March 28, 2005, 08:26:48 PM
Ok here is a NEW smtp project in c/c++.
It works for me.
It mails from my desktop --> hotmail mail account.
Its heavy NOP`ED becouse i use bcc32 /c /B source.cpp
See the zip.
Happy coding,
marco
Maybe it's because I'm using MS VC++ 6.0 on Windows OS. It compiles OK (after I comment out the asm NOP statements and add wsock32.lib) but it still doesn't run.
During run time below cause Unhandled exception: Access Violation.
m_sockADDR.sin_addr.s_addr=*((unsigned long *) m_Hostent->h_addr);
So, your guess is as good as mine.
I have that problem with Visual c/c++ too in Lots of sources.
When i wrote some FileStore.dat project it crashed due to POINTERS and Casts.
The MS compiler is the worst ever.
Quote from: marco1974 on March 28, 2005, 09:05:00 PM
I have that problem with Visual c/c++ too in Lots of sources.
When i wrote some FileStore.dat project it crashed due to POINTERS and Casts.
The MS compiler is the worst ever.
I can't argue with you about the MS compiler but I do believe it's got to be the most popular and it's the one that I use and every one else I know and it's the one that is used where I work.
here is some update.
I found some Neat and simple source code for smtp in asm.
There are bugs, But i think they are string related and NOT smtp command related.
See it,
I will TRY to resolve the bugs and let it work.
But i am new to RFC`s stuff Its a interesting learnintg curve!
I am not sure if i can fix the errors.
anyway here is the src.
ps:
sorry for the double posts.
My pc is a piece of shit and now the mouse port broke.
can`t use a mouse, and that 6/7 days before my new amd64 arives.
it sucks.
[attachment deleted by admin]
hello everybody,
i fixed some errors in the code and it now works.
I added some space " " in the end of the strings.
looked to my c++ code and found out they did work only if i added a space.
The Projects is not yet complete, i still have not (see code)
;get tcp and smtp service from user
service db "smtp",0
protocol db "tcp",0
invoke GetServiceByName,protocol,service
mov eax,s_entry ; struct for holdimg the returnd data see winsock manual.
Now the hard part is to fill in the right structures so we DONT NEED TO FILL IN THE MAIL-SERVER.
Thats verry handy becouse most users dont know how to do this.
Remember the first time u had to configure outlook expres with mail.server.com ?
Well i had trouble with it, and so does the normal user too!
this statement will crash the aplication when bcc -B (compile trough asm.lst)
transelates from c to asm.
I mean when i use that source.asm for my program, the asm program crashes.
m_sockADDR.sin_port = sp->s_port; //PORT
m_Hostent=gethostbyname(sp->s_name); //"mail.zeelandnet.nl");
asm:
call @gethostbyname
mov dword ptr [_m_Hostent],eax
?live16387@112: ; EBX = &s@, ESI = &_aa
mov edx,dword ptr [_m_Hostent]
mov ecx,dword ptr [edx+12]
mov eax,dword ptr [ecx]
mov edx,dword ptr [eax]
mov dword ptr [_m_sockADDR+4],edx
this if used will crash, does anybody know what would be BEST PRACTICE here?
I am reall curious why this perfect c++ generated will crash.
Bye ,
and ... happy coding!
[attachment deleted by admin]
Quote from: marco1974 on March 29, 2005, 03:36:15 PM
m_sockADDR.sin_port = sp->s_port; //PORT
m_Hostent=gethostbyname(sp->s_name); //"mail.zeelandnet.nl");
asm:
call @gethostbyname
mov dword ptr [_m_Hostent],eax
?live16387@112: ; EBX = &s@, ESI = &_aa
mov edx,dword ptr [_m_Hostent]
mov ecx,dword ptr [edx+12]
mov eax,dword ptr [ecx]
mov edx,dword ptr [eax]
mov dword ptr [_m_sockADDR+4],edx
this if used will crash, does anybody know what would be BEST PRACTICE here?
I am reall curious why this perfect c++ generated will crash.
I have used the following code many times without it crashing.
assume esi:ptr sockaddr_in
.
.
;pHostStr is the address of the hostname string to get the ip address for (eg. "www.masmforum.com")
invoke gethostbyname, pHostStr
.IF (eax)
mov eax,[eax+12]
mov eax,[eax]
mov eax,[eax] ;eax = ipaddr
.ELSE
;ERROR - bad hostname/not found
;either complain, or use inet_addr to see if it's an ip address string (eg. "66.152.98.201")
.ENDIF
mov [esi].sin_addr,eax