ReactOS 0.4.15-dev-8219-ge8b88cf
apisets.c File Reference
#include <ndk/umtypes.h>
#include <ndk/rtlfuncs.h>
#include "apisetsp.h"
Include dependency graph for apisets.c:

Go to the source code of this file.

Functions

NTSTATUS ApiSetResolveToHost (_In_ DWORD ApisetVersion, _In_ PCUNICODE_STRING ApiToResolve, _Out_ PBOOLEAN Resolved, _Out_ PUNICODE_STRING Output)
 

Variables

const ULONGLONG API_ = (ULONGLONG)0x2D004900500041
 
const ULONGLONG EXT_ = (ULONGLONG)0x2D005400580045
 L"API-".
 
WORD PrefixSize = sizeof(L"api-") - sizeof(WCHAR)
 L"EXT-";.
 
WORD ExtensionSize = sizeof(L".dll") - sizeof(WCHAR)
 

Function Documentation

◆ ApiSetResolveToHost()

NTSTATUS ApiSetResolveToHost ( _In_ DWORD  ApisetVersion,
_In_ PCUNICODE_STRING  ApiToResolve,
_Out_ PBOOLEAN  Resolved,
_Out_ PUNICODE_STRING  Output 
)

Definition at line 32 of file apisets.c.

38{
39 if (ApiToResolve->Length < PrefixSize)
40 {
41 *Resolved = FALSE;
42 return STATUS_SUCCESS;
43 }
44
45 // Grab the first four chars from the string, converting the first 3 to uppercase
46 PWSTR ApiSetNameBuffer = ApiToResolve->Buffer;
47 ULONGLONG ApiSetNameBufferPrefix = ((ULONGLONG *)ApiSetNameBuffer)[0] & 0xFFFFFFDFFFDFFFDF;
48 // Check if it matches either 'api-' or 'ext-'
49 if (!(ApiSetNameBufferPrefix == API_ || ApiSetNameBufferPrefix == EXT_))
50 {
51 *Resolved = FALSE;
52 return STATUS_SUCCESS;
53 }
54
55 // If there is an extension, cut it off (we store apisets without extension)
56 UNICODE_STRING Tmp = *ApiToResolve;
57 const WCHAR *Extension = Tmp.Buffer + (Tmp.Length - ExtensionSize) / sizeof(WCHAR);
58 if (!_wcsnicmp(Extension, L".dll", ExtensionSize / sizeof(WCHAR)))
59 Tmp.Length -= ExtensionSize;
60
61 // Binary search the apisets
62 // Ideally we should use bsearch here, but that drags in another dependency and we do not want that here.
63 LONG UBnd = g_ApisetsCount - 1;
64 LONG LBnd = 0;
65 while (LBnd <= UBnd)
66 {
67 LONG Index = (UBnd - LBnd) / 2 + LBnd;
68
70 if (result == 0)
71 {
72 // Check if this version is included
73 if (g_Apisets[Index].dwOsVersions & ApisetVersion)
74 {
75 // Return a static string (does not have to be freed)
76 *Resolved = TRUE;
78 }
79 return STATUS_SUCCESS;
80 }
81 else if (result < 0)
82 {
83 UBnd = Index - 1;
84 }
85 else
86 {
87 LBnd = Index + 1;
88 }
89 }
90 *Resolved = FALSE;
91 return STATUS_SUCCESS;
92}
const LONG g_ApisetsCount
const ROS_APISET g_Apisets[]
Definition: apisets.table.c:12
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
GLuint64EXT * result
Definition: glext.h:11304
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
@ Output
Definition: arc.h:85
WORD ExtensionSize
Definition: apisets.c:17
const ULONGLONG API_
Definition: apisets.c:13
WORD PrefixSize
L"EXT-";.
Definition: apisets.c:16
const ULONGLONG EXT_
L"API-".
Definition: apisets.c:14
#define STATUS_SUCCESS
Definition: shellext.h:65
const UNICODE_STRING Target
Definition: apisetsp.h:14
uint16_t * PWSTR
Definition: typedefs.h:56
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ WDFCOLLECTION _In_ ULONG Index
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by LdrpApplyFileNameRedirection(), resolve_fail_single(), and resolve_single().

Variable Documentation

◆ API_

const ULONGLONG API_ = (ULONGLONG)0x2D004900500041

Definition at line 13 of file apisets.c.

Referenced by ApiSetResolveToHost().

◆ EXT_

const ULONGLONG EXT_ = (ULONGLONG)0x2D005400580045

L"API-".

Definition at line 14 of file apisets.c.

Referenced by ApiSetResolveToHost().

◆ ExtensionSize

◆ PrefixSize

WORD PrefixSize = sizeof(L"api-") - sizeof(WCHAR)

L"EXT-";.

Definition at line 16 of file apisets.c.

Referenced by ApiSetResolveToHost(), and MupAllocatePrefixEntry().