Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
F

francesco s

@francesco s
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • C++ program and my __asm
    F francesco s

    Hi everybody, I hope you guys don't mind if I ask you a question about assembly in the C/C++ section. I used to love this forum since when I've received help to fix a bug in the program I developed for my thesis. I have a win32 console application written in C++ and a function which invokes the assembler inline (__asm). I need to use assembly in this function for technical reason. I would like to write the assembler code that calls the API WinExec and then ExitProcess. I have tried to do that in 3 different ways but no one worked. Result, my machine crash. 1) db is not allow in Visual C++ within __asm, so the following solution has to be replaced with the #2. jmp short GetCommand CommandReturn: pop ebx xor eax,eax push eax push ebx mov ebx,0x7c8615b5 ;place address of WinExec into ebx call ebx xor eax,eax push eax mov ebx, 0x7c81ca82 ;place address of ExitProcess into ebx call ebx GetCommand: call CommandReturn db "calc.exe" db 0x00 2) This can be compiled and run but it makes the machine crash. It seems the address of WinExec it's wrong and the system get lost. So I have tried the #3. (below only the WinExec) mov ebp,esp push 0x20657865 ; I have also tried with 20657865H, Is there any difference? push 0x2e646d63 lea eax,dword ptr ss:[ebp-8] push eax mov eax,0x7c86114d call eax 3) In the code below I define a pointer to const char c which point to the string that i want to pass as a parameter to the Exec call. I also use the name of the API function instead of the address. Result the code has been compiled but the machine crash. const char* c = "calc.exe"; int foo() { _asm{ push c xor eax,eax push eax call WinExec xor eax,eax push eax call ExitProcess } } That's all. I hope this make sense. :cool: Thanks, FS

    C / C++ / MFC help c++ question database json
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups