Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. question hooking virtual table / class functions

question hooking virtual table / class functions

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nah1337
    wrote on last edited by
    #1

    Hello community, ive got a problem i hooked a function that has virtual table inside it and calls other functions: Decompailed with hex rayz : signed int __cdecl sub_4594F5() { signed int result; // eax@1 result = -691773993; dword_4B0068 = (unsigned int)sub_40511C ^ 0xD6C45DD7; // i suppouse 0 dword_4B006C = (unsigned int)sub_438213 ^ 0xD6C45DD7; // 1 dword_4B0070 = (unsigned int)sub_424041 ^ 0xD6C45DD7; // 2 dword_4B0074 = (unsigned int)sub_42A4FC ^ 0xD6C45DD7; // 3 dword_4B0078 = (unsigned int)sub_410B73 ^ 0xD6C45DD7; // 4 dword_4B02F8 = (unsigned int)((char *)sub_416A34 + 4) ^ 0xD6C45DD7; // 5 // the function list goes alot more on there like this around 50-60 funcs or more... return result; } This is second function from the virtual table that i want to hook int (__cdecl* pointermy_sub_438213)(int, int, int, int); int __cdecl testmy_sub_438213(int a, int b, int c, int d) { return pointermy_sub_438213(a, b, c, d); } This is the hooked vtable func i used ms detours to hook it : int (__cdecl* pPBVTBLsub_4594F5)(); int __cdecl myPBVTBLsub_4594F5() { int dword_4B006C; dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7; return pPBVTBLsub_4594F5(); } So in shortly the testmy_sub_438213 wont get hooked, so anyone knows what im doing wrong or mybe my aproach is false and this way cant be done vtable hooking any input is really welcome.

    S 1 Reply Last reply
    0
    • N nah1337

      Hello community, ive got a problem i hooked a function that has virtual table inside it and calls other functions: Decompailed with hex rayz : signed int __cdecl sub_4594F5() { signed int result; // eax@1 result = -691773993; dword_4B0068 = (unsigned int)sub_40511C ^ 0xD6C45DD7; // i suppouse 0 dword_4B006C = (unsigned int)sub_438213 ^ 0xD6C45DD7; // 1 dword_4B0070 = (unsigned int)sub_424041 ^ 0xD6C45DD7; // 2 dword_4B0074 = (unsigned int)sub_42A4FC ^ 0xD6C45DD7; // 3 dword_4B0078 = (unsigned int)sub_410B73 ^ 0xD6C45DD7; // 4 dword_4B02F8 = (unsigned int)((char *)sub_416A34 + 4) ^ 0xD6C45DD7; // 5 // the function list goes alot more on there like this around 50-60 funcs or more... return result; } This is second function from the virtual table that i want to hook int (__cdecl* pointermy_sub_438213)(int, int, int, int); int __cdecl testmy_sub_438213(int a, int b, int c, int d) { return pointermy_sub_438213(a, b, c, d); } This is the hooked vtable func i used ms detours to hook it : int (__cdecl* pPBVTBLsub_4594F5)(); int __cdecl myPBVTBLsub_4594F5() { int dword_4B006C; dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7; return pPBVTBLsub_4594F5(); } So in shortly the testmy_sub_438213 wont get hooked, so anyone knows what im doing wrong or mybe my aproach is false and this way cant be done vtable hooking any input is really welcome.

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      Umm - which bit is the function table? (Note - it is NOT a virtual function table - that has a specific meaning, which isn't the one you're using). I see no function or function calls in sub_4594F5 at all. Which could be why you can't hook any of them.

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

      N 1 Reply Last reply
      0
      • S Stuart Dootson

        Umm - which bit is the function table? (Note - it is NOT a virtual function table - that has a specific meaning, which isn't the one you're using). I see no function or function calls in sub_4594F5 at all. Which could be why you can't hook any of them.

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

        N Offline
        N Offline
        nah1337
        wrote on last edited by
        #3

        No, no i mean sub_4594F5() is the function that has virtualtable inside it, so i hooked it with micorsoft detours and inside sub_4594F5()i want to do vtable hooking like that int dword_4B006C; dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7; But function sub_438213 wont get hooked and that function is second function from the vtable

        S 1 Reply Last reply
        0
        • N nah1337

          No, no i mean sub_4594F5() is the function that has virtualtable inside it, so i hooked it with micorsoft detours and inside sub_4594F5()i want to do vtable hooking like that int dword_4B006C; dword_4B006C = (unsigned int)testmy_sub_438213 ^ 0xD6C45DD7; But function sub_438213 wont get hooked and that function is second function from the vtable

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          That is because testmy_sub_438213 isn't being called! They are XORing its address with 0xD6C45DD7. There are no function calls there! So there's no way any hooking can intercept any calls.

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p CodeProject MVP for 2010 - who'd'a thunk it!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups