Skip to content

Commit

Permalink
Remove unnecessary DLLIMPORTGENERATOR_ENABLED ifdefs (#61345)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung committed Nov 9, 2021
1 parent 6d5f59b commit 60b7ea5
Show file tree
Hide file tree
Showing 41 changed files with 19 additions and 224 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
internal static unsafe partial bool AdjustTokenPrivileges(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
internal static extern unsafe bool AdjustTokenPrivileges(
#endif
SafeTokenHandle TokenHandle,
bool DisableAllPrivileges,
TOKEN_PRIVILEGE* NewState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool CheckTokenMembership(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern bool CheckTokenMembership(
#endif
SafeAccessTokenHandle TokenHandle,
byte[] SidToCheck,
ref bool IsMember);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial int ConvertStringSidToSid(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "ConvertStringSidToSidW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int ConvertStringSidToSid(
#endif
string stringSid,
out IntPtr ByteArray);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", SetLastError = true)]
internal static partial int CreateWellKnownSid(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "CreateWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int CreateWellKnownSid(
#endif
int sidType,
byte[]? domainSid,
byte[] resultSid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool DuplicateTokenEx(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern bool DuplicateTokenEx(
#endif
SafeAccessTokenHandle hExistingToken,
uint dwDesiredAccess,
IntPtr lpTokenAttributes, // LPSECURITY_ATTRIBUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool DuplicateTokenEx(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern bool DuplicateTokenEx(
#endif
SafeTokenHandle ExistingTokenHandle,
TokenAccessLevels DesiredAccess,
IntPtr TokenAttributes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityInfo", ExactSpelling = true)]
internal static unsafe partial uint GetSecurityInfoByHandle(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityInfo", ExactSpelling = true)]
internal static unsafe extern /*DWORD*/ uint GetSecurityInfoByHandle(
#endif
SafeHandle handle,
/*DWORD*/ uint objectType,
/*DWORD*/ uint securityInformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial uint GetSecurityInfoByName(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetNamedSecurityInfoW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static extern /*DWORD*/ uint GetSecurityInfoByName(
#endif
string name,
/*DWORD*/ uint objectType,
/*DWORD*/ uint securityInformation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", SetLastError = true)]
internal static partial int GetWindowsAccountDomainSid(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetWindowsAccountDomainSid", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int GetWindowsAccountDomainSid(
#endif
byte[] sid,
byte[] resultSid,
ref uint resultSidLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool ImpersonateLoggedOnUser(SafeAccessTokenHandle userToken);
#else
[DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool ImpersonateLoggedOnUser(SafeAccessTokenHandle userToken);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", SetLastError = true)]
internal static partial int IsEqualDomainSid(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "EqualDomainSid", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int IsEqualDomainSid(
#endif
byte[] sid1,
byte[] sid2,
out bool result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", SetLastError = true)]
internal static partial int IsWellKnownSid(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "IsWellKnownSid", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern int IsWellKnownSid(
#endif
byte[] sid,
int type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial int LsaClose(IntPtr handle);
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern int LsaClose(IntPtr handle);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial int LsaFreeMemory(IntPtr handle);
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern int LsaFreeMemory(IntPtr handle);
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", SetLastError = true)]
internal static partial uint LsaLookupSids(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaLookupSids", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern uint LsaLookupSids(
#endif
SafeLsaPolicyHandle handle,
int count,
IntPtr[] sids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", SetLastError = true)]
private static partial uint LsaOpenPolicy(
#else
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "LsaOpenPolicy", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern uint LsaOpenPolicy(
#endif
ref UNICODE_STRING SystemName,
ref OBJECT_ATTRIBUTES ObjectAttributes,
int AccessMask,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
internal static partial bool OpenProcessToken(
#else
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool OpenProcessToken(
#endif
IntPtr ProcessToken,
TokenAccessLevels DesiredAccess,
out SafeTokenHandle TokenHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
private static partial bool OpenThreadToken(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
private static extern bool OpenThreadToken(
#endif
IntPtr ThreadHandle,
TokenAccessLevels dwDesiredAccess,
bool bOpenAsSelf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool OpenThreadToken(
#else
[DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static extern bool OpenThreadToken(
#endif
IntPtr ThreadHandle,
TokenAccessLevels dwDesiredAccess,
bool bOpenAsSelf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[GeneratedDllImport(Interop.Libraries.Advapi32, ExactSpelling = true, SetLastError = true)]
internal static partial bool RevertToSelf();
#else
[DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static extern bool RevertToSelf();
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, SetLastError = true)]
internal static partial bool SetThreadToken(
#else
[DllImport(Libraries.Advapi32, SetLastError = true)]
internal static extern bool SetThreadToken(
#endif
IntPtr ThreadHandle,
SafeTokenHandle? hToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CopyFileEx.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static partial bool CopyFileExPrivate(
#else
[DllImport(Libraries.Kernel32, EntryPoint = "CopyFileExW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool CopyFileExPrivate(
#endif
string src,
string dst,
IntPtr progressRoutine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateDirectory.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static partial bool CreateDirectoryPrivate(
#else
[DllImport(Libraries.Kernel32, EntryPoint = "CreateDirectoryW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool CreateDirectoryPrivate(
#endif
string path,
ref SECURITY_ATTRIBUTES lpSecurityAttributes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use CreateFile.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static unsafe partial IntPtr CreateFilePrivate_IntPtr(
#else
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static unsafe extern IntPtr CreateFilePrivate_IntPtr(
#endif
string lpFileName,
int dwDesiredAccess,
FileShare dwShareMode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteFile.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
private static partial bool DeleteFilePrivate(string path);
#else
[DllImport(Libraries.Kernel32, EntryPoint = "DeleteFileW", CharSet = CharSet.Unicode, SetLastError = true)]
private static extern bool DeleteFilePrivate(string path);
#endif

internal static bool DeleteFile(string path)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ internal static partial class Kernel32
/// <summary>
/// WARNING: This method does not implicitly handle long paths. Use DeleteVolumeMountPoint.
/// </summary>
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, SetLastError = true)]
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial bool DeleteVolumeMountPointPrivate(string mountPoint);
#else
[DllImport(Libraries.Kernel32, EntryPoint = "DeleteVolumeMountPointW", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool DeleteVolumeMountPointPrivate(string mountPoint);
#endif

internal static bool DeleteVolumeMountPoint(string mountPoint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial bool DuplicateHandle(
#else
[DllImport(Libraries.Kernel32, SetLastError = true)]
internal static extern bool DuplicateHandle(
#endif
IntPtr hSourceProcessHandle,
IntPtr hSourceHandle,
IntPtr hTargetProcessHandle,
Expand Down
Loading

0 comments on commit 60b7ea5

Please sign in to comment.