René's URL Explorer Experiment


Title: Interop.cs minor changes · Issue #41 · GhostPack/SharpDPAPI · GitHub

Open Graph Title: Interop.cs minor changes · Issue #41 · GhostPack/SharpDPAPI

X Title: Interop.cs minor changes · Issue #41 · GhostPack/SharpDPAPI

Description: Hi, I just wanted to leave this here in case anyone is interested in adding this. It may not be suitable due to compatibility requirements on the project, but the changes get rid of some warnings for newer C# and .NET. diff --git a/Inter...

Open Graph Description: Hi, I just wanted to leave this here in case anyone is interested in adding this. It may not be suitable due to compatibility requirements on the project, but the changes get rid of some warnings f...

X Description: Hi, I just wanted to leave this here in case anyone is interested in adding this. It may not be suitable due to compatibility requirements on the project, but the changes get rid of some warnings f...

Opengraph URL: https://github.com/GhostPack/SharpDPAPI/issues/41

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Interop.cs minor changes","articleBody":"Hi,\r\n\r\nI just wanted to leave this here in case anyone is interested in adding this. It may not be suitable due to compatibility requirements on the project, but the changes get rid of some warnings for newer C# and .NET.\r\n\r\n```patch\r\ndiff --git a/Interop.cs b/Interop.cs\r\nindex 99544ba..c864c8c 100644\r\n--- a/Interop.cs\r\n+++ b/Interop.cs\r\n@@ -1,16 +1,10 @@\r\n-using System;\r\n-using System.Collections.Generic;\r\n-using System.ComponentModel;\r\n-using System.Diagnostics;\r\n-using System.Linq;\r\n+using System.ComponentModel;\r\n using System.Runtime.InteropServices;\r\n-using System.Security.Principal;\r\n using System.Text;\r\n-using System.Text.RegularExpressions;\r\n \r\n namespace SharpDPAPI\r\n {\r\n     public class Interop\r\n     {\r\n         public enum CryptAlgClass : uint\r\n         {\r\n@@ -164,15 +158,15 @@ namespace SharpDPAPI\r\n             {\r\n                 Marshal.FreeHGlobal(buffer);\r\n                 buffer = IntPtr.Zero;\r\n             }\r\n \r\n             public override string ToString()\r\n             {\r\n-                return Marshal.PtrToStringUni(buffer);\r\n+                return Marshal.PtrToStringUni(buffer) ?? \"\";\r\n             }\r\n         }\r\n \r\n         // From Vincent LE TOUX' \"MakeMeEnterpriseAdmin\"\r\n         //  https://github.com/vletoux/MakeMeEnterpriseAdmin/blob/master/MakeMeEnterpriseAdmin.ps1#L1773-L1794\r\n         [StructLayout(LayoutKind.Sequential)]\r\n         public struct KERB_ECRYPT\r\n@@ -280,15 +274,15 @@ namespace SharpDPAPI\r\n             {\r\n                 Marshal.FreeHGlobal(buffer);\r\n                 buffer = IntPtr.Zero;\r\n             }\r\n \r\n             public override string ToString()\r\n             {\r\n-                return Marshal.PtrToStringUni(buffer);\r\n+                return Marshal.PtrToStringUni(buffer) ?? \"\";\r\n             }\r\n         }\r\n \r\n         [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]\r\n         public struct DOMAIN_CONTROLLER_INFO\r\n         {\r\n             [MarshalAs(UnmanagedType.LPTStr)]\r\n@@ -545,29 +539,33 @@ namespace SharpDPAPI\r\n         public  static extern int NetApiBufferFree(IntPtr Buffer);\r\n \r\n \r\n         public static string GetDCName()\r\n         {\r\n             // retrieves the current domain controller name\r\n             // adapted from https://www.pinvoke.net/default.aspx/netapi32.dsgetdcname\r\n-            DOMAIN_CONTROLLER_INFO domainInfo;\r\n+            DOMAIN_CONTROLLER_INFO? domainInfo;\r\n             const int ERROR_SUCCESS = 0;\r\n             IntPtr pDCI = IntPtr.Zero;\r\n \r\n             int val = DsGetDcName(\"\", \"\", 0, \"\",\r\n             DSGETDCNAME_FLAGS.DS_DIRECTORY_SERVICE_REQUIRED |\r\n             DSGETDCNAME_FLAGS.DS_RETURN_DNS_NAME |\r\n             DSGETDCNAME_FLAGS.DS_IP_REQUIRED, out pDCI);\r\n \r\n             if (ERROR_SUCCESS == val)\r\n             {\r\n-                domainInfo = (DOMAIN_CONTROLLER_INFO)Marshal.PtrToStructure(pDCI, typeof(DOMAIN_CONTROLLER_INFO));\r\n-                string dcName = domainInfo.DomainControllerName;\r\n+                domainInfo = (DOMAIN_CONTROLLER_INFO?)Marshal.PtrToStructure(pDCI, typeof(DOMAIN_CONTROLLER_INFO));\r\n+                if (domainInfo is null)\r\n+                {\r\n+                    return \"\";\r\n+                }\r\n+                string? dcName = domainInfo?.DomainControllerName;\r\n                 NetApiBufferFree(pDCI);\r\n-                return dcName.Trim('\\\\');\r\n+                return dcName?.Trim('\\\\') ?? \"\";\r\n             }\r\n             else\r\n             {\r\n                 string errorMessage = new Win32Exception((int)val).Message;\r\n                 Console.WriteLine(\"\\r\\n  [X] Error {0} retrieving domain controller : {1}\", val, errorMessage);\r\n                 NetApiBufferFree(pDCI);\r\n                 return \"\";\r\n```\r\n\r\nSame patch as zipped up .diff file: [patch.zip](https://github.com/user-attachments/files/17559677/patch.zip).\r\n\r\nPS: this should apply cleanly to 4428263fe85bb1fde1640b6208d11dff6db4fb55.","author":{"url":"https://github.com/exoosh","@type":"Person","name":"exoosh"},"datePublished":"2024-10-29T15:52:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/41/SharpDPAPI/issues/41"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f763b553-7718-6a82-ab09-537d89a77d15
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE696:344520:3CE90F8:511E754:6981AD73
html-safe-nonce6110c846e87fbbe5efd79c15c60b63351deb3d5cae08c21768a06cb1ae0b0304
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjk2OjM0NDUyMDozQ0U5MEY4OjUxMUU3NTQ6Njk4MUFENzMiLCJ2aXNpdG9yX2lkIjoiMTkyNTc2MDQwNDExMDI5MDI5MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfa94c78508158ab769b5965734c5306551e155d6b98357eed211399a0696f2e2
hovercard-subject-tagissue:2621681224
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/GhostPack/SharpDPAPI/41/issue_layout
twitter:imagehttps://opengraph.githubassets.com/65ec3e485921324548a23391584d1572ae0a9fabfd4063ef0eab1635d7bd602d/GhostPack/SharpDPAPI/issues/41
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/65ec3e485921324548a23391584d1572ae0a9fabfd4063ef0eab1635d7bd602d/GhostPack/SharpDPAPI/issues/41
og:image:altHi, I just wanted to leave this here in case anyone is interested in adding this. It may not be suitable due to compatibility requirements on the project, but the changes get rid of some warnings f...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameexoosh
hostnamegithub.com
expected-hostnamegithub.com
Nonee137814e266030874fd2c86863529d0622b13889eeda04148c57654b6ea84ad6
turbo-cache-controlno-preview
go-importgithub.com/GhostPack/SharpDPAPI git https://github.com/GhostPack/SharpDPAPI.git
octolytics-dimension-user_id41304335
octolytics-dimension-user_loginGhostPack
octolytics-dimension-repository_id145742418
octolytics-dimension-repository_nwoGhostPack/SharpDPAPI
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id145742418
octolytics-dimension-repository_network_root_nwoGhostPack/SharpDPAPI
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasedd58d68a7813bbec9c91422c8c35f4af33832d70
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues/41#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FGhostPack%2FSharpDPAPI%2Fissues%2F41
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2FGhostPack%2FSharpDPAPI%2Fissues%2F41
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=GhostPack%2FSharpDPAPI
Reloadhttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues/41
Reloadhttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues/41
Reloadhttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues/41
GhostPack https://patch-diff.githubusercontent.com/GhostPack
SharpDPAPIhttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2FGhostPack%2FSharpDPAPI
Fork 240 https://patch-diff.githubusercontent.com/login?return_to=%2FGhostPack%2FSharpDPAPI
Star 1.4k https://patch-diff.githubusercontent.com/login?return_to=%2FGhostPack%2FSharpDPAPI
Code https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI
Issues 10 https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues
Pull requests 2 https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/pulls
Actions https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/actions
Projects 0 https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/projects
Security 0 https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/security
Insights https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/pulse
Code https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI
Issues https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues
Pull requests https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/pulls
Actions https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/actions
Projects https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/projects
Security https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/security
Insights https://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/GhostPack/SharpDPAPI/issues/41
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/GhostPack/SharpDPAPI/issues/41
Interop.cs minor changeshttps://patch-diff.githubusercontent.com/GhostPack/SharpDPAPI/issues/41#top
https://github.com/exoosh
https://github.com/exoosh
exooshhttps://github.com/exoosh
on Oct 29, 2024https://github.com/GhostPack/SharpDPAPI/issues/41#issue-2621681224
patch.ziphttps://github.com/user-attachments/files/17559677/patch.zip
4428263https://github.com/GhostPack/SharpDPAPI/commit/4428263fe85bb1fde1640b6208d11dff6db4fb55
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.