Skip to content

Instantly share code, notes, and snippets.

View kant2002's full-sized avatar

Andrii Kurdiumov kant2002

View GitHub Profile
@kant2002
kant2002 / GdipCreateBitmapFromStream.cs
Last active June 4, 2021 08:43
System.Drawing and NativeAOT
[DllImport("gdiplus.dll", ExactSpelling = true)]
internal static extern int GdipCreateBitmapFromStream(IStream stream, out IntPtr bitmap);
@kant2002
kant2002 / Interop.OleCreatePictureIndirect.cs
Last active March 25, 2023 18:39
WinForms and NativeAOT
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
internal static partial class Interop
{
internal static partial class Ole32
@kant2002
kant2002 / dgml2dot.py
Created May 17, 2021 18:20
DGML to Dot file conversion for NativeAOT analysis
#!/usr/bin/env python3
import re
import sys
import xml.etree.ElementTree as ET
###########################################
def to_dot(fd):
'''TODO
'''
@kant2002
kant2002 / IMallocSpy.cs
Last active April 23, 2021 10:46
COM in NativeAOT
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("0000001d-0000-0000-C000-000000000046")]
public interface IMallocSpy
{
[PreserveSig]
uint PreAlloc(uint cbRequest);
[PreserveSig]
void* PostAlloc(void* pActual);
[PreserveSig]
@kant2002
kant2002 / Benchmarks.txt
Last active April 2, 2021 05:24
NativeAOT and databases
// * Summary *
BenchmarkDotNet=v0.12.1.20210402-develop, OS=Windows 10.0.19042.867 (20H2/October2020Update)
Intel Core i7-6700HQ CPU 2.60GHz (Skylake), 1 CPU, 8 logical and 4 physical cores
.NET SDK=5.0.201
[Host] : .NET 5.0.4 (5.0.421.11614), X64 RyuJIT
ShortRun : .NET 6.0.0-preview.4.21175.3, X64 AOT
| ORM | Method | Return | Mean | StdDev | Error | Gen 0 | Gen 1 | Gen 2 | Allocated |
using System;
Console.WriteLine("Hello UEFI!");
@kant2002
kant2002 / commandlinesuppor.cs
Created February 5, 2021 12:20
Code for Runtime library to support command line parameters
namespace Internal.Runtime.CompilerHelpers
{
internal partial class StartupCodeHelpers
{
internal static unsafe void InitializeCommandLineArgsW(
int argc, char** argv)
{
}
internal static unsafe void InitializeCommandLineArgs(
@kant2002
kant2002 / entrypoint.cs
Created February 5, 2021 12:16
Generated code by ILC
using Internal.Runtime.CompilerHelpers;
// ....
int main(int argc, char** argv)
{
StartupCodeHelpers.InitializeCommandLineArgsW(argc, argv);
String[] arguments = StartupCodeHelpers.GetMainMethodArguments();
int exitCode = __managed_Main(arguments);
StartupCodeHelpers.SetLatchedExitCode(exitCode);
@kant2002
kant2002 / augmentations.d.ts
Last active July 31, 2020 15:41
jQueryEventextension
/// <reference types="jquery" />
declare interface JQuery {
on(events: ':passageinit', handler: (this: JQuery, t: x, ...args: any[]) => any): this;
}
@kant2002
kant2002 / setup-vm.ps1
Created March 23, 2020 22:24
Create Virtual Machine for UEFI CoreRT application
New-VM -Name SeeSharpSnake -MemoryStartupBytes 32MB -Generation 2 -VHDPath "bin\x64\Release\netcoreapp3.1\win-x64\native\seesharpsnake.vhdx"
Set-VMFirmware -VMName SeeSharpSnake -EnableSecureBoot Off
Set-VM -Name SeeSharpSnake -AutomaticCheckpointsEnabled $false -CheckpointType Disabled