From f8f74cab19c34ad92e56991194d4cd370dfb5da8 Mon Sep 17 00:00:00 2001 From: monkeyman192 Date: Tue, 10 Mar 2026 23:52:12 +1100 Subject: [PATCH] Forgot to include the vulkan file... --- nmspy/data/types.py | 86 ++++++++++++++++++++++++++++++++++++++++++-- nmspy/data/vulkan.py | 11 ++++++ pyproject.toml | 2 +- tools/data.json | 25 +++++++++++++ uv.lock | 2 +- 5 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 nmspy/data/vulkan.py diff --git a/nmspy/data/types.py b/nmspy/data/types.py index 6d6fd46..cd104d9 100644 --- a/nmspy/data/types.py +++ b/nmspy/data/types.py @@ -1500,6 +1500,59 @@ def UpdateGravityPoint( ] +@partial_struct +class cTkTextureBase(Structure): + meType: Annotated[int, Field(c_uint8, 0x0)] + miWidth: Annotated[int, Field(c_int32, 0x10)] + miHeight: Annotated[int, Field(c_int32, 0x14)] + miDepth: Annotated[int, Field(c_int32, 0x14)] + miNumMips: Annotated[int, Field(c_uint16, 0x1C)] + miDataSize: Annotated[int, Field(c_int32, 0x20)] + miMemorySize: Annotated[int, Field(c_int32, 0x24)] + + @static_function_hook("0F B6 C1 45 8B D0") + @staticmethod + def CalculateTextureSize( + leFormat: c_uint32, + liWidth: c_int32, + liHeight: c_int32, + liDepth: c_int32, + ) -> c_uint64: ... + + +@partial_struct +class cTkTexture(cTkTextureBase): + @function_hook("48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B FA 48 8B F1 33 D2 48 8D 0D") + def CopyPixelDataToBuffer( + self, + this: "_Pointer[cTkTexture]", + lpBuffer: c_void_p, + lbCompressed: Annotated[bool, c_bool], + liMipLevel: Annotated[int, c_uint32], + liCubeFace: Annotated[int, c_uint32], + ): ... + + @function_hook("48 8B C4 44 89 48 ? 44 89 40 ? 88 50 ? 48 89 48") + def CreateEmptyTexture( + self, + this: "_Pointer[cTkTexture]", + leType: Annotated[int, c_uint8], # eTkTextureType + liWidth: Annotated[int, c_uint32], + liHeight: Annotated[int, c_uint32], + liDepth: Annotated[int, c_uint32], + liFormat: Annotated[int, c_char], + liNumMipLevels: Annotated[int, c_uint32], + leTextureAddressMode: c_enum32[nmse.cTkMaterialSampler.eTextureAddressModeEnum], + leTextureFilterMode: c_enum32[nmse.cTkMaterialSampler.eTextureFilterModeEnum], + liAnisotropy: Annotated[int, c_uint32], + lbIsSrgb: Annotated[bool, c_bool], + lbCommit: Annotated[bool, c_bool], + lbIsPartiallyResident: Annotated[bool, c_bool], + lbEvictAllEvictable: Annotated[bool, c_bool], + lbAllowUnorderedAccess: Annotated[bool, c_bool], + ): ... + + class Engine: @static_function_hook("40 53 44 8B D1 44 8B C9 41 C1 EA ? 41 81 E1 ? ? ? ? 48 8B DA") @staticmethod @@ -1602,7 +1655,8 @@ def GetResourceHandleForNode( @staticmethod def GetTexture( targetRes: Annotated[int, c_int32], # TkStrongType - ) -> c_char_p64: ... + ) -> c_uint64: # typed as "char *", but is actually cTkTexture * + ... @static_function_hook( "44 8B C9 44 8B C1 41 C1 E9 ? 41 81 E0 ? ? ? ? 45 85 C9 74 ? 41 81 F8 ? ? ? ? 74 ? 4C 8B 15 ? ? ? ? " @@ -1628,6 +1682,18 @@ def GetNodeNumChildren(node: basic.TkHandle) -> c_int32: ... @staticmethod def GetNodeName(node: basic.TkHandle) -> c_char_p64: ... + @static_function_hook( + "40 53 48 83 EC ? 8B DA 85 C9 74 ? 4C 8B 0D ? ? ? ? 8D 41 ? 41 3B 41 ? 73 ? 49 8B 41 ? 4C 63 C1 4A " + "8B 44 C0 ? 48 85 C0 74 ? 80 B8 ? ? ? ? ? 74 ? 4C 8B 80 ? ? ? ? 49 8B C9 8B 50 ? E8 ? ? ? ? EB ? 33 " + "C0 48 85 C0 74 ? 83 78 ? ? 75 ? 8B 90" + ) + @staticmethod + def GetRenderBufferTexture( + targetRes: Annotated[int, c_int32], + liIndex: c_uint32, + ) -> c_uint64: # cTkTexture * + ... + class cEgResource(cTkResource): @function_hook("48 89 5C 24 ? 48 89 6C 24 ? 56 48 83 EC ? 48 8B 01 41 8B F0") @@ -2992,14 +3058,23 @@ class cEgModelNode(cEgSceneNode): def UpdateGeometry(self, this: "_Pointer[cEgModelNode]") -> c_char: ... -class cEgMaterialResource(cEgResource): +@partial_struct +class cEgShaderResource(cEgResource): pass +@partial_struct +class cEgMaterialResource(cEgResource): + # Found by inspecting cEgMaterialResource in memory. + mpShaderResource: Annotated[cTkTypedSmartResHandle[cEgShaderResource], 0x1D8] + + @partial_struct class cEgMeshNode(cEgSceneNode): _total_size_ = 0xE0 + # These top two are found in cEgRenderableSceneNode::cEgRenderableSceneNode. + # Most of the remaining fields are found in cEgMeshNode::cEgMeshNode. mpMaterialResource: Annotated[cTkTypedSmartResHandle[cEgMaterialResource], 0x38] mpParentModel: Annotated[_Pointer[cEgModelNode], 0x48] miNodeIndex: Annotated[int, Field(c_int32, 0x58)] @@ -3213,6 +3288,13 @@ def Update( ): ... +class cGcPhotoModeUI(Structure): + @static_function_hook("48 89 4C 24 ? 55 53 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 8B 49") + @staticmethod + def OnRenderScreenshotFinished(lpData: c_void_p): # Unknown data type... + ... + + class cEgModules: patt_mgpSceneManager = ( "48 89 05 ? ? ? ? E8 ? ? ? ? 48 39 3D ? ? ? ? 75 ? B9 ? ? ? ? E8 ? ? ? ? 48 85 C0 74 ? 48 89 78 ? 40 " diff --git a/nmspy/data/vulkan.py b/nmspy/data/vulkan.py new file mode 100644 index 0000000..16c485f --- /dev/null +++ b/nmspy/data/vulkan.py @@ -0,0 +1,11 @@ +from ctypes import c_uint64, c_void_p +from typing import Annotated + +from pymhf.core.hooking import Structure +from pymhf.utils.partial_struct import Field, partial_struct + + +@partial_struct +class VkBuffer_T(Structure): + size: Annotated[int, Field(c_uint64, 0x0)] + bytes_: Annotated[c_void_p, 0x8] diff --git a/pyproject.toml b/pyproject.toml index 6d38fe9..7ca0b8d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,7 @@ classifiers = [ dependencies = [ "pymhf[gui]==0.2.2" ] -version = "161765.0" +version = "161765.1" [dependency-groups] dev = [ diff --git a/tools/data.json b/tools/data.json index 1b9807e..b486576 100644 --- a/tools/data.json +++ b/tools/data.json @@ -1308,5 +1308,30 @@ "name": "cEgRendererBase::ApplyVertexLayout", "signature": "44 89 44 24 ? 48 89 54 24 ? 48 89 4C 24 ? 53 55 56", "mangled_name": "?ApplyVertexLayout@cEgRendererBase@@QEAA_NAEBVcTkVertexLayoutRT@@AEBVcTkShader@@PEAVcEgThreadableRenderCall@@H@Z" + }, + { + "name": "cGcPhotoModeUI::OnRenderScreenshotFinished", + "signature": "48 89 4C 24 ? 55 53 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 8B 49", + "mangled_name": "?OnRenderScreenshotFinished@cGcPhotoModeUI@@CAXPEAX@Z" + }, + { + "name": "Engine::GetRenderBufferTexture", + "signature": "40 53 48 83 EC ? 8B DA 85 C9 74 ? 4C 8B 0D ? ? ? ? 8D 41 ? 41 3B 41 ? 73 ? 49 8B 41 ? 4C 63 C1 4A 8B 44 C0 ? 48 85 C0 74 ? 80 B8 ? ? ? ? ? 74 ? 4C 8B 80 ? ? ? ? 49 8B C9 8B 50 ? E8 ? ? ? ? EB ? 33 C0 48 85 C0 74 ? 83 78 ? ? 75 ? 8B 90", + "mangled_name": "?GetRenderBufferTexture@Engine@@YAPEAXU?$TkStrongType@HUTkResHandleID@TkStrongTypeIDs@@@@H@Z" + }, + { + "name": "cTkTextureBase::CalculateTextureSize", + "signature": "0F B6 C1 45 8B D0", + "mangled_name": "?CalculateTextureSize@cTkTextureBase@@SAIW4eTexFormat@1@HHH@Z" + }, + { + "name": "cTkTexture::CopyPixelDataToBuffer", + "signature": "48 89 5C 24 ? 48 89 74 24 ? 57 48 83 EC ? 48 8B FA 48 8B F1 33 D2 48 8D 0D", + "mangled_name": "?CopyPixelDataToBuffer@cTkTexture@@QEAAXPEAD_NII@Z" + }, + { + "name": "cTkTexture::CreateEmptyTexture", + "signature": "48 8B C4 44 89 48 ? 44 89 40 ? 88 50 ? 48 89 48", + "mangled_name": "?CreateEmptyTexture@cTkTexture@@QEAAXW4eTkTextureType@@IIIIIW4eTextureAddressMode@@W4eTextureFilterMode@@I_N3333@Z" } ] \ No newline at end of file diff --git a/uv.lock b/uv.lock index 84f86e6..d09f265 100644 --- a/uv.lock +++ b/uv.lock @@ -624,7 +624,7 @@ wheels = [ [[package]] name = "nmspy" -version = "161765.0" +version = "161765.1" source = { editable = "." } dependencies = [ { name = "pymhf", extra = ["gui"] },