News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

PROBLEM IN EXECUTION

Started by Zest, November 08, 2006, 06:57:37 AM

Previous topic - Next topic

sinsi

Quote
Format of EXEC parameter block for AL=00h,01h,04h:
Offset   Size   Description   (Table 01590)
00h   WORD   segment of environment to copy for child process (copy caller's
        environment if 0000h)
02h   DWORD   pointer to command tail to be copied into child's PSP
06h   DWORD   pointer to first FCB to be copied into child's PSP
0Ah   DWORD   pointer to second FCB to be copied into child's PSP
0Eh   DWORD   (AL=01h) will hold subprogram's initial SS:SP on return
12h   DWORD   (AL=01h) will hold entry point (CS:IP) on return
Look at offset 12h, this gives you the entry for the other program.
As far as changing bytes in the program, if you know the code of it then the CS:IP will give
you an idea of addresses - if you don't then you shouldn't be hacking it in the first place.
Light travels faster than sound, that's why some people seem bright until you hear them.

Zest

Hi,
Thanks sinsi for your help.

I fixed this part as follows:

      ParamBlock LABEL WORD
                 WORD  0
                 DWORD CmdLine
                 DWORD DfltFCB,DfltFCB
      LoadSSSP   DWORD ?
      LoadCSIP   DWORD ?


Then I used this code to change and then enter to the second program:


mov bx,SEG ParamBlock ;Loading the Child Process
      mov es,bx
      mov bx,ParamBlock
      lds dx,PgmName
      mov al,01h
      mov ah,4bh
      int 21h
     
     
      mov es,WORD PTR cs:[LoadCSIP] ;Trying to change the twentieth Byte in
      mov si,20h                    ;the second program
      mov BYTE PTR es:[si],'$'
     
      mov ss,WORD PTR cs:[LoadSSSP]   ;Trying to go to the second program and
      mov sp,WORD PTR cs:[LoadSSSP]+2 ;executing it
      jmp DWORD PTR cs:[LoadCSIP]
     

      mov ah,4ch
      int 21h

     
Unfortunately,It doesn't work.
I have some questions to be able to understand the concept.
When the second program is loaded,where is it located?
Is it right after the stack segment of the first program?
If it's so,I should be able to search in the memory for the bytes I want.
But I need an algo to search in memory.

ss of the parent program is the last segment wihch I should use and add sp to it to get the last address in the memory.
After this address normally the first segment of the child program should be loaded.

How can I code an algo to search in this area?
Also what is the last address in the memory?
I mean how far shall I do search in memory to find the desired bytes.

Is there any way to use SCASB instruction to find the place in memory?
In fact,let me know what should be put in ES:DI and AL and CX to be able to use SCAS instruction.

As for being legal or not,I just want to change my previous program which shows DOS Version.

Here is the program and it's souurce code that I want to change.

http://rapidshare.com/files/3490689/Load.rar

I want to change this part in this program:

      mov dl,'.'
      mov ah, 02h
      int 21h   
to

      mov dl,'*'
      mov ah, 02h
      int 21h   


So I should find the first part in RAM and then try to replace it with the second part.
The problem is coding this algo.
I hope you can help.

Thanks in advance.

Regards,
Zest.

sinsi

The (LoadCSIP DWORD) is actually stored as (WORD offset,segment) and points to the start: label, so you would
have to calculate the difference between start: and the byte to change.

QuoteAs for being legal or not,I just want to change my previous program which shows DOS Version
Much easier to change source code...

This seems to be a bit dodgy, so I suggest you read the rules of the forum. I see the other forum locked your topic - don't be suprised
if this one is too.
Light travels faster than sound, that's why some people seem bright until you hear them.

MichaelW

Zest,

So you are going to the trouble of coding a program, to change just one byte, in your own application, when you have the source code for the application, and even if you didn't there would be much easier methods. What are you really trying to do?
eschew obfuscation

Zest

Hi,
Thanks.
So to avoid being banned,I change the focus of this topic to using Overlays.
I mean this fuction which is the last one I want to learn.

Using interrupt 21h function al=3h and ah=4Bh

I know that I should use this ParamBlock

      ParamBlock LABEL WORD
      StartSeg    WORD ?
      RelocFactor WORD 0


But what should be put in the first member of this block?

I mean this:   StartSeg    WORD ?

Also in previous programs we used an address and the second program name to point to the second program which is used for loading.

For example:

PathName  BYTE 'C:\v.exe',0

And it's used in this part of the program:


      mov ah,4Bh
      mov al,3
      mov dx,SEG PathName
      mov ds,dx
      lea dx,PathName
      mov bx,SEG ParamBlock
      mov es,bx
      lea bx,ParamBlock
      int 21h
     


Now I want to know this time,what this element should point to.

I also have seen some files with this extension.

*.OVR
These files are seemingly ,Overlay files.

Could you please let me know how it is possible to compile and make such files?
Do you use any special option with Assembler or Linker to compile such files?

By the way,you didn't talk about the algo which its aim is to search in memory.
Is it possible to write such an algo?
I hope coding such an algo is not illegal.

Thanks in advance.

Best Regards,
Zest.







Zest

Quote from: MichaelW on November 16, 2006, 07:27:50 AM
Zest,

So you are going to the trouble of coding a program, to change just one byte, in your own application, when you have the source code for the application, and even if you didn't there would be much easier methods. What are you really trying to do?


Hi,
The answer is that I want to learn this function of interrupt 21h.
That's why I coded a small program of mine,to be able to learn the behaviour of this undocumented fuction.
What I mostly Like to learn is everything which deals with Computer Memory and its strcuture.
These topics are not popular and that's why most of programers don't know anything about them.
Some also know but don't care to share.
Some are also wicked ones.
By wicked I mean a great programmer in Leggal coding forums like this and simultaneously a great cracker in illegal forums like that.
So when I try to ask about something which is used mostly by wicked ones,the arguments will arise.
I can understand that,but what I can't understand is that why I should for learning a legal function
which is a part of pure programming provided by MICROSOFT go to illegal forums and ask for help.
:(
Still,I beleive that there,at illegal forums,wicked ones are silent.
The help there, will come from a great programmer who is not evil at heart.
A person who beleives in faithfulness,honesty and truthfulness of human beings.

That's the bitterness of the truth.

Best Regards,
Zest.


japheth

> I also have seen some files with this extension.

> *.OVR
> These files are seemingly ,Overlay files.

> Could you please let me know how it is possible to compile and make such files?
> Do you use any special option with Assembler or Linker to compile such files?

> By the way,you didn't talk about the algo which its aim is to search in memory.
> Is it possible to write such an algo?

Your questions suggest that you know almost nothing about DOS programming. Your "project" is too ambitious
for your skills. Thus all you can do is request others to feed you with information, which is not the purpose of this forum. No!




Zest

Quote from: japheth on November 16, 2006, 10:56:03 AM
> I also have seen some files with this extension.

> *.OVR
> These files are seemingly ,Overlay files.

> Could you please let me know how it is possible to compile and make such files?
> Do you use any special option with Assembler or Linker to compile such files?

> By the way,you didn't talk about the algo which its aim is to search in memory.
> Is it possible to write such an algo?

Your questions suggest that you know almost nothing about DOS programming. Your "project" is too ambitious
for your skills. Thus all you can do is request others to feed you with information, which is not the purpose of this forum. No!





Hi japheth,
Everybody has an opinion which is honorable and I respect yours.
Maybe,my project which is just learning is ambitious for my skills and I don't know anything about programming.
So,I need help to overcome this problem.
If the perpose of this board is not to teach and solve others problems,there is still no complaining.
In some previous posts I mentioned that if there were  sorce codes for what I asked please let me know.
Source codes are mostly from the programs which were written by some coders that they made these codes public or they are from Books.

If you still don't know any public source code which can help me ,just introduce a book which can cover the topics I need to know and I have to know.
I promise to buy that book and read it from cover to cover and don't ask anything here.
By reading this book and learning it,rarely can be a man who can express that I don't know anything about programing.
However,not knowing about a case is not a big problem,but not asking is.
The sin is, knowing about not knowing of a case.
So I asked for informaton, to get and then by this information remedy the problem of not knowing or maybe the sin.

In conclusion, I still ask for introducing a book in which the topics I asked and I want to know and I have to know is covered.

Regards,
Zest.

Rockphorr

Strike while the iron is hot - Бей утюгом, пока он горячий

Zest

Quote from: Rockphorr on November 16, 2006, 05:39:41 PM
Download and debug my programm.
I launch command.com.

http://www.masm32.com/board/index.php?topic=5032.0
Thank you so much Rockphorr.
:U
I'll study your code.
Regards,
Zest.

MichaelW

#25
Zest,

Function 4B01h, Load Program, was originally undocumented, but Microsoft had officially documented it by 1991 (MS-DOS 5.0). The use of the function was covered in detail in Chapter 7 of the first edition of UNDOCUMENTED DOS: A Programmer's Guide to Reserved MS-DOS Functions and Data Structures by Andrew Schulman, Raymond J. Michels, Jim Kyle, Tim Paterson, David Maxey, and Ralf Brown, Addison-Wesley, 1990, ISBN 0-201-57064-5. Chapter 7, titled The MS-DOS Debugger Interface, was written by Tim Paterson, who developed the 16-bit x86 OS that eventually became MS-DOS Version 1.0. IIRC that chapter was missing in the second edition, and both editions are out of print.

Calling the function is straight forward, but passing control to the loaded program, and then back to the calling program when the loaded program terminates, is somewhat difficult. Before you pass control to the loaded program, you must set the segment registers and stack pointer as Function 4B00h would. When control returns to the calling program, you must set the segment registers (other than CS) and stack pointer to values that are correct for the calling program, in the state it was in when it performed the call. This is much easier to do if both of the programs are COM files and the calling program has nothing essential on the stack (so you can just leave SP as is). Some other important details are:

The function sets the current PSP to that of the loaded program, so between the function call and the point at which control is passed to the loaded program the calling program cannot do I/O through DOS. Or at least not without first making the current PSP that of the calling program, but the loaded program's PSP (segment address) must be preserved, because it will be needed to set DS and ES, and it must be the current PSP when control is passed to the loaded program. When control returns to the calling program, the current PSP is that of the calling program.

Control can be passed to the loaded program by doing a far call to the far address that the function places in the ldCSIP member of the LOAD structure (these are the documented Microsoft names for the LoadCSIP and ParamBlock in your code).
eschew obfuscation

Zest

Hi MichaelW,
Thanks for your explanation and attention.
Unfortunately my last hope which was buying the books is dead.
:(
The book which I could study and see its source codes is out of print and I just can hear in here and there that the only good book for my purposes in learning and programming is out of print.

Someone esle mentioned that what I need is a book about system programming in assembly.
Then he introduced this book which is out of print indeed.  :(

QuoteAssembly Language Master Class (Wrox Press Master Class) (Paperback)
by Igor Chebotko, Peter Kalatchin, Yuri Kiselev, Efim Podvoisky, Kiril Malakhov, Yuri Petrenko, Mike Schmit, Sergei Shkredov, Gennady Soudlenkov, Daniel Wronski
(7 customer reviews)   

    * Paperback: 1024 pages
    * Publisher: Apress; Bk&Disk edition (October 1994)
    * Language: English
    * ISBN: 1874416346

Do you know anything about this book?
Is it what I should look for?

I wish I could even buy the ebook of these ones.
The wonder is,while the publication doesn't publish the books and there is no money engaged in this case,why these books shouldn't be public and available for everyone who really needs them.

Anyway,it seems that I should follow my work with trial and error to get to the reasult which I become satisfy with.


Thanks anyway,
Best Regards,
Zest.