Skip to content

Instantly share code, notes, and snippets.

View leha-bot's full-sized avatar
🐝
"Then" (c). I may be slow to respond, sorry about this.

Alex leha-bot

🐝
"Then" (c). I may be slow to respond, sorry about this.
View GitHub Profile
@leha-bot
leha-bot / delim_istream_iterator.hpp
Last active November 9, 2016 15:50 — forked from sftrabbit/delim_istream_iterator.hpp
Iterate over a delimited input stream
#include <iterator>
#include <istream>
#include <string>
#include <cassert>
#include <cstddef>
/**
* Iterate over each part of a delimited input stream.
* For example, to split a string into a vector:
*
template<typename T>
class ConstraintUnit {
T minv, maxv, v;
typedef const T &crefT;
ConstraintUnit(const T &minval, const T &maxval)
: minv(minval), maxv (maxval)
{
}
('connect', 1, 0.0)
('send', 1, b'\x00\x00\x00\x85\xffSMBr\x00\x00\x00\x00\x18S\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe\x00\x00@\x00\x00b\x00\x02PC NETWORK PROGRAM 1.0\x00\x02LANMAN1.0\x00\x02Windows for Workgroups 3.1a\x00\x02LM1.2X002\x00\x02LANMAN2.1\x00\x02NT LM 0.12\x00', 9.812499774852768e-05)
('recv', 1, 0.011641267999948468)
('send', 1, b'\x00\x00\x00\x88\xffSMBs\x00\x00\x00\x00\x18\x07\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe\x00\x00@\x00\r\xff\x00\x88\x00\x04\x11\n\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\xd4\x00\x00\x00K\x00\x00\x00\x00\x00\x00W\x00i\x00n\x00d\x00o\x00w\x00s\x00 \x002\x000\x000\x000\x00 \x002\x001\x009\x005\x00\x00\x00W\x00i\x00n\x00d\x00o\x00w\x00s\x00 \x002\x000\x000\x000\x00 \x005\x00.\x000\x00\x00\x00', 0.011713792999216821)
('recv', 1, 0.00983434200315969)
template<typename T> // описываем типы шаблонной функции
void binary_form(T TYPE) {
int z;
for (char j = sizeof(T) * 8 - 1; j >= 0; j--) {
z = ((T)1) << j;
std::cout << ((TYPE & z) != 0) ? 1 : 0; // тернарный оператор ?:. Если условие до знака вопроса истинно,
// то возвращает то, что между вопросом и двоеточием, если не истинно, то возвращает то, что после двоеточия и до конца операции
}
}
  1. NtCreateUserProcess с флагом для создания пустого процесса. Потом поверх пустого процесса и создаются пико-процессы. https://github.com/Microwave89/createuserprocess/blob/master/createuserprocess/main.c - пример вызова этого процесса. Эта функция появилась в висте+ https://github.com/Budskii/ulib-win/blob/master/demo/ddk/safe/safe.h#L458 пойнтер на нее, там выше есть struct. http://rsdn.org/forum/winapi/4972311.hot тред по ней же. https://en.wikipedia.org/wiki/Process_Environment_Block тут тоже есть инфа

https://www.intuit.ru/studies/courses/10471/1078/lecture/16573 - интересно, что на интуите есть инфа по этой функции. По ходу, они дернули ее из windows internals.

Интерфейс функции:

@leha-bot
leha-bot / test.sh
Created April 6, 2018 07:53 — forked from arq5x/test.sh
Compress and then Decompress a string with zlib.
# compile
$ g++ zlib-example.cpp -lz -o zlib-example
# run
$ ./zlib-example
Uncompressed size is: 36
Uncompressed string is: Hello Hello Hello Hello Hello Hello!
----------
#include <iostream>
#include <stdio.h> // snprintf
#include <windows.h>
/// @example Termux Battery Info JSON Format
/// health - "COLD" | "DEAD" | "GOOD" | "OVERHEAT" | "OVER_VOLTAGE" |
/// "UNKNOWN" | "UNSPECIFIED_FAILURE" | integer
/// percentage - integer
/// plugged - "UNPLUGGED" | "PLUGGED_AC" | "PLUGGED_USB" |
/// "PLUGGED_WIRELESS" | "PLUGGED_".integer
class utf8_text_view {
const char *text;
size_t bytes_count;
public:
friend class iterator;
class iterator {
const utf8_text_view &parent;
size_t offset;
public:
// CaptureStackBackTrace
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb204633(v=vs.85).aspx
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////
void capture() {
const ULONG framesToSkip = 0;
const ULONG framesToCapture = 64;
@leha-bot
leha-bot / gist:396942f860f60b5f3565ea2441646dba
Created January 13, 2019 23:09 — forked from riverar/gist:fd6525579d6bbafc6e48
C# structures to implement "Aero Glass" blur on Windows 10
[DllImport("user32.dll")]
internal static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}