{"id":16683407,"url":"https://github.com/quahu/dynamicium","last_synced_at":"2026-04-27T09:02:17.278Z","repository":{"id":113778169,"uuid":"449275100","full_name":"Quahu/Dynamicium","owner":"Quahu","description":"Dynamic P/Invoke copium","archived":false,"fork":false,"pushed_at":"2022-01-18T14:41:16.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-27T20:46:31.383Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Quahu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["Quahu"],"custom":["https://paypal.me/quahu"]}},"created_at":"2022-01-18T12:27:27.000Z","updated_at":"2022-01-18T14:41:20.000Z","dependencies_parsed_at":"2023-03-14T00:15:45.907Z","dependency_job_id":null,"html_url":"https://github.com/Quahu/Dynamicium","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Quahu/Dynamicium","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quahu%2FDynamicium","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quahu%2FDynamicium/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quahu%2FDynamicium/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quahu%2FDynamicium/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Quahu","download_url":"https://codeload.github.com/Quahu/Dynamicium/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Quahu%2FDynamicium/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32329466,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T14:24:27.038Z","updated_at":"2026-04-27T09:02:17.244Z","avatar_url":"https://github.com/Quahu.png","language":"C#","funding_links":["https://github.com/sponsors/Quahu","https://paypal.me/quahu"],"categories":[],"sub_categories":[],"readme":"# Dynamicium\r\nThis is a simple proof of concept for dynamically mapping library exports to delegates using the [`dynamic`](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/reference-types#the-dynamic-type) type.\r\n\r\n## Examples\r\n### `kernel32.dll`:\r\n```cs\r\nusing (dynamic kernel32 = new Kernel32())\r\n{\r\n    kernel32.Beep(2000, 100);\r\n\r\n    var currentThreadId = kernel32.GetCurrentThreadId\u003cuint\u003e();\r\n    Console.WriteLine($\"Current thread ID is {currentThreadId}.\");\r\n}\r\n```\r\n\r\n### `user32.dll`:\r\n```cs\r\nusing (dynamic user32 = new User32())\r\n{\r\n    var monitorCount = user32.GetSystemMetrics\u003cint\u003e(0x50);\r\n    var (x, y) = (user32.GetSystemMetrics\u003cint\u003e(0), user32.GetSystemMetrics\u003cint\u003e(1));\r\n\r\n    var message = $\"You have {monitorCount} monitors.\\n\"\r\n        + $\"Your primary monitor's resolution is {x}x{y}.\";\r\n\r\n    // Null arguments are replaced with null pointers.\r\n    user32.MessageBoxA(null, message, \"Important Info\";, 0x40);\r\n}\r\n```\r\n\r\n### Custom Library (`winmm.dll`):\r\n```cs\r\nusing (dynamic winmm = new DynamicLibrary(\"winmm\"))\r\n{\r\n    const string fileName = \"bgm001.wav\"; // Huh? You don't know, pal?\r\n    winmm.PlaySoundA(fileName, null, 0x1 | 0x8 | 0x20000);\r\n}\r\n```\r\n\r\n## Short Explanation\r\nThe only important type in this project is the [`DynamicLibrary`](/src/Dynamicium/DynamicLibrary.cs) type - a native library handle wrapper that implements [`DynamicObject`](https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicobject). It overrides [TryInvokeMember](https://docs.microsoft.com/en-us/dotnet/api/system.dynamic.dynamicobject.tryinvokemember) which creates delegates from the provided arguments as necessary to be used with [Marshal.GetDelegateForFunctionPointer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.marshal.getdelegateforfunctionpointer) and the library export that matches the invoked method's name.\r\n\r\nTypes such as [`User32`](/src/Dynamicium/Impl/User32.cs) and [`Kernel32`](/src/Dynamicium/Impl/Kernel32.cs) are nothing special, they are implementations of the above explained type with the respective library names passed to its constructor.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquahu%2Fdynamicium","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquahu%2Fdynamicium","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquahu%2Fdynamicium/lists"}