예제 #1
0
static int lookup_functions()
{
	lib_handle = LoadLibraryA("hid.dll");
	if (lib_handle) {
#define RESOLVE(x) x = (x##_)GetProcAddress(lib_handle, #x); if (!x) return -1;
		RESOLVE(HidD_GetAttributes);
		RESOLVE(HidD_GetSerialNumberString);
		RESOLVE(HidD_GetManufacturerString);
		RESOLVE(HidD_GetProductString);
		RESOLVE(HidD_SetFeature);
		RESOLVE(HidD_GetFeature);
		RESOLVE(HidD_GetIndexedString);
		RESOLVE(HidD_GetPreparsedData);
		RESOLVE(HidD_FreePreparsedData);
		RESOLVE(HidP_GetCaps);
#undef RESOLVE
	}
	else
		return -1;

	return 0;
}
예제 #2
0
파일: kernel.c 프로젝트: respu/PS4-SDK
void initKernel(void) {
	int libkernel;
	loadModule("libkernel.sprx", &libkernel);
	
	RESOLVE(libkernel, sceKernelLoadStartModule);
	
	RESOLVE(libkernel, sceKernelAllocateDirectMemory);
	RESOLVE(libkernel, sceKernelMapDirectMemory);
	
	RESOLVE(libkernel, sceKernelSleep);
	RESOLVE(libkernel, sceKernelUsleep);
	RESOLVE(libkernel, sceKernelGettimeofday);
	RESOLVE(libkernel, sceKernelGetProcessTime);
	RESOLVE(libkernel, sceKernelGetCurrentCpu);
}
예제 #3
0
int fclose(FILE *stream)
{
    int fd = fileno(stream);

    if (intercept[fd])
    {
	DEBUGF("fd=%d\n", fd);

	return _intercept_close(fd);
    }

    RESOLVE(fclose);
    return o_fclose(stream);
}
예제 #4
0
__off64_t ftello64 (FILE *stream)
{
    int fd = fileno(stream);

    if (intercept[fd])
    {
	DEBUGF("fd=%d\n", fd);

	return intercept[fd]->offset;
    }

    RESOLVE(ftello64);
    return o_ftello64(stream);
}
예제 #5
0
void
pdf_array_push_drop(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
{
	RESOLVE(obj);
	if (obj >= PDF_OBJ__LIMIT)
	{
		fz_try(ctx)
			pdf_array_push(ctx, obj, item);
		fz_always(ctx)
			pdf_drop_obj(ctx, item);
		fz_catch(ctx)
			fz_rethrow(ctx);
	}
}
예제 #6
0
void
pdf_array_insert_drop(fz_context *ctx, pdf_obj *obj, pdf_obj *item, int i)
{
	RESOLVE(obj);
	if (obj)
	{
		fz_try(ctx)
			pdf_array_insert(ctx, obj, item, i);
		fz_always(ctx)
			pdf_drop_obj(ctx, item);
		fz_catch(ctx)
			fz_rethrow(ctx);
	}
}
예제 #7
0
int __fxstat64(int version, int fd, struct stat64 *buf)
{
    if (intercept[fd])
    {
	DEBUGF("version=%d, fd=%d\n", version, fd);

	_intercept_stat(fd, buf);

	return 0;
    }

    RESOLVE(__fxstat64);
    return o___fxstat64(version, fd, buf);
}
예제 #8
0
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
{
    int fd = fileno(stream);

    if (intercept[fd])
    {
	DEBUGF("ptr=%p, size=%zu, nmemb=%zu, fd=%d", ptr, size, nmemb, fd);

	return _intercept_read(fd, ptr, size * nmemb);
    }

    RESOLVE(fread);
    return o_fread(ptr, size, nmemb, stream);
}
예제 #9
0
파일: pdf-object.c 프로젝트: muennich/mupdf
void
pdf_array_delete(fz_context *ctx, pdf_obj *obj, int i)
{
	RESOLVE(obj);
	if (!OBJ_IS_ARRAY(obj))
		fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));
	if (i < 0 || i >= ARRAY(obj)->len)
		fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
	prepare_object_for_alteration(ctx, obj, NULL);
	pdf_drop_obj(ctx, ARRAY(obj)->items[i]);
	ARRAY(obj)->items[i] = 0;
	ARRAY(obj)->len--;
	memmove(ARRAY(obj)->items + i, ARRAY(obj)->items + i + 1, (ARRAY(obj)->len - i) * sizeof(pdf_obj*));
}
예제 #10
0
파일: pdf-object.c 프로젝트: muennich/mupdf
void
pdf_array_insert(fz_context *ctx, pdf_obj *obj, pdf_obj *item, int i)
{
	RESOLVE(obj);
	if (!OBJ_IS_ARRAY(obj))
		fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));
	if (i < 0 || i > ARRAY(obj)->len)
		fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
	prepare_object_for_alteration(ctx, obj, item);
	if (ARRAY(obj)->len + 1 > ARRAY(obj)->cap)
		pdf_array_grow(ctx, ARRAY(obj));
	memmove(ARRAY(obj)->items + i + 1, ARRAY(obj)->items + i, (ARRAY(obj)->len - i) * sizeof(pdf_obj*));
	ARRAY(obj)->items[i] = pdf_keep_obj(ctx, item);
	ARRAY(obj)->len++;
}
예제 #11
0
CONFUGA_API int confuga_truncate(confuga *C, const char *path, confuga_off_t length)
{
	static const confuga_fid_t empty = {CONFUGA_FID_EMPTY};

	int rc;
	RESOLVE(path)
	debug(D_CONFUGA, "truncate(`%s', %" PRIuCONFUGA_OFF_T ")", unresolved_path, length);
	confuga_fid_t fid;
	confuga_off_t size;
	enum CONFUGA_FILE_TYPE type;
	CATCH(lookup(C, path, &fid, &size, &type));
	if (length > 0)
		CATCH(EINVAL);
	CATCH(update(C, path, empty, 0, 0));
	PROLOGUE
}
예제 #12
0
void
pdf_array_push(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
{
	RESOLVE(obj);
	if (!OBJ_IS_ARRAY(obj))
		fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));

	if (!item)
		item = PDF_OBJ_NULL;

	prepare_object_for_alteration(ctx, obj, item);
	if (ARRAY(obj)->len + 1 > ARRAY(obj)->cap)
		pdf_array_grow(ctx, ARRAY(obj));
	ARRAY(obj)->items[ARRAY(obj)->len] = pdf_keep_obj(ctx, item);
	ARRAY(obj)->len++;
}
예제 #13
0
CONFUGA_API int confuga_link(confuga *C, const char *target, const char *path)
{
	/* This deserves some explanation:
	 *
	 * Since the NM manages both the Confuga NS and the file metadata, the
	 * inode on the local file system contains all the file metadata and a
	 * pointer to file contents. So, when we create a link, we really want to
	 * have both entries point to the local file system inode.
	 *
	 * The inode also points to file data which includes the Confuga file ID.
	 * This would be an identifier for the content, not the metadata.
	 */
	int rc;
	RESOLVE(target);
	SIMPLE_WRAP_UNIX(link(target, path), "link(`%s', `%s')", unresolved_target, unresolved_path);
}
예제 #14
0
static INT64_T chirp_fs_local_open(const char *path, INT64_T flags, INT64_T mode)
{
    const char *unresolved = path;
    RESOLVE(path)
    INT64_T fd = getfd();
    if (fd == -1) return -1;
    mode &= S_IXUSR|S_IRWXG|S_IRWXO;
    mode |= S_IRUSR|S_IWUSR;
    INT64_T lfd = open64(path, flags, mode);
    if (lfd >= 0) {
        open_files[fd].fd = lfd;
        strcpy(open_files[fd].path, unresolved);
        return fd;
    } else {
        return -1;
    }
}
예제 #15
0
static INT64_T chirp_fs_local_open(const char *path, INT64_T flags, INT64_T mode)
{
	PREAMBLE("open(`%s', 0x%" PRIx64 ", 0o%" PRIo64 ")", path, flags, mode);
	const char *unresolved = path;
	RESOLVE(path)
	INT64_T fd = getfd();
	if (fd == -1) return -1;
	mode &= S_IXUSR|S_IRWXG|S_IRWXO;
	mode |= S_IRUSR|S_IWUSR;
	rc = open64(path, flags, (int) mode);
	if (rc >= 0) {
		open_files[fd].fd = rc;
		strcpy(open_files[fd].path, unresolved);
		rc = fd;
	}
	PROLOGUE
}
예제 #16
0
int fseeko64 (FILE *stream, __off64_t offset, int whence)
{
    int fd = fileno(stream);

    if (intercept[fd])
    {
	DEBUGF("fd=%d, offset=%s, whence=%d\n", fd, str_off_t(offset), whence);

	if (_intercept_seek(fd, offset, whence) < 0)
	    return EINVAL;

	return 0;
    }

    RESOLVE(fseeko64);
    return o_fseeko64(stream, offset, whence);
}
예제 #17
0
fz_obj *
fz_copy_dict(fz_context *ctx, fz_obj *obj)
{
	fz_obj *dict;
	int i, n;

	RESOLVE(obj);
	if (obj && obj->kind != FZ_DICT)
		fz_warn(ctx, "assert: not a dict (%s)", fz_objkindstr(obj));

	n = fz_dict_len(obj);
	dict = fz_new_dict(ctx, n);
	for (i = 0; i < n; i++)
		fz_dict_put(dict, fz_dict_get_key(obj, i), fz_dict_get_val(obj, i));

	return dict;
}
예제 #18
0
void
pdf_array_push(pdf_obj *obj, pdf_obj *item)
{
	RESOLVE(obj);

	if (!obj)
		return; /* Can't warn :( */
	if (obj->kind != PDF_ARRAY)
		fz_warn(obj->ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
	else
	{
		if (obj->u.a.len + 1 > obj->u.a.cap)
			pdf_array_grow(obj);
		obj->u.a.items[obj->u.a.len] = pdf_keep_obj(item);
		obj->u.a.len++;
	}
}
예제 #19
0
파일: pdf-object.c 프로젝트: muennich/mupdf
void
pdf_array_put(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *item)
{
	RESOLVE(obj);
	if (!OBJ_IS_ARRAY(obj))
		fz_throw(ctx, FZ_ERROR_GENERIC, "not an array (%s)", pdf_objkindstr(obj));
	if (i == ARRAY(obj)->len)
	{
		pdf_array_push(ctx, obj, item);
		return;
	}
	if (i < 0 || i > ARRAY(obj)->len)
		fz_throw(ctx, FZ_ERROR_GENERIC, "index out of bounds");
	prepare_object_for_alteration(ctx, obj, item);
	pdf_drop_obj(ctx, ARRAY(obj)->items[i]);
	ARRAY(obj)->items[i] = pdf_keep_obj(ctx, item);
}
예제 #20
0
void
pdf_dict_put_val_drop(fz_context *ctx, pdf_obj *obj, int i, pdf_obj *new_obj)
{
	RESOLVE(obj);
	if (!obj || obj->kind != PDF_DICT)
	{
		pdf_drop_obj(ctx, new_obj);
		return;
	}
	if (i < 0 || i >= obj->u.d.len)
	{
		/* FIXME: Should probably extend the dict here */
		pdf_drop_obj(ctx, new_obj);
		return;
	}
	pdf_drop_obj(ctx, obj->u.d.items[i].v);
	obj->u.d.items[i].v = new_obj;
}
예제 #21
0
void
pdf_array_delete(fz_context *ctx, pdf_obj *obj, int i)
{
	RESOLVE(obj);
	if (obj)
	{
		if (obj->kind != PDF_ARRAY)
			fz_warn(ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
		else
		{
			pdf_drop_obj(ctx, obj->u.a.items[i]);
			obj->u.a.items[i] = 0;
			obj->u.a.len--;
			memmove(obj->u.a.items + i, obj->u.a.items + i + 1, (obj->u.a.len - i) * sizeof(pdf_obj*));
		}
	}
	return; /* Can't warn :( */
}
예제 #22
0
fz_obj *
fz_copy_array(fz_context *ctx, fz_obj *obj)
{
	fz_obj *arr;
	int i;
	int n;

	RESOLVE(obj);
	if (!obj || obj->kind != FZ_ARRAY)
		fz_warn(ctx, "assert: not an array (%s)", fz_objkindstr(obj));

	arr = fz_new_array(ctx, fz_array_len(obj));
	n = fz_array_len(obj);
	for (i = 0; i < n; i++)
		fz_array_push(arr, fz_array_get(obj, i));

	return arr;
}
예제 #23
0
FILE *fopen64(const char *pathname, const char *mode)
{
    if (IS_SUPPORTED_URL(pathname))
    {
	int fd;
	FILE *ret = 0;

	DEBUGF("pathname=%s, mode=%s\n", pathname, mode);

	if ((fd = _intercept_open(pathname)) > 0)
	     ret = fdopen(fd, mode);

	return ret;
    }

    RESOLVE(fopen64);
    return o_fopen64(pathname, mode);
}
예제 #24
0
void
fz_array_insert(fz_obj *obj, fz_obj *item)
{
	RESOLVE(obj);

	if (!obj)
		return; /* Can't warn :( */
	if (obj->kind != FZ_ARRAY)
		fz_warn(obj->ctx, "assert: not an array (%s)", fz_objkindstr(obj));
	else
	{
		if (obj->u.a.len + 1 > obj->u.a.cap)
			fz_array_grow(obj);
		memmove(obj->u.a.items + 1, obj->u.a.items, obj->u.a.len * sizeof(fz_obj*));
		obj->u.a.items[0] = fz_keep_obj(item);
		obj->u.a.len++;
	}
}
예제 #25
0
void
pdf_array_put(pdf_obj *obj, int i, pdf_obj *item)
{
	RESOLVE(obj);

	if (!obj)
		return; /* Can't warn :( */
	if (obj->kind != PDF_ARRAY)
		fz_warn(obj->ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
	else if (i < 0)
		fz_warn(obj->ctx, "assert: index %d < 0", i);
	else if (i >= obj->u.a.len)
		fz_warn(obj->ctx, "assert: index %d > length %d", i, obj->u.a.len);
	else
	{
		pdf_drop_obj(obj->u.a.items[i]);
		obj->u.a.items[i] = pdf_keep_obj(item);
	}
}
예제 #26
0
pdf_obj *
pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
{
	pdf_document *doc;
	pdf_obj *dict;
	int i, n;

	RESOLVE(obj);
	if (!OBJ_IS_DICT(obj))
		fz_throw(ctx, FZ_ERROR_GENERIC, "not a dict (%s)", pdf_objkindstr(obj));

	doc = DICT(obj)->doc;
	n = pdf_dict_len(ctx, obj);
	dict = pdf_new_dict(ctx, doc, n);
	for (i = 0; i < n; i++)
		pdf_dict_put(ctx, dict, pdf_dict_get_key(ctx, obj, i), pdf_dict_get_val(ctx, obj, i));

	return dict;
}
예제 #27
0
int __lxstat64(int version, const char *file_name, struct stat64 *buf)
{
    if (IS_SUPPORTED_URL(file_name))
    {
	int fd;

	DEBUGF("version=%d, file_name=%s\n", version, file_name);

	if ((fd = _intercept_open(file_name)) < 0)
	    return -1;
	_intercept_stat(fd, buf);
	_intercept_close(fd);

	return 0;
    }

    RESOLVE(__lxstat64);
    return o___lxstat64(version, file_name, buf);
}
예제 #28
0
pdf_obj *
pdf_copy_dict(fz_context *ctx, pdf_obj *obj)
{
	pdf_obj *dict;
	int i, n;

	RESOLVE(obj);
	if (!obj)
		return NULL; /* Can't warn :( */
	if (obj->kind != PDF_DICT)
		fz_warn(ctx, "assert: not a dict (%s)", pdf_objkindstr(obj));

	n = pdf_dict_len(obj);
	dict = pdf_new_dict(ctx, n);
	for (i = 0; i < n; i++)
		fz_dict_put(dict, pdf_dict_get_key(obj, i), pdf_dict_get_val(obj, i));

	return dict;
}
예제 #29
0
void
pdf_array_push(fz_context *ctx, pdf_obj *obj, pdf_obj *item)
{
	RESOLVE(obj);
	if (obj)
	{
		if (obj->kind != PDF_ARRAY)
			fz_warn(ctx, "assert: not an array (%s)", pdf_objkindstr(obj));
		else
		{
			if (obj->u.a.len + 1 > obj->u.a.cap)
				pdf_array_grow(ctx, obj);
			obj->u.a.items[obj->u.a.len] = pdf_keep_obj(ctx, item);
			obj->u.a.len++;
		}

		object_altered(ctx, obj, item);
	}
	return; /* Can't warn :( */
}
예제 #30
0
pdf_obj *
pdf_copy_array(fz_context *ctx, pdf_obj *obj)
{
	pdf_obj *arr;
	int i;
	int n;

	RESOLVE(obj);
	if (!obj)
		return NULL; /* Can't warn :( */
	if (obj->kind != PDF_ARRAY)
		fz_warn(ctx, "assert: not an array (%s)", pdf_objkindstr(obj));

	arr = pdf_new_array(ctx, pdf_array_len(obj));
	n = pdf_array_len(obj);
	for (i = 0; i < n; i++)
		pdf_array_push(arr, pdf_array_get(obj, i));

	return arr;
}