RTL,Register Transfer Level,直译为寄存器转换级,顾名思义,也就是在这个级别下,要描述各级寄存器(时序逻辑中的寄存器),以及寄存器之间的信号的是如何转换的(时序逻辑中的组合逻辑)。

通俗来讲,RTL代码不是在“写代码”,是在画电路结构。RTL代码需要“画”出输入输出端口,各级寄存器,寄存器之间的组合逻辑和前三者之间的连接。对于组合逻辑,只需要软件级描述,将其功能包装在“黑匣子”中即可,无需考虑其门级结构。

RtlInitUnicodeString


 
    hkey = Scm_OpenKeyForService(SBIESVC, TRUE);
    if (! hkey)
        status = STATUS_UNSUCCESSFUL;
    else {

        RtlInitUnicodeString(&uni, L"SandboxedServices");
        status = NtSetValueKey(
            hkey, &uni, 0, REG_MULTI_SZ, names2, len * sizeof(WCHAR));

        NtClose(hkey);
    }

 

RtlFreeUnicodeString

_FX BOX *Box_Create(POOL *pool, const WCHAR *boxname, BOOLEAN init_paths)
{
    BOX *box;

    UNICODE_STRING SidString;
    ULONG SessionId;
    NTSTATUS status = Process_GetSidStringAndSessionId(
                        NtCurrentProcess(), NULL, &SidString, &SessionId);

    if (NT_SUCCESS(status)) {

        box = Box_CreateEx(
                pool, boxname, SidString.Buffer, SessionId, init_paths);
        RtlFreeUnicodeString(&SidString);

    } else {

        Log_Status_Ex(MSG_BOX_CREATE, 0x11, status, boxname);
        box = NULL;
    }

    return box;
}

  

 

 RtlCompareUnicodeString

_FX int Box_NlsStrCmp(const WCHAR *s1, const WCHAR *s2, ULONG len)
{
    UNICODE_STRING u1, u2;

    u1.Length = u1.MaximumLength = u2.Length = u2.MaximumLength =
        (USHORT)(len * sizeof(WCHAR));
    u1.Buffer = (WCHAR *)s1;
    u2.Buffer = (WCHAR *)s2;

    return RtlCompareUnicodeString(&u1, &u2, TRUE);
}