好友
阅读权限 10
听众
最后登录 1970-1-1
我做了2个函数拦截并显示某个功能,有一个成功 ,有一个报错不知道哪出问题了,是不是返回类型错了还是?
2个原型是
PK_linkage_m PK_ERROR_code_t PK_BODY_extrude
(
/* received */
PK_BODY_t /*profile*/, /* minimum, wire or sheet profile */
PK_VECTOR1_t /*path*/, /* direction of linear extrusion */
const PK_BODY_extrude_o_t * /*options*/, /* options structure */
/* returned */
PK_BODY_t *const /*body*/, /* resulting extruded body */
PK_TOPOL_track_r_t *const /*tracking*/, /* tracking information */
PK_TOPOL_local_r_t *const /*results*/ /* status information */
);
/*
This function creates a new body by performing a linear extrusion of a given
profile.
*/
PK_linkage_m PK_ERROR_code_t PK_CURVE_make_wire_body_2
(
/* received */
int /*n_curves*/, /* number of curves (ie, */
const PK_CURVE_t /*curves*/[], /* curves to create a wire */
const PK_INTERVAL_t /*bounds*/[], /* bounds of each curve */
const PK_CURVE_make_wire_body_o_t * /*options*/, /* options structure */
/* returned */
PK_BODY_t *const /*body*/, /* the created wire body */
int *const /*n_new_edges*/, /* number of new edges */
PK_EDGE_t **const /*new_edges*/, /* new edges */
int **const /*edge_index*/ /* pos in original array */
);
/*
This function creates a wire body from an array of curves and intervals. The
curves do not need to be ordered (unless specified otherwise) or directed.
*/
拦截代码如下,如果某个命令用到这2个函数就提示,使用了某函数
用于分析代码使用哪些函数完成的
HookApi_PK_BODY_extrude是成功的
BOOL HookApi_PK_BODY_extrude();
BOOL UnhookApi_PK_BODY_extrude();
typedef PK_ERROR_code_t(WINAPI* typedef_PK_BODY_extrude)(PK_BODY_t profile, PK_VECTOR1_t path, const PK_BODY_extrude_o_t* options, PK_BODY_t* const body, PK_TOPOL_track_r_t* const tracking, PK_TOPOL_local_r_t* const results);
PK_ERROR_code_t WINAPI New_PK_BODY_extrude(PK_BODY_t profile, PK_VECTOR1_t path, const PK_BODY_extrude_o_t* options, PK_BODY_t* const body, PK_TOPOL_track_r_t* const tracking, PK_TOPOL_local_r_t* const results);
BOOL UnhookApi_PK_BODY_extrude()
{
char* dll_name = "pskernel.dll";
char* addressname = "PK_BODY_extrude";
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return FALSE; }
PVOID OldMessageBoxA = ::GetProcAddress(hDll, addressname);
if (NULL == OldMessageBoxA) { return FALSE; }
DWORD dwNewDataSize = 12;
DWORD dwOldProtect = 0;
::VirtualProtect(OldMessageBoxA, dwNewDataSize, PAGE_EXECUTE_READWRITE, &dwOldProtect);
::RtlCopyMemory(OldMessageBoxA, g_pOldData, dwNewDataSize);
::VirtualProtect(OldMessageBoxA, dwNewDataSize, dwOldProtect, &dwOldProtect);
return TRUE;
}
PK_ERROR_code_t WINAPI New_PK_BODY_extrude(PK_BODY_t profile, PK_VECTOR1_t path, const PK_BODY_extrude_o_t* options, PK_BODY_t* const body, PK_TOPOL_track_r_t* const tracking, PK_TOPOL_local_r_t* const results)
{
PK_ERROR_code_t fanhui = 0;
char* dll_name = "pskernel.dll";
char* addressname = "PK_BODY_extrude";
UnhookApi_PK_BODY_extrude();
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return fanhui; }
typedef_PK_BODY_extrude OldFuncAddr = (typedef_PK_BODY_extrude)::GetProcAddress(hDll, addressname);
if (NULL == OldFuncAddr) { return fanhui; }
fanhui = OldFuncAddr(profile, path, options, body, tracking, results);
UF_UI_write_listing_window("你使用了PK_BODY_extrude函数\n");
HookApi_PK_BODY_extrude();
return fanhui;
}
BOOL HookApi_PK_BODY_extrude()
{
char* dll_name = "pskernel.dll";
char* addressname = "PK_BODY_extrude";
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return FALSE; }
PVOID OldFuncAddr = ::GetProcAddress(hDll, addressname);
if (NULL == OldFuncAddr) { return FALSE; }
BYTE pNewData[12] = { 0x48, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xe0 };
DWORD dwNewDataSize = 12;
ULONGLONG ullNewFuncAddr = (ULONGLONG)New_PK_BODY_extrude;
::RtlCopyMemory(&pNewData[2], &ullNewFuncAddr, sizeof(ullNewFuncAddr));
DWORD dwOldProtect = 0;
::VirtualProtect(OldFuncAddr, dwNewDataSize, PAGE_EXECUTE_READWRITE, &dwOldProtect);
::RtlCopyMemory(g_pOldData, OldFuncAddr, dwNewDataSize);
::RtlCopyMemory(OldFuncAddr, pNewData, dwNewDataSize);
::VirtualProtect(OldFuncAddr, dwNewDataSize, dwOldProtect, &dwOldProtect);
return TRUE;
}
//----
另一个不成功
HookApi_PK_CURVE_make_wire_body_2(); 不成功
BOOL HookApi_PK_CURVE_make_wire_body_2();
BOOL UnhookApi_PK_CURVE_make_wire_body_2();
typedef PK_ERROR_code_t(WINAPI* typedef_PK_CURVE_make_wire_body_2)(int n_curves, const PK_CURVE_t curves[], const PK_INTERVAL_t bounds[], const PK_CURVE_make_wire_body_o_t* options, PK_BODY_t* const body, int* const n_new_edges, PK_EDGE_t** const new_edges, int** const edge_index);
PK_ERROR_code_t WINAPI New_PK_CURVE_make_wire_body_2(int n_curves, const PK_CURVE_t curves[], const PK_INTERVAL_t bounds[], const PK_CURVE_make_wire_body_o_t* options, PK_BODY_t* const body, int* const n_new_edges, PK_EDGE_t** const new_edges, int** const edge_index);
BOOL UnhookApi_PK_CURVE_make_wire_body_2()
{
char* dll_name = "pskernel.dll";
char* addressname = "PK_CURVE_make_wire_body_2";
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return FALSE; }
PVOID OldMessageBoxA = ::GetProcAddress(hDll, addressname);
if (NULL == OldMessageBoxA) { return FALSE; }
DWORD dwNewDataSize = 12;
DWORD dwOldProtect = 0;
::VirtualProtect(OldMessageBoxA, dwNewDataSize, PAGE_EXECUTE_READWRITE, &dwOldProtect);
::RtlCopyMemory(OldMessageBoxA, g_pOldData, dwNewDataSize);
::VirtualProtect(OldMessageBoxA, dwNewDataSize, dwOldProtect, &dwOldProtect);
return TRUE;
}
PK_ERROR_code_t New_PK_CURVE_make_wire_body_2(int n_curves, const PK_CURVE_t curves[], const PK_INTERVAL_t bounds[], const PK_CURVE_make_wire_body_o_t* options, PK_BODY_t* const body, int* const n_new_edges, PK_EDGE_t** const new_edges, int** const edge_index)
{
PK_ERROR_code_t fanhui = 0;
char* dll_name = "pskernel.dll";
char* addressname = "PK_CURVE_make_wire_body_2";
UnhookApi_PK_CURVE_make_wire_body_2();
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return fanhui; }
typedef_PK_CURVE_make_wire_body_2 OldFuncAddr = (typedef_PK_CURVE_make_wire_body_2)::GetProcAddress(hDll, addressname);
if (NULL == OldFuncAddr) { return fanhui; }
fanhui = OldFuncAddr(n_curves, curves, bounds, options, body, n_new_edges, new_edges, edge_index);
UF_UI_write_listing_window("你使用了PK_CURVE_make_wire_body_2函数\n");
HookApi_PK_CURVE_make_wire_body_2();
return fanhui;
}
BOOL HookApi_PK_CURVE_make_wire_body_2()
{
char* dll_name = "pskernel.dll";
char* addressname = "PK_CURVE_make_wire_body_2";
HMODULE hDll = ::GetModuleHandleA(dll_name);
if (NULL == hDll) { return FALSE; }
PVOID OldFuncAddr = ::GetProcAddress(hDll, addressname);
if (NULL == OldFuncAddr) { return FALSE; }
BYTE pNewData[12] = { 0x48, 0xb8, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xe0 };
DWORD dwNewDataSize = 12;
PK_ERROR_code_t ullNewFuncAddr = (PK_ERROR_code_t)New_PK_CURVE_make_wire_body_2;
::RtlCopyMemory(&pNewData[2], &ullNewFuncAddr, sizeof(ullNewFuncAddr));
DWORD dwOldProtect = 0;
::VirtualProtect(OldFuncAddr, dwNewDataSize, PAGE_EXECUTE_READWRITE, &dwOldProtect);
::RtlCopyMemory(g_pOldData, OldFuncAddr, dwNewDataSize);
::RtlCopyMemory(OldFuncAddr, pNewData, dwNewDataSize);
::VirtualProtect(OldFuncAddr, dwNewDataSize, dwOldProtect, &dwOldProtect);
return TRUE;
}
我的想法就是,做个DLL,注入某进程 ,某进程运行某个功能 ,看它调用什么哪个函数,然后我也做个命令山寨这样实现平替
不知道哪有问题了
免费评分
查看全部评分