News:

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

Main Menu

Help! Questions on opening files withing an Assembly IDE

Started by Mike Anum, May 07, 2017, 04:14:32 AM

Previous topic - Next topic

Mike Anum

Hi, I have a question, first time in this community BTW. So I want to know how I can execute, load or open a file, or call a file withing a parent process. I'm not sure what terms I'm supposed to use, so please excuse me if I sound confusing. But if anyone can direct me to finding more on how to do something similar to that, I'd appreciate it

Thanks

jj2007

Hi Mike,

There are many ways to do that from assembler. What exactly do you need it for?

hutch--

Mike, tell us bit more of what you are trying to do, it will give us some idea of how to respond to your question.

Mike Anum

I'm was trying to figure out how I could execute a program from the cmd line. I learned a little more on how to do that which is to use CREATE PROCESS which requres windows.inc, or masm32rt.inc but I now have linker error from executing it. I think it has to do with with my framework.c file because it executes correctly without it. I looked up the errors 2019 and 2001. It says either my _MainPROC doesn't exist or is duplicated somewhere else. However I my header needs framework.c to create a message box. If you have a work around I'd appreciate it
see attached files

hutch--

This will build, I annotated what the changes were.

    .686p
    .mmx
    .xmm
    .MODEL FLAT, stdcall
    option casemap:none

    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

;;; INCLUDE io.h

.DATA

    PrcName db 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe',0
    CmdLine db '/k "echo.&&'
            db 'echo Recover - Recover C:&&'
            db 'echo Wiz [?] - MBRWizard&&'
            db 'echo Exit    - Reboot"',0

        .DATA?

    SUInfo  STARTUPINFO <>
    PrcInfo PROCESS_INFORMATION <>

.CODE

start:              ; <<<<<<<<<< You need a start label

_main   proc

        INVOKE  CreateProcess,ADDR PrcName,ADDR CmdLine,NULL, NULL,NULL,
                NORMAL_PRIORITY_CLASS,NULL,NULL,ADDR SUInfo,ADDR PrcInfo

        INVOKE  ExitProcess,0

_main   endp

        end start   ; <<<<<<<<<< terminate the same label as the start label

hutch--

I have tested it and it runs the version of Google Chrome on my computer. God know what you are trying to do with the command line but you can get it to start a valid URL.

Mike Anum

Ok, just ran your code, and it didn't help, but it does run. However it only runs without framework.c.
Which is the current problem

So basically, it will run with framework.c if windows.inc isn't included, but then I won't be able to run the cmdline. So if I remove framework.c, it will run but then the user won't be able to input or output strings.

I'm using the cmdline to output images, if executed inconditional statements. I'd figure that it would be the easier option, but taking the easy way out doesn't seem to be working. So maybe, there's a better way to display images without a command prompt... I currently don't know

Please see attachment

jj2007

Quote from: Mike Anum on May 08, 2017, 06:01:06 AMSo if I remove framework.c, it will run but then the user won't be able to input or output strings.

You don't need any "framework.c" to input or output strings. There are many alternatives, e.g. crt_printf() and crt_scanf():
include \masm32\include\masm32rt.inc

.data?
buffer db 1000 dup(?)

.code
start:
  mov edi, offset buffer
  invoke crt_printf, chr$("Type a string: ")
  invoke crt_scanf, chr$("%s"), edi
  invoke crt_printf, chr$("You typed %s"), edi
  invoke crt__getch
  exit

end start


Btw, the best thing about Visual Crap is that you can disinstall it fairly easily 8)

Mike Anum

It compiles, but how do you add a message box to it? Help please

jj2007

I don't know, maybe MsgBox 0, "Hello World", "I am a title:", MB_OK ? What does the manual say?

Mike Anum

If found a solution, I just edited my framework.c file to added a function with create process which then ran an exe containing an executable that opens an image from memory. I then edited my io.h headerhe file to executed the c function

Thanks everyone for the help, Cheers  : :biggrin: