Answered by:
4n How to Hook DirectX11 get Shader bytecode

Question
-
【DirectX9 Get shader bytecode-】 I hook DrawIndexedPrimitive
HookCode(PPointer(g_DeviceBaseAddr + $148)^,@NewDrawIndexedPrimitive, @OldDrawIndexedPrimitive); function NewDrawIndexedPrimitive(const Device:IDirect3DDevice9;_Type: TD3DPrimitiveType; BaseVertexIndex: Integer; MinVertexIndex, NumVertices, startIndex, primCount: LongWord): HResult; stdcall; var ppShader: IDirect3DVertexShader9; _Code:Pointer; _CodeLen:Cardinal; begin Device.GetVertexShader(ppShader);//<------1.Get ShaderObject(ppShader) ppShader.GetFunction(nil,_CodeLen); GetMem(_Code,_CodeLen); ppShader.GetFunction(_Code,_CodeLen);//<----2.Get bytecode from ShaderObject(ppShader) Result:=OldDrawIndexedPrimitive(Self,_Type,BaseVertexIndex,MinVertexIndex, NumVertices, startIndex, primCount); end;
【How to DirectX11 Get VSShader bytecode?】 I hook DrawIndexed
pDrawIndexed:=PPointer(PUINT_PTR(UINT_PTR(g_ImmContext)+0)^ + 12 * SizeOf(Pointer))^; HookCode(pDrawIndexed,@NewDrawIndexed,@OldDrawIndexed); procedure NewDrawIndexed(g_Real_ImmContext:ID3D11DeviceContext;IndexCount: UINT;StartIndexLocation: UINT;BaseVertexLocation: Integer); stdcall; var game_pVertexShader: ID3D11VertexShader; ppClassInstances: ID3D11ClassInstance; NumClassInstances: UINT begin g_Real_ImmContext.VSGetShader(game_pVertexShader,ppClassInstances,NumClassInstances); //<------1.Get ShaderObject(game_pVertexShader) .....//<----2.Here's how to get bytecode from ShaderObject(game_pVertexShader)? OldDrawIndexed(ImmContext, IndexCount, StartIndexLocation, BaseVertexLocation); end;
Another way:
HOOK CreateVertexShader()
but
HOOK need to be created before the game CreateVertexShader, HOOK will not get bytecode if the game is running later,I need to get bytecode at any time like DirectX9
- Edited by hksoobe Sunday, February 25, 2018 9:07 AM
- Moved by Annie Chen-MSFT Monday, February 26, 2018 3:17 AM
Sunday, February 25, 2018 5:59 AM
Answers
-
I'd ask for help over here.
http://xboxforums.create.msdn.com/forums/default.aspx?GroupID=7
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Richard MuellerMVP, Banned Monday, February 26, 2018 3:31 PM
- Marked as answer by Richard MuellerMVP, Banned Monday, March 5, 2018 5:14 PM
Monday, February 26, 2018 3:35 AM
All replies
-
Hi @hksoobe,
Since this forum is only for account related issues, I will move this DirectX11 related thread to another forum so that you can get advice where to post this question.
Thanks for your understanding.
Best Regards,
Annie
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.Monday, February 26, 2018 3:13 AM -
I'd ask for help over here.
http://xboxforums.create.msdn.com/forums/default.aspx?GroupID=7
Regards, Dave Patrick ....
Microsoft Certified Professional
Microsoft MVP [Windows Server] Datacenter Management
Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.- Proposed as answer by Richard MuellerMVP, Banned Monday, February 26, 2018 3:31 PM
- Marked as answer by Richard MuellerMVP, Banned Monday, March 5, 2018 5:14 PM
Monday, February 26, 2018 3:35 AM