Skip to content

Commit 4fb7dda

Browse files
committed
FormatMessage functions fix: winbase.h line 2455
1 parent ebd2433 commit 4fb7dda

File tree

13 files changed

+2240
-716
lines changed

13 files changed

+2240
-716
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#include <AccCtrl.h>
1+
#include <Windows.h>
22

33
int main(int argc, char* argv[])
44
{
5-
ACE_HEADER instance;
5+
DWORD_PTR instance;
66
const int size = sizeof(instance);
7-
const int value = ACE_OBJECT_TYPE_PRESENT;
7+
const int value = FORMAT_MESSAGE_ALLOCATE_BUFFER;
88

9-
const void* ptr = AccFree;
9+
const void* ptr = FormatMessage;
1010

1111
return EXIT_SUCCESS;
1212
}

src-native/THNETII.WinApi.Headers.ErrHandlingApi/ErrHandlingApiFunctions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33
using System.Text;
44
using THNETII.WinApi.Native.WinBase;
@@ -25,7 +25,7 @@ public static class ErrHandlingApiFunctions
2525
/// </returns>
2626
/// <remarks>
2727
/// <para>Functions executed by the calling thread set this value by calling the <see cref="SetLastError"/> function. You should call the <see cref="GetLastError"/> function immediately when a function's return value indicates that such a call will return useful data. That is because some functions call <see cref="SetLastError"/> with a zero when they succeed, wiping out the error code set by the most recently failed function.</para>
28-
/// <para>To obtain an error string for system error codes, use the <see cref="FormatMessage(FORMAT_MESSAGE_OPTIONS, IntPtr, int, int, StringBuilder, int, IntPtr)"/> function. For a complete list of error codes provided by the operating system, see <a href="https://msdn.microsoft.com/en-us/library/ms681381.aspx">System Error Codes</a>.</para>
28+
/// <para>To obtain an error string for system error codes, use the <see cref="FormatMessage"/> function. For a complete list of error codes provided by the operating system, see <a href="https://msdn.microsoft.com/en-us/library/ms681381.aspx">System Error Codes</a>.</para>
2929
/// <para>The error codes returned by a function are not part of the Windows API specification and can vary by operating system or device driver. For this reason, we cannot provide the complete list of error codes that can be returned by each function. There are also many functions whose documentation does not include even a partial list of error codes that can be returned.</para>
3030
/// <para>Error codes are 32-bit values (bit 31 is the most significant bit). Bit 29 is reserved for application-defined error codes; no system error code has this bit set. If you are defining an error code for your application, set this bit to one. That indicates that the error code has been defined by an application, and ensures that your error code does not conflict with any error codes defined by the system.</para>
3131
/// <para>To convert a system error into an <see cref="T:THNETII.WindowsProtocols.WindowsErrorCodes.HRESULT"/> value, use the <see cref="M:THNETII.WindowsProtocols.WindowsErrorCodes.HRESULT.FromWin32(System.Int32)"/> function.</para>
@@ -41,7 +41,7 @@ public static class ErrHandlingApiFunctions
4141
/// </remarks>
4242
/// <exception cref="DllNotFoundException">The native library containg the function could not be found.</exception>
4343
/// <exception cref="EntryPointNotFoundException">Unable to find the entry point for the function in the native library.</exception>
44-
/// <seealso cref="FormatMessage(FORMAT_MESSAGE_OPTIONS, IntPtr, int, int, StringBuilder, int, IntPtr)"/>
44+
/// <seealso cref="FormatMessage"/>
4545
/// <seealso cref="M:THNETII.WindowsProtocols.WindowsErrorCodes.HRESULT.FromWin32(System.Int32)"/>
4646
/// <seealso cref="SetLastError"/>
4747
/// <seealso cref="M:THNETII.WinApi.Native.WinUser.WinUserFunctions.SetLastErrorEx(System.Int32,THNETII.WinApi.Native.WinUser.SLE_TYPE)"/>

src-native/THNETII.WinApi.Headers.WinBase/FORMAT_MESSAGE_OPTIONS.cs

-100
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
1-

1+
22
// This file is used by Code Analysis to maintain SuppressMessage
33
// attributes that are applied to this project.
44
// Project-level suppressions either have no target or are given
55
// a specific target and scoped to a namespace, type, member, etc.
66

77
using System.Diagnostics.CodeAnalysis;
88

9-
[assembly: SuppressMessage("Interoperability", "CA1401: P/Invokes should not be visible")]
10-
[assembly: SuppressMessage("Usage", "PC003: Native API not available in UWP")]
11-
[assembly: SuppressMessage("Globalization", "CA2101: Specify marshaling for P/Invoke string arguments")]
12-
[assembly: SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores")]
13-
[assembly: SuppressMessage("Design", "CA1051: Do not declare visible instance fields")]
14-
[assembly: SuppressMessage("Performance", "CA1815: Override equals and operator equals on value types")]
15-
[assembly: SuppressMessage("Naming", "CA1714: Flags enums should have plural names")]
16-
[assembly: SuppressMessage("Documentation", "CA1200: Avoid using cref tags with a prefix")]
9+
[assembly: SuppressMessage("Design",
10+
"CA1051: Do not declare visible instance fields")]
11+
[assembly: SuppressMessage("Documentation",
12+
"CA1200: Avoid using cref tags with a prefix")]
13+
[assembly: SuppressMessage("Interoperability",
14+
"CA1401: P/Invokes should not be visible")]
15+
[assembly: SuppressMessage("Naming",
16+
"CA1707: Identifiers should not contain underscores")]
17+
[assembly: SuppressMessage("Naming",
18+
"CA1714: Flags enums should have plural names")]
19+
[assembly: SuppressMessage("Performance",
20+
"CA1815: Override equals and operator equals on value types")]
21+
[assembly: SuppressMessage("Globalization",
22+
"CA2101: Specify marshaling for P/Invoke string arguments")]
23+
[assembly: SuppressMessage("Documentation",
24+
"CS0419: Ambiguous reference in cref attribute")]
25+
[assembly: SuppressMessage("Usage",
26+
"PC003: Native API not available in UWP")]

src-native/THNETII.WinApi.Headers.WinBase/THNETII.WinApi.Headers.WinBase.csproj

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33

44
<PropertyGroup>
5-
<LangVersion>7.2</LangVersion>
5+
<LangVersion>8</LangVersion>
6+
<Nullable>enable</Nullable>
67
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
78
<TargetFrameworks>netstandard1.3;netstandard1.6;netstandard2.0</TargetFrameworks>
89
<GenerateDocumentationFile>true</GenerateDocumentationFile>
9-
<NoWarn>CS1591</NoWarn>
10+
<NoWarn>$(NoWarn);CS0419;CS1591</NoWarn>
1011
<RootNamespace>THNETII.WinApi.Native.WinBase</RootNamespace>
1112
</PropertyGroup>
1213

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System.Runtime.InteropServices;
2+
3+
namespace THNETII.WinApi.Native.WinBase
4+
{
5+
6+
public static partial class WinBaseFunctions
7+
{
8+
// C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um\errhandlingapi.h, line 96
9+
#region SetLastError function
10+
/// <inheritdoc cref="M:THNETII.WinApi.Native.ErrHandlingApi.ErrHandlingApiFunctions.SetLastError(System.Int32)"/>
11+
[DllImport(NativeLibraryNames.Kernel32, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
12+
private static extern void SetLastError(
13+
[In] int dwErrCode
14+
);
15+
#endregion
16+
}
17+
}

src-native/THNETII.WinApi.Headers.WinBase/WinBaseFunctions.MinWinBase.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
3+
34
using THNETII.WinApi.Native.MinWinDef;
5+
46
using static THNETII.WinApi.Native.MinWinBase.LMEM_FLAGS;
5-
#if NETSTANDARD1_3
7+
8+
#if NETSTANDARD1_6
69
using EntryPointNotFoundException = System.Exception;
710
#endif
811

0 commit comments

Comments
 (0)