News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

C -> ASM

Started by six_L, March 06, 2023, 02:49:47 AM

Previous topic - Next topic

six_L

Hello everyone!

How do the C codes translate into asm codes?

void EditPrintf (HWND hwndEdit, TCHAR * szFormat, ...)
{
     TCHAR   szBuffer [1024] ;
     va_list pArgList ;

     va_start (pArgList, szFormat) ;
     wvsprintf (szBuffer, szFormat, pArgList) ;
     va_end (pArgList) ;


     SendMessage (hwndEdit, EM_SETSEL, (WPARAM) -1, (LPARAM) -1) ;
     SendMessage (hwndEdit, EM_REPLACESEL, FALSE, (LPARAM) szBuffer) ;
     SendMessage (hwndEdit, EM_SCROLLCARET, 0, 0) ;
}

    EditPrintf (hwndEdit,
                 TEXT ("System date and time successfully changed ")
                 TEXT ("from\r\n\t%s, %s.%03i to\r\n\t%s, %s.%03i."),
                 szDateOld, szTimeOld, pstOld->wMilliseconds,
                 szDateNew, szTimeNew, pstNew->wMilliseconds) ;
}
Say you, Say me, Say the codes together for ever.

jj2007

Similar to this - just to give you a start. Go ahead and play yourself, it's not that difficult. Instead of TEXT ("..., use cfm$("...

EditPrintf proc hwndEdit, pFormat
Local szBuffer[BYTE]:1024
Local pArgList:DWORD, vaStart:DWORD

     ??? va_start (pArgList, szFormat) ;
     invoke wvsprintf, addr szBuffer, pFormat, addr pArgList
     ??? va_end (pArgList) ;

     invoke SendMessage, hwndEdit, EM_SETSEL, -1, -1
     invoke SendMessage, hwndEdit, EM_REPLACESEL, FALSE, addr szBuffer
     invoke SendMessage, hwndEdit, EM_SCROLLCARET, 0, 0
     ret
EditPrintf endp

morgot

You can use https://godbolt.org/

https://ibb.co/D7kTpQW
Sorry for the bad English

hutch--

You used to be able to generate an ASM listing with the 32 bit versions of Visual C, they were a bit rough to understand but if you set the options to turn all optimisation off, you could then manually optimise it and often get it faster. If its a 32 bit version of VC, have a look at the command line options.

mikeburr

if youve got a working exe chuck it in IDA [32 bit freeware] or Radare cutter [64 bit freeware] .. youll notice that the compilers such as Visual C put an awful lot of junk in largely revolving around the ability to recover your program in the event of failure .. further if youre running a 64 bit program theres a lot of "bodging" done by MS to try and ensure some sort of compatibility  with what are basically 32 bit functions ... Cutter really highlights what a mess it is sometimes .. std function calls are ok but anything non standard is fraught to say the least
regards
mikeb

six_L

Hi,jj2007/morgot/hutch--/mikeburr

Thank you very much!
Special emphasis on the our member(morgot) from Ukraine. you are fine, we'r gratified.
Say you, Say me, Say the codes together for ever.