Files
SuperScriptMaterializer/materializer/Utilities.hpp
yyc12345 c1abf2cdcd refactor: refactor project.
- apply reporter for exporter.
- use utf8 as exported string instead of ordinary string.
- finish environment export check.
2024-08-06 18:06:17 +08:00

41 lines
1.2 KiB
C++

#pragma once
#include "stdafx.hpp"
#include <GenericHelper.hpp>
namespace VSW::Materializer::Utilities {
/// @brief The value representing a invalid CK_ID.
constexpr CK_ID INVALID_CK_ID = static_cast<CK_ID>(-1);
constexpr char NULLPTR_CKSTRING[] = "<null>";
class EnhancedReporter : public VSW::Reporter {
public:
EnhancedReporter(CKContext* ctx);
~EnhancedReporter();
protected:
virtual void PrePrint(const YYCC::yycc_char8_t* strl) const override;
private:
CKContext* m_Ctx;
};
/**
* @brief Get relative address from given absolute address
* @details This function is used when exporting function pointer into database.
* @param[in] absolute_addr The absolute address
* @return Module based relative address like \c xxx.dll+0x00000000.
*/
YYCC::yycc_u8string RelativeAddress(const EnhancedReporter& reporter, const void* absolute_addr);
void CopyStrGuid(const EnhancedReporter& reporter, YYCC::yycc_u8string& dst, const CKGUID& src);
void CopyGuid(const EnhancedReporter& reporter, int64_t& dst, const CKGUID& src);
void CopyCKString(
const EnhancedReporter& reporter,
YYCC::yycc_u8string& storage,
const char* str,
UINT code_page,
const YYCC::yycc_char8_t* fallback = YYCC::EncodingHelper::ToUTF8(NULLPTR_CKSTRING)
);
}