#include "classes.h" // 0090d360 void * KAGE::Filesys::BufferedStream::operator_assign(void *other) { uint32_t dataSize; void *dstData; int *buffer; void *srcData; buffer = GHIDRA_CAST((GHIDRA_INT(this) + 0xc)); *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 4)); *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 8)); if (buffer != GHIDRA_CAST((GHIDRA_INT(other) + 0xc))) { srcData = *(void **)(GHIDRA_CAST(other) + 0xc); dstData = (void *)*buffer; dataSize = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x10)) - GHIDRA_INT(srcData); if (GHIDRA_UINT((*GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) - GHIDRA_INT(dstData))) < dataSize) { msvc::vector::_Clear_and_reserve(dataSize); dstData = (void *)*buffer; } memmove(dstData,srcData,dataSize); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) = dataSize + GHIDRA_INT(dstData); } *GHIDRA_CAST((GHIDRA_CAST(this) + 0x18)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x18)); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x1c)); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x20)); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = *GHIDRA_CAST((GHIDRA_CAST(other) + 0x24)); return this; } // 00a57fc0 uint8_t KAGE::Filesys::BufferedStream::rebuffer() { uint32_t remainingBytes; uint32_t readBytes; if (*GHIDRA_CAST((GHIDRA_CAST(this) + 0x18)) != 0) { KAGE_LogMessage(0x10,GHIDRA_CAST("Attempting to rebuffer data on a read-only buffer")); } *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)); remainingBytes = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); readBytes = 0; if (-1 < GHIDRA_INT(remainingBytes)) { readBytes = remainingBytes; } *GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) = 0; if (*GHIDRA_CAST((GHIDRA_CAST(this) + 8)) < readBytes) { readBytes = *GHIDRA_CAST((GHIDRA_CAST(this) + 8)); } if (readBytes == 0) { return 0; } FUN_007dccd0(readBytes); this->vfunc_9(*GHIDRA_CAST((GHIDRA_CAST(this) + 0x20))); this->vfunc_10(*GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)),1,readBytes); return 1; } // 00a58040 KAGE::Filesys::BufferedStream::BufferedStream(int bufferSize) { uint32_t available; uint32_t fillSize; void *local_10; uint8_t *puStack_c; uint32_t local_8; puStack_c = &LAB_00b12b18; local_10 = ExceptionList; ExceptionList = &local_10; *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x14)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x18)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x28)) = StreamBase::vftable; local_8 = 1; *GHIDRA_CAST(this) = vftable; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x28)) = vftable; *GHIDRA_CAST((GHIDRA_CAST(this) + 8)) = 0xffffffff; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x18)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x1c)) = 0; *GHIDRA_CAST((GHIDRA_CAST(this) + 0x10)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)); available = *GHIDRA_CAST((GHIDRA_CAST(this) + 4)) - *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); *GHIDRA_CAST((GHIDRA_CAST(this) + 0x24)) = *GHIDRA_CAST((GHIDRA_CAST(this) + 0x20)); fillSize = 0; if (-1 < GHIDRA_INT(available)) { fillSize = available; } if (*GHIDRA_CAST((GHIDRA_CAST(this) + 8)) < fillSize) { fillSize = *GHIDRA_CAST((GHIDRA_CAST(this) + 8)); } if (fillSize != 0) { FUN_007dccd0(fillSize); if (*(code **)(*GHIDRA_CAST(this) + 0x24) != GridEntity_Statue::Render) { this->vfunc_9(*GHIDRA_CAST((GHIDRA_CAST(this) + 0x20))); } if (*(code **)(*GHIDRA_CAST(this) + 0x28) != FUN_00a584b0) { this->vfunc_10(*GHIDRA_CAST((GHIDRA_CAST(this) + 0xc)),1,fillSize); } } if (bufferSize != 0) { FUN_007dccd0(bufferSize); } ExceptionList = local_10; return this; } // 00a58270 void KAGE::Filesys::BufferedStream::seek_base2(int param_1, int param_2) { int in_ECX; uint32_t streamSize; uint32_t bufferStart; uint32_t position; if (param_2 != 0) { if (param_2 == 1) { *GHIDRA_CAST((in_ECX + -8)) = *GHIDRA_CAST((in_ECX + -8)) + param_1; goto LAB_00a582a0; } if (param_2 != 2) goto LAB_00a582a0; param_1 = *GHIDRA_CAST((in_ECX + -0x24)) + param_1; } *GHIDRA_CAST((in_ECX + -8)) = param_1; LAB_00a582a0: if (*GHIDRA_CAST((in_ECX + -0x10)) == 0) { streamSize = *GHIDRA_CAST((in_ECX + -0x18)) - *GHIDRA_CAST((in_ECX + -0x1c)); } else { streamSize = *GHIDRA_CAST((in_ECX + -0x24)); } position = *GHIDRA_CAST((in_ECX + -8)); bufferStart = *GHIDRA_CAST((in_ECX + -4)); if ((position < bufferStart) || (streamSize < position - bufferStart)) { rebuffer((void *)(in_ECX + -0x28)); position = *GHIDRA_CAST((in_ECX + -8)); bufferStart = *GHIDRA_CAST((in_ECX + -4)); } *GHIDRA_CAST((in_ECX + -0xc)) = position - bufferStart; return; }