• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ InitializeSecurityDescriptor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中InitializeSecurityDescriptor函数的典型用法代码示例。如果您正苦于以下问题:C++ InitializeSecurityDescriptor函数的具体用法?C++ InitializeSecurityDescriptor怎么用?C++ InitializeSecurityDescriptor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了InitializeSecurityDescriptor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _CreateFile

HANDLE _CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile )
{
	SECURITY_DESCRIPTOR sd;
	SECURITY_ATTRIBUTES sa;
	 
	memset(&sd,0,sizeof(sd));
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	memset(&sa,0,sizeof(sa));
	sa.nLength=sizeof(sa);
	sa.lpSecurityDescriptor=&sd;

	return ::CreateFile( lpFileName, dwDesiredAccess, dwShareMode, &sa, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile );
}
开发者ID:epgdatacapbon,项目名称:BonDriver_PT3-ST,代码行数:14,代码来源:Util.cpp


示例2: InitBranding

int InitBranding() {
    char *s;
    s = (char *)GlobalAlloc(GPTR,lstrlen(EXENAME)+10);
    wsprintf(s,"%s /version",EXENAME);
    {
        STARTUPINFO si= {sizeof(si),};
        SECURITY_ATTRIBUTES sa= {sizeof(sa),};
        SECURITY_DESCRIPTOR sd= {0,};
        PROCESS_INFORMATION pi= {0,};
        HANDLE newstdout=0,read_stdout=0;

        OSVERSIONINFO osv= {sizeof(osv)};
        GetVersionEx(&osv);
        if (osv.dwPlatformId == VER_PLATFORM_WIN32_NT) {
            InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
            SetSecurityDescriptorDacl(&sd,true,NULL,false);
            sa.lpSecurityDescriptor = &sd;
        }
        else sa.lpSecurityDescriptor = NULL;
        sa.bInheritHandle = true;
        if (!CreatePipe(&read_stdout,&newstdout,&sa,0)) {
            return 0;
        }
        GetStartupInfo(&si);
        si.dwFlags = STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
        si.wShowWindow = SW_HIDE;
        si.hStdOutput = newstdout;
        si.hStdError = newstdout;
        if (!CreateProcess(NULL,s,NULL,NULL,TRUE,CREATE_NEW_CONSOLE,NULL,NULL,&si,&pi)) {
            CloseHandle(newstdout);
            CloseHandle(read_stdout);
            return 0;
        }
        char szBuf[1024];
        DWORD dwRead = 1;
        DWORD dwExit = !STILL_ACTIVE;
        if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
            return 0;
        }
        ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
        szBuf[dwRead] = 0;
        if (lstrlen(szBuf)==0) return 0;
        g_sdata.branding = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+6);
        wsprintf(g_sdata.branding,"NSIS %s",szBuf);
        g_sdata.brandingv = (char *)GlobalAlloc(GPTR,lstrlen(szBuf)+1);
        lstrcpy(g_sdata.brandingv,szBuf);
        GlobalFree(s);
    }
    return 1;
}
开发者ID:kichik,项目名称:nsis-1,代码行数:50,代码来源:utils.cpp


示例3: SetTokenObjectIntegrityLevel

static void SetTokenObjectIntegrityLevel(DWORD dwIntegrityLevel)
{
    SID_IDENTIFIER_AUTHORITY Sia = SECURITY_MANDATORY_LABEL_AUTHORITY;
    SECURITY_DESCRIPTOR sd;
    HANDLE hToken;
    DWORD dwLength;
    PACL pAcl;
    PSID pSid;

    // Do nothing on OSes where mandatory ACEs are not supported
    if(pfnAddMandatoryAce == NULL)
        return;

    // Initialize blank security descriptor
    if(!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
        return;

    // Allocate mandatory label SID
    if(!AllocateAndInitializeSid(&Sia, 1, dwIntegrityLevel, 0, 0, 0, 0, 0, 0, 0, &pSid))
        return;

    // Open current token
    if(!OpenThreadToken(GetCurrentThread(), WRITE_OWNER, TRUE, &hToken))
    {
        if(GetLastError() == ERROR_NO_TOKEN)
            OpenProcessToken(GetCurrentProcess(), WRITE_OWNER, &hToken);
    }
    
    // If succeeded, set the integrity level
    if(hToken != NULL)
    {
        // Create ACL
        dwLength = sizeof(ACL) + sizeof(SYSTEM_MANDATORY_LABEL_ACE) - sizeof(DWORD) + GetLengthSid(pSid);
        pAcl = (PACL)HeapAlloc(g_hHeap, 0, dwLength);
        if(pAcl != NULL)
        {
            if(InitializeAcl(pAcl, dwLength, ACL_REVISION))
            {
                if(pfnAddMandatoryAce(pAcl, ACL_REVISION, 0, SYSTEM_MANDATORY_LABEL_NO_WRITE_UP, pSid))
                {
                    NtSetSecurityObject(hToken, LABEL_SECURITY_INFORMATION, &sd);
                }
            }

            HeapFree(g_hHeap, 0, pAcl);
        }
    }

    FreeSid(pSid);
}
开发者ID:transformersprimeabcxyz,项目名称:FileTest,代码行数:50,代码来源:WinMain.cpp


示例4: init_security_attributes_allow_all

bool
init_security_attributes_allow_all (struct security_attributes *obj)
{
  CLEAR (*obj);

  obj->sa.nLength = sizeof (SECURITY_ATTRIBUTES);
  obj->sa.lpSecurityDescriptor = &obj->sd;
  obj->sa.bInheritHandle = TRUE;
  if (!InitializeSecurityDescriptor (&obj->sd, SECURITY_DESCRIPTOR_REVISION))
    return false;
  if (!SetSecurityDescriptorDacl (&obj->sd, TRUE, NULL, FALSE))
    return false;
  return true;
}
开发者ID:AVESH-RAI,项目名称:guizmovpn,代码行数:14,代码来源:openvpnserv.c


示例5: _CreateFileMapping

HANDLE _CreateFileMapping( HANDLE hFile, DWORD flProtect, DWORD dwMaximumSizeHigh, DWORD dwMaximumSizeLow, LPCTSTR lpName)
{
	SECURITY_DESCRIPTOR sd;
	SECURITY_ATTRIBUTES sa;
	 
	memset(&sd,0,sizeof(sd));
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	memset(&sa,0,sizeof(sa));
	sa.nLength=sizeof(sa);
	sa.lpSecurityDescriptor=&sd;

	return ::CreateFileMapping( hFile, &sa, flProtect, dwMaximumSizeHigh, dwMaximumSizeLow, lpName);
}
开发者ID:ACUVE,项目名称:EDCB,代码行数:14,代码来源:Util.cpp


示例6: _CreateNamedPipe

HANDLE _CreateNamedPipe( LPCTSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut )
{
	SECURITY_DESCRIPTOR sd;
	SECURITY_ATTRIBUTES sa;
	 
	memset(&sd,0,sizeof(sd));
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	memset(&sa,0,sizeof(sa));
	sa.nLength=sizeof(sa);
	sa.lpSecurityDescriptor=&sd;

	return ::CreateNamedPipe( lpName, dwOpenMode, dwPipeMode, nMaxInstances, nOutBufferSize, nInBufferSize, nDefaultTimeOut, &sa );
}
开发者ID:ACUVE,项目名称:EDCB,代码行数:14,代码来源:Util.cpp


示例7: CreateBannerInstanceMutex

// Для запуска только одного экземпляра банера 
// создаем мютекс.Если он уже создан - значит 
// уже банерная часть уже загружена и работает.
HANDLE CreateBannerInstanceMutex()
{
  SECURITY_ATTRIBUTES sa;
  SECURITY_DESCRIPTOR sd;

  InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
  SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
  
  sa.nLength = sizeof (SECURITY_ATTRIBUTES);
  sa.lpSecurityDescriptor = &sd;
  sa.bInheritHandle = FALSE;

  return ::CreateMutex(&sa, FALSE, L"Global\\DCCFF93F3ACC4B2F8B4957A6A47D7DFE");
}
开发者ID:12019,项目名称:Carberp,代码行数:17,代码来源:banner.cpp


示例8: CreateStartedEvent

HANDLE CreateStartedEvent()
{
  SECURITY_ATTRIBUTES sa;
  SECURITY_DESCRIPTOR sd;

  InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
  SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
  
  sa.nLength = sizeof (SECURITY_ATTRIBUTES);
  sa.lpSecurityDescriptor = &sd;
  sa.bInheritHandle = FALSE;

  return ::CreateEvent(&sa, TRUE, FALSE, L"Global\\CC64BD66BCA1444C86FC0D8019E381E9");
}
开发者ID:12019,项目名称:Carberp,代码行数:14,代码来源:banner.cpp


示例9: _CreateMutex

HANDLE _CreateMutex( BOOL bInitialOwner, LPCTSTR lpName )
{
	SECURITY_DESCRIPTOR sd;
	SECURITY_ATTRIBUTES sa;
	 
	memset(&sd,0,sizeof(sd));
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	memset(&sa,0,sizeof(sa));
	sa.nLength=sizeof(sa);
	sa.lpSecurityDescriptor=&sd;

	return ::CreateMutex( &sa, bInitialOwner, lpName );
}
开发者ID:epgdatacapbon,项目名称:BonDriver_PT3-ST,代码行数:14,代码来源:Util.cpp


示例10: isc_fsaccess_changeowner

isc_result_t
isc_fsaccess_changeowner(const char *filename, const char *user) {
    SECURITY_DESCRIPTOR psd;
    BYTE sidBuffer[500];
    BYTE groupBuffer[500];
    PSID psid=(PSID) &sidBuffer;
    DWORD sidBufferSize = sizeof(sidBuffer);
    char domainBuffer[100];
    DWORD domainBufferSize = sizeof(domainBuffer);
    SID_NAME_USE snu;
    PSID pSidGroup = (PSID) &groupBuffer;
    DWORD groupBufferSize = sizeof(groupBuffer);


    /*
     * Determine if this is a FAT or NTFS disk and
     * call the appropriate function to set the ownership
     * FAT disks do not have ownership attributes so it's
     * a noop.
     */
    if (is_ntfs(filename) == FALSE)
        return (ISC_R_SUCCESS);

    if (!InitializeSecurityDescriptor(&psd, SECURITY_DESCRIPTOR_REVISION))
        return (ISC_R_NOPERM);

    if (!LookupAccountName(0, user, psid, &sidBufferSize, domainBuffer,
                           &domainBufferSize, &snu))
        return (ISC_R_NOPERM);

    /* Make sure administrators can get to it */
    domainBufferSize = sizeof(domainBuffer);
    if (!LookupAccountName(0, "Administrators", pSidGroup,
                           &groupBufferSize, domainBuffer, &domainBufferSize, &snu))
        return (ISC_R_NOPERM);

    if (!SetSecurityDescriptorOwner(&psd, psid, FALSE))
        return (ISC_R_NOPERM);

    if (!SetSecurityDescriptorGroup(&psd, pSidGroup, FALSE))
        return (ISC_R_NOPERM);

    if (!SetFileSecurity(filename,
                         OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
                         &psd))
        return (ISC_R_NOPERM);

    return (ISC_R_SUCCESS);
}
开发者ID:ryo,项目名称:netbsd-src,代码行数:49,代码来源:fsaccess.c


示例11: VBoxIPCInit

/**
 * Initializes the IPC communication.
 *
 * @return  IPRT status code.
 * @param   pEnv                        The IPC service's environment.
 * @param   ppInstance                  The instance pointer which refer to this object.
 * @param   pfStartThread               Pointer to flag whether the IPC service can be started or not.
 */
int VBoxIPCInit(const VBOXSERVICEENV *pEnv, void **ppInstance, bool *pfStartThread)
{
    Log(("VBoxTray: VBoxIPCInit\n"));

    *pfStartThread = false;
    gCtx.pEnv = pEnv;

    int rc = VINF_SUCCESS;
    SECURITY_ATTRIBUTES sa;
    sa.lpSecurityDescriptor = (PSECURITY_DESCRIPTOR)RTMemAlloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
    if (!sa.lpSecurityDescriptor)
        rc = VERR_NO_MEMORY;
    else
    {
        if (!InitializeSecurityDescriptor(sa.lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION))
            rc = RTErrConvertFromWin32(GetLastError());
        else
        {
            if (!SetSecurityDescriptorDacl(sa.lpSecurityDescriptor, TRUE, (PACL)0, FALSE))
                rc = RTErrConvertFromWin32(GetLastError());
            else
            {
                sa.nLength = sizeof(sa);
                sa.bInheritHandle = TRUE;
            }
        }

        if (RT_SUCCESS(rc))
        {
            gCtx.hPipe = CreateNamedPipe((LPSTR)VBOXTRAY_PIPE_IPC,
                                         PIPE_ACCESS_DUPLEX,
                                         PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT,
                                         PIPE_UNLIMITED_INSTANCES,
                                         VBOXTRAY_PIPE_IPC_BUFSIZE, /* Output buffer size. */
                                         VBOXTRAY_PIPE_IPC_BUFSIZE, /* Input buffer size. */
                                         NMPWAIT_USE_DEFAULT_WAIT,
                                         &sa);
            if (gCtx.hPipe == INVALID_HANDLE_VALUE)
                rc = RTErrConvertFromWin32(GetLastError());
            else
            {
                *pfStartThread = true;
                *ppInstance = &gCtx;
            }
        }
        RTMemFree(sa.lpSecurityDescriptor);
    }
    return rc;
}
开发者ID:CandyYao,项目名称:VirtualBox-OSE,代码行数:57,代码来源:VBoxIPC.cpp


示例12: AllocateAndInitializeSid

SECURITY_ATTRIBUTES SecurDescr::CreateSID()
{
	SID_IDENTIFIER_AUTHORITY SIDAuthWorld = SECURITY_WORLD_SID_AUTHORITY;
    SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY;
	AllocateAndInitializeSid(&SIDAuthWorld, 1,
                     SECURITY_WORLD_RID,
                     0, 0, 0, 0, 0, 0, 0,
                     &pEveryoneSID);
	ZeroMemory(ea, 2 * sizeof(EXPLICIT_ACCESS));
    ea[0].grfAccessPermissions = FILE_GENERIC_READ | FILE_GENERIC_WRITE | SYNCHRONIZE;
    ea[0].grfAccessMode = SET_ACCESS;
    ea[0].grfInheritance= NO_INHERITANCE;
    ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
    ea[0].Trustee.TrusteeType = TRUSTEE_IS_WELL_KNOWN_GROUP;
    ea[0].Trustee.ptstrName  = (LPTSTR) pEveryoneSID;

	AllocateAndInitializeSid(&SIDAuthNT, 2,
                     SECURITY_BUILTIN_DOMAIN_RID,
                     DOMAIN_ALIAS_RID_ADMINS,
                     0, 0, 0, 0, 0, 0,
                     &pAdminSID);

	ea[1].grfAccessPermissions = FILE_GENERIC_READ | FILE_GENERIC_WRITE | SYNCHRONIZE;
    ea[1].grfAccessMode = SET_ACCESS;
    ea[1].grfInheritance= NO_INHERITANCE;
    ea[1].Trustee.TrusteeForm = TRUSTEE_IS_SID;
    ea[1].Trustee.TrusteeType = TRUSTEE_IS_GROUP;
    ea[1].Trustee.ptstrName  = (LPTSTR) pAdminSID;

	SetEntriesInAcl(2, ea, NULL, &pACL);

	pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, 
                             SECURITY_DESCRIPTOR_MIN_LENGTH);

	InitializeSecurityDescriptor(pSD,
            SECURITY_DESCRIPTOR_REVISION);

	SetSecurityDescriptorDacl(pSD, 
            TRUE,     // bDaclPresent flag   
            pACL, 
            FALSE);

	sa.nLength = sizeof (SECURITY_ATTRIBUTES);
    sa.lpSecurityDescriptor = pSD;
    sa.bInheritHandle = FALSE;

	return sa;
}
开发者ID:angelAMSoft,项目名称:MyProjects,代码行数:48,代码来源:SecurDescr.cpp


示例13: CreateIpcTable

int
CreateIpcTable()
{
/*2000.9.4 add---------------------------------------------------------------*/
	SECURITY_ATTRIBUTES	FileMappingAttributes;
	SECURITY_DESCRIPTOR	SecuDesc;
#ifdef	TERMINAL_SERVICE
	char	*evtname;
#endif	/* TERMINAL_SERVICE */

	InitializeSecurityDescriptor( &SecuDesc, SECURITY_DESCRIPTOR_REVISION );
	SetSecurityDescriptorDacl( &SecuDesc, TRUE, NULL, FALSE );
	FileMappingAttributes.nLength = sizeof(FileMappingAttributes);
l_ipclog("[ipcd] CreateIpcTable, FileMappingAttributes.nLength	= %d\n", FileMappingAttributes.nLength);
	FileMappingAttributes.lpSecurityDescriptor = &SecuDesc;
/*2000.9.4 end---------------------------------------------------------------*/

#ifdef	TERMINAL_SERVICE
	if( osvi.dwMajorVersion >= 5 )	/* Windows 2000 */
		evtname = "Global\\ipct";
	else
		evtname = "ipct";
#endif	/* TERMINAL_SERVICE */

	/*2000.9.4 change. NULL -> &FileMappingAttributes */
	hIpc=CreateFileMapping( (HANDLE)0xFFFFFFFF, &FileMappingAttributes,
#ifdef	TERMINAL_SERVICE
		PAGE_READWRITE,	0, sizeof(IPCT), evtname );
#else
		PAGE_READWRITE,	0, sizeof(IPCT), "ipct" );
#endif	/* TERMINAL_SERVICE */
	if (hIpc==NULL)
	{
		errno=GetLastError();
		return -1;
	}

	ipct=(IPCT *)MapViewOfFile(hIpc, FILE_MAP_ALL_ACCESS, 0, 0, 0);
	if (ipct==NULL)
	{
		errno=GetLastError();
		return -1;
	}

	InitIPCT();

	return 0;
}
开发者ID:nawhizz,项目名称:KAIT,代码行数:48,代码来源:ipcd.c


示例14: _CreateFile

HANDLE _CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile )
{
	SECURITY_DESCRIPTOR sd;
	SECURITY_ATTRIBUTES sa;
	 
	memset(&sd,0,sizeof(sd));
	InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	memset(&sa,0,sizeof(sa));
	sa.nLength=sizeof(sa);
	sa.lpSecurityDescriptor=&sd;
/*
	PACL                pDacl;
	EXPLICIT_ACCESS     explicitAccess[3];
	SECURITY_ATTRIBUTES sa;
	SECURITY_DESCRIPTOR sd;

	InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);

	BuildExplicitAccessWithName(&explicitAccess[0], TEXT("SYSTEM"), FILE_ALL_ACCESS, GRANT_ACCESS, 0);
	BuildExplicitAccessWithName(&explicitAccess[1], TEXT("Administrators"), FILE_ALL_ACCESS, GRANT_ACCESS, 0);
	BuildExplicitAccessWithName(&explicitAccess[2], TEXT("Everyone"), FILE_ALL_ACCESS, GRANT_ACCESS, 0);
	SetEntriesInAcl(3, explicitAccess, NULL, &pDacl);

	SetSecurityDescriptorDacl(&sd, TRUE, pDacl, FALSE);

	sa.nLength              = sizeof(SECURITY_ATTRIBUTES);
	sa.lpSecurityDescriptor = &sd;
	sa.bInheritHandle       = FALSE;
*/
	HANDLE hFile =  ::CreateFile( lpFileName, dwDesiredAccess, dwShareMode, &sa, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile );
	if( hFile == INVALID_HANDLE_VALUE ){
		TCHAR* p = (TCHAR*)_tcsrchr(lpFileName, '\\');
		TCHAR* szDirPath = NULL;
		if( p != NULL ){
			int iSize = (int)(p - lpFileName);
			szDirPath = new TCHAR[iSize+1];
			_tcsncpy_s(szDirPath, iSize+1, lpFileName, iSize);
		}
		if( szDirPath != NULL ){
			_CreateDirectory(szDirPath);
			delete[] szDirPath;
			hFile =  ::CreateFile( lpFileName, dwDesiredAccess, dwShareMode, &sa, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile );
		}
	}
	return hFile;
}
开发者ID:HK323232,项目名称:EDCB,代码行数:47,代码来源:Util.cpp


示例15: GetNamedPipeHandle

HANDLE GetNamedPipeHandle()
{
	SECURITY_DESCRIPTOR sd = {0};
	InitializeSecurityDescriptor(&sd, 1);
	SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
	SECURITY_ATTRIBUTES sa = {0};
	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.lpSecurityDescriptor = &sd;
	sa.bInheritHandle = NULL;
	
	HANDLE h = CreateFile(TEXT("\\\\.\\pipe\\acsipc_server"), 0xC0000000, 3, 
		&sa, 3, 0x80000080, NULL);
	if(h != (HANDLE)-1 )
		return h;

	return NULL;
}
开发者ID:AlanWatts,项目名称:Exploit,代码行数:17,代码来源:exploit.cpp


示例16: XL_INFO_FUNCTION

bool RegKeyDaclAquireRestore::Aquire(HKEY hRootKey, LPCTSTR lpszSubKey)
{
    XL_INFO_FUNCTION();

    Backup(hRootKey, lpszSubKey);

    HKEY hKey = nullptr;

    LSTATUS lRes = RegOpenKeyEx(hRootKey,
                                lpszSubKey,
                                0,
                                WRITE_DAC,
                                &hKey);

    if (lRes != ERROR_SUCCESS || hKey == nullptr)
    {
        XL_ERROR(_T("Failed to open key with WRITE_DAC access. Key: %s."), lpszSubKey);
        return false;
    }

    XL_ON_BLOCK_EXIT(RegCloseKey, hKey);

    SECURITY_DESCRIPTOR sd = {};

    if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION))
    {
        XL_ERROR(_T("Failed to initialize security descriptor."));
        return false;
    }

    if (!SetSecurityDescriptorDacl(&sd, FALSE, nullptr, FALSE))
    {
        XL_ERROR(_T("Failed to clear DACL in security descriptor."));
        return false;
    }

    lRes = RegSetKeySecurity(hKey, DACL_SECURITY_INFORMATION, &sd);

    if (lRes != ERROR_SUCCESS)
    {
        XL_ERROR(_T("Failed to set DACL to Key: %s."), lpszSubKey);
        return false;
    }

    return true;
}
开发者ID:sftt,项目名称:MSPYForever,代码行数:46,代码来源:RegKeyPrivilege.cpp


示例17: CreateRegistryKey

// Creates a key specified by pszSubKey - you can't create
// keys directly under HKEY_LOCAL_MACHINE in Windows NT or 2000
// just for an extra bit of info.
bool CreateRegistryKey(HKEY hKeyRoot, LPCTSTR pszSubKey)
{
    HKEY hKey;
    DWORD dwFunc;
    LONG  lRet;

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

    SECURITY_DESCRIPTOR SD;
    SECURITY_ATTRIBUTES SA;

    if(!InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION))
        return false;

    if(!SetSecurityDescriptorDacl(&SD, true, 0, false))
        return false;

    SA.nLength             = sizeof(SA);
    SA.lpSecurityDescriptor = &SD;
    SA.bInheritHandle      = false;

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

    lRet = RegCreateKeyEx(
        hKeyRoot,
        pszSubKey,
        0,
        (LPTSTR)NULL,
        REG_OPTION_NON_VOLATILE,
        KEY_WRITE,
        &SA,
        &hKey,
        &dwFunc
    );

    if(lRet == ERROR_SUCCESS)
    {
        RegCloseKey(hKey);
        hKey = (HKEY)NULL;
        return true;
    }

    SetLastError((DWORD)lRet);
    return false;
}
开发者ID:sd-eblana,项目名称:bawx,代码行数:48,代码来源:Registry.cpp


示例18: mmf_init

void mmf_init()
{
#ifndef MY_DEBUG
    printf("1\n");
#endif

    SECURITY_DESCRIPTOR    sd;
    InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&sd, TRUE, (PACL)NULL, FALSE);

    SECURITY_ATTRIBUTES sa;
    sa.nLength = sizeof(SECURITY_ATTRIBUTES);
    sa.bInheritHandle = TRUE;
    sa.lpSecurityDescriptor = &sd;



    hEvent = CreateEvent( &sa, 0, 0, "MYMESSAGE");

    hMap = CreateFileMapping( (HANDLE)-1, // Paging 화일을 사용해서 매핑
                              &sa, PAGE_READWRITE, 0, sizeof(PACKET), "mymmf");


    if ( hMap == 0 )
    {
        MessageBox( 0, "Fail", "", MB_OK);
        return ;
    }
#ifndef MY_DEBUG
    printf("%d\n",hMap);
    printf("%d\r\n",hEvent);
#endif
    pData = (PACKET*)MapViewOfFile( hMap, FILE_MAP_WRITE, 0, 0,0);

    if ( pData == 0 )
    {
        MessageBox( 0, "Fail", "", MB_OK);
        return ;
    }

#ifndef MY_DEBUG
    printf("2");
#endif

}
开发者ID:gawallsibya,项目名称:BIT_API-WNP-WSP,代码行数:45,代码来源:myservice.cpp


示例19: BOOST_LOG_ONCE_BLOCK

    BOOST_LOG_ONCE_BLOCK()
    {
        if (!InitializeSecurityDescriptor(&g_unrestricted_security_descriptor, SECURITY_DESCRIPTOR_REVISION))
        {
            DWORD err = GetLastError();
            BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to initialize security descriptor", (err));
        }

        if (!SetSecurityDescriptorDacl(&g_unrestricted_security_descriptor, TRUE, NULL, FALSE))
        {
            DWORD err = GetLastError();
            BOOST_LOG_THROW_DESCR_PARAMS(system_error, "Failed to set null DACL to a security descriptor", (err));
        }

        g_unrestricted_security_attributes.nLength = sizeof(g_unrestricted_security_attributes);
        g_unrestricted_security_attributes.lpSecurityDescriptor = &g_unrestricted_security_descriptor;
        g_unrestricted_security_attributes.bInheritHandle = FALSE;
    }
开发者ID:LocutusOfBorg,项目名称:poedit,代码行数:18,代码来源:permissions.cpp


示例20: memset

ChighPerformanceTimer::ChighPerformanceTimer(CString p_TimerName,bool p_Periodic,LONG p_Period)
{
// 	p_TimerName 定时器名;
// 	p_Periodic 设置是否为周期性定时器;
// 	p_Period时钟周期
	g_Valid=false;
	if (p_Periodic)
	{
		g_TimerPeriod=p_Period;
		g_ManualReset=false;
	}
	else
	{
		g_TimerPeriod=0;
		g_ManualReset=true;
	}
	g_Set=false;
	g_TimerExpires.QuadPart=Int32x32To64(-10000,p_Period);
	memset(g_Name,0,MAX_PATH);
	if (! p_TimerName.IsEmpty())
		if(p_TimerName.GetLength()>MAX_PATH)
			memcpy(g_Name,p_TimerName,MAX_PATH);
		else
			memcpy(g_Name,p_TimerName,p_TimerName.GetLength());
		//如果定时器已经创建, 则使用已有的定时器;否则建立一个新的定时器
		g_TimerHandle=OpenWaitableTimer(TIMER_ALL_ACCESS | TIMER_MODIFY_STATE | SYNCHRONIZE,TRUE,(char *) g_Name);
		if (g_TimerHandle==NULL)
		{
			//建立并且初始化缺省的安全描述符和属性
			g_SecurityAttributes.lpSecurityDescriptor=&g_SecurityDescriptor;
			InitializeSecurityDescriptor(g_SecurityAttributes.lpSecurityDescriptor,SECURITY_DESCRIPTOR_REVISION);
			SetSecurityDescriptorDacl(g_SecurityAttributes.lpSecurityDescriptor,TRUE,(PACL)NULL,FALSE);
			g_SecurityAttributes.nLength = sizeof SECURITY_ATTRIBUTES;
			g_SecurityAttributes.bInheritHandle=TRUE;
			g_TimerHandle=CreateWaitableTimer(&g_SecurityAttributes,g_ManualReset,(char *)g_Name);
		}
		if(g_TimerHandle==NULL)
		{
			//ERROR AND RETURN
			return;
		}
		g_Result=g_WaitableTimer_TickOkay;//?????????
		g_Valid=true;
}
开发者ID:honghaoz,项目名称:Merging-Unit-Electric-Power-System-Fault-Simulator,代码行数:44,代码来源:highPerformanceTimer.cpp



注:本文中的InitializeSecurityDescriptor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ InitializeShader函数代码示例发布时间:2022-05-30
下一篇:
C++ InitializeObjectAttributes函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap