The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: lelejau on December 17, 2010, 07:18:01 PM

Title: Translate block of code from C++ to ASM.
Post by: lelejau on December 17, 2010, 07:18:01 PM
Hi.

I made a program in C++, and I want to translate it to asm, but I dont have a clue of what to do.

Here is the code:

Quote
typedef void (*t_ChatPrint)      ( char * );
t_ChatPrint   ChatPrint      = (t_ChatPrint)0x0054E410;

void ChatPrintf( const char *format, ... )
{
   va_list   ap;
   char   szBuffer[512] = "";

   va_start( ap, format );
   _vsnprintf_s( szBuffer, 512, 511, format, ap );
   va_end( ap );

   ChatPrint( szBuffer );
}

Thanks in advance.
Title: Re: Translate block of code from C++ to ASM.
Post by: hutch-- on December 17, 2010, 07:45:32 PM
Try learning assembler, its a trivial task.
Title: Re: Translate block of code from C++ to ASM.
Post by: lelejau on December 17, 2010, 07:47:26 PM
I am trying, but this is too far from my knoledge, so I hope anyone here can help me out. I read in the rules that asking for others to do your homework isnt allowed, but this isnt my homework. just in case someone talks about it.. thanks in advance.
Title: Re: Translate block of code from C++ to ASM.
Post by: drizz on December 17, 2010, 11:25:04 PM
;typedef void (*t_ChatPrint)      ( char * );
t_ChatPrint_fn typedef proto c :ptr sbyte
t_ChatPrint typedef ptr t_ChatPrint_fn

;t_ChatPrint   ChatPrint      = (t_ChatPrint)0x0054E410;
.data
ChatPrint t_ChatPrint 00054E410h

.code
;void ChatPrintf( const char *format, ... )
ChatPrintf proc c format:ptr sbyte, ap:vararg
;{
   ;va_list   ap;
   ;char   szBuffer[512] = "";
   LOCAL szBuffer[512]:sbyte

   mov szBuffer[0],0
   
   ;va_start( ap, format );
   invoke _vsnprintf_s, addr szBuffer, 512, 511, format, addr ap ;
   ;va_end( ap );

   invoke ChatPrint, addr szBuffer;
;}
ret
ChatPrintf endp

Title: Re: Translate block of code from C++ to ASM.
Post by: lelejau on December 18, 2010, 01:30:09 AM
thanks, I will test and tell if it works.



undefined symbol: _vsnprintf_s
Title: Re: Translate block of code from C++ to ASM.
Post by: drizz on December 18, 2010, 02:00:31 AM
Quote from: lelejau on December 18, 2010, 01:30:09 AM
undefined symbol: _vsnprintf_s

What did you expect? All external functions automagically working under masm32?

Short solution is to use unsafe version _vsnprintf (i guess masm32 version is crt__vsnprintf :eek).

The long (right) solution is to link against newer msvcrt (msvcrt80 or msvcrt90 i don't know) and add a prototype.

Quote from: lelejau on December 18, 2010, 01:30:09 AM
thanks, I will test and tell if it works.
Like i don't know what I'm doing...
Title: Re: Translate block of code from C++ to ASM.
Post by: hutch-- on December 18, 2010, 03:46:06 AM
lelejau,

If all you want to do is output some text to the console you can manually use Windows API functions or use the masm32 library function StdOut or cheat and use the masm32 "print" macro.
Title: Re: Translate block of code from C++ to ASM.
Post by: lelejau on December 20, 2010, 05:56:27 PM
No no, it isn't for a MASM program. this is for a game. Display text inside the game chat. But that nothing to do with hacking, or malicious program, I'm far from it. I would never learn assembler or any other language to hack someone, or something like that.
Title: Re: Translate block of code from C++ to ASM.
Post by: dedndave on December 20, 2010, 06:09:20 PM
Quote from: lelejau on December 20, 2010, 05:56:27 PM
No no, it isn't for a MASM program. this is for a game. Display text inside the game chat. But that nothing to do with hacking, or malicious program, I'm far from it. I would never learn assembler or any other language to hack someone, or something like that.

(http://images.zaazu.com/img/Angel-male-bird-smiley-smiley-emoticon-000278-large.gif)
Title: Re: Translate block of code from C++ to ASM.
Post by: lelejau on December 20, 2010, 06:52:16 PM
Quote from: dedndave on December 20, 2010, 06:09:20 PM
Quote from: lelejau on December 20, 2010, 05:56:27 PM
No no, it isn't for a MASM program. this is for a game. Display text inside the game chat. But that nothing to do with hacking, or malicious program, I'm far from it. I would never learn assembler or any other language to hack someone, or something like that.

(http://images.zaazu.com/img/Angel-male-bird-smiley-smiley-emoticon-000278-large.gif)
Sorry?
Title: Re: Translate block of code from C++ to ASM.
Post by: dedndave on December 20, 2010, 09:09:30 PM
lol
not asking forgiveness

appearance of innocence - facetious
reminds me of Jade when she was little.....

Who ate all the cookies ????

(http://img208.imageshack.us/img208/9623/jade078.jpg)
Title: Re: Translate block of code from C++ to ASM.
Post by: oex on December 20, 2010, 09:23:52 PM
It was you wasnt it Dave :bdg, really.... If we are being completely honest :lol
Title: Re: Translate block of code from C++ to ASM.
Post by: dedndave on December 21, 2010, 01:19:02 AM
especially if they are ginger-snaps   :P
Title: Re: Translate block of code from C++ to ASM.
Post by: MichaelW on December 21, 2010, 01:35:45 AM
So that's not a guilty look, it's a "I wonder what's wrong with my daddy" look?
Title: Re: Translate block of code from C++ to ASM.
Post by: dedndave on December 21, 2010, 01:37:30 AM
she is spoiled rotten - lol
daddy's little girl
Title: Re: Translate block of code from C++ to ASM.
Post by: vanjast on December 24, 2010, 06:32:19 PM
Twisted around her little finger you are ...   :bg
Title: Re: Translate block of code from C++ to ASM.
Post by: hutch-- on December 25, 2010, 11:03:04 AM
 :bg

Dave,

If you post that photo much more the little girl will have rights of royalties for extended publication.  :P
Title: Re: Translate block of code from C++ to ASM.
Post by: dedndave on December 25, 2010, 12:23:16 PM
i like that pic   :P
if you aren't careful, Hutch, i'll make it my avatar - lol
Title: Re: Translate block of code from C++ to ASM.
Post by: ToutEnMasm on December 25, 2010, 12:52:49 PM

:bg
This topic is full of angels.Don't look at the dark side and never use th cl /Fa.