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

📄 loccore.cpp

📁 Windows CE 6.0 Server 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
BOOL LocationRegisterForReportIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::PSL_HANDLE hNewLocationReport,
    ce::PSL_HANDLE hStateChangeEvent, 
    MY_PSL_COPYIN_GUID pReportType,
    DWORD flags
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationRegisterForReport(0x%08x," SVSUTIL_GUID_FORMAT_W L") called\r\n",
                       hLocation,SVSUTIL_PGUID_ELEMENTS(pReportType)));
    DEBUGCHK(g_pLocLock->IsLocked());

    DWORD err;
    locOpenHandle_t *pLocHandle;

    if (flags != 0) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationRegisterForReport set flags = <0x%08x>, currently must be 0\r\n",flags));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    pLocHandle = g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation);
    if (!pLocHandle)
        return FALSE; // caller SetLastError()

    err = g_pPluginMgr->RegisterAppForReport(pReportType, pLocHandle, hNewLocationReport, hStateChangeEvent);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationRegisterForReport succeeded\r\n"));
    return TRUE;
}

BOOL LocationUnRegisterForReportIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    MY_PSL_COPYIN_GUID pReportType, 
    DWORD flags
) 
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationUnRegisterForReport(0x%08x," SVSUTIL_GUID_FORMAT_W L") called\r\n",
                       hLocation,SVSUTIL_PGUID_ELEMENTS(pReportType)));
    DEBUGCHK(g_pLocLock->IsLocked());

    DWORD err;
    locOpenHandle_t *pLocHandle;

    if (flags != 0) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationUnRegisterForReport set flags = <0x%08x>, currently must be 0\r\n",flags));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    pLocHandle = g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation);
    if (!pLocHandle)
        return FALSE; // caller SetLastError()

    err = g_pPluginMgr->UnRegisterAppForReport(pLocHandle,pReportType);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationUnRegisterForReport succeeded\r\n"));
    return TRUE;
}


BOOL LocationGetReportIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    MY_PSL_COPYIN_GUID pReportType, 
    DWORD maximumAge, 
    ce::marshal_arg<ce::copy_out,ce::psl_buffer_wrapper<BYTE*> > pLocationReportBuffer,
    ce::marshal_arg<ce::copy_in_out,DWORD*> pcbLocationReport, 
    DWORD flags
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationGetReport(0x%08x," SVSUTIL_GUID_FORMAT_W L", 0x%08x) called\r\n",
                       hLocation,SVSUTIL_PGUID_ELEMENTS(pReportType),maximumAge));
    DEBUGCHK(g_pLocLock->IsLocked());

    LOCATION_REPORT *pLocationReport = (LOCATION_REPORT *)(pLocationReportBuffer.buffer());
    DWORD err;

    reportCol_t *pRC;

    if (flags != 0) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationGetReport set flags = <0x%08x>, currently must be 0\r\n",flags));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (pcbLocationReport == NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationGetReport has pLocationReport and/or reportLen = NULL ptr\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    DEBUGCHK(pLocationReportBuffer.count() == *pcbLocationReport);

    if (!g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation))
        return FALSE; // caller SetLastError()

    pRC = g_pPluginMgr->FindRC(pReportType);
    if (! pRC) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: No plugin supports report type <" SVSUTIL_GUID_FORMAT_W L">\r\n",
                                SVSUTIL_PGUID_ELEMENTS(pReportType)));

        SetLastError(ERROR_DEV_NOT_EXIST);
        return FALSE;
    }

    err = pRC->GetReport(maximumAge, pLocationReport, pcbLocationReport);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationGetReport succeeded\r\n"));
    return TRUE;
}

BOOL LocationGetServiceStateIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::marshal_arg<ce::copy_out,LOCATION_SERVICE_STATE*> pServiceState
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationGetServiceState(0x%08x)\r\n",hLocation));
    DEBUGCHK(g_pLocLock->IsLocked());

    if (! g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation))
        return FALSE; // Caller SetLastError()

    if (pServiceState == NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationGetServiceState pointer is NULL\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    //
    // Fill in the structure
    //
    g_pPluginMgr->GetServiceState(pServiceState);

    DEBUGMSG(ZONE_API,(L"LOC: LocationGetServiceState succeeded\r\n"));
    return TRUE;
}

BOOL LocationGetPluginInfoForReportIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    MY_PSL_COPYIN_GUID pReportType, 
    ce::marshal_arg<ce::copy_out,PLUGIN_STATE *> pPluginState, 
    ce::marshal_arg<ce::copy_out,GUID *> pPluginGuid
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationGetPluginInfoForReport(0x%08x," SVSUTIL_GUID_FORMAT_W L") called\r\n",
                       hLocation,SVSUTIL_PGUID_ELEMENTS(pReportType)));
    DEBUGCHK(g_pLocLock->IsLocked());

    if (! g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation))
        return FALSE;

    if (pPluginState == NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationGetReportState pointer is NULL\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    *pPluginState = g_pPluginMgr->GetPluginInfoForReport(pReportType,pPluginGuid,FALSE);

    DEBUGMSG(ZONE_API,(L"LOC: LocationGetReportState suceeds.  Report type status is <0x%08x>\r\n",*pPluginState));
    return TRUE;
}

BOOL LocationGetProvidersInfoIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::marshal_arg<ce::copy_out,ce::psl_buffer_wrapper<BYTE*> > pProvidersBuffer,
    ce::marshal_arg<ce::copy_in_out,DWORD*> pcbBuffer
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationGetProvidersInfo(0x%08x)\r\n",hLocation));
    DEBUGCHK(g_pLocLock->IsLocked());

    PROVIDER_INFORMATION *pProviders = (PROVIDER_INFORMATION *)pProvidersBuffer.buffer();

    if (! g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation))
        return FALSE;

    if (pcbBuffer==NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: LocationGetProvidersInfo was passed a NULL for pcbBuffer\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (((*pcbBuffer)!= 0) && (pProviders==NULL)) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: LocationGetProvidersInfo was passed a NULL for pProviders but non zero buffer len\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    DWORD err = g_pPluginMgr->GetProvidersInfo(pProviders, pcbBuffer);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationGetProvidersInfo succeeded\r\n"));
    return TRUE;    
}

BOOL LocationGetResolversInfoIntrnl(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::marshal_arg<ce::copy_out,ce::psl_buffer_wrapper<BYTE*> > pResolversBuffer,
    ce::marshal_arg<ce::copy_in_out,DWORD*> pcbBuffer
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationGetResolversInfo(0x%08x)\r\n",hLocation));
    DEBUGCHK(g_pLocLock->IsLocked());

    RESOLVER_INFORMATION *pResolvers = (RESOLVER_INFORMATION *)pResolversBuffer.buffer();

    if (pcbBuffer==NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: LocationGetResolversInfo was passed a NULL for pcbBuffer\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (((*pcbBuffer)!= 0) && (pResolvers==NULL)) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: LocationGetResolversInfo was passed a NULL for pResolvers but non zero buffer len\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (! g_pHandleMgr->FindLocationHandle((HLOCATION)hLocation))
        return FALSE; // caller SetLastError()

    DWORD err = g_pPluginMgr->GetResolversInfo(pResolvers, pcbBuffer);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationGetResolversInfo succeeded\r\n"));
    return TRUE;
}

BOOL LocationPluginOpenIntrnl(
    serviceHandle_t *pServiceHandle, 
    HLOCATION hLocation, 
    const GUID *pPluginGuid, 
    HLOCATIONPLUGIN *phOutHandle
) 
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginOpen(0x%08x,0x%08x) called\r\n",hLocation,pPluginGuid));
    DEBUGCHK(g_pLocLock->IsLocked());

    if (pPluginGuid == NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationPluginOpen fails because pPluginGuid=NULL\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (phOutHandle == NULL) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: LocationPluginOpen fails because phOutHandle=NULL\r\n"));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    locOpenHandle_t *pLocHandle = g_pHandleMgr->FindLocationHandle(hLocation);
    if (! pLocHandle) 
        return FALSE; // Caller SetLastError()

    plugin_t *pPlugin = g_pPluginMgr->FindPlugin(pPluginGuid);
    if (NULL == pPlugin) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR:  LocationPluginOpen fails because GUID " SVSUTIL_GUID_FORMAT_W 
                             L" is not installed on system\r\n",SVSUTIL_PGUID_ELEMENTS(pPluginGuid)));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    SetLastError(0); // Reset last error code.

    HLOCATIONPLUGIN hPluginReturned = (HLOCATIONPLUGIN)pPlugin->CallIoctlOpen();
    if (hPluginReturned == 0) {
        if (GetLastError() == 0) {
            // Plugins should always set an error code here, but in case they 
            // don't we have to set one here so that apps don't get confused
            DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: PluginIoctlOpen did not set last error.  Setting ERROR_INTERNAL_ERROR for it\r\n"));
            SetLastError(ERROR_INTERNAL_ERROR);
            DEBUGCHK(0);
        }

        DEBUGMSG(ZONE_ERROR,(L"LOC: ERROR: PluginIoctlOpen call failed.  GLE=<0x%08x>\r\n",GetLastError()));
        return FALSE;
    }

    HLOCATIONPLUGIN hPlugin = g_pHandleMgr->AllocPluginHandle(pLocHandle,pPlugin,hPluginReturned);
    if (hPlugin == 0) { // Caller SetLastError()
        pPlugin->CallIoctlClose(hPluginReturned);
        g_pHandleMgr->FreePluginHandle(hPluginReturned);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginOpen succeeded, pluginHandle = <0x%08x>\r\n",hPlugin));
    *phOutHandle = hPlugin;
    return TRUE;
}

BOOL LocationPluginOpenPSL(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    MY_PSL_COPYIN_GUID pPluginGuid, 
    ce::marshal_arg<ce::copy_out,ce::PSL_HANDLE *> phOutHandle
) 
{
    return LocationPluginOpenIntrnl(pServiceHandle, (HLOCATION)hLocation, pPluginGuid, (HLOCATIONPLUGIN*)((ce::PSL_HANDLE *)phOutHandle));
}


BOOL LocationPluginIOCTLIntrnl(
    serviceHandle_t *pServiceHandle, 
    HLOCATION hLocation, 
    HLOCATIONPLUGIN hPlugin, 
    DWORD dwCode,
    BYTE* pbIn,
    DWORD cbIn,
    BYTE* pbOut,
    DWORD* pcbOut
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginIOCTL(0x%08x,0x%08x,0x%08x) called\r\n",hLocation,hPlugin,dwCode));
    DEBUGCHK(g_pLocLock->IsLocked());

    if (dwCode < IOCTL_LOCATION_PLUGIN_USER) {
        DEBUGMSG(ZONE_ERROR,(L"LOC: LocationPluginIOCTL passed IOCTL code <0x%08x>, less than <%d>.  This range is reserved for LF direct generation\r\n",
                 dwCode,IOCTL_LOCATION_PLUGIN_USER));
        SetLastError(ERROR_INVALID_PARAMETER);
        return FALSE;
    }

    if (! g_pHandleMgr->FindLocationHandle(hLocation)) 
        return FALSE; // Caller SetLastError()

    pluginHandle_t *pPluginHandle = g_pHandleMgr->FindPluginHandle(hPlugin);
    if (! pPluginHandle) 
        return FALSE; // Caller SetLastError()

    plugin_t *pPlugin = pPluginHandle->GetPlugin();
    DWORD err = pPlugin->CallIoctlCall(pPluginHandle->GetBaseHandle(),dwCode, pbIn, 
                                       cbIn, pbOut, pcbOut);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginIOCTL succeeded\r\n"));
    return TRUE;
}

BOOL LocationPluginIOCTLPSL(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::PSL_HANDLE hPlugin, 
    DWORD dwCode,
    ce::marshal_arg<ce::copy_in,ce::psl_buffer_wrapper<BYTE*> > pbIn,
    ce::marshal_arg<ce::copy_out,ce::psl_buffer_wrapper<BYTE*> > pbOut,
    ce::marshal_arg<ce::copy_in_out,DWORD*> pcbOut
)
{
    return LocationPluginIOCTLIntrnl(pServiceHandle, (HLOCATION)hLocation, 
                                    (HLOCATIONPLUGIN)hPlugin, dwCode, 
                                     pbIn.buffer(),pbIn.count(),pbOut.buffer(),pcbOut);
}

BOOL LocationPluginCloseIntrnl(
    serviceHandle_t *pServiceHandle, 
    HLOCATION hLocation, 
    HLOCATIONPLUGIN hPlugin
)
{
    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginClose(0x%08x,0x%08x) called\r\n",hLocation,hPlugin));
    DEBUGCHK(g_pLocLock->IsLocked());

    if (! g_pHandleMgr->FindLocationHandle(hLocation)) 
        return FALSE;  // Caller SetLastError()

    pluginHandle_t *pPluginHandle = g_pHandleMgr->FindPluginHandle(hPlugin);
    if (! pPluginHandle) 
        return FALSE; // Caller SetLastError()

    plugin_t *pPlugin = pPluginHandle->GetPlugin();
    DWORD err = pPlugin->CallIoctlClose(pPluginHandle->GetBaseHandle());

    g_pHandleMgr->FreePluginHandle((HLOCATIONPLUGIN)hPlugin);

    if (err != ERROR_SUCCESS) {
        SetLastError(err);
        return FALSE;
    }

    DEBUGMSG(ZONE_API,(L"LOC: LocationPluginClose succeeded\r\n"));
    return TRUE;
}

BOOL LocationPluginClosePSL(
    serviceHandle_t *pServiceHandle, 
    ce::PSL_HANDLE hLocation, 
    ce::PSL_HANDLE hPlugin
)
{
    return LocationPluginCloseIntrnl(pServiceHandle,(HLOCATION)hLocation,
                                     (HLOCATIONPLUGIN)hPlugin);
}

⌨️ 快捷键说明

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