100+ results for 'win32error'
Not the results you expected?
Exceptions.cs (https://gitlab.com/unofficial-mirrors/PowerShell) C# · 688 lines
WinUsb.Helpers.cs (https://github.com/AArnott/pinvoke.git) C# · 127 lines
GdiPlusTypes2.h (https://github.com/snowie2000/mactype.git) C Header · 770 lines
Utility.cs (https://github.com/Microsoft/service-fabric.git) C# · 953 lines
StatusConverter.Test.cpp (https://github.com/Microsoft/service-fabric.git) C++ · 416 lines
I2C.cs (https://GumstixIII.svn.codeplex.com/svn) C# · 463 lines
128 {
129 case -7:
130 throw new Exception("No Acknowledge Issued:" + Marshal.GetLastWin32Error());
131 case -8:
132 throw new Exception("NULL Buffer:" + Marshal.GetLastWin32Error());
133 case -9:
134 throw new Exception("Invalid Buffer Size:" + Marshal.GetLastWin32Error());
135 case -10:
136 throw new Exception("NULL lpiResult field:" + Marshal.GetLastWin32Error());
137 case -11:
138 throw new Exception("CRM Operation Failure:" + Marshal.GetLastWin32Error());
139 case -12:
140 throw new Exception("I2C transmit timeout error:" + Marshal.GetLastWin32Error());
PrintSystemException.cs (https://github.com/dotnet/wpf.git) C# · 1294 lines
266 )
267 {
268 StringBuilder win32ErrorMessage = new StringBuilder(defaultWin32ErrorMessageLength);
270 int charCount = NativeMethodsForPrintExceptions.InvokeFormatMessage(FormatMessageFromSystem,
271 IntPtr.Zero,
272 win32Error,
273 0,
274 win32ErrorMessage,
278 if(charCount < 0)
279 {
280 win32ErrorMessage.Length = 0;
281 }
282 else
kernel32.cs (https://blend.svn.codeplex.com/svn) C# · 4524 lines
SafeCryptHandles.cs (https://github.com/pruiz/mono.git) C# · 122 lines
32 protected override bool ReleaseHandle()
33 {
34 // PreSharp Bug: Call 'Marshal.GetLastWin32Error' or 'Marshal.GetHRForLastWin32Error' before any other interop call.
35 #pragma warning suppress 56523 // We are not interested in throwing an exception here if CloseHandle fails.
36 return NativeMethods.CryptReleaseContext(handle, 0);
59 protected override bool ReleaseHandle()
60 {
61 // PreSharp Bug: Call 'Marshal.GetLastWin32Error' or 'Marshal.GetHRForLastWin32Error' before any other interop call.
62 #pragma warning suppress 56523 // We are not interested in throwing an exception here if CloseHandle fails.
63 bool ret = NativeMethods.CryptDestroyKey(handle);
100 if (!b)
101 {
102 err = Marshal.GetLastWin32Error();
103 provHandle.DangerousRelease();
104 }
regclient.c (https://github.com/BeyondTrust/pbis-open.git) C · 868 lines
samdbsecurity.c (https://github.com/BeyondTrust/pbis-open.git) C · 1448 lines
color.cxx (https://github.com/pustladi/Windows-2000.git) C++ · 910 lines
AdvancedProviderEvents.cs (https://github.com/pauldotknopf/WindowsSDK7-Samples.git) C# · 1511 lines
71 private EventDescriptor SampleEvt_ValueMap_UInt8;
72 private EventDescriptor SampleEvt_BitMap_UInt8;
73 private EventDescriptor SampleEvt_UInt32_Win32Error;
74 private EventDescriptor SampleEvt_UInt32_NTSTATUS;
75 private EventDescriptor SampleEvt_Int32_HResult;
570 // Event method for SampleEvt_UInt32_Win32Error
571 //
572 public bool EventWriteSampleEvt_UInt32_Win32Error(uint Prop_UInt32_Win32Error)
573 {
578 }
580 return m_provider.TemplateT_UInt32_Win32Error(ref SampleEvt_UInt32_Win32Error, Prop_UInt32_Win32Error);
581 }
error.h (https://github.com/stephenegriffin/mfcmapi.git) C Header · 436 lines
19 // WC_W32 - does the same as WC_H, wrapping the result of the function call in HRESULT_FROM_WIN32
21 // EC_B - Similar to EC_H, but for Boolean functions, using CheckWin32Error to set failure in hRes
22 // WC_B - Similar to WC_H, but for Boolean functions, using CheckWin32Error to set failure in hRes
59 _Check_return_ HRESULT
60 CheckWin32Error(bool bDisplayDialog, _In_z_ LPCSTR szFile, int iLine, _In_z_ LPCSTR szFunction);
62 // Flag parsing array - used by ErrorNameFromErrorCode
216 }()
218 // Execute a bool/BOOL function, log error, and return CheckWin32Error(HRESULT)
219 // Will display dialog on error
220 #define EC_B(fnx) \
221 error::CheckMe( \
222 [&]() -> HRESULT { return !(fnx) ? error::CheckWin32Error(true, __FILE__, __LINE__, #fnx) : S_OK; }())
224 // Execute a bool/BOOL function, log error, and swallow error
DrsReplicaSyncFailures.cs (https://github.com/microsoft/WindowsProtocolTestSuites.git) C# · 570 lines
269 msgIn);
270 BaseTestSite.Assert.AreEqual<uint>(
271 (uint)Win32ErrorCode_32.ERROR_DS_DRA_INVALID_PARAMETER,
272 ret,
273 "DrsReplicaSync: return code mismatch."
331 msgIn);
332 BaseTestSite.Assert.AreEqual<uint>(
333 (uint)Win32ErrorCode_32.ERROR_DS_DRA_INVALID_PARAMETER,
334 ret,
335 "DrsReplicaSync: return code mismatch."
387 msgIn);
388 BaseTestSite.Assert.AreEqual<uint>(
389 (uint)Win32ErrorCode_32.ERROR_DS_DRA_INVALID_PARAMETER,
390 ret,
391 "DrsReplicaSync: return code mismatch."
StreamInfo.cs (https://github.com/RoDaniel/featurehouse.git) C# · 282 lines
80 return false;
81 default:
82 throw Win32ErrorCode.GetExceptionForWin32Error(errorCode);
83 }
84 }
210 else
211 if (!NativeMethods.DeleteFile(FullName))
212 throw Win32ErrorCode.GetExceptionForWin32Error(Marshal.GetLastWin32Error());
213 }
214 public FileStream Open(FileMode mode)
258 int errorCode = Marshal.GetLastWin32Error();
259 result.Close();
260 throw Win32ErrorCode.GetExceptionForWin32Error(errorCode);
261 }
262 if (share == FileShare.None)
Windows.Foundation.Diagnostics.0.h (https://github.com/WhitewaterFoundry/WSLFedoraRemix.git) C Header · 971 lines
gdiplustypes.h (https://github.com/aragaer/wine.git) C Header · 276 lines
SelfSignedCertificate.cs (https://github.com/pruiz/mono.git) C# · 236 lines
116 out addedCert))
117 {
118 int error = Marshal.GetLastWin32Error();
119 Utility.CloseInvalidOutSafeHandle(addedCert);
120 PeerExceptionHelper.ThrowInvalidOperation_PeerCertGenFailure(new Win32Exception(error));
180 ContextFlags.NewKeySet | ContextFlags.Silent))
181 {
182 int error = Marshal.GetLastWin32Error();
183 Utility.CloseInvalidOutSafeHandle(keyContainer);
184 keyContainer = null;
192 out key))
193 {
194 int error = Marshal.GetLastWin32Error();
195 Utility.CloseInvalidOutSafeHandle(key);
196 key = null;
SystemColorsEx.cs (https://github.com/ctacke/sdf.git) C# · 676 lines
73 Int32[] rgbs = GetArrayOfRGBs(aSchemeName);
74 if (SetSysColors(29, el, rgbs) == false) {
75 throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
76 }
208 set {
209 if (SetSysColors(1, new Int32[]{COLOR_GRADIENTACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
210 throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
211 }
212 }
223 set {
224 if (SetSysColors(1, new Int32[]{COLOR_GRADIENTINACTIVECAPTION}, new Int32[]{ColorTranslator.ToWin32(value)}) == false) {
225 throw new ApplicationException(Marshal.GetLastWin32Error().ToString());
226 }
227 }
LongPathDirectory.cs (https://hg.codeplex.com/longpaths) C# · 927 lines
66 // To mimic Directory.CreateDirectory, we don't throw if the directory (not a file) already exists
67 int errorCode = Marshal.GetLastWin32Error();
68 if (errorCode != NativeMethods.ERROR_ALREADY_EXISTS || !LongPathDirectory.Exists(path)) {
69 throw LongPathCommon.GetExceptionFromWin32Error(errorCode);
128 if (!NativeMethods.RemoveDirectory(normalizedPath)) {
129 throw LongPathCommon.GetExceptionFromLastWin32Error();
130 }
131 }
804 int errorCode = LongPathCommon.TryGetDirectoryAttributes(normalizedPath, out attributes);
805 if (errorCode != 0) {
806 throw LongPathCommon.GetExceptionFromWin32Error(errorCode);
807 }
FtpConnection.cs (https://ftplib.svn.codeplex.com/svn) C# · 528 lines
198 if (hFindFile == IntPtr.Zero)
199 {
200 if (Marshal.GetLastWin32Error() == WINAPI.ERROR_NO_MORE_FILES)
201 {
202 return files;
232 }
234 if (Marshal.GetLastWin32Error() != WINAPI.ERROR_NO_MORE_FILES)
235 Error();
263 if (hFindFile == IntPtr.Zero)
264 {
265 if (Marshal.GetLastWin32Error() == WINAPI.ERROR_NO_MORE_FILES)
266 {
267 return files.ToArray();
Win32ExceptionTest.cs (https://github.com/QuickJack/mono.git) C# · 182 lines
41 public void Constructor0 ()
42 {
43 int native_error = Marshal.GetLastWin32Error ();
45 Win32Exception ex = new Win32Exception ();
83 Win32Exception ex;
84 string msg = "ERROR";
85 int native_error = Marshal.GetLastWin32Error ();
87 ex = new Win32Exception (msg);
150 Win32Exception ex;
151 string msg = "ERROR";
152 int native_error = Marshal.GetLastWin32Error ();
153 Exception inner = new Exception ();
FileAsyncOperation.cpp (https://github.com/Microsoft/service-fabric.git) C++ · 355 lines
to32.c (https://github.com/Paolo-Maffei/OpenNT.git) C · 1268 lines
113 //
114 vLastCall = LAST_CALL_IS_WIN32 ;
115 err = MapWin32ErrorToWN16( CallProc32W(aligned_p1,
116 (DWORD)aligned_p2,
117 (DWORD)aligned_p3,
171 //
172 vLastCall = LAST_CALL_IS_WIN32 ;
173 err = MapWin32ErrorToWN16( CallProc32W(aligned_p1,
174 (DWORD)p2,
175 (DWORD)lpfnWNetCancelConnection,
233 //
234 vLastCall = LAST_CALL_IS_WIN32 ;
235 err = MapWin32ErrorToWN16( CallProc32W(aligned_p1,
236 (DWORD)aligned_p2,
237 (DWORD)aligned_p3,
Win32Exception.cs (https://github.com/letssellsomebananas/mono.git) C# · 115 lines
48 #endif
49 public Win32Exception ()
50 : base (W32ErrorMessage (Marshal.GetLastWin32Error ()))
51 {
52 native_error_code = Marshal.GetLastWin32Error ();
74 : base (message)
75 {
76 native_error_code = Marshal.GetLastWin32Error ();
77 }
84 : base (message, innerException)
85 {
86 native_error_code = Marshal.GetLastWin32Error ();
87 }
88 #endif
HookKeyboard.cs (https://github.com/Wiladams/NewTOAPIA.git) C# · 235 lines
91 if (IntPtr.Zero == hKeyboardHook)
92 {
93 //Common.Log("Error installing keyboard hook: " + Marshal.GetLastWin32Error().ToString());
94 Stop();
95 }
105 if (retKeyboard == false)
106 {
107 int errorCode = Marshal.GetLastWin32Error();
108 //throw new Win32Exception(errorCode);
109 //Common.Log("Exception uninstalling keyboard hook, error code: " + errorCode.ToString());
E3ErrorManager.c (git://pkgs.fedoraproject.org/quesa) C · 550 lines
UacProperties.cs (https://gitlab.com/doubledown/CitiBike) C# · 130 lines
UnsafeNativeMethods.cs (https://github.com/dotnet/winforms.git) C# · 59 lines
35 // Performance should not be an issue for current MAX_PATH length due to this change.
36 while (((length = GetModuleFileName(hModule, buffer, buffer.Capacity)) == buffer.Capacity)
37 && Marshal.GetLastWin32Error() == ERROR.INSUFFICIENT_BUFFER
38 && buffer.Capacity < Kernel32.MAX_UNICODESTRING_LEN)
39 {
NamedPipeClient.cs (https://github.com/QuickJack/mono.git) C# · 113 lines
InternalResources.cs (https://github.com/kumpera/mono.git) C# · 148 lines
85 internal static void WinIOError()
86 {
87 int errorCode = Marshal.GetLastWin32Error();
88 WinIOError(errorCode, String.Empty);
89 }
94 internal static void WinIOError(string str)
95 {
96 int errorCode = Marshal.GetLastWin32Error();
97 WinIOError(errorCode, str);
98 }
99 #endif
101 // After calling GetLastWin32Error(), it clears the last error field,
102 // so you must save the HResult and pass it to this method. This method
103 // will determine the appropriate exception to throw dependent on your
ExceptionUtilities.cs (https://github.com/terrafx/terrafx.git) C# · 949 lines
147 /// <summary>Throws an <see cref="ExternalException" /> using the last available error code.</summary>
148 /// <param name="methodName">The name of the method that caused the exception.</param>
149 /// <exception cref="ExternalException"><paramref name="methodName" /> failed with an exit code of <see cref="Marshal.GetLastWin32Error()" />.</exception>
150 [DoesNotReturn]
151 public static void ThrowForLastError(string methodName)
ErrorHelper.cs (https://github.com/DavidMoore/Foundation.git) C# · 125 lines
83 internal static void WinIoError(int errorCode, String errorPath)
84 {
85 var isInvalidPath = errorCode == Win32Error.ERROR_INVALID_NAME || errorCode == Win32Error.ERROR_BAD_PATHNAME;
86 var path = GetDisplayablePath(errorPath, isInvalidPath);
100 throw new IOException("Path already exists: " + path, Win32Error.MakeHRFromErrorCode(errorCode));
102 case Win32Error.ERROR_FILENAME_EXCED_RANGE:
103 throw new PathTooLongException("Path too long: " + path);
108 case Win32Error.ERROR_INVALID_PARAMETER:
109 throw new IOException(Win32Error.GetMessage(errorCode), Win32Error.MakeHRFromErrorCode(errorCode));
111 case Win32Error.ERROR_SHARING_VIOLATION:
120 default:
121 throw new IOException(Win32Error.GetMessage(errorCode), Win32Error.MakeHRFromErrorCode(errorCode));
122 }
123 }
Timer.cpp (https://github.com/jiawen/temporal-lightfield-reconstruction.git) C++ · 88 lines
55 LARGE_INTEGER ticks;
56 if (!QueryPerformanceCounter(&ticks))
57 failWin32Error("QueryPerformanceCounter");
59 s_prevTicks = max(s_prevTicks, ticks.QuadPart);
69 LARGE_INTEGER freq;
70 if (!QueryPerformanceFrequency(&freq))
71 failWin32Error("QueryPerformanceFrequency");
72 s_ticksToSecsCoef = max(1.0 / (F64)freq.QuadPart, 0.0);
73 }
tif_xfile.cpp (https://github.com/tokyovigilante/xbmc-sources-fork.git) C++ · 225 lines
CommonUtils.cpp (https://github.com/aybe/Windows-API-Code-Pack-1.1.git) C++ · 104 lines
ServiceSecurity.cs (https://bitbucket.org/splatteredbits/carbon) C# · 103 lines
36 new Dictionary<int, string>
37 {
38 { Win32ErrorCodes.AccessDenied, "Access denied. The specified handle was not opened with READ_CONTROL access, or the calling process is not the owner of the object." },
39 { Win32ErrorCodes.InvalidHandle, "Invalid handle. The specified handle is not valid."},
40 { Win32ErrorCodes.InvalidParameter, "Invalid Parameter. The specified security information is not valid." },
41 { Win32ErrorCodes.InvalidFlags, "Invalid flags." }
54 if (!ok)
55 {
56 var errorCode = Marshal.GetLastWin32Error();
57 if (errorCode == Win32ErrorCodes.InsufficientBuffer)
74 private static readonly Dictionary<int,string> SetServiceObjectSecurityReturnCodes = new Dictionary<int, string>
75 {
76 { Win32ErrorCodes.AccessDenied, "Access denied. The specified handle was not opened with the required access, or the calling process is not the owner of the object." },
77 { Win32ErrorCodes.InvalidHandle, "Invalid handle. The specified handle is not valid." },
Drive.cs (https://github.com/camerb/IronAHK.git) C# · 74 lines
NativeMethods.cs (https://github.com/ProgressiveDeveloper/cairoshell.git) C# · 140 lines
78 if (!tokenOpenResult)
79 {
80 throw new ApplicationException("Error attempting to open process token to raise level for shutdown.\nWin32 Error Code: " + Marshal.GetLastWin32Error());
81 }
85 if (!privLookupResult)
86 {
87 throw new ApplicationException("Error attempting to lookup value for shutdown privilege.\n Win32 Error Code: " + Marshal.GetLastWin32Error());
88 }
96 if (!tokenPrivResult)
97 {
98 throw new ApplicationException("Error attempting to adjust the token privileges to allow shutdown.\n Win32 Error Code: " + Marshal.GetLastWin32Error());
99 }
100 }
ServiceStatusInfo.java (https://github.com/alfresco-mirror/alfresco-mirror.git) Java · 264 lines
kernel.c (https://gitlab.com/dj-tech/reactos) C · 132 lines
45 {
46 SND_ERR(L"CreateFile filed - winerror %d\n", GetLastError());
47 return Win32ErrorToMmResult(GetLastError());
48 }
91 if ( ! Overlapped.hEvent )
92 return Win32ErrorToMmResult(GetLastError());
94 /* Talk to the device */
108 {
109 CloseHandle(Overlapped.hEvent);
110 return Win32ErrorToMmResult(GetLastError());
111 }
112 }
UnitTest1.cs (https://github.com/DavidMoore/Foundation.git) C# · 186 lines
89 }
91 errorCode.IsHR = Win32Error.IsHR(errorCode.Value);
92 errorCode.ErrorMessage = Win32Error.GetMessage(errorCode.Value);
93 errorCode.HR = Win32Error.MakeHRFromErrorCode(errorCode.Value);
94 errorCode.Exception = Marshal.GetExceptionForHR(errorCode.HR);
136 Value = intValue;
138 IsHR = Win32Error.IsHR(Value);
139 }
WhoIsLocking.cs (https://github.com/fitzchak/ravendb.git) C# · 170 lines
47 }
48 if (rv != 0)
49 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to RmStartSession");
50 try
51 {
56 0, null, 0, null);
57 if (rv != 0)
58 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to RmRegisterResources (sessionHandle=" + sessionHandle + ")");
60 // Ask the restart manager what other applications
91 }
92 else
93 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to RmGetList (sessionHandle=" + sessionHandle + ")");
94 }
95 else if (rv != 0)
WbfsDriveInfo.cs (https://wbfssync.svn.codeplex.com/svn) C# · 466 lines
NamedPipeListener.cs (https://github.com/iainlane/mono.git) C# · 113 lines
WinRTFileStream.cs (https://gitlab.com/0072016/0072016-corefx-) C# · 234 lines
JvGnugettextD5.pas (http://my-chuanqi.googlecode.com/svn/trunk/) Pascal · 282 lines
Extensions.cs (https://github.com/Wiladams/NewTOAPIA.git) C# · 101 lines
rpc.c (https://github.com/vmware/lightwave.git) C · 463 lines
Directory.cpp (https://gitlab.com/lxderunner-work/il2cpp-ubuntu) C++ · 245 lines
msrdc.h (https://github.com/tpn/winsdk-10.git) C Header · 2695 lines
WaitHandle.cpp (https://github.com/Microsoft/service-fabric.git) C++ · 253 lines
171 eventName.empty() ? nullptr : eventName.c_str());
173 ASSERT_IFNOT(handle_, "CreateEvent failed: {0}", ErrorCode::FromWin32Error());
174 }
225 if(!::SetEvent(handle_))
226 {
227 err = ErrorCode::FromWin32Error();
228 TRACE_ERROR_AND_ASSERT(TraceType, "SetEvent failed: {0}", err);
229 }
238 if (!::ResetEvent(handle_))
239 {
240 err = ErrorCode::FromWin32Error();
241 TRACE_ERROR_AND_ASSERT(TraceType, "ResetEvent failed: {0}", err);
242 }
JnaException.java (https://github.com/bwalding/jenkins-1.git) Java · 44 lines
http_log.h (https://bitbucket.org/steve_delbar/iepsm-projet-de-d-veloppement-internet-2013.git) C Header · 120 lines
Window.cs (https://github.com/Roemer/FlaUI.git) C# · 167 lines
144 if (User32.SetWindowLong(Properties.NativeWindowHandle, WindowLongParam.GWL_EXSTYLE, WindowStyles.WS_EX_LAYERED) == 0)
145 {
146 throw new Win32Exception(Marshal.GetLastWin32Error());
147 }
148 if (!User32.SetLayeredWindowAttributes(Properties.NativeWindowHandle, 0, alpha, LayeredWindowAttributes.LWA_ALPHA))
149 {
150 throw new Win32Exception(Marshal.GetLastWin32Error());
151 }
152 }
SidHelper.cs (https://github.com/disaster123/MediaPortal-1.git) C# · 205 lines
83 LookupAccountName(null, name, _sid, ref _sidLength, _domain,
84 ref _domainLength, out _use);
85 int _error = Marshal.GetLastWin32Error();
87 //error 122 (The data area passed to a system call is too small)
100 if (_rc == false)
101 {
102 Marshal.GetLastWin32Error();
103 Marshal.FreeHGlobal(_sid);
104 return IntPtr.Zero;
126 LookupAccountName(null, name, _sid, ref _sidLength, _domain,
127 ref _domainLength, out _use);
128 int _error = Marshal.GetLastWin32Error();
130 //error 122 (The data area passed to a system call is too small)
TimerQueueTimer_.cs (https://gitlab.com/matt81093/space-station-14) C# · 144 lines
93 IntPtr.Zero // CompletionEvent - A handle to an optional event to be signaled when the function is successful and all callback functions have completed. Can be NULL.
94 );
95 int error = Marshal.GetLastWin32Error();
96 //CloseHandle(phNewTimer);
97 }
105 period
106 );
107 int error = Marshal.GetLastWin32Error();
108 }
RSACertificateExtensions.cs (https://github.com/kumpera/mono.git) C# · 112 lines
samr_binding.c (https://github.com/BeyondTrust/pbis-open.git) C · 396 lines
tif_xfile.cpp (https://github.com/energy6/xbmc.git) C++ · 224 lines
ipendpoint_properties.cpp (https://github.com/dotnet/docs.git) C++ · 123 lines
Volume.VolumeLabel.cs (https://github.com/alphaleonis/AlphaFS.git) C# · 114 lines
74 var success = NativeMethods.SetVolumeLabel(null, volumeName);
76 var lastError = Marshal.GetLastWin32Error();
77 if (!success)
78 NativeError.ThrowException(lastError, volumeName);
106 var success = NativeMethods.SetVolumeLabel(volumePath, volumeName);
108 var lastError = Marshal.GetLastWin32Error();
109 if (!success)
110 NativeError.ThrowException(lastError, volumePath, volumeName);
SemaphoreAcl.cs (https://github.com/dotnet/runtime.git) C# · 92 lines
Impersonation.cs (https://github.com/bertvan/CruiseControl.NET.git) C# · 121 lines
RawPrinterHelper.cs (https://github.com/emreeren/SambaPOS-3.git) C# · 125 lines
FtpConnection.cs (https://github.com/clawsoftware/clawPDF.git) C# · 428 lines
170 if (intPtr == IntPtr.Zero)
171 {
172 if (Marshal.GetLastWin32Error() == 18) return list;
173 Error();
174 return list;
211 }
213 if (Marshal.GetLastWin32Error() != 18) Error();
214 return list;
215 }
234 if (intPtr == IntPtr.Zero)
235 {
236 if (Marshal.GetLastWin32Error() == 18) return list.ToArray();
237 Error();
238 return list.ToArray();
FileSystemInfo.Windows.cs (https://gitlab.com/0072016/0072016-corefx-) C# · 132 lines
WindowsPrincipal.cs (https://github.com/madewokherd/mono.git) C# · 193 lines
168 (uint)TokenType.TokenImpersonation,
169 ref token))
170 throw new SecurityException(string.Format(CultureInfo.InvariantCulture, "DuplicateTokenEx returned error {0}", Marshal.GetLastWin32Error()));
171 }
184 sid.BinaryForm,
185 ref isMember))
186 throw new SecurityException(string.Format(CultureInfo.InvariantCulture, "CheckTokenMembership returned error {0}", Marshal.GetLastWin32Error()));
187 #endif
messages.h (https://github.com/lithnet/ad-password-protection.git) C Header · 229 lines
LongPathFile.cs (https://bcl.svn.codeplex.com/svn) C# · 499 lines
95 string normalizedPath = LongPathCommon.NormalizeLongPath(path);
96 if (!NativeMethods.DeleteFile(normalizedPath)) {
97 throw LongPathCommon.GetExceptionFromLastWin32Error();
98 }
99 }
162 if (!NativeMethods.MoveFile(normalizedSourcePath, normalizedDestinationPath))
163 throw LongPathCommon.GetExceptionFromLastWin32Error();
164 }
242 if (!NativeMethods.CopyFile(normalizedSourcePath, normalizedDestinationPath, !overwrite))
243 throw LongPathCommon.GetExceptionFromLastWin32Error();
244 }
TimerQueueTimer.cs (https://gitlab.com/matt81093/space-station-14) C# · 213 lines
65 if (Handle == IntPtr.Zero)
66 {
67 throw new Win32Exception(Marshal.GetLastWin32Error(), "Error creating timer queue.");
68 }
69 }
125 if (!rslt)
126 {
127 int err = Marshal.GetLastWin32Error();
128 throw new Win32Exception(err, "Error disposing timer queue");
129 }
166 if (!rslt)
167 {
168 throw new Win32Exception(Marshal.GetLastWin32Error(), "Error creating timer.");
169 }
170 }
COMError.cpp (https://github.com/Templier/desktopx.git) C++ · 138 lines
DIBSection.cs (https://gitlab.com/gpo04174/HSAudio) C# · 197 lines
Cmdline.c (https://github.com/pcmac77/truecrypt-android.git) C · 244 lines
subprocess.h (https://github.com/chromium/chromium.git) C Header · 113 lines
PosixElectricFencedMemory.cs (https://github.com/fitzchak/ravendb.git) C# · 122 lines
24 if (virtualAlloc == (byte*)-1)
25 {
26 var err = Marshal.GetLastWin32Error();
27 throw new InvalidOperationException("Failed to mmap with size " + allocatedSize + " . Err=" + err);
28 }
31 if (msync != 0)
32 {
33 throw new InvalidOperationException("Failed to free call msync " + (IntPtr)virtualAlloc + ". Err=" + Marshal.GetLastWin32Error());
34 }
40 if (virtualAlloc == (byte*)-1)
41 {
42 var err = Marshal.GetLastWin32Error();
43 throw new InvalidOperationException("Failed to re-mmap with size " + allocatedSize + " . Err=" + err);
44 }
ProcessExtensions.cs (https://bitbucket.org/Reivalyn/make-window-fullscreen.git) C# · 84 lines
29 if (hprocess == IntPtr.Zero)
30 {
31 var errorCode = Marshal.GetLastWin32Error();
33 const int AccessDeniedErrorCode = 0x5;
46 if (!SafeNativeMethods.QueryFullProcessImageName(hprocess, 0, buffer, ref size))
47 {
48 throw new Win32Exception(Marshal.GetLastWin32Error(), string.Format("Failed to query the image name for process {0}: \"{1}\"", process.Id, process.ProcessName));
49 }
FileEnumerator.vb
(https://cfx.svn.codeplex.com/svn)
Visual Basic · 230 lines
✨ Summary
This Visual Basic code implements an IEnumerable(Of String)
that uses Win32 File Management functions to enumerate files and subdirectories in a specified directory one item at a time, based on a given search pattern and mode (directory or file). It provides methods for finding the next match, resetting the enumerator, and disposing of resources.
This Visual Basic code implements an IEnumerable(Of String)
that uses Win32 File Management functions to enumerate files and subdirectories in a specified directory one item at a time, based on a given search pattern and mode (directory or file). It provides methods for finding the next match, resetting the enumerator, and disposing of resources.
111 If Me.hFindFile.IsInvalid Then
112 ' Got an invalid find handle, get the error code
113 Dim code As Integer = Marshal.GetLastWin32Error()
115 If code = NativeMethods.ERROR_FILE_NOT_FOUND Then
147 End While
149 Dim code As Integer = Marshal.GetLastWin32Error()
151 If code = NativeMethods.ERROR_NO_MORE_FILES Then
processwaithandle.cs (https://github.com/pruiz/mono.git) C# · 38 lines
24 if (!succeeded) {
25 #if MONO
26 // In Mono, Marshal.GetHRForLastWin32Error is not implemented;
27 // and also DuplicateHandle throws its own exception rather
28 // than returning false on error, so this code is unreachable.
29 throw new SystemException("Unknown error in DuplicateHandle");
30 #else
31 Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
32 #endif
33 }
PosixHelper.cs (https://github.com/fitzchak/ravendb.git) C# · 189 lines
52 if (fd == -1)
53 {
54 var err = Marshal.GetLastWin32Error();
55 Syscall.ThrowLastError(err, "when opening " + path);
56 }
68 if (written == -1)
69 {
70 var err = Marshal.GetLastWin32Error();
71 Syscall.ThrowLastError(err, "writing to " + path);
72 }
77 if (Syscall.FSync(fd) == -1)
78 {
79 var err = Marshal.GetLastWin32Error();
80 Syscall.ThrowLastError(err, "FSync " + path);
81 }
CnGlobalKeyHook.pas (http://cnpack.googlecode.com/svn/trunk/) Pascal · 365 lines
Native.SetupApiAdapter.fs (https://github.com/jwelch222/HidLibrary.git) F# · 128 lines
19 let success = SetupApi.SetupDiEnumDeviceInterfaces(handle, &info, &classFilter, index, &deviceInterface)
20 if not success then
21 let error = Marshal.GetLastWin32Error()
22 match error with
23 | SetupApi.ERROR_NO_MORE_ITEMS -> (deviceInterface,false)
24 | SetupApi.SUCCESS -> (deviceInterface,false)
25 | _ -> raise (Win32Exception(Marshal.GetLastWin32Error()))
26 else (deviceInterface,true)
46 | false -> DeviceInterfaceGetClassFlags.DEVICEINTERFACE
47 let handle = SetupApi.SetupDiGetClassDevs(&classFilter, null, IntPtr.Zero, flags)
48 let error = Marshal.GetLastWin32Error()
49 match error with
50 | 0 -> handle
Win32Security.cs (https://github.com/RoDaniel/featurehouse.git) C# · 137 lines
30 if (!GetFileSecurity(path, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, fileSD, 0, out sdLength))
31 {
32 lastError = Marshal.GetLastWin32Error();
33 if (lastError != ERROR_INSUFFICIENT_BUFFER)
34 {
38 if (!GetFileSecurity(path, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION, fileSD, sdLength, out sdLength))
39 {
40 lastError = Marshal.GetLastWin32Error();
41 return accessAllowed;
42 }
54 if (!ImpersonateSelf(SECURITY_IMPERSONATION_LEVEL.SecurityImpersonation))
55 {
56 lastError = Marshal.GetLastWin32Error();
57 return accessAllowed;
58 }
WinWindowInfo.cs (https://github.com/virtualglobebook/OpenGlobe.git) C# · 173 lines
IniFileManager.cs (https://bitbucket.org/xact/cs.ff.xact.lib.git) C# · 244 lines
17 /// <para>
18 /// I've built this class too many times in too many languages...this time, the code was found for free at: http://archive.devx.com/dotnet/discussions/040902/cominterop.asp, thank you!...Although he does end with:
19 /// this code is meant for example use only. You should add error-trapping and checking (see the DllImportAttribute.SetLastError field in the documentation, and the Marshal.GetLastWin32Error method in the documentation for more information.)
20 /// </para>
21 /// <para>
memory.c (https://github.com/BeyondTrust/pbis-open.git) C · 216 lines
EmbeddedDLLLoader.cs (git://github.com/kevingadd/Fracture.git) C# · 121 lines
File64.cpp (https://github.com/jeeb/avisynth.git) C++ · 166 lines
56 if (lActual < 0)
57 throw MyWin32Error("Failure reading file: %%s.",GetLastError());
59 if (lActual != len)
82 if (0xFFFFFFFF == SetFilePointer(hFile, (LONG)i64NewPos, &lHi, FILE_BEGIN))
83 if ((dwError = GetLastError()) != NO_ERROR)
84 throw MyWin32Error("File64: %%s", dwError);
86 i64FilePosition = i64NewPos;
109 if (0xFFFFFFFF == (lNewLow = SetFilePointer(hFile, (LONG)bytes, &lHi, FILE_CURRENT)))
110 if ((dwError = GetLastError()) != NO_ERROR)
111 throw MyWin32Error("File64: %%s", dwError);
113 i64FilePosition = (unsigned long)lNewLow | (((__int64)(unsigned long)lHi)<<32);
Microsoft_Windows_WebAuthN.py (https://github.com/airbus-cert/etl-parser.git) Python · 888 lines
CollationKeyFilter.cs (https://github.com/fitzchak/ravendb.git) C# · 139 lines
60 var length = PosixNativeMethods.GetSortKey(sortHandle, text, text.Length, null, 0, CompareOptions.None);
61 if (length == 0)
62 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to GetSortKey for text=" + text);
64 var sortKey = new byte[length];
68 length = PosixNativeMethods.GetSortKey(sortHandle, text, text.Length, pSortKey, sortKey.Length, CompareOptions.None);
69 if (length == 0)
70 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to GetSortKey for text=" + text);
71 return sortKey;
72 }
77 var length = Win32NativeMethods.LCMapStringEx(_cultureInfo.CompareInfo.Name, Win32NativeMethods.LCMAP_SORTKEY, text, text.Length, IntPtr.Zero, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
78 if (length == 0)
79 throw new Win32Exception(Marshal.GetLastWin32Error(), "Failed to GetSortKey for text=" + text);
81 var sortKey = new byte[length];
Window1.xaml.cs (https://github.com/urasandesu/NTroll.git) C# · 145 lines
91 //else
92 //{
93 // Console.WriteLine("Expected error at GetWindow. {0}", new Win32Exception(Marshal.GetLastWin32Error()).Message);
94 //}
132 else
133 {
134 //Console.WriteLine("Expected error at GetWindowText. {0}", new Win32Exception(Marshal.GetLastWin32Error()).Message);
135 return null;
136 }
138 else
139 {
140 //Console.WriteLine("Expected error at GetWindowTextLength. {0}", new Win32Exception(Marshal.GetLastWin32Error()).Message);
141 return null;
142 }
memory.c (https://github.com/vmware/lightwave.git) C · 636 lines
265 ulError = LwNtStatusToWin32Error(
266 LwRtlCStringAllocatePrintfV(
267 ppszString,
296 else
297 {
298 dwError = LwNtStatusToWin32Error(
299 LwRtlWC16StringDuplicate(ppwszDst, pwszSrc));
300 BAIL_ON_LWCA_ERROR(dwError);
327 else
328 {
329 dwError = LwNtStatusToWin32Error(
330 LwRtlWC16StringAllocateFromCString(ppwszDst, pszSrc));
331 }
Memory.cs (https://github.com/warbler/SharpMonoInjector.git) C# · 104 lines
60 if (!Native.ReadProcessMemory(_handle, address, bytes, size))
61 throw new InjectorException("Failed to read process memory", new Win32Exception(Marshal.GetLastWin32Error()));
63 return bytes;
85 if (addr == IntPtr.Zero)
86 throw new InjectorException("Failed to allocate process memory", new Win32Exception(Marshal.GetLastWin32Error()));
88 _allocations.Add(addr, size);
93 {
94 if (!Native.WriteProcessMemory(_handle, addr, data, data.Length))
95 throw new InjectorException("Failed to write process memory", new Win32Exception(Marshal.GetLastWin32Error()));
96 }
PipeCompletionSource.cs (https://gitlab.com/0072016/0072016-corefx-) C# · 185 lines
TempFile.cs (https://github.com/DavidMoore/Foundation.git) C# · 125 lines
_AcceptOverlappedAsyncResult.cs (https://github.com/pruiz/mono.git) C# · 171 lines
87 Marshal.SizeOf(handle));
89 if (errorCode == SocketError.SocketError) errorCode = (SocketError) Marshal.GetLastWin32Error();
90 GlobalLog.Print("AcceptOverlappedAsyncResult#" + ValidationHelper.HashString(this) + "::PostCallback() setsockopt handle:" + handle.ToString() + " AcceptSocket:" + ValidationHelper.HashString(m_AcceptSocket) + " itsHandle:" + m_AcceptSocket.SafeHandle.DangerousGetHandle().ToString() + " returns:" + errorCode.ToString());
91 }