flat assembler
Message board for the users of flat assembler.

Index > Main > load bin direct to code address space and others...

Author
Thread Post new topic Reply to topic
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
first Q
is it possible to load binary direct to address space for code?

second Q
Code:
push SW_SHOW     ;what'll happens when the appl will be opened
push buffer      ;nulpointer to buffer-path expl: 'c:\tah\tak\tay\fasm',0
push NULL       ;parametrs for exe
push PRGrun     ;nulpointer to name executable
push PRGope     ;nulpointer to db'open',0 ( what  should be done?)
push NULL       ; there is no handle to paren window
call shexe        ;invoking ShellExecuteA
    


what parametr is nessesery and I forgot it?

_________________
Microsoft: brings power of yesterday to computers of today.
Post 24 Oct 2003, 14:26
View user's profile Send private message Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024
A1:
Yes, Just do a GlobalAlloc, then call or jump to the code. But remember, if it uses API's, you'll have to figure at how to access them. I don't think that part is hard either.
Also watch out for absolute jumps.
Why do you need to load code?

A2:
Here is what I use to launch an executable
Code:
;*******************************************************************************
; DWORD WaitCmd(                    Create a New Process and Wait for it to Exit
;      lpsz    // ASCIIz Command Line
; );
; Return Value:
;   0 if Successful
; Remarks:
;   If CreateProcess or the Called Process fail, WaitCmd will Exit to the System
;   CreateProcess must be called with bInheritHandles=True
; About:
;   CreateProcess is used by Qcc to invoke the fABIUS tools. Since CreateProcess
; is non-blocking, Qcc must loop while the process is still active. Otherwise
; Qcc will become a multi-treaded application very quickly.
;*******************************************************************************
proc WaitCmd, lpsz
enter
   stdcall  DispLine, Report.Execute, [lpsz]
   invoke   CreateProcess, 0, [lpsz], 0, 0, True, 0, 0, 0, Process.stin, Process.prin
   cmp      eax, False                          ; Process Start Ok?
   jnz      .WhileActive                        ; Yes - Wait for it to return
   stdcall  Croak, Error.Execute, [lpsz]        ;  No - Fatal Error

.WhileActive:
   invoke   GetExitCodeProcess, [Process.prin.hProcess], Process.ExitCode
   mov      eax, [Process.ExitCode]             ; Get Status of Process
   cmp      eax, STILL_ACTIVE                   ; Is it still Active?
   jz       .WhileActive                        ; Yes - Keep Waiting

   cmp      eax, False                          ; Did the Process Succeed?
   jz       .Done                               ; Yes - Return

   stdcall  Dword2Hex, TempPath+2, eax          ; Get ASCII of Error Code
   mov      w[TempPath], '0x'
   mov      b[TempPath+10], Null                ; TempPath = "0xHeXaDeCa"
   stdcall  DispLine, Error.Process, TempPath   ; Tell User What Happened
   invoke   ExitProcess, eax                    ; Return to System
.Done:
return    

Process.stin and Process.prin are uninitialized structures found in kernel32.inc
Post 30 Oct 2003, 21:51
View user's profile Send private message Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
Very Happy

_________________
Microsoft: brings power of yesterday to computers of today.
Post 31 Oct 2003, 11: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-2019, Tomasz Grysztar.

Powered by rwasa.