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();
}
}
-
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 theretry
andtimeout
values.scPort
: Embedded Controller Status/Command port, default value is0x66
dataPort
: Embedded Controller Data port, default value is0x62
endianness
: Byte order of read and write operations, could beLITTLE_ENDIAN
orBIG_ENDIAN
, default value isLITTLE_ENDIAN
retry
: Number of retires for failed read or write operations, default value is5
timeout
: Waiting threshold for reading EC's OBF and IBF flags, default value is100
-
VOID close()
Close the driver resources -
EC_DUMP dump()
Generate amap
object of all registers
return
:map
object of register's address and valueEC_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 asBYTE
bRegister
: Address of register
return
: Value of registerBYTE value = ec.readByte(0x20); std::cout << std::hex << (INT)value; // Print value of register 0x20
-
WORD readWord(BYTE bRegister)
Read EC register asWORD
bRegister
: Address of register
return
: Value of registerWORD 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 asDWORD
bRegister
: Address of register
return
: Value of registerec.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 asBYTE
bRegister
: Address of register
value
: Value of register
return
:TRUE
if the opreation was successful,FALSE
otherwiseec.writeByte(0x20, 0xAA); // Write 0xAA to register 0x20
-
BOOL writeWord(BYTE bRegister, WORD value)
Write EC register asWORD
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 asDWORD
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);
Author of this software is not responsible for damage of any kind, use it at your own risk!