#PInvoke

2025-02-09

От сервера к десктопу: эксперимент с ASP.NET AOT и WebKitGTK

В этой статье я расскажу об экспериментальной связке технологий, которую я раньше не встречал нигде и основным мотиватором была проверка жизнеспособности этой идеи. Цель этого эксперимента — проверка жизнеспособности стека ASP .NET + WebKitGTK + frontend на JS/TS. Этот стек предназначен для работы на ОС Linux. В проекте весь код написан на C# за исключением клиентской части, которая реализована при помощи TypeScript и Angular 19.1. Этот концепт представляет из себя приложение, которое получает данные из Github API и для выбранного языка программирования проводит анализ количества новых репозиториев github по годам, строя линейную диаграмму, показывая тем самым тренд языка программирования. Этот анализ изначально не слишком объективен, но для тестового приложения вполне нормальный сценарий использования. В приложении на том же WebKitGTK реализована OAuth аутентификация Github. Полученные токены хранятся в системе при помощи библиотеки libsecret в зашифрованном (AES) виде. После первого входа пользователю необходимо установить пин-код, который является частью ключа. Немного заморочился с безопасностью токенов, да =)

habr.com/ru/articles/880908/

#ASPNET #NET #AOT #WebKitGTK #Angular #TypeScript #C# #SkiaSharp #GraphQL #PInvoke

2024-11-15

Please explain to me, why a #PInvoke call would be able to heap corrupt a managed #DotNet #CSharp application, when invoking that method repeatedly (<5 times).
If - and only if - that application is running in a packaged MSIX environment (with full trust enabled) since 24H2.

Running that application standalone doesn’t cause a crash.

#Microsoft #Windows

💾 Paweł Łukasikpawel_lukasik@infosec.exchange
2024-04-17

P/Invoke is a way to allow unmanaged libraries from managed code. In the old days, it was a way to access Windows API that was not yet available in the .NET framework.

Since .NET became multi-platform, being present on Mac and Linux, P/Invoke has also been available on those platforms.

To import a native method that we would like to use, we need to create a static extern function and mark it with the DllImport attribute.

The DllImport attribute allows us to specify the native library from which the function should be loaded, as well as some extra parameters to cover more complex scenarios.

Docs 📑: learn.microsoft.com/en-us/dotn

#dotnet #platforminvoke #pinvoke
---
If you find this useful, consider giving a like & share ♻

C# code using p/invoke.
2024-03-08

I'm happy to announce that my NDC Porto talk "Introduction to unsafe C#: Calling native code and crashing in entirely new ways" is now available on YouTube. Thanks NDC for having me and for making all recordings available for free!
#NDC #NDCPorto #NDCConferences #dotnet #CSharp #PInvoke #UnsafeCSharp
youtube.com/watch?v=aSm8o2EIyv

2023-01-23

Fresh new PowerShell module called ctypes powershellgallery.com/packages. This makes it easier to prototype PInvoke calls in PowerShell. As an example, to call `GetCurrentProcess()`, it's simply:

$k32 = New-CtypesLib Kernel32.dll
$k32.GetCurrentProcess[IntPtr]()

#powershell #pinvoke

heise online (inoffiziell)heiseonline@squeet.me
2021-05-10
heise+ | Mit PowerShell Windows-Funktionen steuern: Fenster verstecken, Klänge erzeugen

Mit PowerShell und der Win32-API können Sie Funktionen aufrufen, für die es weder Cmdlets noch Aufrufe in .NET gibt. Ein Einstieg mit Praxisbeispielen. Mit PowerShell Windows-Funktionen steuern: Fenster verstecken, Klänge erzeugen

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst