News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Translate block of code from C++ to ASM.

Started by lelejau, December 17, 2010, 07:18:01 PM

Previous topic - Next topic

lelejau

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.
Learning assembly :)

hutch--

Try learning assembler, its a trivial task.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

lelejau

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.
Learning assembly :)

drizz

;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

The truth cannot be learned ... it can only be recognized.

lelejau

thanks, I will test and tell if it works.



undefined symbol: _vsnprintf_s
Learning assembly :)

drizz

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...
The truth cannot be learned ... it can only be recognized.

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

lelejau

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.
Learning assembly :)

dedndave

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.


lelejau

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.


Sorry?
Learning assembly :)

dedndave

lol
not asking forgiveness

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

Who ate all the cookies ????


oex

It was you wasnt it Dave :bdg, really.... If we are being completely honest :lol
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

dedndave

especially if they are ginger-snaps   :P

MichaelW

So that's not a guilty look, it's a "I wonder what's wrong with my daddy" look?
eschew obfuscation

dedndave

she is spoiled rotten - lol
daddy's little girl