Release 950319

Sun Mar 19 16:30:20 1995  Alexandre Julliard  (julliard@sunsite.unc.edu)

	* [*/*]
	Implemented a new memory mapping scheme. There's no longer a
	one-to-one mapping between 16-bit and 32-bit pointers. Please see
	file DEVELOPERS-HINTS for technical details.

	* [controls/scroll.c]
	Fixed bug when dragging mouse in horizontal scrollbars.

	* [tools/build.c] [if1632/*.spec]
	Removed support for C callback functions and for re-ordering
	of the 32-bit arguments, as these were never used. This should
	allow a more efficient callback scheme to be implemented.

	* [if1632/olecli.spec]
	Reduced the number of entries to make the 16-bit code fit in 64k.
	This limitation will soon be removed.

	* [loader/ldt.c]
	Rewrote LDT manipulation functions and implemented LDT_GetEntry().

	* [memory/global.c]
	Rewrote Global*() routines to use the new selector allocation
	mechanism.

	* [memory/local.c]
	Rewrote local heap handling to use a Windows-compatible layout
	(not really finished yet).
	Implemented TOOLHELP heap-walking routines.

	* [memory/selector.c]
	Implemented LDT manipulation API functions.

Tue Mar 14 19:50:28 EST 1995 William Magro (wmagro@tc.cornell.edu)

	* [windows/defdlg.c]
	Fixed problem where dialogs closed using the System menu 
        ('Close' item or double click on close box) would
	hang Wine.

Sun Mar 12 14:28:13 1995  Michael Patra <micky@marie.physik.TU-Berlin.DE>

	* [controls/listbox.c]
	Removed most of the statements for sending a notification message
	ListBoxDirectory(), DlgDirSelect(), DlgDirList(): Improved the
	code; Borland's standard file open dialog will work now.
	
	* [misc/main.c], [misc/file.c], [miscemu/int21.c]
	Added support for new command line option "-allowreadonly". If set
	an attempt to open a read only file in write mode will be converted 
	to opening it read only (many programs try to open all files in 
	read/write mode even if they only intend to read it - this might 
	cause a few under problems under an unix-like environment where most 
	files are read only for a "normal" user)

	* [loader/selector.c]
	GetMemoryReference(): Added support for __AHIncr and __AHShift

	* [misc/dos_fs.c]
	DOS_SimplifyPath(): This routine simplifies path names ( e.g., it
	will change "/usr///local/bin/../lib//a" to "/usr/local/lib/a" )
	match(): rewritten
	
	* [objects/text.c]
	TEXT_NextLine(): Removed a bug in the handling of LF's

	* [miscemu/int21.c]
	GetFileDateTime(): Fixed. SetFileDateTime() is still broken.

Sat Mar 11 19:46:19 1995  Martin von Loewis  <loewis@informatik.hu-berlin.de>

	* [controls/menu.c]
	ChangeMenu: defaults to MF_INSERT
	InsertMenu: allow insertion even if position is one after last item

	* [if1632/Imakefile] [if1632/compobj.spec] [if1632/relay.c]
	  [if1632/storage.spec] [include/dlls.h]
	Added stubs for STORAGE.DLL and COMPOBJ.DLL

	* [if1632/user.spec] [windows/message.c]
	InSendMessage: new function

	* [include/neexe.h][include/ne_image.c]
	NE_FixupSegment: fixed handling of additive records

	* [loader/selector.c]
	GetEntryDLLName: return NULL instead of pointer to DLL.0 if not found

	* [loader/signal.c]
	win_fault: Enter debugger on SIGFPE, too

Wed Mar  1 21:47:42 1995  Cameron Heide  (heide@ee.ualberta.ca)

        * [miscemu/int*.c]
        Various minor modifications to the clock tick counter,
        FindFirst/FindNext funcs, and DPB handling.
diff --git a/debugger/break.c b/debugger/break.c
index 2c276da..b3945ee 100644
--- a/debugger/break.c
+++ b/debugger/break.c
@@ -6,6 +6,7 @@
 #include <sys/utsname.h>
 #endif
 #include <windows.h>
+#include "db_disasm.h"
 
 #define N_BP 25
 
@@ -140,7 +141,7 @@
    unsigned int addr;
    addr=wbp[num].addr;
    if(wbp[num].next_addr == 0)
-	wbp[num].next_addr=addr+print_insn(addr,addr,stderr,dbg_mode);
+	wbp[num].next_addr = db_disasm( addr, 0, (dbg_mode == 16) );
    wbp[num].addr=wbp[num].next_addr;
    wbp[num].next_addr=addr;
 }
diff --git a/debugger/db_disasm.c b/debugger/db_disasm.c
index 5cb26fd..568a933 100644
--- a/debugger/db_disasm.c
+++ b/debugger/db_disasm.c
@@ -72,6 +72,7 @@
 #endif
 #include <stdio.h>
 #include "db_disasm.h"
+#include "ldt.h"
 
 /*
  * Switch to disassemble 16-bit code.
@@ -888,9 +889,10 @@
 	10,	/* EXTR */
 };
 
-unsigned int db_get_task_value(unsigned int loc, int size, int is_signed)
+static unsigned int db_get_task_value(unsigned int loc, int size, int is_signed)
 {
   unsigned int result;
+  if (db_disasm_16) loc = (unsigned int)PTR_SEG_TO_LIN(loc);
   switch(size)
     {
     case 4:
@@ -921,7 +923,8 @@
 
 #define	get_value_inc(result, loc, size, is_signed) \
 	result = db_get_task_value((loc), (size), (is_signed)); \
-	(loc) += (size);
+        if (!db_disasm_16) (loc) += (size); \
+        else (loc) = ((loc) & 0xffff0000) | (((loc) + (size)) & 0xffff);
 
 /*
  * Read address at location and return updated location.
@@ -1011,6 +1014,23 @@
 	return (loc);
 }
 
+static void db_task_printsym(unsigned int addr, int size)
+{
+    extern void print_address(unsigned int addr, FILE * outfile, int addrlen);
+    switch(size)
+    {
+    case BYTE:
+        fprintf(stderr, "0x%2.2x", addr & 0xff );
+        break;
+    case WORD:
+        fprintf(stderr, "0x%4.4x", addr & 0xffff );
+        break;
+    case LONG:
+        print_address(addr, stderr, db_disasm_16 ? 16 : 32);
+        break;
+    }
+}
+
 void
 db_print_address(seg, size, addrp)
 	char *		seg;
@@ -1035,7 +1055,7 @@
 		fprintf(stderr,",%s,%d", addrp->index, 1<<addrp->ss);
 	    fprintf(stderr,")");
 	} else
-	    db_task_printsym((db_addr_t)addrp->disp);
+	    db_task_printsym((db_addr_t)addrp->disp, size);
 }
 
 /*
@@ -1418,7 +1438,8 @@
 		    if (seg)
 			fprintf(stderr,"%s:%d",seg, displ);
 		    else
-			db_task_printsym((db_addr_t)displ);
+			db_task_printsym((db_addr_t)displ,
+                                         short_addr ? WORD : LONG);
 		    break;
 
 		case Db:
@@ -1430,7 +1451,8 @@
 		    }
 		    else
 			displ = displ + loc;
-		    db_task_printsym((db_addr_t)displ);
+		    db_task_printsym((db_addr_t)displ,
+                                     short_addr ? WORD : LONG);
 		    break;
 
 		case Dl:
@@ -1444,7 +1466,8 @@
 			get_value_inc(displ, loc, 4, TRUE);
 			displ = displ + loc;
 		    }
-		    db_task_printsym((db_addr_t)displ);
+		    db_task_printsym((db_addr_t)displ,
+                                     short_addr ? WORD : LONG);
 		    break;
 
 		case o1:
diff --git a/debugger/dbg.y b/debugger/dbg.y
index d1992f6..54d5992 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -10,6 +10,7 @@
 
 #include <stdio.h>
 #include <signal.h>
+#include "ldt.h"
 
 #define YYSTYPE int
 
@@ -116,8 +117,8 @@
 	
  infocmd: INFO REGS     { info_reg(); }
 	| INFO STACK    { info_stack(); }
+	| INFO SEGMENTS { LDT_Print(); }
 	| INFO BREAK    { info_break(); }
-	| INFO SEGMENTS { print_ldt(); }
 
 
 %%
@@ -197,7 +198,7 @@
 	    int bpnum;
 	    addr = SC_EIP(dbg_mask);
 	    if((addr & 0xffff0000) == 0 && dbg_mode == 16)
-	      addr |= SC_CS << 16;
+	      addr = PTR_SEG_OFF_TO_LIN( SC_CS, addr );
 	    if(should_continue(bpnum=get_bpnum(addr))){
 		insert_break(1);
 		return;
diff --git a/debugger/hash.c b/debugger/hash.c
index cba6ce2..1bce11a 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -10,7 +10,6 @@
 #include <string.h>
 #include <sys/types.h>
 #include <neexe.h>
-#include <segmem.h>
 #include "selectors.h"
 #include <wine.h>
 #include <dlls.h>
@@ -168,7 +167,7 @@
 			j = GetEntryPointFromOrdinal(wpnt, ordinal);		
 			address  = j & 0xffff;
 			j = j >> 16;
-			address |= (wpnt->ne->selector_table[j].selector) << 16;
+			address |= wpnt->ne->selector_table[j] << 16;
 			fprintf(stderr,"%s -> %x\n", buffer, address);
 			add_hash(buffer, (unsigned int *) address);
 			cpnt += len + 2;
diff --git a/debugger/info.c b/debugger/info.c
index 3f640da..9506240 100644
--- a/debugger/info.c
+++ b/debugger/info.c
@@ -6,6 +6,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "ldt.h"
 #include "db_disasm.h"
 #include "regpos.h"
 
@@ -18,60 +19,24 @@
   fprintf(stderr,"Application not running\n");
 }
 
-void print_address(unsigned int addr, FILE * outfile){
-	char * name;
-	extern char * find_nearest_symbol(unsigned int *);
+void print_address(unsigned int addr, FILE * outfile, int addrlen)
+{
+    if (addrlen == 16)
+    {
+        fprintf( outfile, "%4.4x:%4.4x", addr >> 16, addr & 0xffff );
+    }
+    else
+    {
+        extern char * find_nearest_symbol(unsigned int *);
 
-	name = find_nearest_symbol((unsigned int *) addr);
+        char * name = find_nearest_symbol((unsigned int *) addr);
 	if(name)
 		fprintf(outfile,"0x%8.8x(%s)", addr, name);
 	else
 		fprintf(outfile,"0x%8.8x", addr);
-
+    }
 }
 
-#ifdef GNU_DISASM
-void print_address_info(bfd_vma addr, disassemble_info * info){
-	print_address((unsigned int) addr, info->stream);
-}
-
-int print_insn(char *realmemaddr, char *memaddr, FILE *stream, int addrlen){
-	static disassemble_info info;
-	static int initialized = 0;
-
-	if (!initialized) {
-		INIT_DISASSEMBLE_INFO(info, stderr);
-		info.print_address_func = print_address_info;
-		initialized = 1;
-	}
-	info.stream = stream;
-	info.buffer = memaddr;
-	info.buffer_vma = (bfd_vma) realmemaddr;
-	info.buffer_length = 1024;
-	if (addrlen == 16)
-		return print_insn_i286((bfd_vma) realmemaddr, &info);
-	if (addrlen == 32)
-		return print_insn_i386((bfd_vma) realmemaddr, &info);
-	fprintf(stderr, "invalid address length %d.\n", addrlen);
-	return 0;
-}
-#else
-void db_task_printsym(unsigned int addr){
-  print_address(addr, stderr);
-}
-
-int print_insn(char *realmemaddr, char *memaddr, FILE *stream, int addrlen)
-{
-	if (addrlen == 16)
-		return db_disasm((unsigned int) realmemaddr, 0, 1) - 
-			((unsigned int) realmemaddr);
-	if (addrlen == 32)
-	    return db_disasm((unsigned int) realmemaddr, 0, 0) -
-	      ((unsigned int) realmemaddr);
-	fprintf(stderr, "invalid address length %d.\n", addrlen);
-	return 0;
-}
-#endif
 
 void info_reg(){
 
@@ -128,18 +93,17 @@
 	int i;
 
 	if((addr & 0xffff0000) == 0 && dbg_mode == 16)
-	        addr |= (format == 'i' ? SC_CS : SC_DS) << 16;
-
+            addr |= (format == 'i' ? SC_CS : SC_DS) << 16;
 
 	if(format != 'i' && count > 1) {
-		print_address(addr, stderr);
+		print_address(addr, stderr, dbg_mode);
 		fprintf(stderr,":  ");
 	};
 
-
 	switch(format){
 	case 's':
-		pnt = (char *) addr;
+		pnt = dbg_mode == 16 ? (char *)PTR_SEG_TO_LIN(addr)
+                                     : (char *)addr;
 		if (count == 1) count = 256;
 	        while(*pnt && count) {
 			fputc( *pnt++, stderr);
@@ -150,20 +114,22 @@
 
 	case 'i':
 		for(i=0; i<count; i++) {
-			print_address(addr, stderr);
+			print_address(addr, stderr, dbg_mode);
 			fprintf(stderr,":  ");
-			addr += print_insn((char *) addr, (char *) addr, stderr, dbg_mode);
+			addr = db_disasm( addr, 0, (dbg_mode == 16) );
 			fprintf(stderr,"\n");
 		};
 		return;
 	case 'x':
-		dump = (unsigned int *) addr;
+		dump = dbg_mode == 16 ? (unsigned int *)PTR_SEG_TO_LIN(addr)
+                                      : (unsigned int *)addr;
 		for(i=0; i<count; i++) 
 		{
 			fprintf(stderr," %8.8x", *dump++);
+                        addr += 4;
 			if ((i % 8) == 7) {
 				fprintf(stderr,"\n");
-				print_address((unsigned int) dump, stderr);
+				print_address(addr, stderr, dbg_mode);
 				fprintf(stderr,":  ");
 			};
 		}
@@ -171,13 +137,15 @@
 		return;
 	
 	case 'd':
-		dump = (unsigned int *) addr;
+		dump = dbg_mode == 16 ? (unsigned int *)PTR_SEG_TO_LIN(addr)
+                                      : (unsigned int *)addr;
 		for(i=0; i<count; i++) 
 		{
 			fprintf(stderr," %d", *dump++);
+                        addr += 4;
 			if ((i % 8) == 7) {
 				fprintf(stderr,"\n");
-				print_address((unsigned int) dump, stderr);
+				print_address(addr, stderr, dbg_mode);
 				fprintf(stderr,":  ");
 			};
 		}
@@ -185,13 +153,15 @@
 		return;
 	
 	case 'w':
-		wdump = (unsigned short int *) addr;
+		wdump = dbg_mode == 16 ? (unsigned short *)PTR_SEG_TO_LIN(addr)
+                                       : (unsigned short *)addr;
 		for(i=0; i<count; i++) 
 		{
 			fprintf(stderr," %x", *wdump++);
+                        addr += 2;
 			if ((i % 10) == 7) {
 				fprintf(stderr,"\n");
-				print_address((unsigned int) wdump, stderr);
+				print_address(addr, stderr, dbg_mode);
 				fprintf(stderr,":  ");
 			};
 		}
@@ -199,7 +169,8 @@
 		return;
 	
 	case 'c':
-		pnt = (char *) addr;
+		pnt = dbg_mode == 16 ? (char *)PTR_SEG_TO_LIN(addr)
+                                     : (char *)addr;
 		for(i=0; i<count; i++) 
 		{
 			if(*pnt < 0x20) {
@@ -207,9 +178,10 @@
 				pnt++;
 			} else
 				fprintf(stderr," %c", *pnt++);
+                        addr++;
 			if ((i % 32) == 7) {
 				fprintf(stderr,"\n");
-				print_address((unsigned int) pnt, stderr);
+				print_address(addr, stderr, dbg_mode);
 				fprintf(stderr,":  ");
 			};
 		}
@@ -217,13 +189,15 @@
 		return;
 	
 	case 'b':
-		pnt = (char *) addr;
+		pnt = dbg_mode == 16 ? (char *)PTR_SEG_TO_LIN(addr)
+                                     : (char *)addr;
 		for(i=0; i<count; i++) 
 		{
 			fprintf(stderr," %02x", (*pnt++) & 0xff);
+                        addr++;
 			if ((i % 32) == 7) {
 				fprintf(stderr,"\n");
-				print_address((unsigned int) pnt, stderr);
+				print_address(addr, stderr, dbg_mode);
 				fprintf(stderr,":  ");
 			};
 		}
@@ -293,26 +267,32 @@
     return;
   }
 
-  frame = (struct frame *) ((SC_EBP(dbg_mask) & ~1) | (SC_SS << 16));
+  if (dbg_mode == 16)
+      frame = (struct frame *)PTR_SEG_OFF_TO_LIN( SC_SS, SC_BP & ~1 );
+  else
+      frame = (struct frame *)SC_EBP(dbg_mask);
 
   fprintf(stderr,"Backtrace:\n");
-  fprintf(stderr,"%d ",frameno);
-  print_address(frame->u.win32.saved_ip,stderr);
   cs = SC_CS;
   while((cs & 3) == 3) {
     /* See if in 32 bit mode or not.  Assume GDT means 32 bit. */
     if ((cs & 7) != 7) {
       void CallTo32();
-      fprintf(stderr,"\n%d ",frameno++);
-      print_address(frame->u.win32.saved_ip,stderr);
+      fprintf(stderr,"%d ",frameno++);
+      print_address(frame->u.win32.saved_ip,stderr,32);
+      fprintf( stderr, "\n" );
       if(frame->u.win32.saved_ip<((unsigned long)CallTo32+1000))break;
       frame = (struct frame *) frame->u.win32.saved_bp;
     } else {
-      cs = frame->u.win16.saved_cs;
+      if (frame->u.win16.saved_bp & 1) cs = frame->u.win16.saved_cs;
       fprintf(stderr,"%d %4.4x:%4.4x\n", frameno++, cs, 
 	      frame->u.win16.saved_ip);
-      frame = (struct frame *) ((frame->u.win16.saved_bp & ~1) |
-				(SC_SS << 16));
+      frame = (struct frame *) PTR_SEG_OFF_TO_LIN( SC_SS, frame->u.win16.saved_bp & ~1);
+      if ((cs & 7) != 7)  /* switching to 32-bit mode */
+      {
+          extern int IF1632_Saved32_ebp;
+          frame = (struct frame *)IF1632_Saved32_ebp;
+      }
     }
   }
   putchar('\n');
diff --git a/debugger/regpos.h b/debugger/regpos.h
index 01d2e00..39d4b5e 100644
--- a/debugger/regpos.h
+++ b/debugger/regpos.h
@@ -64,6 +64,14 @@
 #define  SC_EDX(dbg_mask)	(regval[RN_EDX] & dbg_mask)
 #define  SC_ECX(dbg_mask)	(regval[RN_ECX] & dbg_mask)
 #define  SC_EAX(dbg_mask)	(regval[RN_EAX] & dbg_mask)
+#define  SC_DI                  (regval[RN_EDI] & 0xffff)
+#define  SC_SI                  (regval[RN_ESI] & 0xffff)
+#define  SC_BP                  (regval[RN_EBP] & 0xffff)
+#define  SC_SP                  (regval[RN_ESP] & 0xffff)
+#define  SC_BX                  (regval[RN_EBX] & 0xffff)
+#define  SC_DX                  (regval[RN_EDX] & 0xffff)
+#define  SC_CX                  (regval[RN_ECX] & 0xffff)
+#define  SC_AX                  (regval[RN_EAX] & 0xffff)
 #define  SC_TRAPNO		regval[RN_TRAPNO]
 #define  SC_ERR			regval[RN_ERR]
 #define  SC_EIP(dbg_mask)	(regval[RN_EIP] & dbg_mask)