diff -urpb idados-master.orig/Makefile.mingw idados-master/Makefile.mingw
--- idados-master.orig/Makefile.mingw	2013-04-22 12:56:12 +0400
+++ idados-master/Makefile.mingw	2013-05-02 00:10:08 +0400
@@ -1,8 +1,8 @@
-IDA=/home/efry/idasdk57
 IDA_DEBUG=$(IDA)/plugins/debugger
 CC=g++
-CFLAGS=-D__NT__ -D__IDP__ -I$(IDA)/include -I$(IDA_DEBUG) -DNO_OBSOLETE_FUNCS -D__IDP__ -D__PLUGIN__ -mrtd -mno-cygwin
-LFLAGS=$(IDA)/lib/gcc.w32/ida.a -Wl,--dll -shared -lwsock32 -lws2_32 
+CFLAGS=-D_WIN32 -DWIN32 -D__NT__ -D__IDP__ -DNO_OBSOLETE_FUNCS -D__EXPR_SRC -D__PLUGIN__ -I$(IDA)/include -I$(IDA_DEBUG)
+LIBS=$(IDA)/lib/x86_win_gcc_32/ida.a -shared -lwsock32 -lws2_32
+LFLAGS=-static -Wl,--dll
 
 all: dosbox_stub.plw
 
@@ -17,10 +17,10 @@ rpc_debmod.cpp:
 debmod.cpp:
 
 rebase_msdos.plw: rebase.cpp
-	$(CC) $(CFLAGS) -o $@ rebase.cpp $(IDA)/lib/gcc.w32/ida.a -Wl,--dll -shared
+	$(CC) $(CFLAGS) $(LFLAGS) -o $@ rebase.cpp $(LIBS)
 
 dosbox_stub.plw: dosbox_rstub.o tcpip.o rpc_debmod_dosbox.o rpc_hlp.o rpc_engine.o util.o rpc_client.o rpc_debmod.o debmod.o
-	$(CC) $(CFLAGS) -o $@ dosbox_rstub.o tcpip.o rpc_debmod_dosbox.o rpc_hlp.o rpc_engine.o util.o rpc_client.o rpc_debmod.o debmod.o $(LFLAGS)
+	$(CC) $(CFLAGS) $(LFLAGS) -o $@ dosbox_rstub.o tcpip.o rpc_debmod_dosbox.o rpc_hlp.o rpc_engine.o util.o rpc_client.o rpc_debmod.o debmod.o $(LIBS)
 
 dosbox_rstub.o: dosbox_rstub.cpp dosbox_local_impl.cpp
 	$(CC) -c $(CFLAGS) -o $@ dosbox_rstub.cpp
diff -urpb idados-master.orig/dosbox_debmod.cpp idados-master/dosbox_debmod.cpp
--- idados-master.orig/dosbox_debmod.cpp	2013-04-22 12:56:12 +0400
+++ idados-master/dosbox_debmod.cpp	2013-05-05 21:32:05 +0400
@@ -1,6 +1,9 @@
 /*
 
 */
+#ifdef _WIN32
+#include <windows.h>
+#endif
 #include <ida.hpp>
 #include <err.h>
 #include <idp.hpp>
@@ -24,6 +27,7 @@ bool DEBUG_AddMemBreakPoint(Bit32u addre
 bool DEBUG_DelBreakPoint(PhysPt address);
 int DEBUG_Continue(void);
 Bits DEBUG_RemoteStep(void);
+bool DEBUG_ParseCommand(char* str);
 
 //server.cpp
 void idados_running();
@@ -216,7 +220,7 @@ int idaapi dosbox_debmod_t::dbg_start_pr
   app_base = find_app_base();
   printf("app_base = %x\n", app_base);
   stack = SegValue(ss);
-printf("name %s \n",path);
+  printf("name %s \n",path);
   create_process_start_event(path);
   return 1;
 }
@@ -239,6 +243,9 @@ void dosbox_debmod_t::create_process_sta
   ev.modinfo.base = app_base + 0x100; //base + PSP //entry_point; //pi.codeaddr;
   ev.modinfo.size = 0;
   ev.modinfo.rebase_to = app_base + 0x100; //base + PSP //entry_point;
+//  ev.modinfo.base = app_base;
+//  ev.modinfo.size = 0;
+//  ev.modinfo.rebase_to = app_base;
   events.enqueue(ev, IN_BACK);
 }
 
@@ -829,14 +836,16 @@ int idaapi dosbox_debmod_t::dbg_get_memo
    miv->perm = 0 | SEGPERM_READ | SEGPERM_WRITE | SEGPERM_EXEC;
    miv++;
 */
-
-static bool first_run = true;
-
-if(!first_run)
+   static bool first_run = true;
+   if (!first_run)
   return -2;
 
    // Read from PSP
    int last_user_seg = mem_readw(GetAddress(app_base>>4, 0x2));
+//   ea_t psp;
+//   if (app_base == 0x100) psp = 0x100;
+//   else psp = (ea_t) GetAddress(SegValue(ds),0);
+//   int last_user_seg = mem_readw(GetAddress(psp>>4, 0x2));
    printf("last user seg = %d\n", last_user_seg);
 
    memory_info_t *mi = &miv.push_back();
@@ -871,15 +880,18 @@ printf("mi = %x,%x\n",mi->startEA, mi->e
    mi = &miv.push_back();
    mi->startEA = app_base;
    mi->endEA = app_base + 0x100;
+//   mi->startEA = psp;
+//   mi->endEA = psp + 0x100;
    mi->endEA--;
    mi->name = "PSP";
    mi->bitness = 0;
    mi->perm = 0 | SEGPERM_READ;
    mi->sbase = app_base>>4;
+//   mi->sbase = psp>>4;
 printf("mi = %x,%x\n",mi->startEA, mi->endEA);
 
    mi = &miv.push_back();
-   mi->startEA = app_base + 0x200;
+   mi->startEA = app_base + 0x100;
    mi->endEA = (ea_t)GetAddress(last_user_seg, 0x10);
    mi->endEA--;
    mi->name = ".text"; // Not the best name; it also covers data/stack/...
@@ -984,6 +996,7 @@ ssize_t idaapi dosbox_debmod_t::dbg_writ
   for(int i=0;i<size;i++)
     mem_writeb(ea + i, ((Bit8u *)buffer)[i]);
 
+  printf("dbg_write_memory @ %x, size=%d\n", ea, size);
   return size;
 }
 
@@ -1090,6 +1103,24 @@ int idaapi dosbox_debmod_t::dbg_is_ok_bp
 }
 
 //--------------------------------------------------------------------------
+int idaapi dosbox_debmod_t::handle_ioctl(
+      int fn,
+      const void *buf,
+      size_t size,
+      void **poutbuf,
+      ssize_t *poutsize)
+{
+  qnotused(size);
+  qnotused(poutbuf);
+  qnotused(poutsize);
+
+  printf("handle_ioctl: '%s'\n", buf);
+  DEBUG_ParseCommand((char *)buf);
+
+  return 0;
+}
+
+//--------------------------------------------------------------------------
 debmod_t *create_debug_session()
 {
   return new dosbox_debmod_t();
@@ -1142,7 +1173,6 @@ bool dosbox_debmod_t::hit_breakpoint(Phy
   return 1;
 }
 
-
 inline ea_t find_app_base()
 {
   ea_t base = (ea_t)GetAddress(SegValue(cs), 0);
@@ -1160,5 +1190,3 @@ inline ea_t find_app_base()
 
  return base;
 }
-
-
diff -urpb idados-master.orig/dosbox_debmod.h idados-master/dosbox_debmod.h
--- idados-master.orig/dosbox_debmod.h	2013-04-22 12:56:12 +0400
+++ idados-master/dosbox_debmod.h	2013-05-02 00:43:16 +0400
@@ -123,6 +123,7 @@ public:
   virtual bool refresh_hwbpts(void);
   virtual HANDLE get_thread_handle(thid_t tid);
   virtual int idaapi dbg_is_ok_bpt(bpttype_t type, ea_t ea, int len);
+  virtual int  idaapi handle_ioctl(int fn, const void *buf, size_t size, void **outbuf, ssize_t *outsize);
 
   bool idaapi close_remote(void);
   bool idaapi open_remote(const char * /*hostname*/, int port_number, const char * /*password*/);
diff -urpb idados-master.orig/dosbox_local_impl.cpp idados-master/dosbox_local_impl.cpp
--- idados-master.orig/dosbox_local_impl.cpp	2013-04-22 12:56:12 +0400
+++ idados-master/dosbox_local_impl.cpp	2013-05-02 22:22:59 +0400
@@ -1,12 +1,60 @@
+#ifdef _WIN32
+#include <windows.h>
+#endif
 #include <segment.hpp>
 #include <srarea.hpp>
+#include <expr.hpp>
+
+//--------------------------------------------------------------------------
+// IDC function name that is exported by a debugger module
+// to allow scripts to send debugger commands
+#define IDC_SENDDBG_CMD "SendDbgCommand"
+
+static const char idc_dosbox_cmd_args[] = { VT_STR, 0 };
+static error_t idaapi idc_dosbox_cmd(idc_value_t *argv, idc_value_t *res)
+{
+  msg("SendDbgCommand: '%s'\n", argv[0].str);
+#ifdef RPC_CLIENT
+  void *out = NULL;
+  ssize_t outsize;
+  g_dbgmod.send_ioctl(0, argv[0].str, strlen(argv[0].str) + 1, &out, &outsize);
+#endif
+/*
+  uint64 value = 0; // shut up the compiler
+  uval_t reg = argv[0].num;
+#ifdef RPC_CLIENT
+  void *out = NULL;
+  ssize_t outsize;
+  int code = g_dbgmod.send_ioctl(WIN32_IOCTL_RDMSR, &reg, sizeof(reg), &out, &outsize);
+  if ( SUCCEEDED(code) && outsize == sizeof(value) )
+    value = *(uint64*)out;
+  qfree(out);
+#else
+  int code = g_dbgmod.rdmsr(reg, &value);
+#endif
+  if ( FAILED(code) )
+  {
+    res->num = code;
+    return set_qerrno(eExecThrow); // read error, raise exception
+  }
+  res->set_int64(value);
+*/  
+  return eOk;
+}
 
 //--------------------------------------------------------------------------
 // installs or uninstalls debugger specific idc functions
-inline bool register_idc_funcs(bool)
+inline bool register_idc_funcs(bool reg)
 {
+  static const extfun_t funcs[] =
+  {
+    { IDC_SENDDBG_CMD,    idc_dosbox_cmd,     idc_dosbox_cmd_args     },
+  };
+  for ( int i=0; i < qnumber(funcs); i++ )
+    if ( !set_idc_func_ex(funcs[i].name, reg ? funcs[i].fp : NULL, funcs[i].args, 0) )
+      return false;
   return true;
-  }
+}
 
 //--------------------------------------------------------------------------
 void idaapi rebase_if_required_to(ea_t new_base)
@@ -54,7 +102,7 @@ static bool init_plugin(void)
     return debugger.is_remote();
   }
 
-  if ( inf.filetype != f_EXE && inf.filetype != f_COM )
+  if ( inf.filetype != f_EXE && inf.filetype != f_COM && inf.filetype != f_LE )
     return false; // only MSDOS EXE or COM files
   if ( ph.id != PLFM_386 )
     return false; // only IBM PC
diff -urpb idados-master.orig/dosbox_rstub.cpp idados-master/dosbox_rstub.cpp
--- idados-master.orig/dosbox_rstub.cpp	2013-04-22 12:56:12 +0400
+++ idados-master/dosbox_rstub.cpp	2013-05-01 19:48:17 +0400
@@ -10,6 +10,9 @@ char wanted_name[] = "Remote Dosbox debu
 //#define HAVE_APPCALL
 
 //////
+#ifdef _WIN32
+#include <windows.h>
+#endif
 #include "tcpip.h"
 #include <ua.hpp>
 #include <area.hpp>
diff -urpb idados-master.orig/makefile.unx idados-master/makefile.unx
--- idados-master.orig/makefile.unx	2013-04-22 12:56:12 +0400
+++ idados-master/makefile.unx	2013-05-02 23:07:45 +0400
@@ -24,7 +24,7 @@ CFLAGS+=-m32
 CCL+=-m32
 endif
 
-CFLAGS+=-D__IDP__ -D__PLUGIN__
+CFLAGS+=-D__IDP__ -D__PLUGIN__ -D__EXPR_SRC
 
 OBJ1=$(F)$(O1)$(O)
 OBJ2=$(IDA)/plugins/debugger/$(OBJDIR)/$(O2)$(O)
diff -urpb idados-master.orig/rebase.cpp idados-master/rebase.cpp
--- idados-master.orig/rebase.cpp	2013-04-22 12:56:12 +0400
+++ idados-master/rebase.cpp	2013-05-01 19:48:18 +0400
@@ -5,6 +5,9 @@
  *
  */
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
 #include <ida.hpp>
 #include <idp.hpp>
 #include <bytes.hpp>
diff -urpb idados-master.orig/rpc_debmod_dosbox.cpp idados-master/rpc_debmod_dosbox.cpp
--- idados-master.orig/rpc_debmod_dosbox.cpp	2013-04-22 12:56:12 +0400
+++ idados-master/rpc_debmod_dosbox.cpp	2013-05-01 19:48:18 +0400
@@ -1,7 +1,8 @@
+#ifdef _WIN32
+#include <windows.h>
+#endif
 #include "typeinf.hpp"
-
 #include "deb_pc.hpp"
-
 #include "rpc_debmod_dosbox.h"
 
 static const char *get_reg_name(int reg_idx);
