flat assembler
Message board for the users of flat assembler.

Index > Windows > createprocess with commandline

Author
Thread Post new topic Reply to topic
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740 08 Jun 2005, 01:08
i was trying to make this code work (it was a test, i tried "create process" in the main program and it didnt work) but i found that it doesn't work with the command line, and when i put a NULL in the command line parameter it works perfect... but i need the command line parameter
this is the code, i tried a lot of things, but i'm feeling a little frustated... i'm trying to do something in fasm since last week (i'm a newbie in asm, i finished reading some tutorials las week)

format PE GUI
entry start

include '..\..\include\win32a.inc'

section '.data' data readable writeable

meemul db 'c:\fasmw161\meosemul\meosemul.exe'
progpath db 'c:\fasmw161\meosemul\guitest.bin'

section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL'

import kernel,CreateProcess,'CreateProcessA',\
ExitProcess,'ExitProcess'

section '.udata' readable writeable
sinfo STARTUPINFO
pinfo PROCESS_INFORMATION
section '.code' code readable executable

start:
invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo
invoke ExitProcess,0
Post 08 Jun 2005, 01:08
View user's profile Send private message Reply with quote
marciano



Joined: 27 Feb 2005
Posts: 18
Location: Argentina
marciano 08 Jun 2005, 02:54
Put a null character after every text string, as follows:

Code:
section '.data' data readable writeable

meemul db 'c:\fasmw161\meosemul\meosemul.exe',0
progpath db 'c:\fasmw161\meosemul\guitest.bin',0
    



Good luck Smile

EDIT: no habia visto que eras de Argentina Wink
Post 08 Jun 2005, 02:54
View user's profile Send private message Visit poster's website Reply with quote
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740 08 Jun 2005, 17:02
thanx for the reply but it didn't work... now i'm frustated Crying or Very sad

jeje espero q alguien encuentre la solucion, ya me estoy volviendo loco jajaj


byes|salu2
Post 08 Jun 2005, 17:02
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov 08 Jun 2005, 18:30
Read a carefully WinAPI manual. In principle it must to work, but is possible and can't. I can't a divine.
Post 08 Jun 2005, 18:30
View user's profile Send private message Reply with quote
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740 08 Jun 2005, 21:50
i have read the windows api reference, i can paste it complete, but i think it's not necesary, anyway i'll post the api declaration
the most strange thing is that i have worked with this api before, making a program in C and i didn't have any problem, but now in asm, the things are getting a little hard




The CreateProcess function creates a new process and its primary thread. The new process executes the specified executable file.

BOOL CreateProcess(

LPCTSTR lpApplicationName, // pointer to name of executable module
LPTSTR lpCommandLine, // pointer to command line string
LPSECURITY_ATTRIBUTES lpProcessAttributes, // pointer to process security attributes
LPSECURITY_ATTRIBUTES lpThreadAttributes, // pointer to thread security attributes
BOOL bInheritHandles, // handle inheritance flag
DWORD dwCreationFlags, // creation flags
LPVOID lpEnvironment, // pointer to new environment block
LPCTSTR lpCurrentDirectory, // pointer to current directory name
LPSTARTUPINFO lpStartupInfo, // pointer to STARTUPINFO
LPPROCESS_INFORMATION lpProcessInformation // pointer to PROCESS_INFORMATION
);
Post 08 Jun 2005, 21:50
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 09 Jun 2005, 06:30
hi! it really does not work and i do not know why, but if you want exactly just run look for these two working variants:
Code:
format PE GUI 
entry start 

include '%fasminc%\win32a.inc'

section '.data' data readable writeable 

meemul db 'c:\fasm\fasmw.exe',0 
progpath db 'c:\fasm\beer.asm',0 
_open   db 'open',0

_cmd    db 'c:\fasm\fasmw.exe '; no zero here - continued by cmdline!
cmdline db 'c:\fasm\beer.asm',0

section '.idata' import data readable writeable 

library kernel,'KERNEL32.DLL',shell,'SHELL32.DLL' 

import kernel,CreateProcess,'CreateProcessA',\ 
    ExitProcess,'ExitProcess' 

import shell,\ 
    ShellExecute,'ShellExecuteA'

section '.udata' readable writeable 
sinfo STARTUPINFO 
pinfo PROCESS_INFORMATION 
section '.code' code readable executable 

start: 
invoke ShellExecute,0,_open,meemul,progpath,0,SW_SHOWDEFAULT
;invoke CreateProcess,meemul,progpath,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo 
invoke CreateProcess,0,_cmd,NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,sinfo,pinfo 
invoke ExitProcess,0    


regards!
Post 09 Jun 2005, 06:30
View user's profile Send private message Visit poster's website Reply with quote
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740 09 Jun 2005, 16:54
thanxxxxxxxxxxxxxxx now it's working, Smile Smile Smile Smile tahnx a lot to everyone
Post 09 Jun 2005, 16:54
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 10 Jun 2005, 09:44
Wouldn't it be easier to tell Mike that MeOSEmulator should associate itself with MenuetOS header. I tried your code - it works, but doesn't give me any advantage...
A)
1. I compile ASM->MeOS
2. I drag&drop this to MeOSEmul.exe
B)
1. I compile ASM->MeOS
2. I run your program that in turn runs my MeOS binary with MeOSEmul

I tried messing with registry but I can't get the emulator to accept my parameters and FASM won't run .bin by default Very Happy
Post 10 Jun 2005, 09:44
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
DC740



Joined: 01 Oct 2004
Posts: 74
Location: Argentina
DC740 10 Jun 2005, 17:17
hello madis Smile i'lll explain you what i'm trying to do... the code that i posted was a test to try the api, the main program was the fasm IDE for win32, my idea is to make it "run" the menuetos compiled .bin with the emulator directly from the IDE (pressing F9 or clicking in "Run").
the api is working, but i don't know how to make it work with the path_buffer variable (inside fasmw.asm), i think that path_buffer doesn't finish with a null byte (0) and that is causing my modifications to not work, now i'm trying to find the way to work with strings to learn to solve my problem, if you have any documentation about that i would be very grateful... it should be easy for an experienced programmer but i started last week and it's my first program... well... is not my program, but you know what i mean... i hope this will be useful... thanx MenuetOS rulez
Post 10 Jun 2005, 17:17
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.