Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address TODO to switch to generated p/invoke #66057

Merged
merged 1 commit into from
Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,5 @@ internal static partial class Advapi32
{
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "ChangeServiceConfig2W", SetLastError = true)]
public static partial bool ChangeServiceConfig2(SafeServiceHandle serviceHandle, uint infoLevel, ref SERVICE_DESCRIPTION serviceDesc);

#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
// TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we support non-blittable types.
[DllImport(Libraries.Advapi32, EntryPoint = "ChangeServiceConfig2W", ExactSpelling = true, SetLastError = true)]
public static extern bool ChangeServiceConfig2(SafeServiceHandle serviceHandle, uint infoLevel, ref SERVICE_DELAYED_AUTOSTART_INFO serviceDesc);
#pragma warning restore DLLIMPORTGENANALYZER015
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ internal enum SnapshotFlags : uint
NoHeaps = 0x40000000
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
internal struct PROCESSENTRY32
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal unsafe struct PROCESSENTRY32
{
internal int dwSize;
internal int cntUsage;
Expand All @@ -33,23 +33,19 @@ internal struct PROCESSENTRY32
internal int th32ParentProcessID;
internal int pcPriClassBase;
internal int dwFlags;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)]
internal string szExeFile;
internal fixed char szExeFile[MAX_PATH];
}

// https://docs.microsoft.com/windows/desktop/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial IntPtr CreateToolhelp32Snapshot(SnapshotFlags dwFlags, uint th32ProcessID);

#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
// TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we support non-blittable types.
// https://docs.microsoft.com/windows/desktop/api/tlhelp32/nf-tlhelp32-process32first
[DllImport(Libraries.Kernel32, SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
internal static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "Process32FirstW", SetLastError = true)]
internal static partial bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);

// https://docs.microsoft.com/windows/desktop/api/tlhelp32/nf-tlhelp32-process32next
[DllImport(Libraries.Kernel32, SetLastError = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
internal static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
#pragma warning restore DLLIMPORTGENANALYZER015
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "Process32NextW", SetLastError = true)]
internal static partial bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
</PropertyGroup>

<ItemGroup>
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
Link="Common\DisableRuntimeMarshalling.cs"
Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Libraries.cs"
Link="Common\Interop\Windows\Interop.Libraries.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Kernel32\Interop.CloseHandle.cs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
Link="Common\Interop\Windows\Interop.SERVICE_DESCRIPTION.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.ChangeServiceConfig2.cs"
Link="Common\Interop\Windows\Interop.ChangeServiceConfig2.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.SERVICE_DELAYED_AUTOSTART_INFO.cs"
Link="Common\Interop\Windows\Interop.SERVICE_DELAYED_AUTOSTART_INFO.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Advapi32\Interop.DeleteService.cs"
Link="Common\Interop\Windows\Interop.DeleteService.cs" />
<Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs"
Expand Down