Advertisement
joric

How we code in Microsoft

Aug 25th, 2011
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.60 KB | None | 0 0
  1. //WIC (Windows Imaging Component), Microsoft Corp.
  2. //"C with classes", no exceptions, only HRESULT
  3.  
  4. #define IFC(x) if (FAILED(hr=x)) { goto cleanup; }
  5. ...
  6. HRESULT Foo(...)
  7. {
  8.     HRESULT hr;
  9.     IFC(Foo1(...));
  10.     ...
  11.     IFC(Foo2(...));
  12.     ...
  13. cleanup:
  14.     // Do the cleanup
  15.     return hr;
  16. }
  17.  
  18. //Overflow checking
  19. IFC(UIntMult(b,c,&a)); //a = b * c
  20.  
  21. //Annotated parameters - __in, __out
  22. HRESULT Foo(
  23.     __in UINT inparam,
  24.     __in_ecount(inparam) UINT* inarray,
  25.     __out UINT* outparam,
  26.     __deref_out_ecount(outparam) UINT** outarray)
  27. ...
  28.  
  29. Microsoft DDK:
  30.  
  31. 17 parameters:
  32.  
  33. _Must_inspect_result_ __kernel_entry NTSYSCALLAPI NTSTATUS NTAPI NtAccessCheckByTypeResultListAndAuditAlarmByHandle (
  34.     _In_ PUNICODE_STRING SubsystemName,
  35.     _In_opt_ PVOID HandleId,
  36.     _In_ HANDLE ClientToken,
  37.     _In_ PUNICODE_STRING ObjectTypeName,
  38.     _In_ PUNICODE_STRING ObjectName,
  39.     _In_ PSECURITY_DESCRIPTOR SecurityDescriptor,
  40.     _In_opt_ PSID PrincipalSelfSid,
  41.     _In_ ACCESS_MASK DesiredAccess,
  42.     _In_ AUDIT_EVENT_TYPE AuditType,
  43.     _In_ ULONG Flags,
  44.     _In_reads_opt_(ObjectTypeListLength) POBJECT_TYPE_LIST ObjectTypeList,
  45.     _In_ ULONG ObjectTypeListLength,
  46.     _In_ PGENERIC_MAPPING GenericMapping,
  47.     _In_ BOOLEAN ObjectCreation,
  48.     _Out_writes_(ObjectTypeListLength) PACCESS_MASK GrantedAccess,
  49.     _Out_writes_(ObjectTypeListLength) PNTSTATUS AccessStatus,
  50.     _Out_ PBOOLEAN GenerateOnClose
  51.     );
  52.  
  53. Also see:
  54.  
  55. NtAccessCheckByTypeResultListAndAuditAlarmByHandle2
  56. NtAccessCheckByTypeResultListAndAuditAlarmByHandle3
  57. NtAccessCheckByTypeResultListAndAuditAlarmByHandle4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement