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

📄 uuid.c

📁 Windows CE 6.0 BSP for VOIPAC Board (PXA270) Version 2b.
💻 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;
    static const GUID guidPattern = {0x600cc7d0, 0xde3a, 0x4713, {
        0xa5, 0xb0, 0x56, 0xe, 0x6c, 0x36, 0x4e, 0xde 
    }};
    GUID *pUuid;
    LPCSTR pDeviceId;
    UINT32 length;

    // 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 = OALArgsQuery(OAL_ARGS_QUERY_UUID);
    if (pUuid != NULL) {

        // It does, copy it as return value
        memcpy(pOutBuffer, pUuid, sizeof(GUID));

    } else {

        // Try to generate GUID from device id...
        pDeviceId = OALArgsQuery(OAL_ARGS_QUERY_DEVID);
        if (pDeviceId == NULL) {
            NKSetLastError(ERROR_NOT_SUPPORTED);
            OALMSG(OAL_ERROR, (
                L"ERROR: OALIoCtlHalGetUUID: Device doesn't support UUID\r\n"
            ));
            goto cleanUp;
        }

        // How many chars/bytes will be used from device id
        length = strlen(pDeviceId);
        if (length < sizeof(GUID)) {
            // Use pattern
            memcpy(pOutBuffer, &guidPattern, sizeof(GUID) - length);
            (UINT8*)pOutBuffer += sizeof(GUID) - length;
        }
        // Copy deviceId as rest of GUID
        memcpy(pOutBuffer, pDeviceId, length);
        
    }

    // Done
    rc = TRUE;

cleanUp:
    return rc;
}

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

⌨️ 快捷键说明

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