Analysis of SoftRAM 95 SOFTRAM1.386
-----------------------------------

Introduction:

SOFTRAM1.386 is one of two virtual device drivers (VxDs) used by
Synchronys Softcorp's SoftRAM 95 when installed for Windows 3.1.
This analysis of the code in SOFTRAM1.386 was posted anonymously.  I
did *not* write it. However, I have briefly looked at a disassembly
listing for SOFTRAM1.386, and compared it with the PAGEFILE.ASM
sample code that Microsoft ships with the Windows 3.1 Device Driver
Kit (DDK), and have confirmed that large parts of the SOFTRAM1.386
code are absolutely identical to the copyrighted Microsoft code. 

The DDK license agreement does permit redistribution of the sample
code (such as PAGEFILE.ASM) in object-code form, but "only in
conjunction with and as part of your software product which adds
primary and significant functionality to the redistributable
components."  It is obvious from the following analysis that 
SOFTRAM1.386 does not add significant functionality to Microsoft's
PAGEFILE.ASM.

                                    -- Andrew Schulman

;----------------------------------------------------------------------

Softram1.386 is virtually identical to pagefile.386 from the Windows 3.1 DDK.
They both consist of 30 procedures.  These procedures are unchanged:

   PageFile_Control                 PageFile_Clean_Up
   PageFile_Test_IO_Valid           PageFile_Grow_File
   PageFile_Read_Or_Write           PageFile_Cancel
   PageFile_Int_24h                 PageFile_Int_23h
   PageFile_Call_Back               PageFile_Cancel_Call_Back
   PageFile_Map_Null                PageFile_Set_Our_PSP
   PageFile_Set_Client_PSP          PageFile_Call_DOS
   PageFile_Debug_Query             PageFile_Svc_Call
   PSC_Get_Version                  PSC_Paging_Info_Change
   PSC_Get_Cur_Tmp_Sz               PageFile_Init_Complete
   PageFile_Init_File               PageFile_Test_Correct_Sector     
   PageFile_OEM_Cache_Flush         PageFile_Nuke_Swap_File          
   Vxd_Real_Init

And these have changes:
   PageFile_Get_Version
   PSC_Get_Paging_Info
   PageFile_Open_Partition
   PageFile_Sys_Critical_Init
   PageFile_Open_DOS_Swap_File


The changes are as follows:

PageFile_Get_Version:  

   This function now returns 0C03h instead of 010Ah;

PSC_Get_Paging_Info:

   Inserted the following code into this function.  In the DDK version, this
   code is between lines 2782 and 2783 (which are included here for context)

      mov eax, [PF_Max_File_Pages]     ; line 2782

      ;new code
      mov ecx, [Ini_Softram]           ; a boolean indicating whether 
      or ecx, ecx                      ;   Softram= was in the ini file

      jz Around
      cmp [PF_Have_Partition], TRUE 
      jne No_Partition_File

      mov eax, [SRAM_Max_File_Pages]   ; Set to the same as PF_Max_File_Pages
                                       ; in PageFile_Open_Partition
      jmp short Around

      ALIGN 4
   No_Partition_File:
      mov ecx, [Ini_SoftRamSize]       ; value of SoftRamSize= in ini file
      shr ecx, 2
      sub eax, ecx

   Around:
      shl eax, 12                      ; line 2783



PageFile_Open_Partition:
   
   inserted the following code in between lines 736 and 737 (here for 
   context):

   mov [PF_Max_File_Pages], eax              ;736
   mov [SRAM_Max_File_Pages], eax
   mov [PF_Cur_File_Pages], eax              ; 737

PageFile_Sys_Critical_Init:

   Inserts the following code right at the beginning of the function, to 
   read the SoftRam values (most of which are not even used).  It's fairly
   self explanatory so I haven't bothered cleaning it up.

      mov     eax,0
      xor     esi,esi
      mov     edi,offset STR_PermSwapSizeK ; (01AD8='PermSwapSizeK')
      VMMcall Get_Profile_Decimal_Int ; Win-VMM function   fn=100ABh
      mov     Ini_PermSwapSizeK,eax   ; (01A94=0)
      mov     eax,0
      xor     esi,esi
      mov     edi,offset STR_SoftRam  ; (01688='SoftRam')
      VMMcall Get_Profile_Decimal_Int ; Win-VMM function   fn=100ABh
      cmp     eax,0
      je      loc_58
      mov     eax,1

   loc_58:
      mov     Ini_SoftRam,eax         ; (01A9C=0)
      mov     eax,3E8h
      xor     esi,esi
      mov     edi,offset STR_SoftRamSize ; (0167C='SoftRamSize')
      VMMcall Get_Profile_Decimal_Int ; Win-VMM function   fn=100ABh
      cmp     eax,80E9h
      ja      short loc_59
      cmp     eax,64h
      jb      short loc_59
      jmp     short loc_60            ; (00C6C)
      db       90h, 90h, 90h

   loc_59:
      xor     eax,eax
      mov     Ini_SoftRam,eax         ; (01A9C=0)

   loc_60:
      mov     Ini_SoftRamSize,eax     ; (01A98=0)
      mov     eax,3A98h
      xor     esi,esi
      mov     edi,offset STR_SoftRamMaxPhys ; (01690='SoftRamMaxPhys')
      VMMcall Get_Profile_Decimal_Int ; Win-VMM function   fn=100ABh
      cmp     eax,3A99h
      ja      short loc_61
      jmp     short loc_62            ; (00C96)
      db       90h, 90h, 90h

   loc_61:
      xor     eax,eax
      mov     Ini_SoftRam,eax         ; (01A9C=0)

   loc_62:
      mov     Ini_SoftRamMaxPhys,eax  ; (01AA0=0)
      mov     eax,7D0h
      xor     esi,esi
      mov     edi,offset STR_SoftRamMinOper ; (0169F='SoftRamMinOper')
      VMMcall Get_Profile_Decimal_Int ; Win-VMM function   fn=100ABh
      cmp     eax,1F4h
      jb      short loc_63
      jmp     short loc_64            ; (00CC0)
      db       90h, 90h, 90h

   loc_63:
      xor     eax,eax
      mov     Ini_SoftRam,eax         ; (01A9C=0)

   loc_64:
      mov     Ini_SoftRamMinOper,eax  ; (01AA4=0)


PageFile_Open_DOS_Swap_File:

   Added the following code between lines 1166 and 1168

      ;1166\/
      VMMCall Get_Profile_Decimal_Int  ; EAX = Maximum file size
      mov ecx, [Ini_SoftRam]
      or ecx, ecx
      jz PF_ODSF_No_SoftRam
      mov ecx, [Ini_SoftRamSize]
      add eax, ecx
   PF_ODSF_No_SoftRam:

      ; 1168\/
      shr ebx, 10                      ; EBX = Max size in K



That's it on the changes to pagefile.386.  So they changed one line, and
added about 80 lines.  This means my original estimate of 99% was high, it's
only 96 2/3%.





