Giter Club home page Giter Club logo

embeddedcontroller's Introduction

๐Ÿ“‹ How to use

You can either copy the source code directly to your project or using compiled Dynamic-Link Library (DLL) version. You need to compile your app with c++17 flag or newer versions. This app uses WinRing0 driver to access the hardware, make sure you place WinRing0x64.sys or WinRing0.sys beside your binary files. Your program has to run with administrator privileges to work properly.

Include ec.hpp header file and initialize an object from EmbeddedController class.

#include <iostream>
#include <windows.h>

#include "ec.hpp"

int main()
{
    EmbeddedController ec = EmbeddedController();

    // Making sure driver file loaded successfully
    if (ec.driverFileExist && ec.driverLoaded)
    {
        // Your rest of code palces in here
        // ...

        // Free up the resources at the end
        ec.close();
    }

}

Public Methods

  • EmbeddedController(BYTE scPort = EC_SC, BYTE dataPort = EC_DATA, BYTE endianness = LITTLE_ENDIAN, UINT16 retry = 5, UINT16 timeout = 100)
    If read or write operations often fails, you should increase the retry and timeout values.

    • scPort: Embedded Controller Status/Command port, default value is 0x66
    • dataPort: Embedded Controller Data port, default value is 0x62
    • endianness: Byte order of read and write operations, could be LITTLE_ENDIAN or BIG_ENDIAN, default value is LITTLE_ENDIAN
    • retry: Number of retires for failed read or write operations, default value is 5
    • timeout: Waiting threshold for reading EC's OBF and IBF flags, default value is 100
  • VOID close()
    Close the driver resources

  • EC_DUMP dump()
    Generate a map object of all registers
    return: map object of register's address and value

    EC_DUMP dump = ec.dump();
    BYTE value = dump.find(0x20)->second; // Accessing value of 0x20 register
  • VOID printDump()
    Print generated dump of all registers

  • VOID saveDump(std::string output = "dump.bin")
    Store generated dump of all registers to the disk
    output: Path of output file, default is in the current directory

  • BYTE readByte(BYTE bRegister)
    Read EC register as BYTE
    bRegister: Address of register
    return: Value of register

    BYTE value = ec.readByte(0x20);
    std::cout << std::hex << (INT)value; // Print value of register 0x20
  • WORD readWord(BYTE bRegister)
    Read EC register as WORD
    bRegister: Address of register
    return: Value of register

    WORD value = ec.readWord(0x20);
    std::cout << std::hex << (INT)value; // Print value of register 0x20 and 0x21 in Little Endian byte order
  • DWORD readDword(BYTE bRegister)
    Read EC register as DWORD
    bRegister: Address of register
    return: Value of register

    ec.endianness = BIG_ENDIAN;
    DWORD value = ec.readDword(0x20);
    std::cout << std::hex << (INT)value; // Print value of register 0x20, 0x21, 0x22 and 0x23 in Big Endian byte order
  • BOOL writeByte(BYTE bRegister, BYTE value)
    Write EC register as BYTE
    bRegister: Address of register
    value: Value of register
    return: TRUE if the opreation was successful, FALSE otherwise

    ec.writeByte(0x20, 0xAA); // Write 0xAA to register 0x20
  • BOOL writeWord(BYTE bRegister, WORD value)
    Write EC register as WORD
    bRegister: Address of register
    value: Value of register
    return: TRUE if the opreation was successful, FALSE otherwise

    // Write 0xBB to register 0x20 and 0xAA to register 0x21 in Little Endian byte order
    ec.writeWord(0x20, 0xAABB);
  • BOOL writeDword(BYTE bRegister, DWORD value)
    Write EC register as DWORD
    bRegister: Address of register
    value: Value of register
    return: TRUE if the opreation was successful, FALSE otherwise

    // Write 0xAA to register 0x20, 0xBB to register 0x21, 0xCC to register 0x22
    // and 0xDD to register 0x23 in Big Endian byte order
    ec.endianness = BIG_ENDIAN;
    ec.writeDword(0x20, 0xAABBCCDD);

โš ๏ธ Disclaimer

Author of this software is not responsible for damage of any kind, use it at your own risk!

embeddedcontroller's People

Contributors

soberia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.