mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-01-03 17:59:42 -06:00
implements
This commit is contained in:
@@ -1,59 +1,80 @@
|
||||
#include "pch.h"
|
||||
#include "AcpHal.h"
|
||||
#include <stdlib.h>
|
||||
#include "../common/debug.h"
|
||||
|
||||
struct IAcpHal;
|
||||
|
||||
HRESULT AcpHalAllocateShapeContexts_X(__int64 a1) {
|
||||
HRESULT AcpHalAllocateShapeContexts_X(
|
||||
AcpHal_SHAPE_CONTEXTS* contextArrays
|
||||
) {
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT AcpHalCreate_X(IAcpHal* a1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT AcpHalReleaseShapeContexts_X() {
|
||||
HRESULT AcpHalReleaseShapeContexts_X( ) {
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuAlloc_X(
|
||||
void** virtualAddress,
|
||||
UINT32* physicalAddress,
|
||||
APU_ADDRESS* physicalAddress,
|
||||
UINT32 sizeInBytes,
|
||||
UINT32 alignmentInBytes,
|
||||
UINT32 flags
|
||||
)
|
||||
{
|
||||
*virtualAddress = malloc(sizeInBytes);
|
||||
|
||||
if (physicalAddress != nullptr)
|
||||
*physicalAddress = 0;
|
||||
|
||||
alignmentInBytes = 4;
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuCreateHeap_X(size_t initialSize, size_t maximumSize) {
|
||||
HRESULT ApuCreateHeap_X(UINT32 cachedSizeInBytes, UINT32 nonCachedSizeInBytes)
|
||||
{
|
||||
nonCachedSizeInBytes = 0;
|
||||
DEBUG_PRINT( );
|
||||
// Don't think we need that as this is for chaning memory pool iirc...
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuFree_X(void* ptr) {
|
||||
free(ptr);
|
||||
HRESULT ApuFree_X(void* virtualAddress) {
|
||||
DEBUG_PRINT( );
|
||||
free(virtualAddress);
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuHeapGetState_X(ApuHeapState* a1, int type) {
|
||||
HRESULT ApuHeapGetState_X(
|
||||
ApuHeapState* apuHeapState,
|
||||
UINT32 flags
|
||||
)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuIsVirtualAddressValid_X(unsigned __int64 a1, unsigned int a2) {
|
||||
bool ApuIsVirtualAddressValid_X(
|
||||
const void* virtualAddress,
|
||||
UINT32 physicalAlignmentInBytes
|
||||
)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuMapApuAddress_X(unsigned int a1) {
|
||||
APU_ADDRESS ApuMapVirtualAddress_X(
|
||||
const void* virtualAddress
|
||||
)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT ApuMapVirtualAddress_X(unsigned __int64 a1) {
|
||||
HRESULT AcpHalCreate_X(IAcpHal** acp)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
void* ApuMapApuAddress_X(
|
||||
APU_ADDRESS apuPhysicalAddress
|
||||
)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,62 +1,256 @@
|
||||
#pragma once
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "messages.h"
|
||||
struct ApuHeapState {
|
||||
/* 0x0000 */ public: uint32_t bytesFree;
|
||||
/* 0x0004 */ public: uint32_t bytesAllocated;
|
||||
/* 0x0008 */ public: uint32_t bytesLost;
|
||||
/* 0x000c */ public: uint32_t maximumBlockSizeAvailable;
|
||||
/* 0x0010 */ public: uint32_t allocationCount;
|
||||
};
|
||||
#define APU_ALLOC_CACHED 0x1;
|
||||
typedef uint64_t APU_ADDRESS;
|
||||
|
||||
struct ApuHeapState
|
||||
{
|
||||
UINT32 bytesFree; // Size of all unallocated regions
|
||||
UINT32 bytesAllocated; // Size of all allocated regions as visible to the title
|
||||
UINT32 bytesLost; // Size of all memory lost to alignment requests and fragmented blocks too small to allocate
|
||||
UINT32 maximumBlockSizeAvailable; // Largest block available (actual space available can be less due to alignment requirements)
|
||||
UINT32 allocationCount; // Count all allocated blocks
|
||||
typedef struct AcpHal_SHAPE_PCM_CONTEXT {
|
||||
UINT32 bufferStart : 32;
|
||||
UINT32 bufferLength : 21;
|
||||
UINT32 reserved0 : 11;
|
||||
UINT32 loopCount : 8;
|
||||
UINT32 reserved1 : 8;
|
||||
UINT32 full : 1;
|
||||
UINT32 reserved2 : 15;
|
||||
UINT32 readPointer : 21;
|
||||
UINT32 reserved3 : 11;
|
||||
UINT32 loopStartWritePointer : 21;
|
||||
UINT32 reserved4 : 11;
|
||||
UINT32 loopEnd : 21;
|
||||
UINT32 reserved5 : 11;
|
||||
UINT32 mode : 1;
|
||||
UINT32 reserved6 : 15;
|
||||
UINT32 format : 2;
|
||||
UINT32 reserved7 : 14;
|
||||
UINT32 reserved[ 1 ];
|
||||
} AcpHal_SHAPE_PCM_CONTEXT;
|
||||
|
||||
typedef struct AcpHal_SHAPE_SRC_CONTEXT {
|
||||
UINT32 timestamp : 21;
|
||||
UINT32 blocksToSkip : 2;
|
||||
UINT32 internalSaturate : 1;
|
||||
UINT32 mixBufPeakMag : 4;
|
||||
UINT32 peakMag : 4;
|
||||
UINT32 samplingIncrement : 21;
|
||||
UINT32 reserved0 : 1;
|
||||
UINT32 cmd : 2;
|
||||
UINT32 mixBufPeakMag2 : 4;
|
||||
UINT32 peakMag2 : 4;
|
||||
UINT32 sampleCount : 32;
|
||||
UINT32 samplePointer : 25;
|
||||
UINT32 reserved1 : 7;
|
||||
UINT32 samplingIncrementTarget : 21;
|
||||
UINT32 reserved2 : 11;
|
||||
UINT32 reserved[ 3 ];
|
||||
};
|
||||
|
||||
enum ACP_COMMAND_TYPE
|
||||
{
|
||||
ACP_COMMAND_TYPE_LOAD_SHAPE_FLOWGRAPH = 1, // Load a new flow graph and process it (data: ACP_COMMAND_LOAD_SHAPE_FLOWGRAPH)
|
||||
ACP_COMMAND_TYPE_REGISTER_MESSAGE, // Registers for one or more messages (data: ACP_COMMAND_MESSAGE)
|
||||
ACP_COMMAND_TYPE_UNREGISTER_MESSAGE, // Unregisters one or more messages (data: ACP_COMMAND_MESSAGE)
|
||||
ACP_COMMAND_TYPE_START_FLOWGRAPH, // Start processing the flowgraph (data: none)
|
||||
ACP_COMMAND_TYPE_ENABLE_XMA_CONTEXT, // Enables an XMA context (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXT)
|
||||
ACP_COMMAND_TYPE_ENABLE_XMA_CONTEXTS, // Enables a block XMA of contexts (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_DISABLE_XMA_CONTEXT, // Disables an XMA context (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXT)
|
||||
ACP_COMMAND_TYPE_DISABLE_XMA_CONTEXTS, // Disables a block of XMA contexts (data: ACP_COMMAND_ENABLE_OR_DISABLE_XMA_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_SRC_CONTEXT, // Updates a SRC context (data: ACP_COMMAND_UPDATE_XMA_CONTEXT)
|
||||
ACP_COMMAND_TYPE_UPDATE_EQCOMP_CONTEXT, // Updates an EQ/Comp context (data: ACP_COMMAND_UPDATE_EQCOMP_CONTEXT)
|
||||
ACP_COMMAND_TYPE_UPDATE_FILTVOL_CONTEXT, // Updates a Filt/Vol context (data: ACP_COMMAND_UPDATE_FILTVOL_CONTEXT)
|
||||
ACP_COMMAND_TYPE_UPDATE_DMA_CONTEXT, // Updates a DMA context (data: ACP_COMMAND_UPDATE_DMA_CONTEXT)
|
||||
ACP_COMMAND_TYPE_UPDATE_PCM_CONTEXT, // Updates a PCM context (data: ACP_COMMAND_UPDATE_PCM_CONTEXT)
|
||||
ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXT, // Updates a XMA context (data: ACP_COMMAND_UPDATE_XMA_CONTEXT)
|
||||
ACP_COMMAND_TYPE_INCREMENT_DMA_WRITE_POINTER, // Update a DMA write pointer (data: ACP_COMMAND_INCREMENT_DMA_POINTER)
|
||||
ACP_COMMAND_TYPE_INCREMENT_DMA_READ_POINTER, // Updates a DMA read pointer (data: ACP_COMMAND_INCREMENT_PCM_WRITE_POINTER)
|
||||
ACP_COMMAND_TYPE_INCREMENT_PCM_WRITE_POINTER, // Updates a PCM context write pointer (data: ACP_COMMAND_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ)
|
||||
ACP_COMMAND_TYPE_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ, // Updates the read offset in an XMA context write buffer (data: ACP_COMMAND_INCREMENT_XMA_WRITE_BUFFER_OFFSET_READ)
|
||||
ACP_COMMAND_TYPE_UPDATE_XMA_READ_BUFFER, // Updates a PCM context write pointer (data: ACP_COMMAND_UPDATE_XMA_READ_BUFFER)
|
||||
ACP_COMMAND_TYPE_UPDATE_ALL_CONTEXTS, // Updates blocks of contexts (data: ACP_COMMAND_UPDATE_ALL_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_SRC_CONTEXTS, // Updates a block of SRC contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_EQCOMP_CONTEXTS, // Updates a block of EQ/Comp contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_FILTVOL_CONTEXTS, // Updates a block of Filt/Vol contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_DMA_READ_CONTEXTS, // Updates a block of DMA read contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_DMA_WRITE_CONTEXTS, // Updates a block of DMA write contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_PCM_CONTEXTS, // Updates a block of PCM contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXTS, // Updates a block of XMA contexts (data: ACP_COMMAND_UPDATE_CONTEXTS)
|
||||
typedef struct AcpHal_SHAPE_EQCOMP_CONTEXT {
|
||||
UINT32 timestamp : 21;
|
||||
UINT32 reserved0 : 2;
|
||||
UINT32 internalSaturate : 1;
|
||||
UINT32 mixBufPeakMag : 4;
|
||||
UINT32 peakMag : 4;
|
||||
UINT32 eqAB0 : 24;
|
||||
UINT32 eqAB1_L : 8;
|
||||
UINT32 eqAB1_H : 16;
|
||||
UINT32 eqAB2_L : 16;
|
||||
UINT32 eqAB2_H : 8;
|
||||
UINT32 eqAA1 : 24;
|
||||
UINT32 eqAA2 : 24;
|
||||
UINT32 eqBB0_L : 8;
|
||||
UINT32 eqBB0_H : 16;
|
||||
UINT32 eqBB1_L : 16;
|
||||
UINT32 eqBB1_H : 8;
|
||||
UINT32 eqBB2 : 24;
|
||||
UINT32 eqBA1 : 24;
|
||||
UINT32 eqBA2_L : 8;
|
||||
UINT32 eqBA2_H : 16;
|
||||
UINT32 eqCB0_L : 16;
|
||||
UINT32 eqCB0_H : 8;
|
||||
UINT32 eqCB1 : 24;
|
||||
UINT32 eqCB2 : 24;
|
||||
UINT32 eqCA1_L : 8;
|
||||
UINT32 eqCA1_H : 16;
|
||||
UINT32 eqCA2_L : 16;
|
||||
UINT32 eqCA2_H : 8;
|
||||
UINT32 reserved1 : 24;
|
||||
UINT32 eqAInputDelay0 : 24;
|
||||
UINT32 reserved2 : 8;
|
||||
UINT32 eqAInputDelay1 : 24;
|
||||
UINT32 reserved3 : 8;
|
||||
UINT32 eqDelayElements2;
|
||||
UINT32 eqDelayElements3;
|
||||
UINT32 eqDelayElements4;
|
||||
UINT32 eqDelayElements5;
|
||||
UINT32 eqDelayElements6;
|
||||
UINT32 eqDelayElements7;
|
||||
UINT32 compInputLevel;
|
||||
UINT32 compGainReduction : 24;
|
||||
UINT32 reserved4 : 8;
|
||||
UINT32 compGain : 16;
|
||||
UINT32 reserved5 : 16;
|
||||
UINT32 eqAB0Target : 24;
|
||||
UINT32 eqAB1Target_L : 8;
|
||||
UINT32 eqAB1Target_H : 16;
|
||||
UINT32 eqAB2Target_L : 16;
|
||||
UINT32 eqAB2Target_H : 8;
|
||||
UINT32 eqAA1Target : 24;
|
||||
UINT32 eqAA2Target : 24;
|
||||
UINT32 eqBB0Target_L : 8;
|
||||
UINT32 eqBB0Target_H : 16;
|
||||
UINT32 eqBB1Target_L : 16;
|
||||
UINT32 eqBB1Target_H : 8;
|
||||
UINT32 eqBB2Target : 24;
|
||||
UINT32 eqBA1Target : 24;
|
||||
UINT32 eqBA2Target_L : 8;
|
||||
UINT32 eqBA2Target_H : 16;
|
||||
UINT32 eqCB0Target_L : 16;
|
||||
UINT32 eqCB0Target_H : 8;
|
||||
UINT32 eqCB1Target : 24;
|
||||
UINT32 eqCB2Target : 24;
|
||||
UINT32 eqCA1Target_L : 8;
|
||||
UINT32 eqCA1Target_H : 16;
|
||||
UINT32 eqCA2Target_L : 16;
|
||||
UINT32 eqCA2Target_H : 8;
|
||||
UINT32 reserved6 : 24;
|
||||
UINT32 compRelease : 24;
|
||||
UINT32 reserved7 : 2;
|
||||
UINT32 compExpand : 1;
|
||||
UINT32 compLogGain : 1;
|
||||
UINT32 compSidechainMode : 2;
|
||||
UINT32 compMode : 1;
|
||||
UINT32 compEnable : 1;
|
||||
UINT32 compThreshold : 24;
|
||||
UINT32 reserved8 : 8;
|
||||
UINT32 compAttack : 24;
|
||||
UINT32 reserved9 : 8;
|
||||
UINT32 compOneOverRatio : 16;
|
||||
UINT32 compGainTarget : 16;
|
||||
} AcpHal_SHAPE_EQCOMP_CONTEXT;
|
||||
|
||||
typedef struct AcpHal_SHAPE_FILTVOL_CONTEXT {
|
||||
UINT32 timestamp : 21;
|
||||
UINT32 reserved0 : 2;
|
||||
UINT32 internalSaturate : 1;
|
||||
UINT32 mixBufPeakMag : 4;
|
||||
UINT32 peakMag : 4;
|
||||
UINT32 delay1 : 30;
|
||||
UINT32 headroom : 2;
|
||||
UINT32 delay2 : 30;
|
||||
UINT32 svfMode : 2;
|
||||
UINT32 gainTarget : 16;
|
||||
UINT32 gain : 16;
|
||||
UINT32 qRecip : 24;
|
||||
UINT32 reserved1 : 8;
|
||||
UINT32 qRecipTarget : 24;
|
||||
UINT32 reserved2 : 8;
|
||||
UINT32 fc : 24;
|
||||
UINT32 reserved3 : 8;
|
||||
UINT32 fcTarget : 24;
|
||||
UINT32 reserved4 : 8;
|
||||
} AcpHal_SHAPE_FILTVOL_CONTEXT;
|
||||
|
||||
typedef struct AcpHal_SHAPE_DMA_CONTEXT {
|
||||
UINT32 timestamp : 21;
|
||||
UINT32 reserved0 : 3;
|
||||
UINT32 mixBufPeakMag : 4;
|
||||
UINT32 peakMag : 4;
|
||||
UINT32 readPointer : 5;
|
||||
UINT32 reserved1 : 3;
|
||||
UINT32 writePointer : 5;
|
||||
UINT32 reserved2 : 3;
|
||||
UINT32 full : 1;
|
||||
UINT32 reserved3 : 15;
|
||||
UINT32 reserved4 : 9;
|
||||
UINT32 address : 23;
|
||||
UINT32 numFrames : 5;
|
||||
UINT32 reserved5 : 3;
|
||||
UINT32 floatConvert : 1;
|
||||
UINT32 reserved6 : 7;
|
||||
UINT32 numChannels : 3;
|
||||
UINT32 reserved7 : 5;
|
||||
UINT32 channel : 3;
|
||||
UINT32 reserved8 : 5;
|
||||
} AcpHal_SHAPE_DMA_CONTEXT;
|
||||
|
||||
typedef struct AcpHal_SHAPE_XMA_CONTEXT {
|
||||
UINT32 sizeRead0 : 12;
|
||||
UINT32 numLoops : 8;
|
||||
UINT32 validBuffer : 2;
|
||||
UINT32 sizeWrite : 5;
|
||||
UINT32 offsetWrite : 5;
|
||||
UINT32 sizeRead1 : 12;
|
||||
UINT32 loopSubframeEnd : 2;
|
||||
UINT32 reserved0 : 3;
|
||||
UINT32 loopSubframeSkip : 3;
|
||||
UINT32 numSubframesToDecode : 4;
|
||||
UINT32 numSubframesToSkip : 3;
|
||||
UINT32 sampleRate : 2;
|
||||
UINT32 numChannels : 1;
|
||||
UINT32 reserved1 : 1;
|
||||
UINT32 validWrite : 1;
|
||||
UINT32 offsetRead : 26;
|
||||
UINT32 errorStatus : 5;
|
||||
UINT32 errorSet : 1;
|
||||
UINT32 loopStartOffset : 26;
|
||||
UINT32 parserErrorStatus : 5;
|
||||
UINT32 parserErrorSet : 1;
|
||||
UINT32 loopEndOffset : 26;
|
||||
UINT32 packetMetaData : 5;
|
||||
UINT32 currentBuffer : 1;
|
||||
UINT32 ptrRead0;
|
||||
UINT32 ptrRead1;
|
||||
UINT32 ptrWrite;
|
||||
UINT32 ptrOverlapAdd;
|
||||
UINT32 writeBufferOffsetRead : 5;
|
||||
UINT32 reserved2 : 25;
|
||||
UINT32 stopWhenDone : 1;
|
||||
UINT32 interruptWhenDone : 1;
|
||||
UINT32 reserved[ 6 ];
|
||||
} AcpHal_SHAPE_XMA_CONTEXT;
|
||||
|
||||
typedef struct AcpHal_SHAPE_CONTEXTS {
|
||||
UINT32 numSrcContexts;
|
||||
UINT32 numEqCompContexts;
|
||||
UINT32 numFiltVolContexts;
|
||||
UINT32 numDmaContexts;
|
||||
UINT32 numXmaContexts;
|
||||
UINT32 numPcmContexts;
|
||||
AcpHal_SHAPE_SRC_CONTEXT* srcContextArray;
|
||||
AcpHal_SHAPE_EQCOMP_CONTEXT* eqCompContextArray;
|
||||
AcpHal_SHAPE_FILTVOL_CONTEXT* filtVolContextArray;
|
||||
AcpHal_SHAPE_DMA_CONTEXT* dmaContextArray;
|
||||
AcpHal_SHAPE_XMA_CONTEXT* xmaContextArray;
|
||||
AcpHal_SHAPE_PCM_CONTEXT* pcmContextArray;
|
||||
APU_ADDRESS apuSrcContextArray;
|
||||
APU_ADDRESS apuEqCompContextArray;
|
||||
APU_ADDRESS apuFiltVolContextArray;
|
||||
APU_ADDRESS apuDmaContextArray;
|
||||
APU_ADDRESS apuXmaContextArray;
|
||||
APU_ADDRESS apuPcmContextArray;
|
||||
} AcpHal_SHAPE_CONTEXTS;
|
||||
|
||||
class IAcpHal
|
||||
{
|
||||
public:
|
||||
IAcpHal( );
|
||||
~IAcpHal( );
|
||||
|
||||
private:
|
||||
|
||||
ACP_COMMAND_TYPE_COUNT = ACP_COMMAND_TYPE_UPDATE_XMA_CONTEXTS // Count of command types (not an actual command)
|
||||
};
|
||||
|
||||
struct ACP_MESSAGE
|
||||
IAcpHal::IAcpHal( )
|
||||
{
|
||||
UINT32 type; // Message type
|
||||
UINT32 droppedMessageCount; // Count of dropped messages prior to this message
|
||||
UINT32 usec; // time when this message is constructed
|
||||
union // Message data
|
||||
{
|
||||
ACP_MESSAGE_AUDIO_FRAME_START audioFrameStart;
|
||||
ACP_MESSAGE_FLOWGRAPH_COMPLETED flowgraphCompleted;
|
||||
ACP_MESSAGE_SHAPE_COMMAND_BLOCKED shapeCommandBlocked;
|
||||
ACP_MESSAGE_COMMAND_COMPLETED commandCompleted;
|
||||
ACP_MESSAGE_FLOWGRAPH_TERMINATED flowgraphTerminated;
|
||||
ACP_MESSAGE_ERROR error;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
IAcpHal::~IAcpHal( )
|
||||
{
|
||||
}
|
||||
@@ -1,38 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="Arquivos de Origem">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Arquivos de Cabeçalho">
|
||||
<Filter Include="Header Files">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Arquivos de Recurso">
|
||||
<Filter Include="Resource Files">
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Source Files">
|
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Arquivos de Cabeçalho</Filter>
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="pch.h">
|
||||
<Filter>Arquivos de Cabeçalho</Filter>
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="pch.cpp">
|
||||
<Filter>Arquivos de Origem</Filter>
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MMDevAPI.cpp">
|
||||
<Filter>Arquivos de Origem</Filter>
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Exports.def">
|
||||
<Filter>Arquivos de Origem</Filter>
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,71 +1,545 @@
|
||||
// appmodel.cpp : Defines the exported functions for the DLL.
|
||||
#include "pch.h"
|
||||
#include "appmodel.h"
|
||||
#include <stdlib.h>
|
||||
#include <hstring.h>
|
||||
#include <strsafe.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../common/debug.h"
|
||||
|
||||
HRESULT CreateRandomAccessStreamOnFile_X(PCWSTR filePath, DWORD accessMode, REFIID riid, void **ppv) { return TRUE; }
|
||||
CRITICAL_SECTION CriticalSection;
|
||||
__int64 qword_18009E948 = 0;
|
||||
|
||||
struct _XBOX_LIVE_TITLE_INFO {
|
||||
DWORD TitleId;
|
||||
GUID PrimaryServiceConfigId;
|
||||
DWORD RequireXboxLive;
|
||||
};
|
||||
namespace AppModel {
|
||||
namespace Runtime {
|
||||
LSTATUS __fastcall EnumerateKeyNames(HKEY hKey, std::vector<std::wstring>& keyNames)
|
||||
{
|
||||
if (!hKey)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
keyNames.clear( );
|
||||
DWORD index = 0;
|
||||
WCHAR nameBuffer[ 256 ] = { 0 };
|
||||
DWORD nameSize;
|
||||
LSTATUS result;
|
||||
|
||||
while (true)
|
||||
{
|
||||
nameSize = ARRAYSIZE(nameBuffer);
|
||||
result = RegEnumKeyExW(hKey, index, nameBuffer, &nameSize, nullptr, nullptr, nullptr, nullptr);
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
break;
|
||||
|
||||
keyNames.emplace_back(nameBuffer);
|
||||
++index;
|
||||
}
|
||||
|
||||
return (result == ERROR_NO_MORE_ITEMS) ? ERROR_SUCCESS : result;
|
||||
}
|
||||
__int64 __fastcall GetCurrentPackageFullName_X(std::wstring& packageFullName)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
packageFullName.clear( );
|
||||
//if ((NtCurrentPeb( )->BitField & 0x20) == 0)
|
||||
// return 15700;
|
||||
|
||||
HKEY hKey = nullptr;
|
||||
LSTATUS status = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"XBOX\Software\Microsoft\Windows\CurrentVersion\AppModel\Repository\Families",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey);
|
||||
|
||||
if (status == ERROR_SUCCESS)
|
||||
{
|
||||
std::vector<std::wstring> familyKeys;
|
||||
status = EnumerateKeyNames(hKey, familyKeys);
|
||||
if (status == ERROR_SUCCESS && !familyKeys.empty( ))
|
||||
{
|
||||
HKEY phkResult = nullptr;
|
||||
status = RegOpenKeyExW(hKey, familyKeys[ 0 ].c_str( ), 0, KEY_READ, &phkResult);
|
||||
if (status == ERROR_SUCCESS)
|
||||
{
|
||||
std::vector<std::wstring> packageKeys;
|
||||
status = EnumerateKeyNames(phkResult, packageKeys);
|
||||
if (status == ERROR_SUCCESS && !packageKeys.empty( ))
|
||||
{
|
||||
packageFullName = packageKeys[ 0 ];
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 1168;
|
||||
}
|
||||
RegCloseKey(phkResult);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = 1168;
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
__int64 __fastcall GetPackagesByPackageFamily_X(LPCWSTR lpSubKey, std::vector<std::wstring>& packageList)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
if (lpSubKey == nullptr)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
packageList.clear( );
|
||||
HKEY hKey = nullptr;
|
||||
HKEY phkResult = nullptr;
|
||||
|
||||
LSTATUS status = RegOpenKeyExW(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
L"XBOX\\Software\\Microsoft\\Windows\\CurrentVersion\\AppModel\\Repository\\Families",
|
||||
0,
|
||||
KEY_READ,
|
||||
&hKey);
|
||||
|
||||
if (status == ERROR_SUCCESS)
|
||||
{
|
||||
status = RegOpenKeyExW(hKey, lpSubKey, 0, KEY_READ, &phkResult);
|
||||
if (status == ERROR_SUCCESS)
|
||||
{
|
||||
status = EnumerateKeyNames(phkResult, packageList);
|
||||
RegCloseKey(phkResult);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
struct _PSM_APPSTATE_REGISTRATION {
|
||||
CONDITION_VARIABLE CallbackFinished;
|
||||
_LIST_ENTRY Entry;
|
||||
BYTE Flags;
|
||||
};
|
||||
|
||||
class PsmCli {
|
||||
public:
|
||||
static int EnsureInitialized(PsmCli* instance) {
|
||||
return instance ? 0 : -1;
|
||||
}
|
||||
static void UnregisterAppStateChangeNotification(PsmCli* instance, _PSM_APPSTATE_REGISTRATION* registration);
|
||||
};
|
||||
class ModuleBase {
|
||||
public:
|
||||
static ModuleBase* module_;
|
||||
bool CanUnloadNow( ) const {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
ModuleBase* ModuleBase::module_ = nullptr;
|
||||
|
||||
HRESULT __stdcall DllCanUnloadNow_X( )
|
||||
{
|
||||
static ModuleBase moduleInstance;
|
||||
static bool initialized = false;
|
||||
|
||||
if (!initialized) {
|
||||
ModuleBase::module_ = &moduleInstance;
|
||||
atexit([]( ) { ModuleBase::module_ = nullptr; });
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
return (moduleInstance.CanUnloadNow( )) ? S_OK : S_FALSE;
|
||||
}
|
||||
HRESULT CreateRandomAccessStreamOnFile_X(PCWSTR filePath, DWORD accessMode, REFIID riid, void** ppv) { return TRUE; }
|
||||
|
||||
HRESULT CreateRandomAccessStreamOverStream_X(
|
||||
// IStream *stream,
|
||||
// BSOS_OPTIONS options,
|
||||
REFIID riid,
|
||||
void **ppv)
|
||||
// IStream *stream,
|
||||
// BSOS_OPTIONS options,
|
||||
REFIID riid,
|
||||
void** ppv)
|
||||
{
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DllCanUnloadNow_X() { }
|
||||
|
||||
void DllGetActivationFactory_X() { }
|
||||
|
||||
void DllGetClassObject_X() { }
|
||||
|
||||
void GetApplicationUserModelId_X() { }
|
||||
|
||||
void GetApplicationXboxLiveInfo_X() { }
|
||||
|
||||
void GetCurrentApplicationUserModelId_X() { }
|
||||
|
||||
void GetCurrentPackageFamilyName_X() { }
|
||||
|
||||
void GetCurrentPackageFullName_X() { }
|
||||
|
||||
void GetCurrentPackageId_X() { }
|
||||
|
||||
|
||||
void GetCurrentPackagePath_X() { }
|
||||
__int64 __fastcall DllGetActivationFactory_X(HSTRING string, PVOID Ptr)
|
||||
{
|
||||
DEBUG_PRINT( ); return 0;
|
||||
}
|
||||
|
||||
HRESULT __stdcall DllGetClassObject_X(const IID* const rclsid, const IID* const riid, LPVOID* ppv)
|
||||
{
|
||||
DEBUG_PRINT( ); return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetApplicationUserModelId_X(
|
||||
HANDLE hProcess,
|
||||
UINT32* applicationUserModelIdLength,
|
||||
PWSTR applicationUserModelId)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return GetCurrentApplicationUserModelId_X(applicationUserModelIdLength, applicationUserModelId);
|
||||
}
|
||||
|
||||
__int64 __fastcall GetApplicationXboxLiveInfo_X(WCHAR* a1, int a2, void* a3, unsigned int a4)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentApplicationUserModelId_X(UINT32* applicationUserModelIdLength, PWSTR applicationUserModelId)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentPackageFamilyName_X(UINT32* packageFamilyNameLength, PWSTR packageFamilyName)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentPackageFullName_X(UINT32* packageFullNameLength, PWSTR packageFullName)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
LONG CurrentPackageFullName; // edi
|
||||
UINT32 v5; // edi
|
||||
const wchar_t* v6; // r8
|
||||
wchar_t* Source[ 2 ]; // [rsp+20h] [rbp-48h] BYREF
|
||||
__int64 v9; // [rsp+30h] [rbp-38h]
|
||||
unsigned __int64 v10; // [rsp+38h] [rbp-30h]
|
||||
|
||||
if (!packageFullNameLength || *packageFullNameLength && !packageFullName)
|
||||
return 87;
|
||||
v10 = 7;
|
||||
v9 = 0;
|
||||
LOWORD(Source[ 0 ]);
|
||||
CurrentPackageFullName = AppModel::Runtime::GetCurrentPackageFullName_X((std::wstring&) Source);
|
||||
if (!CurrentPackageFullName)
|
||||
{
|
||||
v5 = v9 + 1;
|
||||
if (*packageFullNameLength >= (int) v9 + 1)
|
||||
{
|
||||
v6 = (const wchar_t*) Source;
|
||||
if (v10 >= 8)
|
||||
v6 = Source[ 0 ];
|
||||
wcsncpy_s(packageFullName, *packageFullNameLength, v6, 0xFFFFFFFFFFFFFFFFui64);
|
||||
*packageFullNameLength = v5;
|
||||
CurrentPackageFullName = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*packageFullNameLength = v5;
|
||||
CurrentPackageFullName = 122;
|
||||
}
|
||||
}
|
||||
if (v10 >= 8)
|
||||
{
|
||||
if (Source[ 0 ])
|
||||
{
|
||||
//XMemFree(Source[ 0 ], qword_18009E948); look into this later
|
||||
}
|
||||
|
||||
}
|
||||
return CurrentPackageFullName;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentPackageId_X(UINT32* bufferLength, BYTE* buffer)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LONG __stdcall GetCurrentPackagePath_X(UINT32* pathLength, PWSTR path)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GetPackageFamilyName_X() { }
|
||||
LONG __stdcall GetPackageFamilyName_X(HANDLE hProcess, UINT32* packageFamilyNameLength, PWSTR packageFamilyName)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return GetCurrentPackageFamilyName_X(packageFamilyNameLength, packageFamilyName);
|
||||
}
|
||||
|
||||
void GetPackagePath_X() { }
|
||||
LONG __stdcall GetPackagePath_X(const PVOID* packageId, const UINT32 reserved, UINT32* pathLength, PWSTR path)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return GetCurrentPackagePath_X(pathLength, path);
|
||||
}
|
||||
|
||||
void GetPackageXboxLiveInfo_X() { }
|
||||
void GetPackageXboxLiveInfo_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void GetProcessXboxLiveInfo_X() { }
|
||||
void GetProcessXboxLiveInfo_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void GetXboxLiveTitleId_X() { }
|
||||
void GetXboxLiveTitleId_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void PsmBlockAppStateChangeCompletion_X() { }
|
||||
void PsmBlockAppStateChangeCompletion_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void PsmRegisterAppStateChangeNotification_X() { }
|
||||
void PsmRegisterAppStateChangeNotification_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void PsmShutdownApplication_X() { }
|
||||
void PsmShutdownApplication_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void PsmUnblockAppStateChangeCompletion_X() { }
|
||||
void PsmUnblockAppStateChangeCompletion_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
void PsmWaitForAppResume_X() { }
|
||||
void PsmWaitForAppResume_X( ) { DEBUG_PRINT( ); }
|
||||
|
||||
LONG GetPackageId(HANDLE hProcess, UINT32* bufferLength, BYTE* buffer) { return 0; }
|
||||
LONG __stdcall GetPackageId(HANDLE hProcess, UINT32* bufferLength, BYTE* buffer)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return GetCurrentPackageId_X(bufferLength, buffer);
|
||||
}
|
||||
|
||||
LONG GetPackageFullName_X(HANDLE hProcess, UINT32* packageFullNameLength, PWSTR packageFullName) { return 0; }
|
||||
LONG __stdcall GetPackageFullName_X(HANDLE hProcess, UINT32* packageFullNameLength, PWSTR packageFullName)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return GetCurrentPackageFullName_X(packageFullNameLength, packageFullName);
|
||||
}
|
||||
|
||||
LONG GetCurrentPackageInfo_X(const UINT32 flags, UINT32* bufferLength, BYTE* buffer, UINT32* count) { return 0; }
|
||||
LONG GetCurrentPackageInfo_X(const UINT32 flags, UINT32* bufferLength, BYTE* buffer, UINT32* count) { DEBUG_PRINT( ); return 0; }
|
||||
|
||||
LONG GetPackagesByPackageFamily_X(PCWSTR packageFamilyName, UINT32* count, PWSTR* packageFullNames, UINT32* bufferLength, WCHAR* buffer) { return 0; }
|
||||
LONG __stdcall GetPackagesByPackageFamily_X(
|
||||
PCWSTR packageFamilyName,
|
||||
UINT32* count,
|
||||
PWSTR* packageFullNames,
|
||||
UINT32* bufferLength,
|
||||
WCHAR* buffer)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
if (!packageFamilyName || !count || !bufferLength || (*count && !packageFullNames) || (*bufferLength && !buffer))
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
__int64 __fastcall GetCurrentXboxLiveTitleId_X(__int64 a) { return 0; }
|
||||
std::vector<std::wstring> packageList;
|
||||
LONG status = AppModel::Runtime::GetPackagesByPackageFamily_X(packageFamilyName, packageList);
|
||||
if (status != ERROR_SUCCESS)
|
||||
return status;
|
||||
|
||||
__int64 __fastcall GetCurrentXboxLiveInfo_X(__int64 a, __int64 b, __int64 c) { return 0; }
|
||||
size_t requiredBufferSize = 0;
|
||||
for (const auto& package : packageList)
|
||||
requiredBufferSize += package.size( ) + 1;
|
||||
|
||||
__int64 __fastcall PsmUnregisterAppStateChangeNotification(__int64 notificationId, __int64 processId, __int64 additionalParam) { return 0; }
|
||||
if (*bufferLength < requiredBufferSize)
|
||||
{
|
||||
*bufferLength = static_cast<UINT32>(requiredBufferSize);
|
||||
return ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
|
||||
if (*count < packageList.size( ))
|
||||
{
|
||||
*count = static_cast<UINT32>(packageList.size( ));
|
||||
return ERROR_INSUFFICIENT_BUFFER;
|
||||
}
|
||||
|
||||
WCHAR* currentBufferPosition = buffer;
|
||||
for (size_t i = 0; i < packageList.size( ); ++i)
|
||||
{
|
||||
wcsncpy_s(currentBufferPosition, *bufferLength - (currentBufferPosition - buffer), packageList[ i ].c_str( ), packageList[ i ].size( ));
|
||||
packageFullNames[ i ] = currentBufferPosition;
|
||||
currentBufferPosition += packageList[ i ].size( ) + 1;
|
||||
}
|
||||
|
||||
*count = static_cast<UINT32>(packageList.size( ));
|
||||
*bufferLength = static_cast<UINT32>(currentBufferPosition - buffer);
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
_int64 __fastcall GetCurrentXboxLiveTitleId_X(int* a1)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
int v4[ 6 ]; // [rsp+20h] [rbp-28h] BYREF
|
||||
|
||||
int v1 = 0;
|
||||
if (!a1)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
__int64 result = GetCurrentXboxLiveInfo_X(0, v4, 24);
|
||||
if (!result)
|
||||
v1 = v4[ 0 ];
|
||||
*a1 = v1;
|
||||
return result;
|
||||
}
|
||||
__int64 __fastcall GetSystemXboxLiveInfo_X(int a1, void* a2, unsigned int a3)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
LONG __fastcall GetCurrentXboxLiveInfo_X(unsigned int a1, void* a2, unsigned int a3)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
LONG result; // eax
|
||||
HMODULE ModuleHandleW; // rax
|
||||
UINT32 applicationUserModelIdLength[ 4 ]; // [rsp+20h] [rbp-138h] BYREF
|
||||
WCHAR applicationUserModelId[ 136 ]; // [rsp+30h] [rbp-128h] BYREF
|
||||
|
||||
if (!a2 || !a3)
|
||||
return 87;
|
||||
applicationUserModelIdLength[ 0 ] = 130;
|
||||
result = GetCurrentApplicationUserModelId_X(applicationUserModelIdLength, applicationUserModelId);
|
||||
if (result == 15703)
|
||||
{
|
||||
ModuleHandleW = GetModuleHandleW(0);
|
||||
if (a1 == 1)
|
||||
{
|
||||
result = GetSystemXboxLiveInfo_X(1, a2, a3);
|
||||
}
|
||||
else if (a1)
|
||||
{
|
||||
result = 50;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = XblRegReadModuleTitleInfo_X(ModuleHandleW, 0, a2, a3);
|
||||
}
|
||||
if (result == 2)
|
||||
return 1168;
|
||||
}
|
||||
else if (!result)
|
||||
{
|
||||
return GetApplicationXboxLiveInfo_X(applicationUserModelId, a1, a2, a3);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
LSTATUS __fastcall XblRegReadValue_X(HKEY hKey, LPCWSTR valueName, int expectedType, void* buffer, unsigned int bufferSize)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
DWORD dataType = 0;
|
||||
DWORD dataSize = bufferSize;
|
||||
|
||||
LSTATUS result = RegQueryValueExW(hKey, valueName, 0, &dataType, reinterpret_cast<LPBYTE>(buffer), &dataSize);
|
||||
if (result == ERROR_SUCCESS && (dataType != static_cast<DWORD>(expectedType) || dataSize != bufferSize))
|
||||
{
|
||||
return ERROR_INVALID_DATA;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
__int64 __fastcall XblRegReadModuleTitleInfo_X(HINSTANCE a1, const unsigned __int16* a2, void* a3, unsigned int a4)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
unsigned int result;
|
||||
HKEY hKey = nullptr;
|
||||
int useSystemTitleId = 0;
|
||||
|
||||
if (a4 < 0x18)
|
||||
return ERROR_INSUFFICIENT_BUFFER;
|
||||
|
||||
memset(a3, 0, 0x18);
|
||||
result = XblRegOpenModuleKey_X(a1, 0, &hKey);
|
||||
|
||||
if (result == ERROR_SUCCESS) {
|
||||
if (XblRegReadValue_X(hKey, L"UseSystemTitleId", REG_DWORD, &useSystemTitleId, sizeof(useSystemTitleId)) != ERROR_SUCCESS || !useSystemTitleId) {
|
||||
result = XblRegReadTitleInfo_X(hKey, static_cast<_XBOX_LIVE_TITLE_INFO*>(a3));
|
||||
}
|
||||
else {
|
||||
result = GetSystemXboxLiveInfo_X(0, a3, a4);
|
||||
}
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
LSTATUS __fastcall XblRegReadTitleInfo_X(HKEY a1, struct _XBOX_LIVE_TITLE_INFO* TitleInfo)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
LSTATUS result; // eax
|
||||
|
||||
result = XblRegReadValue_X(a1, L"TitleId", 4, TitleInfo, 4u);
|
||||
if (!result)
|
||||
{
|
||||
result = XblRegReadValue_X(a1, L"PrimaryServiceConfigId", 3, &TitleInfo->PrimaryServiceConfigId, 0x10u);
|
||||
if (!result)
|
||||
{
|
||||
result = XblRegReadValue_X(a1, L"RequireXboxLive", 4, &TitleInfo->RequireXboxLive, 4u);
|
||||
if (result == 2)
|
||||
{
|
||||
TitleInfo->RequireXboxLive = 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
__int64 __fastcall XblRegOpenModuleKey_X(HMODULE a1, __int64 a2, HKEY* a3)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
unsigned int v4 = 1359;
|
||||
WCHAR Filename[ 264 ] = { 0 };
|
||||
WCHAR SubKey[ 512 ] = { 0 };
|
||||
|
||||
if (a1 && GetModuleFileNameW(a1, Filename, 0x104))
|
||||
{
|
||||
for (WCHAR* i = Filename; *i; ++i)
|
||||
{
|
||||
unsigned __int16 v6 = *i - 46;
|
||||
if (v6 <= 0x2E)
|
||||
{
|
||||
__int64 v7 = 0x400000001003;
|
||||
if (_bittest64(&v7, v6))
|
||||
*i = L'_';
|
||||
}
|
||||
}
|
||||
if (SUCCEEDED(StringCchPrintfW(SubKey, 0x200, L"XBOX\\Software\\Microsoft\\Windows\\CurrentVersion\\XboxLive\\TitleIds\\%s", Filename)))
|
||||
return RegOpenKeyExW(HKEY_LOCAL_MACHINE, SubKey, 0, KEY_READ, a3);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
return v4;
|
||||
}
|
||||
|
||||
void __fastcall PsmCli::UnregisterAppStateChangeNotification(PsmCli* instance, struct _PSM_APPSTATE_REGISTRATION* a2)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
_LIST_ENTRY* Flink;
|
||||
_LIST_ENTRY* Blink;
|
||||
|
||||
if (PsmCli::EnsureInitialized(instance) >= 0)
|
||||
{
|
||||
EnterCriticalSection(&CriticalSection);
|
||||
a2->Flags |= 2u;
|
||||
|
||||
if ((a2->Flags & 1) != 0)
|
||||
{
|
||||
do
|
||||
SleepConditionVariableCS(&a2->CallbackFinished, &CriticalSection, INFINITE);
|
||||
while ((a2->Flags & 1) != 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Flink = a2->Entry.Flink;
|
||||
Blink = a2->Entry.Blink;
|
||||
|
||||
if (reinterpret_cast<_PSM_APPSTATE_REGISTRATION*>(Flink->Blink) != a2 ||
|
||||
reinterpret_cast<_PSM_APPSTATE_REGISTRATION*>(Blink->Flink) != a2)
|
||||
{
|
||||
__fastfail(3);
|
||||
}
|
||||
|
||||
Blink->Flink = Flink;
|
||||
Flink->Blink = Blink;
|
||||
a2->Entry.Flink = nullptr;
|
||||
a2->Entry.Blink = nullptr;
|
||||
}
|
||||
|
||||
LeaveCriticalSection(&CriticalSection);
|
||||
HeapFree(GetProcessHeap( ), 0, a2);
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall PsmUnregisterAppStateChangeNotification_X(struct _PSM_APPSTATE_REGISTRATION* a1)
|
||||
{
|
||||
DEBUG_PRINT( );
|
||||
if (a1)
|
||||
PsmCli::UnregisterAppStateChangeNotification(reinterpret_cast<PsmCli*>(a1), a1);
|
||||
}
|
||||
@@ -16,6 +16,11 @@ public:
|
||||
Cappmodel(void);
|
||||
// TODO: add your methods here.
|
||||
};
|
||||
LONG __fastcall GetCurrentXboxLiveInfo_X(unsigned int a1, void* a2, unsigned int a3);
|
||||
__int64 __fastcall XblRegOpenModuleKey_X(HMODULE a1, __int64 a2, HKEY* a3);
|
||||
__int64 __fastcall XblRegReadModuleTitleInfo_X(HINSTANCE a1, const unsigned __int16* a2, void* a3, unsigned int a4);
|
||||
LSTATUS __fastcall XblRegReadTitleInfo_X(HKEY a1, struct _XBOX_LIVE_TITLE_INFO* TitleInfo);
|
||||
LONG __stdcall GetCurrentApplicationUserModelId_X(UINT32* applicationUserModelIdLength, PWSTR applicationUserModelId);
|
||||
|
||||
extern APPMODEL_API int nappmodel;
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
#pragma once
|
||||
#define DurangoAPI __stdcall
|
||||
@@ -150,10 +150,12 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="debug.h" />
|
||||
<ClInclude Include="logfmtxx.hpp" />
|
||||
<ClInclude Include="toml.hpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="debug.cpp" />
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
<ClCompile Include="debug.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="toml.hpp" />
|
||||
<ClInclude Include="logfmtxx.hpp" />
|
||||
<ClInclude Include="debug.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
1
dlls/common/debug.cpp
Normal file
1
dlls/common/debug.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "debug.h"
|
||||
77
dlls/common/debug.h
Normal file
77
dlls/common/debug.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
// Function to extract the last folder name (project/module name)
|
||||
inline const char* ExtractProjectName(const char* filePath) {
|
||||
const char* lastSlash = strrchr(filePath, '/'); // UNIX-like path
|
||||
if (!lastSlash) lastSlash = strrchr(filePath, '\\'); // Windows path
|
||||
|
||||
if (lastSlash) {
|
||||
const char* secondLastSlash = filePath; // Start from beginning
|
||||
while (secondLastSlash < lastSlash) { // Find second-to-last slash
|
||||
const char* temp = strpbrk(secondLastSlash + 1, "/\\");
|
||||
if (temp && temp < lastSlash) secondLastSlash = temp;
|
||||
else break;
|
||||
}
|
||||
|
||||
if (secondLastSlash != filePath) {
|
||||
static char projectName[ 256 ]; // Buffer to store project/module name
|
||||
size_t length = lastSlash - secondLastSlash - 1; // Get only folder name
|
||||
length = (length < sizeof(projectName) - 1) ? length : sizeof(projectName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(projectName, sizeof(projectName), secondLastSlash + 1, length); // MSVC-safe
|
||||
#else
|
||||
strncpy(projectName, secondLastSlash + 1, length); // GCC/Clang-safe
|
||||
projectName[ length ] = '\0'; // Null-terminate
|
||||
#endif
|
||||
return projectName;
|
||||
}
|
||||
}
|
||||
return "UnknownProject"; // Fallback if no directory structure found
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__) // GCC/Clang
|
||||
#define FUNCTION_NAME __PRETTY_FUNCTION__
|
||||
#elif defined(_MSC_VER) // MSVC
|
||||
#define FUNCTION_NAME __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_NAME __FUNCTION__
|
||||
#endif
|
||||
|
||||
// Function to extract only the function name from the full signature
|
||||
inline const char* ExtractFunctionName(const char* fullSignature) {
|
||||
const char* paren = strchr(fullSignature, '('); // Find first '('
|
||||
if (paren) {
|
||||
static char functionName[ 256 ]; // Buffer to store function name
|
||||
size_t length = paren - fullSignature; // Length before '('
|
||||
length = (length < sizeof(functionName) - 1) ? length : sizeof(functionName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(functionName, sizeof(functionName), fullSignature, length); // Safe for MSVC
|
||||
#else
|
||||
strncpy(functionName, fullSignature, length); // Safe for GCC/Clang
|
||||
functionName[ length ] = '\0'; // Null-terminate
|
||||
#endif
|
||||
return functionName;
|
||||
}
|
||||
return fullSignature; // Fallback if '(' not found
|
||||
}
|
||||
|
||||
// Debug Print Macro (Basic)
|
||||
#define DEBUG_PRINT() printf("Line: %d --> %s --> %s \r\n", __LINE__,ExtractProjectName(__FILE__) ,ExtractFunctionName(FUNCTION_NAME) )
|
||||
|
||||
// Debug Print Macro (Custom Message)
|
||||
#define DEBUGPRINT(fmt, ...) printf("Line: %d --> %s --> %s " fmt "\r\n", __LINE__ , ExtractProjectName(__FILE__), __FUNCTION__ , ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define DEBUG_PRINT() // No-op in release mode
|
||||
#define DEBUGPRINT(fmt, ...) // No-op in release mode
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_H
|
||||
@@ -1,25 +1,53 @@
|
||||
#include "EtwPlus.h"
|
||||
#include "pch.h"
|
||||
#include <stdio.h>
|
||||
#include "../common/debug.h"
|
||||
#include "../common/common.h"
|
||||
|
||||
ULONG EtxEventWrite_X(__int64 a1, __int64 a2, __int64 a3, ULONG a4, struct _EVENT_DATA_DESCRIPTOR* a5) {
|
||||
return 0;
|
||||
VOID DurangoAPI EtxFillCommonFields_v7_X(EVENT_DATA_DESCRIPTOR* eventDataDescriptors, UINT8* buffer, UINT32 bufferSize) {
|
||||
DEBUG_PRINT( );
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
__int64 EtxFillCommonFields_v7_X(__int64 a1, char* a2, unsigned int a3) {
|
||||
return 0;
|
||||
ULONG DurangoAPI EtxRegister_X(EVENT_PROVIDER_DESCRIPTOR* provider, REGHANDLE* handle) {
|
||||
// Implementation here
|
||||
DEBUG_PRINT( );
|
||||
return 0;
|
||||
}
|
||||
|
||||
__int64 EtxRegister_X(void* Source, __int64 RegHandle) {
|
||||
return 0;
|
||||
ULONG DurangoAPI EtxUnregister_X(EVENT_PROVIDER_DESCRIPTOR* provider, REGHANDLE* handle) {
|
||||
DEBUG_PRINT( );
|
||||
REGHANDLE v3; // rcx
|
||||
|
||||
v3 = *handle;
|
||||
if (*handle)
|
||||
{
|
||||
*handle = 0i64;
|
||||
EventUnregister(v3);
|
||||
//sub_180001658(provider);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EtxResumeUploading_X() {
|
||||
|
||||
ULONG DurangoAPI EtxEventWrite_X(
|
||||
__in const EVENT_DESCRIPTOR_STRUCT* eventDescriptor,
|
||||
__in const EVENT_PROVIDER_DESCRIPTOR* providerDescriptor,
|
||||
__in REGHANDLE handle,
|
||||
__in ULONG dataCount,
|
||||
__in const EVENT_DATA_DESCRIPTOR* eventData
|
||||
) {
|
||||
DEBUG_PRINT( );
|
||||
// Implementation here
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EtxSuspendUploading_X() {
|
||||
|
||||
void DurangoAPI EtxSuspendUploading_X( ) {
|
||||
DEBUG_PRINT( );
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
__int64 EtxUnregister_X(__int64 a1, __int64 a2) {
|
||||
return 0;
|
||||
}
|
||||
void DurangoAPI
|
||||
EtxResumeUploading_X( ) {
|
||||
DEBUG_PRINT( );
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
146
dlls/etwplus/EtwPlus.h
Normal file
146
dlls/etwplus/EtwPlus.h
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef EVENT_TRACKING_LOG_H
|
||||
#define EVENT_TRACKING_LOG_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <evntrace.h> // Contains EVENT_DATA_DESCRIPTOR, REGHANDLE, etc.
|
||||
#include <wmistr.h> // For WMI and ETW structures
|
||||
#include "evntprov.h" // Ensure this file is available
|
||||
|
||||
|
||||
|
||||
#ifndef WINAPI
|
||||
#define WINAPI __stdcall
|
||||
#endif
|
||||
#define _DWORD DWORD // Define _DWORD as DWORD (32-bit unsigned int)
|
||||
#define _QWORD UINT64 // Define _QWORD as UINT64 (64-bit unsigned int)
|
||||
#define BUFFER_SIZE 64 // Define a reasonable buffer size
|
||||
|
||||
#define DEFAULT_SAMPLE_PERCENTAGE 10
|
||||
|
||||
typedef enum _EventSampleRate {
|
||||
EventSample_UseProviderSample = -2,
|
||||
EventSample_UseSystemSample = -1,
|
||||
EventSample_Undefined = 0,
|
||||
} EventSampleRate;
|
||||
|
||||
typedef enum _EventProviderLatency {
|
||||
EventProviderLatency_Undefined = 0,
|
||||
EventProviderLatency_Normal,
|
||||
EventProviderLatency_RealTime,
|
||||
EventProviderLatency_Max
|
||||
} EventProviderLatency;
|
||||
|
||||
typedef enum _EventLatency {
|
||||
EventLatency_Undefined = 0,
|
||||
EventLatency_Normal,
|
||||
EventLatency_RealTime,
|
||||
EventLatency_DefaultProvider,
|
||||
EventLatency_Max
|
||||
} EventLatency;
|
||||
|
||||
typedef enum _EventProviderPriority {
|
||||
EventProviderPriority_Undefined = 0,
|
||||
EventProviderPriority_Normal,
|
||||
EventProviderPriority_Critical,
|
||||
EventProviderPriority_Max
|
||||
} EventProviderPriority;
|
||||
|
||||
typedef enum _EventPriority {
|
||||
EventPriority_Undefined = 0,
|
||||
EventPriority_Normal,
|
||||
EventPriority_Critical,
|
||||
EventPriority_DefaultProvider,
|
||||
EventPriority_Max
|
||||
} EventPriority;
|
||||
|
||||
typedef enum _ProviderState {
|
||||
ProviderState_Undefined = 0,
|
||||
ProviderState_ForceOff,
|
||||
ProviderState_Disabled,
|
||||
ProviderState_Enabled,
|
||||
ProviderState_ForceOn,
|
||||
ProviderState_Max
|
||||
} ProviderState;
|
||||
|
||||
typedef enum _EventState {
|
||||
EventState_Undefined = 0,
|
||||
EventState_Disabled,
|
||||
EventState_DefaultProvider,
|
||||
EventState_Enabled,
|
||||
EventState_Max
|
||||
} EventState;
|
||||
|
||||
typedef struct _FIELD_DESCRIPTOR {
|
||||
UINT8 Type : 5;
|
||||
UINT8 IsLengthField : 1;
|
||||
} FIELD_DESCRIPTOR;
|
||||
|
||||
|
||||
typedef struct _EVENT_DESCRIPTOR_STRUCT {
|
||||
const EVENT_DESCRIPTOR BaseDescriptor;
|
||||
LPCSTR EventName;
|
||||
LPCSTR SchemaVersion;
|
||||
const FIELD_DESCRIPTOR* FieldDescriptors;
|
||||
UINT8 FieldCount;
|
||||
UINT8 UploadEnabled;
|
||||
UINT8 CurrentUploadState;
|
||||
UINT8 DefaultUploadState;
|
||||
INT8 CurrentSampleRate;
|
||||
INT8 DefaultSampleRate;
|
||||
UINT8 CurrentLatency;
|
||||
UINT8 DefaultLatency;
|
||||
UINT8 CurrentPriority;
|
||||
UINT8 DefaultPriority;
|
||||
} EVENT_DESCRIPTOR_STRUCT, * PEVENT_DESCRIPTOR_STRUCT;
|
||||
|
||||
typedef struct _EVENT_PROVIDER_DESCRIPTOR {
|
||||
LPCSTR ProviderName;
|
||||
const GUID ProviderGuid;
|
||||
UINT32 EventCount;
|
||||
EVENT_DESCRIPTOR_STRUCT* EventDescriptors;
|
||||
UINT8 UploadEnabled;
|
||||
UINT8 CurrentUploadState;
|
||||
UINT8 DefaultUploadState;
|
||||
INT8 CurrentSampleRate;
|
||||
INT8 DefaultSampleRate;
|
||||
UINT8 CurrentLatency;
|
||||
UINT8 DefaultLatency;
|
||||
UINT8 CurrentPriority;
|
||||
UINT8 DefaultPriority;
|
||||
} EVENT_PROVIDER_DESCRIPTOR, * PEVENT_PROVIDER_DESCRIPTOR;
|
||||
|
||||
typedef enum _UserIdType {
|
||||
UserIdType_Xuid = 1,
|
||||
UserIdType_LiveId,
|
||||
UserIdType_LiveAnid,
|
||||
UserIdType_Anonymous
|
||||
} UserIdType;
|
||||
|
||||
VOID WINAPI
|
||||
FillEventCommonFields(
|
||||
__out_ecount(1) EVENT_DATA_DESCRIPTOR* eventDataDescriptors,
|
||||
__out_ecount(bufferSize) UINT8* buffer,
|
||||
__in UINT32 bufferSize
|
||||
);
|
||||
|
||||
ULONG WINAPI
|
||||
RegisterEventProvider(__inout EVENT_PROVIDER_DESCRIPTOR* provider, __inout REGHANDLE* handle);
|
||||
|
||||
ULONG WINAPI
|
||||
UnregisterEventProvider(__inout EVENT_PROVIDER_DESCRIPTOR* provider, __inout REGHANDLE* handle);
|
||||
|
||||
ULONG WINAPI
|
||||
WriteEventLog(
|
||||
__in const EVENT_DESCRIPTOR_STRUCT* eventDescriptor,
|
||||
__in const EVENT_PROVIDER_DESCRIPTOR* providerDescriptor,
|
||||
__in REGHANDLE handle,
|
||||
__in ULONG dataCount,
|
||||
__in const EVENT_DATA_DESCRIPTOR* eventData
|
||||
);
|
||||
void WINAPI
|
||||
PauseEventLogging( );
|
||||
|
||||
void WINAPI
|
||||
ResumeEventLogging( );
|
||||
#pragma warning(pop)
|
||||
#endif // EtwPlus_H
|
||||
@@ -15,6 +15,7 @@
|
||||
<ClCompile Include="pch.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="EtwPlus.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="EtwPlus.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Exports.def" />
|
||||
|
||||
Reference in New Issue
Block a user