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. hooking problem

hooking problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpjsonquestion
1 Posts 1 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.
  • D Offline
    D Offline
    Dev578
    wrote on last edited by
    #1

    I am having trouble with the "Process-wide api spying" article by Anton Bassov. Here is the code: HMODULE hMod = GetModuleHandle("kernel32.dll"); if (hMod == NULL) MessageBox(NULL,"could not load dll","error",MB_OK); else { IMAGE_DOS_HEADER * dosheader=(IMAGE_DOS_HEADER *)hMod; IMAGE_OPTIONAL_HEADER * opthdr =(IMAGE_OPTIONAL_HEADER *) ((BYTE*)hMod+dosheader->e_lfanew+24); IMAGE_IMPORT_DESCRIPTOR * descriptor=(IMAGE_IMPORT_DESCRIPTOR*)(BYTE*)hMod + opthdr->DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; while(descriptor->FirstThunk) { char*dllname=(char*)((BYTE*)hMod+ descriptor->Name); IMAGE_THUNK_DATA* thunk=( IMAGE_THUNK_DATA*)((BYTE*) hMod + descriptor->OriginalFirstThunk); int x=0; while(thunk->u1.Function) { char*functionname=(char*)((BYTE*) hMod + ( DWORD)thunk->u1.AddressOfData+2); MessageBox(NULL,functionname,"function",MB_OK); DWORD *IATentryaddress=( DWORD *)((BYTE*) hMod + descriptor->FirstThunk)+x; x++; thunk++; } descriptor++; } } It is crashing at run-time, saying that it cannot read from desciptor. Anyone have any idea what the problem is? Any help is appreciated. -Dev578

    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