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

📄 warwin32nt.c

📁 ftpserver very good sample
💻 C
字号:
/* WarWin32Nt.c */#include "StdAfx.h"// From http://msdn.microsoft.com/library/psdk/winbase/accctrl_199w.htmBOOL WarGetTextualSid(    PSID pSid,            // binary Sid    LPTSTR TextualSid,    // buffer for Textual representation of Sid    LPDWORD lpdwBufferLen // required/provided TextualSid buffersize    ){    PSID_IDENTIFIER_AUTHORITY psia;    DWORD dwSubAuthorities;    DWORD dwSidRev=SID_REVISION;    DWORD dwCounter;    DWORD dwSidSize;    // Validate the binary SID.    if(!IsValidSid(pSid)) return FALSE;    // Get the identifier authority value from the SID.    psia = GetSidIdentifierAuthority(pSid);    // Get the number of subauthorities in the SID.    dwSubAuthorities = *GetSidSubAuthorityCount(pSid);    // Compute the buffer length.    // S-SID_REVISION- + IdentifierAuthority- + subauthorities- + NULL    dwSidSize=(15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR);    // Check input buffer length.    // If too small, indicate the proper size and set last error.    if (*lpdwBufferLen < dwSidSize)    {        *lpdwBufferLen = dwSidSize;        SetLastError(ERROR_INSUFFICIENT_BUFFER);        return FALSE;    }    // Add 'S' prefix and revision number to the string.    dwSidSize=wsprintf(TextualSid, TEXT("S-%lu-"), dwSidRev );    // Add SID identifier authority to the string.    if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) )    {        dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),                    TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"),                    (USHORT)psia->Value[0],                    (USHORT)psia->Value[1],                    (USHORT)psia->Value[2],                    (USHORT)psia->Value[3],                    (USHORT)psia->Value[4],                    (USHORT)psia->Value[5]);    }    else    {        dwSidSize+=wsprintf(TextualSid + lstrlen(TextualSid),                    TEXT("%lu"),                    (ULONG)(psia->Value[5]      )   +                    (ULONG)(psia->Value[4] <<  8)   +                    (ULONG)(psia->Value[3] << 16)   +                    (ULONG)(psia->Value[2] << 24)   );    }    // Add SID subauthorities to the string.    //    for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++)    {        dwSidSize+=wsprintf(TextualSid + dwSidSize, TEXT("-%lu"),                    *GetSidSubAuthority(pSid, dwCounter) );    }    return TRUE;}//============================= ACCESS     ===================================//============================= INQUIRY    ===================================/////////////////////////////// PROTECTED  ////////////////////////////////////////////////////////////////// PRIVATE    ///////////////////////////////////

⌨️ 快捷键说明

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