Skip to content

Instantly share code, notes, and snippets.

@Novakov
Novakov / gist:8055374
Created December 20, 2013 14:17
C# pipeline written using | operator - like command line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace PipelineOperators
{
class Program
@Novakov
Novakov / usart.c
Created January 26, 2016 14:25
EFM32
USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;
init.enable = usartDisable;
CMU_ClockEnable(cmuClock_USART1, true);
GPIO_PinModeSet(gpioPortD, 0, gpioModePushPull, 1);
GPIO_PinModeSet(gpioPortD, 1, gpioModeInput, 0);
USART_InitAsync(USART, &init);
USART->ROUTE = USART_ROUTE_LOCATION_LOC1 | USART_ROUTE_RXPEN | USART_ROUTE_TXPEN;
@Novakov
Novakov / merge.ps1
Last active February 17, 2016 15:37
TFS Powershell scripts
param([string]$repo, [string]$source,[string]$dest)
$base = "$/MAPS Onboard/Dev/$repo"
set-alias tf 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe'
tf get /recursive "$base/$source"
tf merge /recursive "$base/$source" "$base/$dest"
package test;
import java.io.IOException;
import org.kohsuke.github.GHCommitState;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GitHub;
public class Program {
@Novakov
Novakov / EnvInjectionHelper.fs
Last active March 11, 2016 21:17
[Blog] Ustawianie zmiennych srodowiskowych - implementacja
open System
let rec loop () =
let c = char (Console.Read())
let response = match c with
| 'E' -> "echo"
| 'S' ->
let varName = Console.ReadLine()
let varValue = Console.ReadLine()
@Novakov
Novakov / DllImports.fs
Last active March 14, 2016 21:22
[Blog] Wstrzykiwanie biblioteki DLL do procesu
[<DllImport("kernel32.dll", SetLastError = true)>]
extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, IntPtr lpBuffer, int nSize, int * lpNumberOfBytesWritten);
[<DllImport("kernel32.dll", SetLastError = true)>]
extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, IntPtr dwSize, AllocationType flAllocationType, MemoryProtection flProtect);
[<DllImport("kernel32.dll")>]
extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, UInt32 dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, UInt32 dwCreationFlags, IntPtr * lpThreadId);
[<DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)>]
@Novakov
Novakov / findFunction.fs
Created March 20, 2016 20:29
[Blog]O szukaniu funkcji w procesie
let findFunction (processHandle: IntPtr) (library: string) (name: string) =
let library = ToolHelp.createSnapshot(ToolHelp.SnapshotFlags.Module ||| ToolHelp.SnapshotFlags.Module32) (GetProcessId(processHandle))
|> ToolHelp.modules
|> Seq.find (fun m -> m.ModuleName.Equals(library, StringComparison.InvariantCultureIgnoreCase))
let peFile = PeFile(library.ModulePath)
let func = peFile.ExportedFunctions |> Seq.find (fun f -> f.Name.Equals(name))
library.BaseAddress + (nativeint func.Address)
@Novakov
Novakov / Pather\paket.references
Last active March 23, 2016 20:53
[Blog] Paket i Fake
System.Collections.Immutable
CommandLineParser
PeNet
Antlr4.Runtime
@Novakov
Novakov / add_injections.xml
Last active March 31, 2016 07:02
[Blog] Pakowanie aplikacji z ILRepack
<Target Name="_AddInjections">
<ItemGroup>
<Injections Include="Injection.x86">
<Arch>x86</Arch>
</Injections>
<Injections Include="Injection.x64">
<Arch>x64</Arch>
</Injections>
</ItemGroup>
<ItemGroup>
@Novakov
Novakov / command.fs
Last active April 3, 2016 19:50
[Blog] Obsługa wiersza polecenia
module Pather.Commands.Run
[<Verb("run", HelpText = "Run process with given path set")>]
type Args = {
[<Option('f', "file", Required = true, HelpText = "Input file")>]File: string;
[<Option('g', "group", Default = "default", HelpText = "Name of group to use")>]Group: string;
[<Option('m', "mode", Default = PathSet.MergeKind.Append, HelpText = "Pathset merge mode")>]Mode: PathSet.MergeKind;
[<Value(0, HelpText = "Command to run", Required = true)>]Command: string;
[<Value(1, HelpText = "Command args")>]Args: string seq
}