w21k3r驾到... 发一个AVA上色源码  高手来吧

社区服务
高级搜索
猴岛论坛综合游戏交流w21k3r驾到... 发一个AVA上色源码  高手来吧
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
8个回复

w21k3r驾到... 发一个AVA上色源码  高手来吧

楼层直达
w21k3r

ZxID:8816696

等级: 大将
不要迷恋姐 姐只是传说
举报 只看楼主 使用道具 楼主   发表于: 2010-01-13 0
  1. //程序仅供交流,切勿用于游戏以及商业用途
  2. //By w21k3r 2010.01.13  [url]http://www.w21k3r.com[/url]
  3. #include <windows.h>
  4. #include <d3d9.h>
  5. #pragma comment(lib, "d3d9.lib")
  6. #include <d3dx9.h>
  7. #pragma comment(lib, "d3dx9.lib")
  8. #include <time.h>
  9. #include <stdlib.h>
  10. #include <fstream>
  11. #include <vector>   
  12. #include <D3dx9tex.h>
  13. #include <stdio.h>
  14. #include <time.h>
  15. #include <tchar.h>
  16. #include <iostream>
  17. #pragma warning(disable:4996)
  18. //-----------//
  19. bool fCall = true;
  20. bool Chams = true;
  21. IDirect3DPixelShader9 *Front,
  22.                       *Back;
  23. //----------//
  24. HRESULT CreateMyShader(IDirect3DPixelShader9 **pShader, IDirect3DDevice9 *Device, float red, float green, float blue, float alpha )
  25. {
  26.     ID3DXBuffer *MyBuffer = NULL;
  27.     char MyShader[ 256 ];
  28.     sprintf( MyShader, "w21k3r.10.01.13\ndef c0, %f, %f, %f, %f\nmov r0,c0", red/255, green/255, blue/255, alpha/255 );
  29.     D3DXAssembleShader( MyShader, sizeof( MyShader ), NULL, NULL, 0, &MyBuffer , NULL );
  30.     if( FAILED( Device->CreatePixelShader((const DWORD*)MyBuffer ->GetBufferPointer(), pShader)) )return E_FAIL;
  31.     return S_OK;
  32. }
  33. //=====================================================================================
  34. typedef HRESULT (WINAPI* CreateDevice_Prototype)        (LPDIRECT3D9, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE9*);
  35. typedef HRESULT (WINAPI* Reset_Prototype)              (LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
  36. typedef HRESULT (WINAPI* EndScene_Prototype)            (LPDIRECT3DDEVICE9);
  37. typedef HRESULT (WINAPI* DrawIndexedPrimitive_Prototype)(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
  38. CreateDevice_Prototype        CreateDevice_Pointer        = NULL;
  39. Reset_Prototype                Reset_Pointer                = NULL;
  40. EndScene_Prototype            EndScene_Pointer            = NULL;
  41. DrawIndexedPrimitive_Prototype DrawIndexedPrimitive_Pointer = NULL;
  42. HRESULT WINAPI Direct3DCreate9_VMTable    (VOID);
  43. HRESULT WINAPI CreateDevice_Detour        (LPDIRECT3D9, UINT, D3DDEVTYPE, HWND, DWORD, D3DPRESENT_PARAMETERS*, LPDIRECT3DDEVICE9*);
  44. HRESULT WINAPI Reset_Detour              (LPDIRECT3DDEVICE9, D3DPRESENT_PARAMETERS*);
  45. HRESULT WINAPI EndScene_Detour            (LPDIRECT3DDEVICE9);
  46. HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE9, D3DPRIMITIVETYPE, INT, UINT, UINT, UINT, UINT);
  47. DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching(LPVOID);
  48. PDWORD Direct3D_VMTable = NULL;
  49. //=====================================================================================
  50. BOOL WINAPI DllMain(HINSTANCE hinstModule, DWORD dwReason, LPVOID lpvReserved)
  51. {
  52.   if(dwReason == DLL_PROCESS_ATTACH)
  53.   {
  54.     DisableThreadLibraryCalls(hinstModule);
  55.     if(Direct3DCreate9_VMTable() == D3D_OK)
  56.     return TRUE;
  57.   }
  58.   return FALSE;
  59. }
  60. //=====================================================================================
  61. HRESULT WINAPI Direct3DCreate9_VMTable(VOID)
  62. {
  63.   LPDIRECT3D9 Direct3D_Object = Direct3DCreate9(D3D_SDK_VERSION);
  64.   if(Direct3D_Object == NULL)
  65.   return D3DERR_INVALIDCALL;
  66.  
  67.   Direct3D_VMTable = (PDWORD)*(PDWORD)Direct3D_Object;
  68.   Direct3D_Object->Release();
  69.   DWORD dwProtect;
  70.   if(VirtualProtect(&Direct3D_VMTable[16], sizeof(DWORD), PAGE_READWRITE, &dwProtect) != 0)
  71.   {
  72.     *(PDWORD)&CreateDevice_Pointer = Direct3D_VMTable[16];
  73.     *(PDWORD)&Direct3D_VMTable[16] = (DWORD)CreateDevice_Detour;
  74.     if(VirtualProtect(&Direct3D_VMTable[16], sizeof(DWORD), dwProtect, &dwProtect) == 0)
  75.     return D3DERR_INVALIDCALL;
  76.   }
  77.   else
  78.     return D3DERR_INVALIDCALL;
  79.   return D3D_OK;
  80. }
  81. //=====================================================================================
  82. HRESULT WINAPI CreateDevice_Detour(LPDIRECT3D9 Direct3D_Object, UINT Adapter, D3DDEVTYPE DeviceType, HWND FocusWindow,
  83.                     DWORD BehaviorFlags, D3DPRESENT_PARAMETERS* PresentationParameters,
  84.                     LPDIRECT3DDEVICE9* Returned_Device_Interface)
  85. {
  86.   HRESULT Returned_Result = CreateDevice_Pointer(Direct3D_Object, Adapter, DeviceType, FocusWindow, BehaviorFlags,
  87.                                               PresentationParameters, Returned_Device_Interface);
  88.  
  89.   DWORD dwProtect;
  90.   if(VirtualProtect(&Direct3D_VMTable[16], sizeof(DWORD), PAGE_READWRITE, &dwProtect) != 0)
  91.   {
  92.     *(PDWORD)&Direct3D_VMTable[16] = *(PDWORD)&CreateDevice_Pointer;
  93.     CreateDevice_Pointer          = NULL;
  94.     if(VirtualProtect(&Direct3D_VMTable[16], sizeof(DWORD), dwProtect, &dwProtect) == 0)
  95.     return D3DERR_INVALIDCALL;
  96.   }
  97.   else
  98.   return D3DERR_INVALIDCALL;
  99.   if(Returned_Result == D3D_OK)
  100.   {
  101.     Direct3D_VMTable = (PDWORD)*(PDWORD)*Returned_Device_Interface;
  102.     *(PDWORD)&Reset_Pointer                = (DWORD)Direct3D_VMTable[16];
  103.     *(PDWORD)&EndScene_Pointer            = (DWORD)Direct3D_VMTable[42];
  104.     *(PDWORD)&DrawIndexedPrimitive_Pointer = (DWORD)Direct3D_VMTable[82];
  105.     if(CreateThread(NULL, 0, VirtualMethodTableRepatchingLoopToCounterExtensionRepatching, NULL, 0, NULL) == NULL)
  106.     return D3DERR_INVALIDCALL;
  107.   }
  108.    
  109.   return Returned_Result;
  110. }
  111. //=====================================================================================
  112. HRESULT WINAPI Reset_Detour(LPDIRECT3DDEVICE9 Device_Interface, D3DPRESENT_PARAMETERS* PresentationParameters)
  113. {
  114.   return Reset_Pointer(Device_Interface, PresentationParameters);
  115. }
  116. //=====================================================================================
  117. HRESULT WINAPI EndScene_Detour(LPDIRECT3DDEVICE9 Device_Interface)
  118. {
  119.   return EndScene_Pointer(Device_Interface);
  120. }
  121. //=====================================================================================
  122. HRESULT WINAPI DrawIndexedPrimitive_Detour(LPDIRECT3DDEVICE9 Device_Interface, D3DPRIMITIVETYPE Type, INT BaseIndex,
  123.                                           UINT MinIndex, UINT NumVertices, UINT StartIndex, UINT PrimitiveCount)
  124. {
  125.   LPDIRECT3DVERTEXBUFFER9 Stream_Data;
  126.   UINT Offset = 0;
  127.   UINT Stride = 0;
  128.   if(Device_Interface->GetStreamSource(0, &Stream_Data, &Offset, &Stride) == D3D_OK)
  129.   Stream_Data->Release();
  130.   if(fCall)
  131.   {
  132.   CreateMyShader( &Front, Device_Interface,    255,    0,  0,  255 );
  133.   CreateMyShader( &Back,  Device_Interface,    255,  255,  0,  255 );
  134.   fCall = false;
  135.   }
  136.   if ( GetAsyncKeyState ( VK_NUMPAD1 ) &1 )
  137.     {
  138.         Chams = !Chams;
  139.     } 
  140.   if(Chams && (Stride == 32 && StartIndex == 0))
  141.   {
  142.         DWORD dwOldZEnable = D3DZB_TRUE;
  143.         Device_Interface->GetRenderState(D3DRS_ZENABLE, &dwOldZEnable);
  144.         Device_Interface->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
  145.         Device_Interface->SetPixelShader( Front );
  146.         DrawIndexedPrimitive_Pointer(Device_Interface, Type, BaseIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
  147.         Device_Interface->SetRenderState(D3DRS_ZENABLE, dwOldZEnable);
  148.         Device_Interface->SetPixelShader( Back );
  149.   }
  150.   return DrawIndexedPrimitive_Pointer(Device_Interface, Type, BaseIndex, MinIndex, NumVertices, StartIndex, PrimitiveCount);
  151. }
  152. //=====================================================================================
  153. DWORD WINAPI VirtualMethodTableRepatchingLoopToCounterExtensionRepatching(LPVOID Param)
  154. {
  155.   UNREFERENCED_PARAMETER(Param);
  156.   while(1)
  157.   {
  158.     Sleep(100);
  159.     *(PDWORD)&Direct3D_VMTable[42] = (DWORD)EndScene_Detour;
  160.     *(PDWORD)&Direct3D_VMTable[82] = (DWORD)DrawIndexedPrimitive_Detour;
  161.     *(PDWORD)&Direct3D_VMTable[16] = (DWORD)Reset_Detour;
  162.   }
  163.   return 1;
  164. }
本帖de评分: 1 条评分 DB +1
DB+1

好东西。

丶死在美梦中╮

ZxID:10215799

等级: 上校
Brothel still full, I say who

举报 只看该作者 沙发   发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
= =.小猴子应该早就知道了

   
末路伴侣。

ZxID:5543624

等级: 元老
让眼泪奔放去

举报 只看该作者 板凳   发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
源码...???
长期在线~长期隐藏!
hai5811061

ZxID:10318385

等级: 上等兵
举报 只看该作者 地板   发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
看不懂 但还是顶你下
zyf587

ZxID:7495311

等级: 中士
CF、AVA
举报 只看该作者 4楼  发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
我也看不懂。。不过,,支持,。,,
五谷轮回之所
丶死在美梦中╮

ZxID:10215799

等级: 上校
Brothel still full, I say who

举报 只看该作者 5楼  发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
  没点亮

   
x2580479

ZxID:1356081

等级: 上等兵
举报 只看该作者 6楼  发表于: 2010-01-13 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
看不懂
lizhen1598

ZxID:8761053

等级: 中士
举报 只看该作者 7楼  发表于: 2010-01-14 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
看不懂啊
11744687

ZxID:10055044

等级: 大校
盗我签名者  木有小JJ

举报 只看该作者 8楼  发表于: 2010-01-14 0
Re:w21k3r驾到... 发一个AVA上色源码 高手来吧
不晓得~~!!~~!!
[fly][img]http://s8.hk/1mx8[/URL][/mig][/fly]
« 返回列表
发帖 回复