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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Getting an "Access violation reading location" error for an iTunes plugin

Getting an "Access violation reading location" error for an iTunes plugin

Scheduled Pinned Locked Moved C / C++ / MFC
helptestingbeta-testing
3 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.
  • G Offline
    G Offline
    Grant Hudgens
    wrote on last edited by
    #1

    I am very new to creating Windows DLLs and I am trying to create a plugin for iTunes but I need this plugin to have a window that runs alongside iTunes. When I open iTunes it does create the window but I get "Unhandled exception at 0x10911758 in iTunes.exe: 0xC0000005: Access violation reading location 0x10911758."

    BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
    {
    HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(_T("iTunesLyrics"));
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH: InitWnd(hInstance); break;
    case DLL_THREAD_ATTACH:
    case DLL_PROCESS_DETACH:
    case DLL_THREAD_DETACH:
    break;
    }
    return true;

    }

    int InitWnd(HINSTANCE hInst)
    {
    static TCHAR szAppName[] = TEXT("iTunesLyrics");
    MSG msg;

    WNDCLASSEX wndclass;
    	wndclass.hIcon			= LoadIcon(0,IDI\_EXCLAMATION);
    	wndclass.cbSize			= sizeof(WNDCLASSEX);
    	wndclass.style			= CS\_HREDRAW | CS\_VREDRAW;
    	wndclass.lpfnWndProc	= (WNDPROC)WindowProcedure;
    	wndclass.cbClsExtra		= 0;
    	wndclass.cbWndExtra		= 0;
    	wndclass.hInstance		= hInst;
    	wndclass.hCursor		= LoadCursor(NULL, IDC\_ARROW);
    	wndclass.hbrBackground	= (HBRUSH)(COLOR\_WINDOW+1);
    	wndclass.lpszMenuName	= NULL;
    	wndclass.lpszClassName	= \_T("Testing");
    	wndclass.hIconSm		= NULL;
    
    if(!RegisterClassEx(&wndclass))
    	MessageBox(NULL, \_T("RegClass Failed"), \_T("Error"), MB\_OK);
    
    hWnd = CreateWindow(\_T("Testing"), \_T("This is a test"), WS\_OVERLAPPEDWINDOW, CW\_USEDEFAULT, 0, CW\_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
    ShowWindow(hWnd, SW\_SHOW);
    
    return 0;
    

    } //InitWnd()

    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_DESTROY: PostQuitMessage (0);
    break;
    case WM_CREATE: return 0;
    break;
    case WM_NCCREATE: return true;
    break;
    default:
    return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
    

    }

    Any help would be greatly appreciated.

    D 1 Reply Last reply
    0
    • G Grant Hudgens

      I am very new to creating Windows DLLs and I am trying to create a plugin for iTunes but I need this plugin to have a window that runs alongside iTunes. When I open iTunes it does create the window but I get "Unhandled exception at 0x10911758 in iTunes.exe: 0xC0000005: Access violation reading location 0x10911758."

      BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
      {
      HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(_T("iTunesLyrics"));
      switch (ul_reason_for_call)
      {
      case DLL_PROCESS_ATTACH: InitWnd(hInstance); break;
      case DLL_THREAD_ATTACH:
      case DLL_PROCESS_DETACH:
      case DLL_THREAD_DETACH:
      break;
      }
      return true;

      }

      int InitWnd(HINSTANCE hInst)
      {
      static TCHAR szAppName[] = TEXT("iTunesLyrics");
      MSG msg;

      WNDCLASSEX wndclass;
      	wndclass.hIcon			= LoadIcon(0,IDI\_EXCLAMATION);
      	wndclass.cbSize			= sizeof(WNDCLASSEX);
      	wndclass.style			= CS\_HREDRAW | CS\_VREDRAW;
      	wndclass.lpfnWndProc	= (WNDPROC)WindowProcedure;
      	wndclass.cbClsExtra		= 0;
      	wndclass.cbWndExtra		= 0;
      	wndclass.hInstance		= hInst;
      	wndclass.hCursor		= LoadCursor(NULL, IDC\_ARROW);
      	wndclass.hbrBackground	= (HBRUSH)(COLOR\_WINDOW+1);
      	wndclass.lpszMenuName	= NULL;
      	wndclass.lpszClassName	= \_T("Testing");
      	wndclass.hIconSm		= NULL;
      
      if(!RegisterClassEx(&wndclass))
      	MessageBox(NULL, \_T("RegClass Failed"), \_T("Error"), MB\_OK);
      
      hWnd = CreateWindow(\_T("Testing"), \_T("This is a test"), WS\_OVERLAPPEDWINDOW, CW\_USEDEFAULT, 0, CW\_USEDEFAULT, 0, NULL, NULL, hInst, NULL);
      ShowWindow(hWnd, SW\_SHOW);
      
      return 0;
      

      } //InitWnd()

      LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
      {
      switch (message)
      {
      case WM_DESTROY: PostQuitMessage (0);
      break;
      case WM_CREATE: return 0;
      break;
      case WM_NCCREATE: return true;
      break;
      default:
      return DefWindowProc (hwnd, message, wParam, lParam);
      }

      return 0;
      

      }

      Any help would be greatly appreciated.

      D Offline
      D Offline
      Dustin Henry
      wrote on last edited by
      #2

      I can't tell from the code where the problem lies, but this is caused by memory trying to be used without being initialized first. How are you debugging your DLL? Are you just compiling and then running iTunes to load it? If so, you should try launching iTunes from within the dev environment so that you can see at what point the dll if failing. If you're using VS, under your project properties there is a 'Debugging' tab and a 'Command' argument. You can place the path to iTunes.exe in here and it should launch iTunes when you run your program. It probably needs some command arguments in order to load your dll, but you will have to consult the iTunes documentation for that. Not sure how helpful this is. If apple has an SDK there is probably more info on the message boards for it. Dustin

      G 1 Reply Last reply
      0
      • D Dustin Henry

        I can't tell from the code where the problem lies, but this is caused by memory trying to be used without being initialized first. How are you debugging your DLL? Are you just compiling and then running iTunes to load it? If so, you should try launching iTunes from within the dev environment so that you can see at what point the dll if failing. If you're using VS, under your project properties there is a 'Debugging' tab and a 'Command' argument. You can place the path to iTunes.exe in here and it should launch iTunes when you run your program. It probably needs some command arguments in order to load your dll, but you will have to consult the iTunes documentation for that. Not sure how helpful this is. If apple has an SDK there is probably more info on the message boards for it. Dustin

        G Offline
        G Offline
        Grant Hudgens
        wrote on last edited by
        #3

        The Way I debug is I try to open iTunes after putting the compiled dll into the plugins folder a Visual Studio Just in Time Debugger pops up and gives me the option of using visual studio to debug so I click yes and that is when I get the violation reading location error.I tried adding iTunes.exe to the debugging tab but it says debugging information cannot be found or does not match. Unfortunatly I was not able to find any information for any arguments to put in for the debugger. Also I have not been able to find an iTunes debugging message boards either...

        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