Exemple #1
0
Config::Config(QDialog *parent) :
    QDialog(parent),
    ui(new Ui::Config)
{
    ui->setupUi(this);

    Clientcont = ClientControl::getInstance();
    Clientcam = ClientCamera::getInstance();
    QObject::connect(this, SIGNAL(getIPCam()),Clientcam, SLOT(getIP()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(getPortCam()),Clientcam, SLOT(getPort()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(getIPRobot()),Clientcont, SLOT(getIP()), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(getPortRobot()),Clientcont, SLOT(getPort()), Qt::QueuedConnection);
    QObject::connect(Clientcam, SIGNAL(sendIP(QString)),this, SLOT(receiveIPCam(QString)), Qt::QueuedConnection);
    QObject::connect(Clientcam, SIGNAL(sendPort(int)),this, SLOT(receivePortCam(int)), Qt::QueuedConnection);
    QObject::connect(Clientcont, SIGNAL(sendIP(QString)),this, SLOT(receiveIPRobot(QString)), Qt::QueuedConnection);
    QObject::connect(Clientcont, SIGNAL(sendPort(int)),this, SLOT(receivePortRobot(int)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(setIPCam(QString)),Clientcam, SLOT(setIP(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(setPortCam(int)),Clientcam, SLOT(setPort(int)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(setIPRobot(QString)),Clientcont, SLOT(setIP(QString)), Qt::QueuedConnection);
    QObject::connect(this, SIGNAL(setPortRobot(int)),Clientcont, SLOT(setPort(int)), Qt::QueuedConnection);

    emit getIPCam();
    emit getPortCam();
    emit getIPRobot();
    emit getPortRobot();
    this->setAttribute(Qt::WA_DeleteOnClose );
}
Exemple #2
0
void MS_bop_8 (void)
{
    ULONG iFunc;
    UCHAR uchMode = getMSW() & MSW_PE ? TRUE : FALSE;


    // Get the Function Number
    iFunc = (ULONG)(*Sim32GetVDMPointer(SEGOFF(getCS(),getIP()),
                                        1,
                                        uchMode
                                        ));

    switch (iFunc) {
    case 0:    /* RegisterModule */
        ISV_RegisterModule (uchMode);
        break;
    case 1:    /* DeRegisterModule */
        ISV_DeRegisterModule ();
        break;
    case 2:    /* DispatchCall */
        ISV_DispatchCall ();
        break;
    default:
        setCF(1);
    }
    setIP((USHORT)(getIP() + 1));
    return;
}
Exemple #3
0
UnixClient::UnixClient() {
	char * localhost = new char[10];
	strcpy(localhost, "127.0.0.1");
	setIP(localhost);
	setPort(12345);
	setLogStream(&std::cout);
}
Exemple #4
0
static VOID WINAPI VidBiosINT(LPWORD Stack)
{
    /*
     * Set up a false stack to hardwire the BOP function (that can directly
     * manipulate CPU registers) to the 32-bit interrupt function (which uses
     * the stack to be able to modify the original CS:IP and FLAGS).
     *
     * See int32.h stack codes.
     */
    WORD EmuStack[4];
    DWORD Flags = getEFLAGS();

    DPRINT1("Calling BOP VidBiosINT\n");

    EmuStack[STACK_FLAGS]   = LOWORD(Flags);
    EmuStack[STACK_CS]      = getCS();
    EmuStack[STACK_IP]      = getIP();
    EmuStack[STACK_INT_NUM] = BOP_VIDEO_INT;

    VidBiosVideoService(EmuStack);

    setIP(EmuStack[STACK_IP]);
    setCS(EmuStack[STACK_CS]);
    setEFLAGS(MAKELONG(EmuStack[STACK_FLAGS], HIWORD(Flags)));
}
Exemple #5
0
static VOID WINAPI DosSystemBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        case 0x11:  // Load the DOS kernel
        {
            BOOLEAN Success = FALSE;
            HANDLE  hDosKernel;
            ULONG   ulDosKernelSize = 0;

            DPRINT1("You are loading Windows NT DOS!\n");

            /* Open the DOS kernel file */
            hDosKernel = FileOpen("ntdos.sys", &ulDosKernelSize);

            /* If we failed, bail out */
            if (hDosKernel == NULL) goto Quit;

            /*
             * Attempt to load the DOS kernel into memory.
             * The segment where to load the DOS kernel is defined
             * by the DOS BIOS and is found in DI:0000 .
             */
            Success = FileLoadByHandle(hDosKernel,
                                       REAL_TO_PHYS(TO_LINEAR(getDI(), 0x0000)),
                                       ulDosKernelSize,
                                       &ulDosKernelSize);

            DPRINT1("Windows NT DOS loading %s at 0x%04X:0x%04X, size 0x%x ; GetLastError() = %u\n",
                    (Success ? "succeeded" : "failed"),
                    getDI(), 0x0000,
                    ulDosKernelSize,
                    GetLastError());

            /* Close the DOS kernel file */
            FileClose(hDosKernel);

Quit:
            if (!Success)
            {
                /* We failed everything, stop the VDM */
                EmulatorTerminate();
            }

            break;
        }

        default:
        {

            DPRINT1("Unknown DOS System BOP Function: 0x%02X\n", FuncNum);
            // setCF(1); // Disable, otherwise we enter an infinite loop
            break;
        }
    }
}
Exemple #6
0
bool StationClass::setIP(IPAddress address)
{
	IPAddress mask = IPAddress(255, 255, 255, 0);
	IPAddress gateway = IPAddress(address);
	gateway[3] = 1; // x.x.x.1
	setIP(address, mask, gateway);
}
Exemple #7
0
void MsBop0(){

    DemDispatch((ULONG)(*Sim32GetVDMPointer(
        ((ULONG)getCS() << 16) + (getIP()), 1, FALSE)));
    setIP(getIP() + 1);

}
Exemple #8
0
void MsBop5()
{
#ifdef NTVDM_NET_SUPPORT
    VrDispatch((ULONG)(*Sim32GetVDMPointer(
        ((ULONG)getCS() << 16) + (getIP()), 1, FALSE)));
    setIP(getIP() + 1);
#endif
}
Exemple #9
0
// XMS BOP
void MS_bop_2(void) {
    XMSDispatch((ULONG)(*Sim32GetVDMPointer(SEGOFF(getCS(),getIP()),
                                            1,
                                            FALSE
                                            )));

    setIP((USHORT)(getIP() + 1));
}
Exemple #10
0
void MS_bop_4(void)
{
    half_word Command;
    IMPORT BOOL CmdDispatch(ULONG);

    sas_load( ((ULONG)getCS()<<4) + getIP(), &Command);
    CmdDispatch((ULONG) Command);
    setIP((USHORT)(getIP() + 1));
}
Exemple #11
0
void ServerSocket::bind(char* ip,int port)
{
	//初始化
	memset(&_hostAddress, 0, sizeof(_hostAddress));
	_hostAddress.sin_family = AF_INET;
	_hostAddress.sin_addr.s_addr = inet_addr(ip);
	_hostAddress.sin_port = htons(port);
	setIP(ip);
	setPort(port);

	bind();
}
Exemple #12
0
BOOLEAN DosInitialize(IN LPCSTR DosKernelFileName)
{
    /* Register the DOS BOPs */
    RegisterBop(BOP_DOS, DosSystemBop        );
    RegisterBop(BOP_CMD, DosCmdInterpreterBop);

    if (DosKernelFileName)
    {
        BOOLEAN Success;
        HANDLE  hDosBios;
        ULONG   ulDosBiosSize = 0;

        /* Open the DOS BIOS file */
        hDosBios = FileOpen(DosKernelFileName, &ulDosBiosSize);

        /* If we failed, bail out */
        if (hDosBios == NULL) return FALSE;

        /* Attempt to load the DOS BIOS into memory */
        Success = FileLoadByHandle(hDosBios,
                                   REAL_TO_PHYS(TO_LINEAR(0x0070, 0x0000)),
                                   ulDosBiosSize,
                                   &ulDosBiosSize);

        DPRINT1("DOS BIOS loading %s at 0x%04X:0x%04X, size 0x%x ; GetLastError() = %u\n",
                (Success ? "succeeded" : "failed"),
                0x0070, 0x0000,
                ulDosBiosSize,
                GetLastError());

        /* Close the DOS BIOS file */
        FileClose(hDosBios);

        if (Success)
        {
            /* Position execution pointers and return */
            setCS(0x0070);
            setIP(0x0000);
        }

        return Success;
    }
    else
    {
        BOOLEAN Result;

        Result  = DosBIOSInitialize();
        // Result &= DosKRNLInitialize();

        return Result;
    }
}
Exemple #13
0
void ServerSocket::bindDefault()
{
	//初始化
	memset(&_hostAddress, 0, sizeof(_hostAddress));
	_hostAddress.sin_family = AF_INET;
	_hostAddress.sin_addr.s_addr = htonl(INADDR_ANY); //IP地址设置成INADDR_ANY,让系统自动获取本机的IP地址。
	_hostAddress.sin_port = htons(DEFAULT_PORT); //设置的端口为DEFAULT_PORT

	setIP(inet_ntoa(_hostAddress.sin_addr));
	setPort(DEFAULT_PORT);

	bind();
}
Exemple #14
0
void MainWindow::connectHost()
{
    m_gobang->m_camp = Gobang::white;
    if(m_startMenu->currentIp.size() > 0)
    {
        m_server->connectHost(m_startMenu->currentIp);
    }
    else
    {
        enterDialog tempDialog(this);
        connect(&tempDialog, SIGNAL(setIP(QString)), m_server, SLOT(connectHost(QString)));
        tempDialog.exec();
    }
}
Exemple #15
0
bool JPWiFly::createApModeNetwork(const char *ssid, int channel, const int port) {
	StCommand st(this);
	setJoin(WIFLY_WLAN_JOIN_APMODE);
	setChannel(channel);
	setSSID(ssid);
	setDHCP(WIFLY_DHCP_MODE_SERVER);
	setPort(port);
	setIP(PSTR("1.2.3.4"));
	setNetmask(PSTR("255.255.255.0"));
	setGateway(PSTR("1.2.3.4"));
	
	save();
	reboot();
	return true;
}
Exemple #16
0
// DOS EMULATION BOP
void MS_bop_0(void) {
    ULONG DemCmd;

    DemCmd = (ULONG)(*Sim32GetVDMPointer(SEGOFF(getCS(),getIP()),
                                         1,
                                         FALSE
                                         ));
    DemDispatch( DemCmd );
    setIP((USHORT)(getIP() + 1));

    // we need to prevent the idle system from going off on intensive file
    // reads. However, we don't want to disable it for continuous 'Get Time'
    // calls (command 0x15). Nor for Get Date (0x15).
    if (DemCmd != 0x15 && DemCmd != 0x14)
        IDLE_disk();
}
static void prvNetifInit( void )
{
	i2chip_init();
	initW3100A();

	setMACAddr( ( unsigned char * ) ucMacAddress );
	setgateway( ( unsigned char * ) ucGatewayAddress );
	setsubmask( ( unsigned char * ) ucSubnetMask );
	setIP( ( unsigned char * ) ucIPAddress );

	/* See definition of 'sysinit' in socket.c
	 - 8 KB transmit buffer, and 8 KB receive buffer available.  These buffers
	   are shared by all 4 channels.
	 - (0x55, 0x55) configures the send and receive buffers at 
		httpSOCKET_BUFFER_SIZE bytes for each of the 4 channels. */
	sysinit( 0x55, 0x55 );
}
Exemple #18
0
static VOID WINAPI ControlBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        case BOP_CONTROL_INT32:
            Int32Dispatch(Stack);
            break;

        default:
            // DPRINT1("Unassigned Control BOP Function: 0x%02X\n", FuncNum);
            DisplayMessage(L"Unassigned Control BOP Function: 0x%02X", FuncNum);
            break;
    }
}
Exemple #19
0
static VOID WINAPI DosSystemBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        /* Load the DOS kernel */
        case 0x11:
        {
            DemLoadNTDOSKernel();
            break;
        }

        /* Call 32-bit Driver Strategy Routine */
        case BOP_DRV_STRATEGY:
        {
            DeviceStrategyBop();
            break;
        }

        /* Call 32-bit Driver Interrupt Routine */
        case BOP_DRV_INTERRUPT:
        {
            DeviceInterruptBop();
            break;
        }

        default:
        {
            DPRINT1("Unknown DOS System BOP Function: 0x%02X\n", FuncNum);
            // setCF(1); // Disable, otherwise we enter an infinite loop
            break;
        }
    }
}
Exemple #20
0
UnixClient::UnixClient(char* ip, unsigned short port, std::ostream log) {
	setIP(ip);
	setPort(port);
	setLogStream(&log);
}
Exemple #21
0
void MainWindow::connect_clicked() {
    emit setRequestedTeam(ui->comboBoxTeam->currentIndex());
    emit setIP(ui->ipEdit->text(),ui->portEdit->text().toInt());
    emit startNetworkManager();
    startPlay();
}
Exemple #22
0
/*=========================================================================
* FUNCTION:      tVM_Execute
* TYPE:          public interface
* OVERVIEW:      execute a basic function
* INTERFACE:
*   parameters:  
*   returns:     
*                the result of the basic function
*=======================================================================*/
int tVM_Execute()
{
	int       running = 1;
	u8        bytecode;
	u8        type;
	u8        ac_flag;
	s32       integer;
	s32       stackindex,index;
	tVMValue  value1,value2,value3;
	tVMValue  retValue;// = (tVMValue*)mem_alloc(sizeof(tVMValue));

	/* initialize the running Stack FP */
	setFP(FirstFP);

	/* seek to the entry function */
	setFI(0);
	
	/* initialize the code reader */
	tVM_InitializeCodeReader();

	/* execute the byte codes in loop  */
	while(running)
	{
		bytecode = ReadCode();
		switch(bytecode)
		{
		case C_NOP:
			break;
		case C_CONST:
			{
				ReadVMValue(&value1);
				PushVMValue(&value1);
				break;
			}
		case C_LOAD:
			{
				ac_flag  =ReadAccessFlag();
				if(ac_flag == ACCESS_FLAG_GLOBAL)
					stackindex = ReadIndex();
				else
					stackindex = ReadIndex() + getFP();
				LoadVMValue(stackindex,&value1);
				PushVMValue(&value1);
				break;
			}
		case C_STORE:
			{
				ac_flag  =ReadAccessFlag();
				if(ac_flag == ACCESS_FLAG_GLOBAL)
					stackindex = ReadIndex();
				else
					stackindex = ReadIndex() + getFP();
				PopVMValue(&value1); /* pop the source value */
				StoreVMValue(stackindex,&value1);
				break;
			}
		case C_HEAP_LOAD:
			{
				type = ReadDataType();

				PopVMValue(&value2); /* Pop Addr */
				PopVMValue(&value1); /* Pop Base */	
				tVMValue_HeapLoad(value1.value.ptr_val+value2.value.int_val,type,&value3); /* load the heap memory */
				PushVMValue(&value3); /* push the loaded value */
				break;
			}
		case C_HEAP_STORE:
			{
				ptr32 addr;
				type = ReadDataType();

				PopVMValue(&value3); /* Pop Addr */
				PopVMValue(&value2); /* Pop Base */
				PopVMValue(&value1); /* Pop Value */
				addr = (ptr32)(value2.value.ptr_val + value3.value.int_val);
				if(value1.type != type)
				{
					tVMValue_ConvertType(&value1,type);
				}
				tVMValue_HeapStore(addr,&value1);
				break;
			}
		case C_FORCE_LOAD:
			{
				ac_flag  =ReadAccessFlag();
				if(ac_flag == ACCESS_FLAG_GLOBAL)
					stackindex = ReadIndex();
				else
					stackindex = ReadIndex() + getFP();
				type = ReadDataType();

				ForceLoadVMValue(stackindex,type,&value1);
				PushVMValue(&value1);
				break;
			}
		case C_ALLOC:
			{
				PopVMValue(&value1);
				value2.type = PtrType;
				value2.value.ptr_val = (ptr32)mem_alloc(value1.value.int_val);
				memset(value2.value.ptr_val,0,value1.value.int_val);
				PushVMValue(&value2);
				break;
			}
		case C_ALLOC_ARRAY:
			{
				s32   i;
				s32  dimension; 
				s32* index_ranges;
				
				dimension = ReadInteger();
				if(dimension < 1)
					break;
				index_ranges = (s32*)mem_alloc(sizeof(s32)*dimension);
				for(i=0;i<dimension;i++)
				{
					PopVMValue(&value1);
					index_ranges[dimension-i-1] = value1.value.int_val;
				}
				value1.type = PtrType;
				value1.value.ptr_val = tVMValue_HeapAllocMultiArray(dimension,index_ranges,0);
				PushVMValue(&value1);
				
				mem_free(index_ranges);
				break;
			}
		case C_FREE:
			{
				PopVMValue(&value1);
				if(value1.value.ptr_val != NULL)
					mem_free(value1.value.ptr_val);
				break;
			}
		case C_FREE_ARRAY:
			{
				break;
			}
		case C_PUSH:
			{
				value1.type  = ReadDataType();
				value1.value.int_val = 0;
				PushVMValue(&value1);
				break;
			}
		case C_POP:
			{
				s32 i;
				integer = ReadInteger();
				for(i=0;i<integer;i++)
				{
					PopVMValue(&value1);
					tVMValue_FreeSelf(&value1);
				}
				break;
			}
		case C_POP_RESTOP:
			{
				s32 i;
				integer = ReadInteger();
				PopVMValue(&value2); /* reserve top value */
				for(i=0;i<integer;i++)
				{
					PopVMValue(&value1);
					tVMValue_FreeSelf(&value1);
				}
				PushVMValue(&value2); /* push back top value */
				break;
			}
		case C_CONVERT:
			{
				u8 type = (u8)ReadDataType();
				PopVMValue(&value1);
				tVMValue_ConvertType(&value1,type);
				PushVMValue(&value1);
				break;
			}
		case C_ADD:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_Add(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_SUB:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_Sub(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_MUL:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_Mul(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_DIV:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_Div(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_MOD:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_Mod(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_OPP:
			{
				PopVMValue(&value1);
				tVMValue_Opp(&value1,&value2);
				PushVMValue(&value2);

				tVMValue_FreeSelf(&value1);
				break;
			}
		case C_AND:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_AND(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_OR:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_OR(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_EQ:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_EQ(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_NOT_EQ:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_NOTEQ(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_LT:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_LT(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_LG:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_LG(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_LT_EQ:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_LTEQ(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_LG_EQ:
			{
				PopVMValue(&value2);
				PopVMValue(&value1);
				tVMValue_LGEQ(&value1,&value2,&value3);
				PushVMValue(&value3);

				tVMValue_FreeSelf(&value1);
				tVMValue_FreeSelf(&value2);
				break;
			}
		case C_FJP:
			{
				s32 size = ReadIndex();
				PopVMValue(&value1);
				if(value1.value.int_val == 0) /* if it is false */
					addIP(size);
				break;
			}
		case C_TJP:
			{
				s32 size = ReadIndex();
				PopVMValue(&value1);
				if(value1.value.int_val != 0) /* if it is true */
					addIP(size);
				break;
			}
		case C_JMP:
			{
				s32 size = ReadIndex();
				addIP(size);
				break;
			}
		case C_CALL:
			{
				/* read function name */
				integer = ReadIndex();
				/* push the stack frame */
				PushInteger(getIP());
				PushInteger(getFI());
				PushInteger(getFP());
				/* goto the call function code */
				tVM_ReleaseCodeReader();
				setFI(integer);
				tVM_InitializeCodeReader();
				/* set new FP,RP */
				setFP(getSP());
				break;
			}
		case C_INVOKE:
			{
				/* read function name */
				index = ReadIndex();
				/* execute the native function */
				tNativeFunction_Invoke(index);
				break;
			}
		case C_RET:
			{
				u32 param_bytes = ReadIndex();

				/* get the result of the function */
				retValue.type = NullType;
				PopVMValue(&retValue); 
				
				/* if this is the start function,then exit the loop */
				if(getFP() == FirstFP)
				{
					running = 0; /* set flag to stop while */
					break;
				}

				/* restore last stack frame and return to last function code */
				tVM_ReleaseCodeReader();
				PopInteger(integer);
				setFP(integer); 
				PopInteger(integer);
				setFI(integer);
				tVM_InitializeCodeReader();
				PopInteger(integer);
				setIP(integer);
				
				/* pop the old parameters */
				PopBytes(param_bytes);

				/* push back result of last function */
				PushVMValue(&retValue);
				break;
			}
		}
	}

	/* close the code reader */
	tVM_ReleaseCodeReader();
	return 1;
}
Exemple #23
0
User::User(char* n, char* i, SOCKET s) : handle(NULL), update(true){
	setName(string(n));
	setIP(string(i));
	setSocket(s);
}
Exemple #24
0
User::User(string n, string i, SOCKET s) : handle(NULL), update(true){
	setName(n);
	setIP(i);
	setSocket(s);
}
Exemple #25
0
static VOID WINAPI DosInitialize(LPWORD Stack)
{
    BOOLEAN Success = FALSE;

    /* Get the DOS kernel file name (NULL-terminated) */
    // FIXME: Isn't it possible to use some DS:SI instead??
    LPCSTR DosKernelFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + strlen(DosKernelFileName) + 1); // Skip it

    DPRINT("DosInitialize('%s')\n", DosKernelFileName);

    /* Register the DOS BOPs */
    RegisterBop(BOP_DOS, DosSystemBop        );
    RegisterBop(BOP_CMD, DosCmdInterpreterBop);

    if (DosKernelFileName && DosKernelFileName[0] != '\0')
    {
        HANDLE  hDosBios;
        ULONG   ulDosBiosSize = 0;

        /* Open the DOS BIOS file */
        hDosBios = FileOpen(DosKernelFileName, &ulDosBiosSize);

        /* If we failed, bail out */
        if (hDosBios == NULL) goto QuitCustom;

        /* Attempt to load the DOS BIOS into memory */
        Success = FileLoadByHandle(hDosBios,
                                   REAL_TO_PHYS(TO_LINEAR(0x0070, 0x0000)),
                                   ulDosBiosSize,
                                   &ulDosBiosSize);

        DPRINT1("DOS BIOS loading %s at %04X:%04X, size 0x%X ; GetLastError() = %u\n",
                (Success ? "succeeded" : "failed"),
                0x0070, 0x0000,
                ulDosBiosSize,
                GetLastError());

        /* Close the DOS BIOS file */
        FileClose(hDosBios);

        if (!Success) goto QuitCustom;

        /* Position execution pointers and return */
        setCS(0x0070);
        setIP(0x0000);

        /* Return control */
QuitCustom:
        if (!Success)
            DisplayMessage(L"Custom DOS '%S' loading failed, what to do??", DosKernelFileName);
    }
    else
    {
        Success = DosBIOSInitialize();
        // Success &= DosKRNLInitialize();

        if (!Success) goto Quit32;

        /* Write the "bootsector" */
        RtlCopyMemory(SEG_OFF_TO_PTR(0x0070, 0x0000), Startup, sizeof(Startup));

        /* Register the DOS Starting BOP */
        RegisterBop(BOP_START_DOS, DosStart);

        /* Position execution pointers and return */
        setCS(0x0070);
        setIP(0x0000);

        /* Return control */
Quit32:
        if (!Success)
            DisplayMessage(L"DOS32 loading failed, what to do??");
    }

    if (Success)
    {
        /*
         * We succeeded, deregister the DOS Loading BOP
         * so that no app will be able to call us back.
         */
        RegisterBop(BOP_LOAD_DOS, NULL);
    }
}
Exemple #26
0
static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        case 0x08:  // Launch external command
        {
#define CMDLINE_LENGTH  1024

            BOOL Result;
            DWORD dwExitCode;

            LPSTR Command = (LPSTR)SEG_OFF_TO_PTR(getDS(), getSI());
            LPSTR CmdPtr  = Command;
            CHAR CommandLine[CMDLINE_LENGTH] = "";
            STARTUPINFOA StartupInfo;
            PROCESS_INFORMATION ProcessInformation;

            /* NULL-terminate the command line by removing the return carriage character */
            while (*CmdPtr && *CmdPtr != '\r') CmdPtr++;
            *CmdPtr = '\0';

            DPRINT1("CMD Run Command '%s'\n", Command);

            /* Spawn a user-defined 32-bit command preprocessor */

            /* Build the command line */
            // FIXME: Use COMSPEC env var!!
            strcpy(CommandLine, "cmd.exe /c ");
            strcat(CommandLine, Command);

            ZeroMemory(&StartupInfo, sizeof(StartupInfo));
            ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));

            StartupInfo.cb = sizeof(StartupInfo);

            VidBiosDetachFromConsole();

            Result = CreateProcessA(NULL,
                                    CommandLine,
                                    NULL,
                                    NULL,
                                    TRUE,
                                    0,
                                    NULL,
                                    NULL,
                                    &StartupInfo,
                                    &ProcessInformation);
            if (Result)
            {
                DPRINT1("Command '%s' launched successfully\n", Command);

                /* Wait for process termination */
                WaitForSingleObject(ProcessInformation.hProcess, INFINITE);

                /* Get the exit code */
                GetExitCodeProcess(ProcessInformation.hProcess, &dwExitCode);

                /* Close handles */
                CloseHandle(ProcessInformation.hThread);
                CloseHandle(ProcessInformation.hProcess);
            }
            else
            {
                DPRINT1("Failed when launched command '%s'\n");
                dwExitCode = GetLastError();
            }

            VidBiosAttachToConsole();

            setAL((UCHAR)dwExitCode);

            break;
        }

        default:
        {
            DPRINT1("Unknown DOS CMD Interpreter BOP Function: 0x%02X\n", FuncNum);
            // setCF(1); // Disable, otherwise we enter an infinite loop
            break;
        }
    }
}
Exemple #27
0
static VOID WINAPI DosCmdInterpreterBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        /* Kill the VDM */
        case 0x00:
        {
            /* Stop the VDM */
            EmulatorTerminate();
            return;
        }

        /*
         * Get a new app to start
         *
         * Input
         *     DS:DX : Data block.
         *
         * Output
         *     CF    : 0: Success; 1: Failure.
         */
        case 0x01:
        {
            CmdStartProcess();
            break;
        }

        /*
         * Check binary format
         *
         * Input
         *     DS:DX : Program to check.
         *
         * Output
         *     CF    : 0: Success; 1: Failure.
         *     AX    : Error code.
         */
        case 0x07:
        {
            DWORD BinaryType;
            LPSTR ProgramName = (LPSTR)SEG_OFF_TO_PTR(getDS(), getDX());

            if (!GetBinaryTypeA(ProgramName, &BinaryType))
            {
                /* An error happened, bail out */
                setCF(1);
                setAX(LOWORD(GetLastError()));
                break;
            }

            // FIXME: We only support DOS binaries for now...
            ASSERT(BinaryType == SCS_DOS_BINARY);
            if (BinaryType != SCS_DOS_BINARY)
            {
                /* An error happened, bail out */
                setCF(1);
                setAX(LOWORD(ERROR_BAD_EXE_FORMAT));
                break;
            }

            /* Return success: DOS application */
            setCF(0);
            break;
        }

        /*
         * Start an external command
         *
         * Input
         *     DS:SI : Command to start.
         *     ES    : Environment block segment.
         *     AL    : Current drive number.
         *     AH    : 0: Directly start the command;
         *             1: Use "cmd.exe /c" to start the command.
         *
         * Output
         *     CF    : 0: Shell-out; 1: Continue.
         *     AL    : Error/Exit code.
         */
        case 0x08:
        {
            CmdStartExternalCommand();
            break;
        }

        /*
         * Start the default 32-bit command interpreter (COMSPEC)
         *
         * Input
         *     ES    : Environment block segment.
         *     AL    : Current drive number.
         *
         * Output
         *     CF    : 0: Shell-out; 1: Continue.
         *     AL    : Error/Exit code.
         */
        case 0x0A:
        {
            CmdStartComSpec32();
            break;
        }

        /*
         * Set exit code
         *
         * Input
         *     DX    : Exit code
         *
         * Output
         *     CF    : 0: Shell-out; 1: Continue.
         */
        case 0x0B:
        {
            CmdSetExitCode();
            break;
        }

        /*
         * Get start information
         *
         * Output
         *     AL    : 0 (resp. 1): Started from (resp. without) an existing console.
         */
        case 0x10:
        {
#ifndef STANDALONE
            /*
             * When a new instance of our (internal) COMMAND.COM is started,
             * we check whether we need to run a 32-bit COMSPEC. This goes by
             * checking whether we were started in a new console (no parent
             * console process) or from an existing one.
             *
             * However COMMAND.COM can also be started in the case where a
             * 32-bit process (started by a 16-bit parent) wants to start a new
             * 16-bit process: to ensure DOS reentry we need to start a new
             * instance of COMMAND.COM. On Windows the COMMAND.COM is started
             * just before the 32-bit process (in fact, it is this COMMAND.COM
             * which starts the 32-bit process via an undocumented command-line
             * switch '/z', which syntax is:
             *     COMMAND.COM /z\bAPPNAME.EXE
             * notice the '\b' character inserted in-between. Then COMMAND.COM
             * issues a BOP_CMD 08h with AH=00h to start the process).
             *
             * Instead, we do the reverse, i.e. we start the 32-bit process,
             * and *only* if needed, i.e. if this process wants to start a
             * new 16-bit process, we start our COMMAND.COM.
             *
             * The problem we then face is that our COMMAND.COM will possibly
             * want to start a new COMSPEC, however we do not want this.
             * The chosen solution is to flag this case -- done with the 'Reentry'
             * boolean -- so that COMMAND.COM will not attempt to start COMSPEC
             * but instead will directly try to start the 16-bit process.
             */
            // setAL(SessionId != 0);
            setAL((SessionId != 0) && !Reentry);
            /* Reset 'Reentry' */
            Reentry = FALSE;
#else
            setAL(0);
#endif
            break;
        }

        default:
        {
            DPRINT1("Unknown DOS CMD Interpreter BOP Function: 0x%02X\n", FuncNum);
            // setCF(1); // Disable, otherwise we enter an infinite loop
            break;
        }
    }
}
Exemple #28
0
static VOID WINAPI DosInitialize(LPWORD Stack)
{
    /* Get the DOS BIOS file name (NULL-terminated) */
    // FIXME: Isn't it possible to use some DS:SI instead??
    LPCSTR DosBiosFileName = (LPCSTR)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + strlen(DosBiosFileName) + 1); // Skip it

    DPRINT("DosInitialize('%s')\n", DosBiosFileName);

    /*
     * We succeeded, deregister the DOS Loading BOP
     * so that no app will be able to call us back.
     */
    RegisterBop(BOP_LOAD_DOS, NULL);

    /* Register the DOS BOPs */
    RegisterBop(BOP_DOS, DosSystemBop        );
    RegisterBop(BOP_CMD, DosCmdInterpreterBop);

    if (DosBiosFileName[0] != '\0')
    {
        BOOLEAN Success = FALSE;
        HANDLE  hDosBios;
        ULONG   ulDosBiosSize = 0;

        /* Open the DOS BIOS file */
        hDosBios = FileOpen(DosBiosFileName, &ulDosBiosSize);
        if (hDosBios == NULL) goto Quit;

        /* Attempt to load the DOS BIOS into memory */
        Success = FileLoadByHandle(hDosBios,
                                   REAL_TO_PHYS(TO_LINEAR(0x0070, 0x0000)),
                                   ulDosBiosSize,
                                   &ulDosBiosSize);

        DPRINT1("DOS BIOS file '%s' loading %s at %04X:%04X, size 0x%X (Error: %u).\n",
                DosBiosFileName,
                (Success ? "succeeded" : "failed"),
                0x0070, 0x0000,
                ulDosBiosSize,
                GetLastError());

        /* Close the DOS BIOS file */
        FileClose(hDosBios);

Quit:
        if (!Success)
        {
            BiosDisplayMessage("DOS BIOS file '%s' loading failed (Error: %u). The VDM will shut down.\n",
                               DosBiosFileName, GetLastError());
            return;
        }
    }
    else
    {
        /* Load the 16-bit startup code for DOS32 and register its Starting BOP */
        RtlCopyMemory(SEG_OFF_TO_PTR(0x0070, 0x0000), Startup, sizeof(Startup));

        // This is the equivalent of BOP_LOAD_DOS, function 0x11 "Load the DOS kernel"
        // for the Windows NT DOS.
        RegisterBop(BOP_START_DOS, DosStart);
    }

    /* Position execution pointers for DOS startup and return */
    setCS(0x0070);
    setIP(0x0000);
}
Exemple #29
0
VOID WINAPI ThirdPartyVDDBop(LPWORD Stack)
{
    /* Get the Function Number and skip it */
    BYTE FuncNum = *(PBYTE)SEG_OFF_TO_PTR(getCS(), getIP());
    setIP(getIP() + 1);

    switch (FuncNum)
    {
        /* RegisterModule */
        case 0:
        {
            BOOL Success = TRUE;
            WORD RetVal  = 0;
            WORD Entry   = 0;
            LPCSTR DllName = NULL,
                   InitRoutineName     = NULL,
                   DispatchRoutineName = NULL;
            HMODULE hDll = NULL;
            VDD_PROC InitRoutine     = NULL,
                     DispatchRoutine = NULL;

            DPRINT("RegisterModule() called\n");

            /* Clear the Carry Flag (no error happened so far) */
            setCF(0);

            /* Retrieve the next free entry in the table (used later on) */
            Entry = GetNextFreeVDDEntry();
            if (Entry >= MAX_VDD_MODULES)
            {
                DPRINT1("Failed to create a new VDD module entry\n");
                Success = FALSE;
                RetVal = 4;
                goto Quit;
            }

            /* Retrieve the VDD name in DS:SI */
            DllName = (LPCSTR)SEG_OFF_TO_PTR(getDS(), getSI());

            /* Retrieve the initialization routine API name in ES:DI (optional --> ES=DI=0) */
            if (TO_LINEAR(getES(), getDI()) != 0)
                InitRoutineName = (LPCSTR)SEG_OFF_TO_PTR(getES(), getDI());

            /* Retrieve the dispatch routine API name in DS:BX */
            DispatchRoutineName = (LPCSTR)SEG_OFF_TO_PTR(getDS(), getBX());

            DPRINT1("DllName = '%s' - InitRoutineName = '%s' - DispatchRoutineName = '%s'\n",
                    (DllName ? DllName : "n/a"),
                    (InitRoutineName ? InitRoutineName : "n/a"),
                    (DispatchRoutineName ? DispatchRoutineName : "n/a"));

            /* Load the VDD DLL */
            hDll = LoadLibraryA(DllName);
            if (hDll == NULL)
            {
                DWORD LastError = GetLastError();
                Success = FALSE;

                if (LastError == ERROR_NOT_ENOUGH_MEMORY)
                {
                    DPRINT1("Not enough memory to load DLL '%s'\n", DllName);
                    RetVal = 4;
                    goto Quit;
                }
                else
                {
                    DPRINT1("Failed to load DLL '%s'; last error = %d\n", DllName, LastError);
                    RetVal = 1;
                    goto Quit;
                }
            }

            /* Load the initialization routine if needed */
            if (InitRoutineName)
            {
                InitRoutine = (VDD_PROC)GetProcAddress(hDll, InitRoutineName);
                if (InitRoutine == NULL)
                {
                    DPRINT1("Failed to load the initialization routine '%s'\n", InitRoutineName);
                    Success = FALSE;
                    RetVal = 3;
                    goto Quit;
                }
            }

            /* Load the dispatch routine */
            DispatchRoutine = (VDD_PROC)GetProcAddress(hDll, DispatchRoutineName);
            if (DispatchRoutine == NULL)
            {
                DPRINT1("Failed to load the dispatch routine '%s'\n", DispatchRoutineName);
                Success = FALSE;
                RetVal = 2;
                goto Quit;
            }

            /* If we arrived there, that means everything is OK */

            /* Register the VDD DLL */
            VDDList[Entry].hDll = hDll;
            VDDList[Entry].DispatchRoutine = DispatchRoutine;

            /* Call the initialization routine if needed */
            if (InitRoutine) InitRoutine();

            /* We succeeded. RetVal will contain a valid VDD DLL handle */
            Success = TRUE;
            RetVal  = ENTRY_TO_HANDLE(Entry); // Convert the entry to a valid handle

Quit:
            if (!Success)
            {
                /* Unload the VDD DLL */
                if (hDll) FreeLibrary(hDll);

                /* Set the Carry Flag to indicate that an error happened */
                setCF(1);
            }
            // else
            // {
                // /* Clear the Carry Flag (success) */
                // setCF(0);
            // }
            setAX(RetVal);
            break;
        }

        /* UnRegisterModule */
        case 1:
        {
            WORD Handle = getAX();
            WORD Entry  = HANDLE_TO_ENTRY(Handle); // Convert the handle to a valid entry

            DPRINT("UnRegisterModule() called\n");

            /* Sanity checks */
            if (!IS_VALID_HANDLE(Handle) || VDDList[Entry].hDll == NULL)
            {
                DPRINT1("Invalid VDD DLL Handle: %d\n", Entry);
                /* Stop the VDM */
                EmulatorTerminate();
                return;
            }

            /* Unregister the VDD DLL */
            FreeLibrary(VDDList[Entry].hDll);
            VDDList[Entry].hDll = NULL;
            VDDList[Entry].DispatchRoutine = NULL;
            break;
        }

        /* DispatchCall */
        case 2:
        {
            WORD Handle = getAX();
            WORD Entry  = HANDLE_TO_ENTRY(Handle); // Convert the handle to a valid entry

            DPRINT("DispatchCall() called\n");

            /* Sanity checks */
            if (!IS_VALID_HANDLE(Handle)    ||
                VDDList[Entry].hDll == NULL ||
                VDDList[Entry].DispatchRoutine == NULL)
            {
                DPRINT1("Invalid VDD DLL Handle: %d\n", Entry);
                /* Stop the VDM */
                EmulatorTerminate();
                return;
            }

            /* Call the dispatch routine */
            VDDList[Entry].DispatchRoutine();
            break;
        }

        default:
        {
            DPRINT1("Unknown 3rd-party VDD BOP Function: 0x%02X\n", FuncNum);
            setCF(1);
            break;
        }
    }
}
Exemple #30
0
UnixClient::UnixClient(char* ip, unsigned short port) {
	setIP(ip);
	setPort(port);
	setLogStream(&std::cout);
}