Category: Blog

  • SEH-VEH-hook-Page-Guard-Exception

    Structered/Vectored Exception Handler hook

    A demo of a Structured or Vectored Exception Handler (SEH/VEH) hook using a Page Guard Exception.

    Structured/Vectored Exception Handler

    Structured Exception Handling (SEH) is a mechanism for handling both hardware and software exceptions. This enables applications to have complete control over the handling of exceptions and provides support for debuggers. Vectored Exception Handling is an extension to Structured Exception Handling.

    When an exception is raised, a list of ExceptionFilters will be traversed until a handler for that particular exception is found. Once the ExceptionFilter is finished handling the exception, it can return control to the rest of the application.

    SEH/VEH hook

    To install a SEH hook, we will first inject the DLL in this project using a DLL injector. This DLL contains a hook function, an ExceptionFilter and an installation function.

    To install the hook, we can use SetUnhandledExceptionFilter for an SEH hook or SetVectoredExceptionHandler for a VEH hook. In both cases, the ExceptionFilter can be the same.

    In this implementation we will add a PAGE_GUARD to the memory page that contains the original function to trigger the exception. When a STATUS_GUARD_PAGE_VIOLATION is caught, we can check if the accessed address is the address of the target function. If this is the case, we can change the instruction pointer in the ContextRecord to point to our hook function. Once the ExceptionFilter is done, this will cause the program to continue from that function.

    Demo

    When a STATUS_GUARD_PAGE_VIOLATION is caught, the PAGE_GUARD is removed, so we need to reapply it at the end of the hook function.

    There is an additional problem if the accessed address on the page is not caused by the target function. In this case we will make sure the PAGE_GUARD stays applied by using STATUS_SINGLE_STEP. This will cause another exception to be throw after executing a single instruction, at which point we can reapply the page guard. Note that the program can be slowed down significantly when this happens frequently.

    The triggering and recovering from the exceptions can be accomplished in multiple different ways. For some alternative implementations of a SEH/VEH hook, you can view:

    Demo

    In this particular implementation, we will hook the MessageBoxW function in the user32.dll. The hook function will simply call the original function with a modified argument to replace the title.

    1. Clone the repository:

      git clone https://github.com/BenteVE/SEH-VEH-hook-Page-Guard-Exception.git
    2. Build the DLL for the desired architecture (x86 or x64) using Visual Studio. The architecture of the DLL should match the architecture of the target program and the used DLL injector.

    3. Use a DLL injector to inject the built DLL into the target process. The injector used here is available in another repository with a detailed explanation.

    4. Trigger an action that uses a MessageBox in the target program to verify that the hook worked. For Notepad++, attempting to close an unsaved file does this:

      Demo

    Visit original content creator repository https://github.com/BenteVE/SEH-VEH-hook-Page-Guard-Exception
  • markmyimage

    Mark My Image

    Mark my image는 웹에서 쉽게 이미지에 워터마크를 세기는 서비스입니다. 추가 기능을 개발 중에 있습니다.

    Version

    v1.0.3

    미리보기

    미리보기

    Update

    • 1.0.3
      • fix
        • 사진만 회전할 때 이미지 크기 유지하고 이미지만 잘려서 회전되는 버그 수정
        • 텍스트 멀티라인 간격 계산 수정
        • 텍스트 멀티라인 오프셋 간격 계산 수정
        • “published by” 텍스트 표시 정도 색상별 대응
        • “published by” 사이즈 이미지 크기에 따라 대응하도록 변경
      • add
        • 이미지 파일 크기 및 이름, 타입, 사이즈 표기
        • gif 파일 재생 관련 문제 알림 추가
        • 워딩 나열 간격 크기 조정 추가
        • 기본 위치 지정 시 워터마크 패딩 조정 추가
        • 각도, 폰트크기 등 조정 인풋 값 +, – 버튼 추가 (누르고 있을 시(500ms 유지), 단일 클릭 시 값 조정)
          • 해당 컴포넌트 모두 교체
    • 1.0.2
      • fix
        • 오프셋 타입 텍스트 및 값 범위 0 ~ 9
        • 폰트크기 타입 텍스트 및 값 범위 8 ~ 150
        • 기본 다크모드
        • 헤더 로고 추가
        • meta tag host 변경 안 된 부분 수정
        • 모바일 위주 UI 변경
        • published by 추가
    • 1.0.1
      • add
        • 사진만 회전 기능 추가 (좌 90도,우 90도,원래대로)
        • 이미지 레이어 블렌드 효과 선택 추가
      • fix
        • 회전 버튼 및 placement 위치 지정 버튼 UI 수정
    • 1.0.0
      • feat
        • 초기화 커밋

    작성자

    Profile
    author
    devkimson
    Visit original content creator repository https://github.com/kkn1125/markmyimage
  • 115-days-of-coding-challenge-python-HackerRank

    115-days-of-coding-challenge-python-HackerRank

    This is a coding challenge. In this challenge I’m gonna complete all the coding exercise in HackerRank python preparation.

    Subdomains

    Based on Subdomains


    Introduction

    DAY Problem
    1 Hello World
    2 If Else
    3 Arithmetic Operators
    4 Division
    5 Loop
    6 Write a function
    7 Print Function

    Basic DataTypes

    DAY Problem
    8 List Comprehensions
    9 Find The Runner Up Score
    10 Nested Lists
    11 Finding The Percentage
    12 Lists
    13 Tuples

    Strings

    DAY Problem
    14 sWAP cASE
    15 String Split And Join
    16 What’s Your Name
    17 Mutations
    18 Find A String
    19 String Validators
    20 Text Alignment
    21 Text Wrap
    22 Designer Door Mat
    23 String Formatting
    24 Alphabet Rangoli
    25 Capitalize
    26 The Minion Game
    27 Merge The Tools

    Sets

    DAY Problem
    28 Introduction To Sets
    29 No Idea
    30 Symmetric Difference
    31 Set .add()
    32 Set .discard(), .remove() & .pop()
    33 Set .union() Operation
    34 Set .intersection() Operation
    35 Set .difference() Operation
    36 Set .symmetric_difference() Operation
    37 Set Mutations
    38 The Captain’s Room
    39 Check Subset
    40 Check Strict Superset

    Math

    DAY Problem
    41 Polar Coordinates
    42 Find Angle MBC
    43 Mod Divmod
    44 Power-Mod Power
    45 Integer Comes in all sizes
    46 Triangle Quest
    47 Triangle Quest2

    Itertools

    DAY Problem
    48 Itertools .product()
    49 Itertools .permutations()
    50 Itertools .combinations()
    51 Itertools .combinations_with_replacement()
    52 Compress The String
    53 Iterables And Iterators
    54 Maximize It

    Collections

    DAY Problem
    55 Collections.Counter()
    56 DefaultDict
    57 Named Tuple
    58 Ordered Dict
    59 Word Order
    60 Collections.deque()
    61 Company Logo
    62 Piling Up

    Date and Time

    DAY Problem
    63 Calendar Module
    64 Time Delta

    Errors and Exceptions

    DAY Problem
    65 Errors And Exceptions
    66 Incorrect Regex

    Classes

    DAY Problem
    67 Dealing With Complex Number
    68 Find The Torsional Angle

    Built-Ins

    DAY Problem
    69 Zipped!
    70 Input()
    71 Python Evaluation
    72 Athlete Sort
    73 Any Or All
    74 ginortS

    Python Functionals

    DAY Problem
    75 Map And Lambda Function
    76 Validating Email Address
    77 Reduce Function

    XML

    DAY Problem
    78 XML1 – Find the Score
    79 XML2 – Find the Maximum Depth

    Closures And Decorators

    DAY Problem
    80 Standardize Mobile Number using Decorators
    81 Decorators 2 – Name Dictonary

    Debugging

    DAY Problem
    82 Words Score
    83 Default Arguments

    Regex And Parsing

    DAY Problem
    84 Detect Floating Point Number
    85 Re.split()
    86 Group(), Groups() & Groupdict()
    87 Re.findall() & Re.finditer()
    88 Re.start() & Re.end()
    89 Regex Substitution
    90 Validating Roman Numerals
    91 Validating Phone Numbers
    92 Validating And Parsing Email Address
    93 Hex Color Code
    94 HTML Parser – Part 1
    95 HTML Parser – Part 2
    96 Detect HTML Tags, Attributes and Attribute Values
    97 Validating UID
    98 Validating Credit card Number
    99 Validating Postal Codes
    100 Matrix Script

    Numpy

    DAY Problem
    101 Arrays
    102 Shape and Reshape
    103 Transpose and Flatten
    104 Concatenate
    105 Zeroes and Ones
    106 Eye and Identity
    107 Array Mathematics
    108 Floor, Ceil and Rint
    109 Sum and Prod
    110 Min and Max
    111 Mean, Var and Std
    112 Dot and Cross
    113 Inner and Outer
    114 Polynomials
    115 Linear Algebra

    —-THE END—-

    Visit original content creator repository
    https://github.com/Sugapriyan-P-K/115-days-of-coding-challenge-python-HackerRank

  • cdt-gd

    Visit original content creator repository
    https://github.com/path9263/cdt-gd

  • dhrandy-RG35XX-2023-Modern-Theme

    RG35XX dhrandy-2023-Modern-Theme

    I took the 2022 and 2023 stock theme and combined the elements I liked in both of them. I also added a few things and changed out the gaming icons for ones that, to me, more matched the theme.

    Click the link below to see all my themes. https://github.com/dhrandy/dhrandy-RG35XX-Themes

    ezgif-3-492b179e98-2

    Installation – *This only works with Garlic OS

    *Only Works with Garlic OS 1.2.3

    1. Download this theme, click on the most recent version in the Releases section and download the zip file.
    2. Open your CFW folder on your main RG35XX sd card. (It’s the same SD card that has your Garlic OS installation).
    3. Make a backup copy of your current skin folder. If this theme doesn’t work you can revert back.
    4. Copy the downloaded skin folder over the existing skin folder. Agree to overwrite.
    5. Copy lang folder over existing lang folder. Agree to overwrite.
    6. Copy font folder over existing font folder. Agree to overwrite.
    7. Enjoy your new theme and feel free to donate to my Patreon at www.patreon.com/dhrandy. If you want a one time donation, signup for 1 month and cancel.

    Boxart Option

    If you are using boxart/artwork you can use options 1 or 2 to get the text to align correctly. You don’t need to do both.

    1. Move the file in boxart optional/skin/settings.json to the skin folder and overwrite the original.

    2. Update the following in the settings.json in the skin folder (Edit with Notepad):

    For Artwork: “text-alignment”: “left”, “text-margin”: 352,

    No Artwork: “text-alignment”: “center”, “text-margin”: 16,

    Changelog

    3/11/23 – Works with Garlic OS 1.2.4

    • Added boxart optional/skin/settings.json file so it’s easier to just copy and paste if you are using boxart/artwork.
    • Resized the charging icons to the appropriate size.
    • Changed the name from Stockish to Modern theme.

    3/10/23

    -Initial upload

    Notes

    By downloading this file you take all responsibility for messing up your Anbernic RG35XX. I am not held responsible. I can’t guarantee this works with all versions of Garlic OS. Be sure to backup your current them in the skin folder! You don’t need the CFW folder on the second SD card.

    Garlic OS screenshots are saved in: CFW\retroarch.retroarch\screenshots

    If you are using a mobile browser switch to desktop mode to see the Code/Download ZIP option.

    Useful Links

    RG35XX Starter Guide (Has how to install Garlic OS and add artwork) – https://retrogamecorps.com/2023/01/03/anbernic-rg35xx-starter-guide/

    Garlic OS – https://www.patreon.com/posts/garlicos-for-76561333

    RG35XX Sub Reddit – https://www.reddit.com/r/RG35XX/

    RG35XX Themes and More – https://www.rg35xx.com/

    Visit original content creator repository https://github.com/dhrandy/dhrandy-RG35XX-2023-Modern-Theme
  • bf2csharp

    Brainfuck to C# compiler

    The program resulting from this project parses Brainfuck, compiling to C#.

    Much of the code is what’s left from an assignment at the Compiler’s course I received at college, circa 2013. At the time what everyone in my class used was Antlr-3.4, but since Antlr-4 is available as a Nuget package, it is much easier to run, so I converted it to the latter.

    Installation

    1. Clone the repository or download the github-generated zip to a directory, uncompress it, and open the solution file with Visual Studio.

    2. In Visual Studio, to be able to resolve headers and dependencies, go to View > Other Windows > Package Manager Console. Once the Package Manager opens, clic the Restore button. If that doesn’t work, enter the following:

        Update-Package Antlr4.Runtime.Standard -reinstall
    1. If that doesn’t work, then try:
        Uninstall-Package Antlr4.Runtime.Standard; Install-Package Antlr4.Runtime.Standard

    Is there anything cool with this project?

    I think so. All of the code C# generation is written in form of actions on the grammar file (bf.g4).

    How’s that?

    The following code shows the rule listOfPlus of the grammar (which contains some action):

    listOfPlus
        @init {
            int n = 0;
        }
        @after {
            push_back($"data[cursor] += (char){n};");
        }
        :   PLUS {n++;} (PLUS {n++;})*
        ;
    
    

    This rule is in almost every way equivalent to the Extended Backus Naur Form (EBNF) rule with Antlr actions:

    listOfPlus
        :   PLUS * { push_back("data[cursor]++;"); }
        ;
    

    But you don’t need a rule for that!

    Yeap, but then you don’t produce C#-pseudo-optimized code.

    Why is this somehow useful?

    If you are asking, probably it is not, at least not for you.

    Why it may be useful to others (but not to me)?

    ANTLR is a powerful tool to try compilers’ course various concepts, make domain-specific languages (DSLs) or for some cool project you might be doing, and this grammar can serve as an intro to this amazing lexer and parser generator.

    If you are looking for an example in Antlr 3.x, or just a more complete example, look no further than Yet Another Tiger Compiler, this one a semester-long assignment and final project, circa 2014.

    Is there any code optimization being applied?

    Yes, all commands adjacent, repeated in source that share the same token from {+, -, >, <} are “merged” together.

    Where do I get Brainfuck sources?

    Esolang is a good starting point.

    Where do I send all those comments and suggestions?

    Nice of you to ask. All complaints should go to /dev/null.

    Just kidding, just send those comments to me.

    Visit original content creator repository
    https://github.com/jksware/bf2csharp

  • table-relations-one-to-many-laravel8

    Build Status Total Downloads Latest Stable Version License

    TABLE RELATIONS ONE TO MANY LARAVEL

    Code to create table Relation One-to-Many with Laravel 8.

    Stack

    • Laravel 8
    • MySql
    • Artisan
    • Composer
    • Bootstrap

    The Commands

    • to create project –> composer create-project laravel/laravel:^8.0 relaciones-uno-muchos-laravel8 –ignore-platform-reqs
    • php artisan make:model Producto ( para crear el modelo Producto)
    • php artisan make:model Categoria ( para crear el modelo Categoria)
    • php artisan make:migration create_categorias_table ( para crear la migración de la tabla Categoria)
    • php artisan make:migration create_productos_table ( para crear la migración de la tabla Producto)
    • php artisan migrate ( para correr las migraciones)
    • php artisan make:controller RelacionController ( creamos un controlador para que nos gestione las relaciones)
    • php artisan serve (para mostrar en la web)

    Screenshot

    About Laravel

    Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

    Laravel is accessible, powerful, and provides tools required for large, robust applications.

    Learning Laravel

    Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

    If you don’t feel like reading, Laracasts can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

    Laravel Sponsors

    We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Patreon page.

    Premium Partners

    Contributing

    Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

    Code of Conduct

    In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

    Security Vulnerabilities

    If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

    License

    The Laravel framework is open-sourced software licensed under the MIT license.

    Visit original content creator repository https://github.com/ronytacodev/table-relations-one-to-many-laravel8
  • Magick.NET

    Visit original content creator repository
    https://github.com/shekky/Magick.NET

  • sequence_generator

    Sequence Generator

    By Clayton Boneli

    Number or letter sequences are easy to obtain when you are only interested in sequence of numbers (ascending or descending) that follow
    a predefined order, for example decimal numbers 0,1,2,3,4,5,6,7,8,9 always follow that order, the number 1 will follow the number 0, the number 3 will follow the number 2.

    Other numbers of larger quantities also follow the same order of formation, all are composed of digits between 0 and 9. This same feature for sequential letters can be applied to vowels, all of which correspond to characters sequences that follow a predefined order.

    But, what if you need to create a sequence that has a completely different formation order? A string or number that does not follow the rule natural of decimal numbers or the alphabet? For example, if you need to create sequences like the following:

    AA-0001
    AA-0002
    AA-0003
    
    AA-9999
    AB-0001
    AB-0002
    AB-0003
    
    AB-9999
    AC-0001
    AC-0002
    AC-0003
    
    AC-9999
    AD-0001
    AD-0002
    AD-0003
    
    
    Other sequence
    
    A-2019-01
    A-2019-02
    A-2019-03
    
    A-2019-99
    B-2019-01
    B-2019-02
    
    B-2019-99
    C-2019-01
    C-2019-02

    How to create growing sequences but made up of characters made up of letters, numbers, punctuation marks, etc.? For this kind of need it is that the “sequence” package was created which contains classes and the means that allow the definition of a sequence of alphanumeric values and the generation these values in ascending / descending sequential order.

    You can define any sequence of numeric or alphanumeric characters, which can be letters, numbers, decimals, hexadecimals, DNA sequence, etc. Using the sequence generator you can create sequences that will be generated in ascending or descending order.

    You can create your own sequences or use the predefined ones.

    Example:

    seq = factory("WM [0-9][0-9]")
    for x in range(100):
        print(seq.next().get())
        
    seq = factory("WM [0-9]{2}")
    for x in range(100):
        print(seq.next().get())
        
    seq = factory("WM [0-9]{2}", order=[0, 1])
    for x in range(100):
        print(seq.next().get())
        

    Dependencies:

    • exrex

    Visit original content creator repository
    https://github.com/claytonbonelli/sequence_generator

  • dlock13

    dlock13

    Breakout design (in EAGLE) and source code for our door lock actuator, running on a Raspberry PI(1). Communication with the lock happens over MQTT. Does not contain user interface, check door-web for that.

    MQTT interface

    To open the door, send the number of seconds to open to:

    /bitraf/door/$door_id/open  # Ex: 20
    

    On success, will output values:

    /bitraf/door/$door_id/isopen # Ex: true/false
    /bitraf/door/$door_id/openuntil # Unix timestamp when door will lock again. Ex: 1495469392
    

    On error, will send a string with an error message:

    /bitraf/door/$door_id/error # Ex: "Time to open is negative"
    

    Where $door_id is for instance 2floor, frontdoor, 4floor. The /bitraf/door/ prefix is configurable, can be set to /mysystem/doorlocks.

    Code

    At dlock13-msgflo/dlock13.cpp.

    Impementation is in C++11, using msgflo-cpp.

    Python API

    Also provided is a simple Python module which will handle checking the MQTT messages being sent out on success/error.

    Installing

    pip install dlock13
    

    A command-line tool is included

    dlock13-open /bitraf/door/$door_id 60
    

    For how to use programatically, use dlock13-open as example code.

    Board

    RPI breakout board with components

    The board has two MOSFETS for driving standard electronic locks. Expansion for two inputs also exists.

    Single-sided board with through-hole components, can easily be CNC milled or etched.

    RPi breakout board schematic

    Pinout

    # Function | Connector pin |  BCM SoC pin |  WiringPi pin  |
    ===
    mosfet1    |     19        |   10         |  12
    mosfet2    |     2         |   11         |  14
    

    BCM SoC pin is the on used for /sys/class/gpio/gpioNN and similar.

    Deployment

    A systemd service template is normally used to each doorlock: dlock13@.service.

    systemctl status dlock13@2floor
    

    The following environment variables are used. They can be specified in /etc/dlock13/$door_id.conf.

    • MSGFLO_BROKER – the MQTT broker connection details. Ex: mqtt://user:password@mqtt.example.net
    • DLOCK13_PIN – the GPIO pin number to use. Ex: 11
    Visit original content creator repository https://github.com/bitraf/dlock13