1 /*
   2  * Copyright 2000-2001 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 #ifndef _MESSAGE_
  26 #define _MESSAGE_
  27 
  28 // These are the commands sent from the server to the child processes
  29 // over the child processes' stdin pipes. A subset of the commands
  30 // understood by the overall system, these require responses from the
  31 // child process. Having a data structure rather than sending text
  32 // simplifies parsing on the child side. The child replies by sending
  33 // back fully-formatted replies which are copied by the server process
  34 // to the clients' sockets.
  35 
  36 struct PeekArg {
  37   DWORD address;
  38   DWORD numBytes;
  39 };
  40 
  41 // NOTE: when sending a PokeArg to the child process, we handle the
  42 // buffer specially
  43 struct PokeArg {
  44   DWORD address;
  45   DWORD numBytes;
  46   void* data;
  47 };
  48 
  49 // Used for continueevent
  50 struct BoolArg {
  51   bool val;
  52 };
  53 
  54 // Used for duphandle, closehandle, and getcontext
  55 struct HandleArg {
  56   HANDLE handle;
  57 };
  58 
  59 // Used for setcontext
  60 const int NUM_REGS_IN_CONTEXT = 22;
  61 struct SetContextArg {
  62   HANDLE handle;
  63   DWORD  Eax;
  64   DWORD  Ebx;
  65   DWORD  Ecx;
  66   DWORD  Edx;
  67   DWORD  Esi;
  68   DWORD  Edi;
  69   DWORD  Ebp;
  70   DWORD  Esp;
  71   DWORD  Eip;
  72   DWORD  Ds;
  73   DWORD  Es;
  74   DWORD  Fs;
  75   DWORD  Gs;
  76   DWORD  Cs;
  77   DWORD  Ss;
  78   DWORD  EFlags;
  79   DWORD  Dr0;
  80   DWORD  Dr1;
  81   DWORD  Dr2;
  82   DWORD  Dr3;
  83   DWORD  Dr6;
  84   DWORD  Dr7;
  85 };
  86 
  87 // Used for selectorentry
  88 struct SelectorEntryArg {
  89   HANDLE handle;
  90   DWORD  selector;
  91 };
  92 
  93 struct Message {
  94   typedef enum {
  95     ATTACH,
  96     DETACH,
  97     LIBINFO,
  98     PEEK,
  99     POKE,
 100     THREADLIST,
 101     DUPHANDLE,
 102     CLOSEHANDLE,
 103     GETCONTEXT,
 104     SETCONTEXT,
 105     SELECTORENTRY,
 106     SUSPEND,
 107     RESUME,
 108     POLLEVENT,
 109     CONTINUEEVENT
 110   } Type;
 111 
 112   Type type;
 113   union {
 114     PeekArg          peekArg;
 115     PokeArg          pokeArg;
 116     BoolArg          boolArg;
 117     HandleArg        handleArg;
 118     SetContextArg    setContextArg;
 119     SelectorEntryArg selectorArg;
 120   };
 121 };
 122 
 123 #endif  // #defined _MESSAGE_