MASM32 x86 windows assembly GetCommandLineToArgvW

Viewed 1258

I would like to ask how to use the CommandLineToArgvW function in x86 assembly. I'm having trouble with it. All I can print as of today is the number of the arguments along with the program execution in cmd. I would like to save the arguments in different variables. How can I do it?

My code looks like this:

include \masm32\include\masm32rt.inc

.data
  Format db "%d", 10, 0

.data?
  Arguments db 100 dup(?)

.code

start:

  mov esi, offset Arguments

  push ebp
  mov ebp, esp
  sub esp, 4

  call GetCommandLineW

  lea ecx, dword ptr[ebp - 4]
  push ecx
  push eax
  call CommandLineToArgvW

  mov esi, eax
  push offset Arguments
  call StdOut

  push dword ptr [ebp - 4]
  push offset Format
  call crt_printf
  add esp, 8


  push 0
  call ExitProcess

end start

My output as of now is the number of arguments. For example:

  • D:\masm32>Hello.exe I am Hello
  • 4
  • D:\masm32>
1 Answers
Related