CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2011
    Posts
    17

    [RESOLVED] Code Works in XP Not Vista

    I have a program that runs (under Windows 95 compatibility) in both XP and Vista. However, the following code (while it works in XP) crashes the program in Vista...

    mov eax, dword_10010000
    push 0
    push 0FFFFFFFFh
    push 0
    mov ecx, [eax+80h]
    push 1
    push 10h
    push 1
    push ecx
    push 0
    push 0C0000000h
    mov ecx, esi
    call dword ptr [edi+0F4h]

    The error message says the type of error is 0xC0000005 which I've found is an access violation. Any thoughts how to remedy this code so it also works in Vista?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Code Works in XP Not Vista

    What does it do? If it needs to be run under Windows 95 compatibility it's a good chance that Vista doesn't allow it even in compatibility mode.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jun 2011
    Posts
    17

    Re: Code Works in XP Not Vista

    It plays an audio clip. Aside from this piece of code, the program doesn't really encounter any issues playing audio clips on Vista.
    Last edited by Mr. Smith; July 3rd, 2012 at 09:07 AM. Reason: Removed info not relevant to issue.

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: Code Works in XP Not Vista

    What you posted is just a fragment. If you provide more code and OS details maybe someone can figure this out. I haven't seen any posts from Eri523 lately but this migth make him curious...
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  5. #5
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Code Works in XP Not Vista

    Quote Originally Posted by S_M_A View Post
    I haven't seen any posts from Eri523 lately [...].
    I've been quite busy recently with one of my larger projects, so unfortunately I neglected CG a bit. Every now and then, however, I stop by, looking for something interesting.

    [...] but this migth make him curious...
    In deed, it does. (1) I don't see anything about any audio stuff in the snippet. When doing multimedia stuff, I'd probably use some API, unless perhaps it's really hardware-level driver-like stuff (which happens rather rarely). (2) Indirect calls or jumps without any context explaining their purpose always raise my suspicion. Might be some stuff to be injected into something...

    Bottom line Without any additional context from the OP, we're definitely stuck.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  6. #6
    Join Date
    Jun 2011
    Posts
    17

    Re: Code Works in XP Not Vista

    [Removed info not relevant to issue.]
    Last edited by Mr. Smith; July 3rd, 2012 at 09:09 AM. Reason: Removed info not relevant to issue.

  7. #7
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Wink Re: Code Works in XP Not Vista

    It's still quite unclear what even is intended to be going on here. The calls may be API calls, and the way the stack is handled indicates that they seem to use __stdcall or Pascal calling convention, but that's not really much information. Overall, that looks like disassembly rather than assembly language anyway: The few labels used to access data (unknown to us) are named sometging like dword_10010000, which are cryptic names a developer with a sane mind is unlikely to use. Even a compiler generating assembly language output would most probably use more descriptive symbols.

    So all I can give you is quite general debugging advice: Try to remove either snippet (the "works" and "doesn't work" snippet) from the code and see if they both work on their own. If "doesn't work" still doesn't work in that scenario, it in fact seems to be the culprit (for whatever reason). If they both do work on their own, try to reverse their sequence in the original code. Then, if the new first one works and the new second one does not, the reason may be that they're just called in too rapid succession.

    BTW, many API calls return error/success codes that may indicate reasons for failure, but I don't see any trace of return value checking here at all.

    Finally, if something suddenly stops working when taken from XP to Vista, it's quite often a permission issue, since Vista handles security much more strict.
    Last edited by Eri523; June 9th, 2012 at 07:18 AM.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  8. #8
    Join Date
    Jun 2011
    Posts
    17

    Re: Code Works in XP Not Vista

    I figured out the issue. Manually moving the "mov eax, dword_10010000" (even by 1 byte) was causing the issue in Vista. I resolved this by making a subroutine around "mov eax, dword_10010000" and calling the subroutine.

    Thanks for the general debugging advice. It helped find the issue. And, if there's a more elegant solution, feel free to share.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured