Exemplo n.º 1
0
gboolean
uservinfo_get_debug_output(const UserVInfo *in_info, ustring *ustr)
{
    if (in_info == NULL
        || ustr == NULL)
    {
        return FALSE;
    }

    int i;
    const finfo *fi = get_finfo(in_info);

    ustr_printfa(ustr, "Hexdump:\n");
    ustr_hexdumpa(ustr, value_cell_get_data(in_info->vc),
                  0, value_cell_get_data_length(in_info->vc), TRUE, TRUE);

    for (i = 0; i < UV_FIELD_COUNT; i++)
    {
        ustr_printfa(ustr,
                     "Field %s(%d): offset(%d), len(%d), unknown(%08x)\n",
                     uv_field_names[i], i,
                     fi->e[i].off, fi->e[i].len, fi->e[i].unknown);
        ustr_hexdumpa(ustr, fi->data, fi->e[i].off,
                      fi->e[i].off + fi->e[i].len, TRUE, TRUE);
    }

    ustr_printfa(ustr, "\n");

    return TRUE;
}
Exemplo n.º 2
0
const SecurityDescriptor*
uservinfo_get_secdesc(const UserVInfo *in_info)
{
    if (in_info == NULL)
    {
        return NULL;
    }

    if (in_info->secdesc == NULL)
    {
        finfo *fi = get_finfo(in_info);
        gsize len = fi->e[UV_SECDESC].len;
        ((UserVInfo*)in_info)->secdesc =
            secdesc_new_parse_binary(fi->data + fi->e[UV_SECDESC].off, &len);
    }

    return in_info->secdesc;
}
Exemplo n.º 3
0
static const ustring*
get_ustring_val(const UserVInfo *in_info, uv_field in_field)
{
    if (in_info == NULL)
    {
        return NULL;
    }

    if (in_info->vals[in_field] == NULL)
    {
        finfo *fi = get_finfo(in_info);
        ustring *tmp_str = ustr_new();
        ustr_strnset_type(tmp_str, USTR_TYPE_UTF16LE,
                          (char*)(fi->data + fi->e[in_field].off),
                          fi->e[in_field].len);
        ((UserVInfo*)in_info)->vals[in_field] = tmp_str;
    }

    return in_info->vals[in_field];
}
Exemplo n.º 4
0
int
fseek2 (FILE *file, long offset, int mode)
{
#undef  fseek
  st_finfo_t *finfo = get_finfo (file);

/*
//  if (fmode != FM_NORMAL)
  printf ("fmode = %s\n", finfo->fmode == FM_NORMAL ? "FM_NORMAL" :
                            (finfo->fmode == FM_GZIP ? "FM_GZIP" :
                              (finfo->fmode == FM_ZIP ? "FM_ZIP" : "FM_UNDEF")));
*/

  if (finfo->fmode == FM_NORMAL)
    return fseek (file, offset, mode);
  else if (finfo->fmode == FM_GZIP)
    {
      if (mode == SEEK_END)                     // zlib doesn't support SEEK_END
        {
          // Note that this is _slow_...
          while (!gzeof (file))
            {
              gzgetc (file); // necessary for _uncompressed_ files in order to set EOF
              gzseek (file, 1024 * 1024, SEEK_CUR);
            }
          offset += gztell (file);
          mode = SEEK_SET;
        }
      /*
        F*****G zlib documentation! It took me around 4 hours of debugging time
        to find out that the doc is wrong! From the doc:
          gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
        That is not true for uncompressed files. gzrewind() doesn't change the
        file pointer for uncompressed files in the ports I tested (zlib 1.1.3,
        DJGPP, Cygwin & GNU/Linux). It clears the EOF indicator.
      */
      if (!finfo->compressed)
        gzrewind (file);
      return gzseek (file, offset, mode) == -1 ? -1 : 0;
    }
  else if (finfo->fmode == FM_ZIP)
    {
      int base;
      if (mode != SEEK_SET && mode != SEEK_CUR && mode != SEEK_END)
        {
          errno = EINVAL;
          return -1;
        }
      if (mode == SEEK_SET)
        base = 0;
      else if (mode == SEEK_CUR)
        base = unztell (file);
      else // mode == SEEK_END
        {
          unz_file_info info;

          unzip_goto_file (file, unzip_current_file_nr);
          unzGetCurrentFileInfo (file, &info, NULL, 0, NULL, 0, NULL, 0);
          base = info.uncompressed_size;
        }
      return unzip_seek_helper (file, base + offset);
    }
  return -1;
#define fseek   fseek2
}
Exemplo n.º 5
0
static fmode2_t
get_fmode (FILE *file)
{
  return get_finfo (file)->fmode;
}
Exemplo n.º 6
0
// !!UNC
void init_posix_emu(void)
{
	if(!validate_stat_struct) {
		ErrorAlert( "Invalid struct my_stat -- edit posix_emu.h" );
		QuitEmulator();
	}

#if DEBUG_EXTFS
	debug_extfs = PrefsFindInt16("debugextfs");

	debug_extfs = DB_EXTFS_LOUD;

	if(debug_extfs != DB_EXTFS_NONE) {
		extfs_log_open( EXTFS_LOG_FILE_NAME );
	}
#endif

	// We cannot use ExtFS "RootPath" because of the virtual desktop.
	if(PrefsFindBool("enableextfs")) {
		PrefsReplaceString("extfs", "");
	} else {
		PrefsRemoveItem("extfs");
		D(bug("extfs disabled by user\n"));
#if DEBUG_EXTFS
		extfs_log_close();
#endif
		return;
	}

	const char *extdrives = PrefsFindString("extdrives");

	// Set up drive list.
	size_t outinx = 0;
	for( TCHAR letter = TEXT('A'); letter <= TEXT('Z'); letter++ ) {
		if(extdrives && !strchr(extdrives,letter)) continue;
		TCHAR rootdir[20];
		_sntprintf( rootdir, lengthof(rootdir), TEXT("%c:\\"), letter );
		use_streams[ letter - 'A' ] = false;
		switch(GetDriveType(rootdir)) {
			case DRIVE_FIXED:
			case DRIVE_REMOTE:
			case DRIVE_RAMDISK:
				// TODO: NTFS AFP?
				// fall
			case DRIVE_REMOVABLE:
			case DRIVE_CDROM:
				if(outinx < lengthof(host_drive_list)) {
					host_drive_list[outinx] = letter;
					outinx += 2;
				}
		}
	}

	// Set up virtual desktop root.
	// TODO: this should be customizable.
	GetModuleFileName( NULL, virtual_root, lengthof(virtual_root) );
	TCHAR *p = _tcsrchr( virtual_root, TEXT('\\') );
	if(p) {
		_tcscpy( ++p, desktop_name );
	} else {
		// should never happen
		_sntprintf( virtual_root, lengthof(virtual_root), TEXT("C:\\%s"), desktop_name );
	}
	CreateDirectory( virtual_root, 0 );

	// Set up an icon looking like "My Computer"
	// Can be overwritten just like any other folder custom icon.
	if(my_access(custom_icon_name,0) != 0) {
		int fd = my_creat( custom_icon_name, 0 );
		if(fd >= 0) {
			my_close(fd);
			fd = open_rfork( custom_icon_name, O_RDWR|O_CREAT );
			if(fd >= 0) {
				my_write( fd, my_comp_icon, sizeof(my_comp_icon) );
				my_close(fd);
				static uint8 host_finfo[SIZEOF_FInfo];
				uint32 finfo = Host2MacAddr(host_finfo);
				get_finfo(custom_icon_name, finfo, 0, false);
				WriteMacInt16(finfo + fdFlags, kIsInvisible);
				set_finfo(custom_icon_name, finfo, 0, false);
				get_finfo(my_computer, finfo, 0, true);
				WriteMacInt16(finfo + fdFlags, ReadMacInt16(finfo + fdFlags) | kHasCustomIcon);
				set_finfo(my_computer, finfo, 0, true);
			} else {
				my_remove(custom_icon_name);
			}
		}
	}
}