News:

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

convert c++ to masm

Started by ragdog, May 23, 2010, 10:39:57 AM

Previous topic - Next topic

ragdog

Hi

I have again a question to this

This use a procedur as last parameter

(char *)&szString[24]

ConvertString(szString,(char *)&szString[24]);

Can any translate it please in masm32

THANks


ecube


.data?
szString byte 24 dup(?)

.code
invoke ConvertString,szString,addr szString

or

invoke ConvertString,addr szString,addr szString


depending if local or global

ragdog

ahh ok thanks :U

i have a other little question to this

DWORD OutBuf[0x100];
DWORD OutBufSize=0x100*sizeof(DWORD);   

NextString(DWORD *)&OutBuf,&OutBufSize;


If this correct?
.data?
OutBuf db 100 dup(?)
.code
Invoke NextString,addr OutBuf,sizeof OutBuf


ecube

Quote from: ragdog on May 23, 2010, 11:22:13 AM
ahh ok thanks :U

i have a other little question to this

DWORD OutBuf[0x100];
DWORD OutBufSize=0x100*sizeof(DWORD);   

NextString(DWORD *)&OutBuf,&OutBufSize;


If this correct?
.data?
OutBuf db 100 dup(?)
.code
Invoke NextString,addr OutBuf,sizeof OutBuf



not quite

.data?
OutBuf dd 100 dup(?)
OutBufSize dd ?

.code
mov OutBufSize,sizeof OutBuf
Invoke NextString,addr OutBuf,addr OutBufSize


some things to note, they used dword instead of byte this time, also i'm assuming since it says out for the variable input size it'll be writn somethin out so we passed the address it can write to along the buffers size on input.

clive

Quote from: ragdog
ConvertString(szString,(char *)&szString[24]);

This would be addr szString, addr szString +24
It could be a random act of randomness. Those happen a lot as well.

qWord

it must be 100h and not 100 (decimal)
FPU in a trice: SmplMath
It's that simple!

ragdog

Thanks

It this  DWORD OutBufSize=0x100*sizeof(DWORD); not 100*4?


OutBufSize dd 400 dup(?)

Or Think your?

dedndave

100 dwords is 400 bytes
the SIZEOF operator always returns a byte count

ragdog

So

OutBufSize db 400 dup(?)

?


dedndave

that would work, or....

OutBuf dd 100 dup(?)

i wouldn't name it OutBufSize - it is the buffer
the size of the buffer is probably a dword value

clive

It's not a buffer, it holds the size, and it is in hex

OutBuf  dd  100h dup(?)
OutBufSize dd  0400h


E^Cube is the closest

.data?
OutBuf dd 100h dup(?)
OutBufSize dd ?

.code
mov OutBufSize,sizeof OutBuf
Invoke NextString,addr OutBuf,addr OutBufSize


This might also work
OutBufSize dd sizeof(OutBuf)

Although passing the size like this via a pointer is a tad queer for my tastes, unless the called procedure is returning a different (truncated?) size back up to the calling procedure
It could be a random act of randomness. Those happen a lot as well.

ragdog

Yes this is it :U

This works fine

OutBuf dd 100h dup(?)
OutBufSize dd ?

.code
mov  OutBufSize,sizeof OutBuf  ;in OllyDbg if this "mov OutBufSize,400"

This  works not OutBufSize dd sizeof(OutBuf)

Why?

clive

Tend not to spend a lot of time fighting with MASM syntax, following are workable methods

OutBuf  dd  100h dup(?)
OutBufSize  dd  $-OutBuf

or

OutBufSize  dd  SIZEOF OutBuf
It could be a random act of randomness. Those happen a lot as well.

ragdog

I learn  :bg

This example works not for sizeof
OutBuf  dd  100h dup(?)
OutBufSize  dd  $-OutBuf

or

OutBufSize  dd  SIZEOF OutBuf

Only this with "mov  OutBufSize,sizeof OutBuf"

This get the correct size why not declare this sizeof in the .data?

I do not understand

clive

Not sure I follow your English,
Microsoft (R) Macro Assembler Version 6.15.8803     05/24/10 11:27:57
test16.asm      Page 1 - 1


        .386
        .MODEL FLAT

00000000         .DATA

00000000  00000100 [ OutBuf          dd      100h dup(?)
    00000000
   ]
00000400 00000400 OutBufSize      dd      $-OutBuf

00000404  00000400         dd      SIZEOF OutBuf

00000000         .CODE

        END
It could be a random act of randomness. Those happen a lot as well.