Ejemplo n.º 1
0
bool IpcCallExtra(handle_t ipc, uint32_t code, const wnd_params_t *params, 
				  const void *extra, size_t extra_length)
{
	ipc_packet_t packet = { 0 };

	if (ipc == NULL)
		ipc = IpcGetDefault();

	packet.code = code;
	if (params != NULL)
		packet.params = *params;
	packet.extra_length = extra_length;
	errno = 0;
	if (!FsWrite(ipc, &packet, 0, sizeof(packet), NULL))
	{
		_wdprintf(L"%s: IpcCallExtra: FsWrite(1) failed: %s\n",
			ProcGetProcessInfo()->module_first->name,
			_wcserror(errno));
		//return false;
	}

	if (extra_length > 0)
	{
		if (!FsWrite(ipc, extra, 0, extra_length, NULL))
		{
			_wdprintf(L"%s: IpcCallExtra: FsWrite(2) failed: %s\n",
				ProcGetProcessInfo()->module_first->name,
				_wcserror(errno));
			//return false;
		}
	}

	return true;
}
Ejemplo n.º 2
0
Archivo: v86.c Proyecto: 1tgr/mobius
static void ShInt21(context_v86_t *ctx)
{
    void *ptr;
    char *ch;
    uint32_t key;
    
    switch ((uint16_t) ctx->regs.eax >> 8)
    {
    case 0:
	ThrExitThread(0);
	break;

    case 1:
        while (!FsRead(ProcGetProcessInfo()->std_in, &key, 0, sizeof(key), NULL))
            ;

	wprintf(L"%c", (uint8_t) key);
	ctx->regs.eax = (ctx->regs.eax & 0xffffff00) | (uint8_t) key;
	break;

    case 2:
	wprintf(L"%c", ctx->regs.edx & 0xff);
	break;

    case 9:
	ptr = FP_TO_LINEAR(ctx->v86_ds, ctx->regs.edx);
	ch = strchr(ptr, '$');
	fwrite(ptr, 1, ch - (char*) ptr, stdout);
	break;

    case 0x4c:
	ThrExitThread(ctx->regs.eax & 0xff);
	break;
    }
}
Ejemplo n.º 3
0
static module_info_t* DbgLookupModule(addr_t addr)
{
    module_info_t* mod;

    for (mod = ProcGetProcessInfo()->module_first; mod != NULL; mod = mod->next)
	if (addr >= mod->base && addr < mod->base + mod->length)
	    return mod;

    return NULL;
}
Ejemplo n.º 4
0
/*
 * xxx -- windres has virtually no Unicode support, so no escape sequences 
 *  in resource files
 */
void ConDisplaySignonMessage(void)
{
    addr_t base;
    size_t length;
    wchar_t *message;

    base = ProcGetProcessInfo()->base;
    length = ResGetStringLength(base, 1);
    message = malloc(sizeof(wchar_t) * (length + 1));
    if (message != NULL)
    {
        ResLoadString(base, 1, message, length);
        ConPutStr(consoles + 0, message, length);
        free(message);
    }
}
Ejemplo n.º 5
0
bool _kbhit(void)
{
    fileop_t op;
    size_t bytes;
    bytes = 0;
    op.event = ProcGetProcessInfo()->std_in;
    if (FsIoCtl(op.event, IOCTL_BYTES_AVAILABLE, &bytes, 
        sizeof(bytes), &op))
        return bytes > 0;
    else
    {
        errno = op.result;
        return false;
    }

    return false;
}
Ejemplo n.º 6
0
void __libc_init(void)
{
    extern void (*__CTOR_LIST__[])();
    void (**pfunc)() = __CTOR_LIST__;

    if (ProcGetProcessInfo()->std_out != 0)
	ThrGetThreadInfo()->exception_handler = __libc_exception_handler;

    __malloc_lock_init();
    __malloc_debug_init();
    atexit(__malloc_lock_cleanup);
    __get_stdin();
    __get_stdout();
    __get_stderr();
    __setup_file_rec_list();

    while (*++pfunc)
	;
    while (--pfunc > __CTOR_LIST__)
	(*pfunc) ();
}
Ejemplo n.º 7
0
static bool IpcReadFromPipe(handle_t file, void *buf, size_t length)
{
    size_t bytes, total;

    total = 0;
	errno = 0;
    while (total < length)
    {
        //printf("FsRead(file=%u, length=%u-%u=%u)\n",
            //file, length, total, length - total);
        if (!FsRead(file, (char*) buf + total, 0, length - total, &bytes) ||
			(length > 0 && bytes == 0))
		{
			_wdprintf(L"%s: IpcReadFromPipe(%u): bytes = %u, errno = %d\n", 
				ProcGetProcessInfo()->module_first->name, file, bytes, errno);
            return false;
		}

        total += bytes;
    }

    return true;
}
Ejemplo n.º 8
0
pid_t getpid(void)
{
	return ProcGetProcessInfo()->id;
}