home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 15 / CD_ASCQ_15_070894.iso / vrac / borlan32.zip / 32BIT.TXT next >
Text File  |  1994-05-09  |  5KB  |  141 lines

  1. Why can't I use Borland C++ 4.0 in 32 bit DOS protected mode?  Well 
  2. with these few steps now you can!!
  3.  
  4. You will need to have access to the following  files, these are all contained 
  5. on the CD version of Borland C++ 4.0
  6.     
  7.     bc4rtl\crtl386\win32\clib\errormsg.c
  8.     bc4\bin\32rtm.exe
  9.     bc4\bin\32dpmivm.ovl
  10.     bc4\bin\bcc32.exe
  11.     bc4\bin\tlink32.exe
  12.     bc4\bin\tlib.exe
  13.     bc4\lib\cw32.lib
  14.  
  15. Borland C++ 4.0 is shipped with a DOS extender that can run 32 bit DOS 
  16. protected mode programs by following these steps. The program fixup.exe 
  17. is a 16 bit real mode program that automates steps 1 and 2 for you.  
  18.  
  19. 1 There is a stub program that is normally put at the beginning of all 
  20. window files and it just comes back with the error message "This program 
  21. will not run in DOS.".  The programs bcc32.exe, tlink32.exe and tlib.exe 
  22. and others have a different stub on them that call 32rtm.exe to run them in 
  23. DOS protected mode.  First we need to extract this stub program.  
  24.  
  25. 2.  After compiling with this new stub program, I kept getting the error 
  26. message "program will not run under DOS" from 32rtm.exe.  Well I looked 
  27. and looked but couldn't find out what the program needed.  So I finally 
  28. found in 32rtm.exe that Borland had put some sort of checksum block 
  29. somewhere in the file.  I couldn't for the life of me figure out where they 
  30. had put it.  So I ended up patching the 32rtm.exe file to not expect this 
  31. "magic block"
  32.  
  33. 3.  I ran into a couple of errors trying to run the program that I tracked 
  34. down to the errormsg.c file.  This program was a little hard to try and 
  35. recompile. Get the ntbc.h file from the bc4rtl\crtl386\win32\rtlinc directory. 
  36. You will also need the file dosexcptn.h from the bc4rtl\rtlapi directory.  
  37. You should place all these files in the same directory, since I didn't want to 
  38. add that many path names to the includes directory for bcc32.exe.  Since 
  39. this piece of code is Copyright by Borland I will describe where to delete, 
  40. since I can't actually include any of there code. Now starting with the line:
  41.  
  42. extern unsigned char __isGUI
  43. remove all lines to the comment header that describes _ErrorMessage
  44. <------- delete to here -------->
  45. /*--------------------------------------------------------------------------------
  46. Name:        _ErrorMessage
  47.  
  48. Also delete the statements that are included in the if statement
  49.  
  50. <delete all this>    if (__isGUI)
  51. <delete all this>        {
  52. <delete all this>        ...
  53. <delete all this>        ...
  54. <delete all this>        } else
  55. <delete all this>        {
  56. <KEEP THIS PART>...
  57. <KEEP THIS PART>...
  58. <delete all this>        }
  59.  
  60.  
  61. Now compile the program with the following:
  62.     bcc32 /v /c -I. errormsg.c
  63.  
  64. make sure you have configured the bcc32.cfg file to specify the correct 
  65. paths to the
  66. Borland C++ include directory and Lib directory.
  67.  
  68. Now we have to replace it in the library :
  69.     first make a copy of the library
  70.     copy bc4\lib\cw32.lib <destination> where destination is a working 
  71. directory.
  72.     tlib cw32.lib +- errormsg.obj
  73.  
  74.  
  75. 4.  Compile the program as a 32 bit Windows console application.  
  76.     Required parameters are /Tpe = create protected mode 32 bit exe 
  77. file
  78.                   /ap = create win32 console application
  79.  
  80.     You will need to link with the startup file c0x32.obj and the 
  81. libraries cw32.lib & 
  82.     import32.lib.
  83.  
  84. The module definition file should look similar to the following
  85.  
  86. NAME         test32 WINDOWCOMPAT
  87.  
  88. DESCRIPTION 'Test 32 bit program'
  89.  
  90. STUB     'STUB32.EXE'
  91.  
  92. IMPORTS    
  93.     ntdll.RtlUnwind
  94.  
  95. CODE         PRELOAD EXECUTEREAD
  96. DATA         PRELOAD READWRITE
  97.  
  98. EXETYPE      WINDOWS
  99.  
  100. HEAPSIZE     128
  101. STACKSIZE    8192
  102.  
  103.  
  104.  
  105. Voila' the program ran in 32 bit protected mode.
  106.  
  107. That's all there is to it. :-}
  108.  
  109. There are functions that are not supported by the 32 bit run time manager.  
  110. If you get an error saying that XXXXX is not supported in the DLL then 
  111. the routine you use probably won't work.  You'll have to experiment to find 
  112. out which ones will.  If you want to debug these programs.  My guess is 
  113. you'll have to do it with windows NT and td32.exe since it won't run under 
  114. DOS.  I haven't tested this yet so I don't know if this will work.
  115.  
  116. SoapBox:
  117.     I am really baffled that Borland didn't actually try to make Borland 
  118. C++ version 4.0 capable of  making 32 bit DOS protected mode programs.  
  119. They have included all the right tools for the job, but then go and cripple it 
  120. so nobody can use it.  I am a game programmer and really have liked 
  121. Borland C since it came out, before that I was a Borland Pascal user.  As a 
  122. game programmer, we cannot afford the overhead of windows or any other 
  123. GUI based product.  These hacks could have been easily implemented by 
  124. Borland for all of us to enjoy 32 bit DOS protected mode programming.  
  125. Most of the programmers that I know in my industry have started using 32 
  126. bit DOS protected mode,  Of course they have mostly switched to 
  127. WatComm C++ for their development tools.  This really pains me, since 
  128. Turbo Debugger is the best debugger, that has ever been invented.  Maybe 
  129. Borland will find it in their heart to release a version for 32 bit DOS 
  130. Protect mode that would include td32.exe as a DOS program and not a 
  131. Windows NT program.  Well anyway my times over and I'm getting kicked 
  132. off my Soap box.
  133.  
  134.  
  135.                     Sincerely,
  136.  
  137.                     Kenneth L. Hurley
  138.                     Internet:  kenh@futurescape.com
  139.                     CIS ID: 71334,1613
  140.  
  141.