Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- #include <stdio.h>
- #include <windows.h>
- class TestClass {
- private:
- char * name;
- char * dataString;
- BYTE * data;
- int dataSize;
- void formatDataString();
- public:
- TestClass(char * name, BYTE * data, int size);
- ~TestClass();
- char * getName();
- BYTE * getData();
- int getDataSize();
- char * getDataString();
- // Display Functions
- };
- // Constructors
- TestClass::TestClass(char * name, BYTE * data, int size) {
- this->name = (char*)malloc(sizeof(char) * strlen(name));
- this->data = (BYTE*)malloc(sizeof(BYTE) * size);
- this->dataString = (char*)malloc(sizeof(char) * size * 5);
- this->dataSize = size;
- memcpy((VOID*)this->name,(VOID*)name,strlen(name));
- memcpy((VOID*)this->data,(VOID*)data,size);
- formatDataString();
- }
- // Private Methods
- void TestClass::formatDataString() {
- char temp[5];
- for (int i = 0; i < dataSize; ++i) {
- sprintf(temp,"%#.2X ",data[i]);
- memcpy((VOID*)(dataString + i*5),(VOID*)temp,5);
- }
- }
- // Public Methods
- TestClass::~TestClass() {
- delete this->name;
- delete this->data;
- delete this->dataString;
- }
- char * TestClass::getName() {
- return name;
- }
- BYTE * TestClass::getData() {
- return data;
- }
- int TestClass::getDataSize() {
- return dataSize;
- }
- char * TestClass::getDataString() {
- return dataString;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement