⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uuid.c

📁 Lido PXA270平台开发板的最新BSP,包括源代码
💻 C
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
//  File:  uuid.c
//
//  This file implements the IOCTL_HAL_GET_UUID handler.
//
#include <windows.h>
#include <oal.h>

//------------------------------------------------------------------------------
//
//  Function:  OALIoCtlHalGetUUID
//
//  Implements the IOCTL_HAL_GET_UUID handler. This function fills in a 
//  GUID structure.
//
BOOL OALIoCtlHalGetUUID ( 
    UINT32 code, VOID *pInpBuffer, UINT32 inpSize, VOID *pOutBuffer, 
    UINT32 outSize, UINT32 *pOutSize
) {
    BOOL rc = FALSE;
    const GUID *pUuid;
    LPCSTR pDeviceId;

    // Check buffer size
    if (pOutSize != NULL) *pOutSize = sizeof(GUID);
    if (pOutBuffer == NULL || outSize < sizeof(GUID)) {
        NKSetLastError(ERROR_INSUFFICIENT_BUFFER);
        OALMSG(OAL_WARN, (L"WARN: OALIoCtlHalGetUUID: Buffer too small\r\n"));
        goto cleanUp;
    }

    // Does BSP specific UUID exist?
    pUuid = (const GUID *)OALArgsQuery(OAL_ARGS_QUERY_UUID);

    // try using device id if BSP specific UUID doesnt' exist
    if (pUuid == NULL) {
        pDeviceId = OALArgsQuery(OAL_ARGS_QUERY_DEVID);
        if (pDeviceId == NULL) {
            NKSetLastError(ERROR_NOT_SUPPORTED);
            OALMSG(OAL_WARN, (
                L"ERROR: OALIoCtlHalGetUUID: Device doesn't support UUID\r\n"
            ));
            goto cleanUp;
        }            

        // Use the last sizeof(GUID) bytes of the device id as GUID
        pUuid = (const GUID *)(pDeviceId + strlen(pDeviceId) - sizeof(GUID));
    }

    // Return good value
    memcpy(pOutBuffer, pUuid, sizeof(GUID));

    // Done
    rc = TRUE;

cleanUp:    
    return rc;
}

//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -