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. Calling a dll function from __asm blocks?

Calling a dll function from __asm blocks?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontestingbeta-testing
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.
  • M Offline
    M Offline
    mvworld
    wrote on last edited by
    #1

    Hi I am trying to call a DLL (for testing I use the SetWindowTextA function from User32.dll) Everything seems correct to me...and the program compiles and links fine, except that on executing it, it given an illegal operation. I have checked that SetWindowTextA is in User32.dll, so I guess it should work? Here is the code: #include #define TAILLE_MAX 40 void main() { char *szFuncName = "SetWindowTextA"; char *szDllName = "User32.dll"; HINSTANCE hLibrary; HWND hwnd; char szOldWndTitle[TAILLE_MAX]; char *szNewWndTitle = "Changed Title"; BOOL RetVal; GetConsoleTitle(szOldWndTitle, TAILLE_MAX); hwnd = FindWindow(NULL, szOldWndTitle); __asm { push szDllName call LoadLibrary mov hLibrary, eax push szFuncName push hLibrary call GetProcAddress ;eax recieves function pointer push szNewWndTitle push hwnd call eax mov RetVal, eax push hLibrary call FreeLibrary } } Any ideas what is wrong? Thanks in advance :)

    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