(file) Return to nitsdll.cpp CVS log (file) (dir) Up to [OMI] / omi / nits / base

File: [OMI] / omi / nits / base / nitsdll.cpp (download)
Revision: 1.1, Mon Apr 20 17:19:53 2015 UTC (9 years, 2 months ago) by krisbash
Branch: MAIN
CVS Tags: OMI_1_0_8_2, OMI_1_0_8_1, HEAD
OMI 1.0.8-1

//*****************************************************************************
//  Copyright (C) 2007 Microsoft Corporation
//  All rights reserved.
//*****************************************************************************

#include "Globals.h"
#ifdef _MSC_VER
    #include <nitsdll.tmh>
#endif

#include <pal/lock.h>

namespace TestSystem
{

//This object sets up internal cross-process structures automatically.
//No other action is necessary beyond linking to this DLL.
System System::s_system;

NITS_EXPORT DWORD Initialize(_In_z_ const PAL_Char * name,
                 _In_reads_bytes_(bytes) void const *context,
                 _Outptr_result_bytebuffer_(bytes) void **shared,
                 long bytes)
{
    static Lock s_spinlock = LOCK_INITIALIZER;

    Lock_Acquire(&s_spinlock);

    DWORD error = 0;

    Mapping &m = System::GetInstance().GetMapping(name);
    error = m.Initialize(context, bytes);
    *shared = m.m_data;

    Lock_Release(&s_spinlock);
    return error;
}

NITS_EXPORT DWORD GetFaultWin32()
{
    return WIN32_FROM_HRESULT(GetGlobals().GetFaultError());
}

}//namespace TestSystem

ViewCVS 0.9.2