Thread: Access Violation...

  1. #16
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Was fairly slow to respond to this but no Jimmy I do NOT expect you to do ANY of the work for me but rather point me in the right direction, if you do it for me then I won't learn anything from the problem and end up back here the next time a similar problem occurs. I'd rather learn something from this then just be told how to fix it.
    Last edited by awsdert; 01-26-2015 at 04:42 PM. Reason: mispell

  2. #17
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    555
    Just curious... you mentioned a FILE * stream but then keep talking about the FD API? Which is it? And I don't see any FILE * streams in your guiOpen() call, the only thing resembling file I/O is this ipFdOpen() which seems to be pointing to some ridiculous internal function

  3. #18
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    It's in the Ipipe project files but here's the defines for them anyway:
    Code:
    #define ipFdOpen       _sopen_s
    #define ipFdGetSize    _filelength
    #define ipFdGetSizeLI  _filelengthi64
    #define ipFdGetPos     _tell
    #define ipFdGetPosLI   _telli64
    #define ipFdRdBuff     _read
    #define ipFdEof        _eof
    #define ipFdSetSize    _chsize
    #define ipFdSetSizeLI  _chsize_s
    #define ipFdSetPos     _lseek
    #define ipFdSetPosLI   _lseeki64
    #define ipFdWrBuff     _write
    #define ipFdFlush      _commit
    #define ipFdShut       _close
    
    #define ipMovPath( src, dst ) rename( src, dst )
    
    // Conversion
    #define ipPidOpenHandle OpenProcess
    #define ipHandleOpenFd _open_osfhandle
    #define ipDirOpenFd    dirfd
    #define ipFdOpenDir    fdopendir
    #define ipFdOpenHandle _get_osfhandle
    #define ipFdOpenFile   _fdopen
    
    // FILE*
    #define ipRdBuff       fread
    #define ipRdLineA      fgets
    #define ipRdLineW      fgetws
    #define ipEof          feof
    #define ipWrBuff       fwrite
    #define ipWrLineA      fputs
    #define ipWrLineW      fputws
    #define ipFlush        fflush
    #define ipShut         fclose
    The FILE* stream ONLY comes into play when loading hacklists/cheatlists the guiOpen() function just passes on the fd from it's path building and file opening code, the guiHacks_OnLoad() I mentioned is where the stream becomes associated with it before the stream is then passed onto the library, I can't have the library built-in because there are who knows how many formats for cheatlists so exertnal library support seemed the most appropriate.

    Edit:I'm using defines because I never found the naming convention to be clear enough so defines made it easier for me to understand.

  4. #19
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by awsdert View Post
    I do NOT expect you to do ANY of the work for me but rather point me in the right direction

    Out <---- Right direction for you.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #20
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Mario if you're not going to help then just don't post, I want helpful comments from someone who understands/experienced the file/fd API more than I do/have and thus will see the problem area that I just haven't seen. For those who want to help the only suspicion I have is the call that creates a file stream from the fd (in guiHacks_OnLoad), unfortunately I can't see how the line is being a problem.

    Actually while I'm at it, is the fd API or the file API faster? And if the file API is faster is there a way to control the sharing permissions without switching to another API

  6. #21
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Oh if anyone thinks I'm blunt with my words it's because I have Aspurgers (I think that's how it's spelt), leaves me with poor social skills for life basically.

  7. #22
    Registered User
    Join Date
    May 2009
    Posts
    3,825
    Quote Originally Posted by awsdert View Post
    Oh if anyone thinks I'm blunt with my words it's because I have Aspurgers (I think that's how it's spelt), leaves me with poor social skills for life basically.
    It is spelled "Aspergers".
    Asperger syndrome - Wikipedia, the free encyclopedia

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  8. #23
    Registered User
    Join Date
    May 2009
    Posts
    3,825
    I just cloned the git repos and your code does NOT even compile for me.

    I suggest posting the full rebuild log (of CB project medit or whichever project is the one you are having a problem with) if you still want help.
    FAQ-Compiling (errors) - CodeBlocks

    Tim S.
    Last edited by stahta01; 01-28-2015 at 12:53 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  9. #24
    Registered User
    Join Date
    May 2009
    Posts
    3,825
    After a lot of CB Project build changes I finally get an error on missing "pipe.dll.manifest".
    Code:
    -------------- Build: msw-x86-d-vc in Ipipe (compiler: msvc2013-x86)---------------
    
    cl.exe /nologo /D_X86_  /MDd /W3 /Zi /DBUILD_DLL /D_DEBUG    /I..\medit /I"C:\Program Files (x86)\Windows Kits\8.1\include\um" /I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" /I"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include" /I"C:\Program Files (x86)\Windows Kits\8.1\Include\um" /c Ipipe.c /FoC:\Users\stahta01\AppData\Local\Temp\obj\Ipipe\msw-x86-d-vc\Ipipe.obj
    Ipipe.c
    link.exe /dll /nologo /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\lib" /out:Ipipe-msw-x86-d-vc.dll user32.lib shell32.lib C:\Users\stahta01\AppData\Local\Temp\obj\Ipipe\msw-x86-d-vc\Ipipe.obj  /DEBUG /INCREMENTAL:NO 
       Creating library Ipipe-msw-x86-d-vc.lib and object Ipipe-msw-x86-d-vc.exp
    Output file is Ipipe-msw-x86-d-vc.dll with size 7.50 KB
    Running target post-build steps
    mt.exe /nologo /manifest "Ipipe.dll.manifest" /outputresource:"Ipipe.dll";2
    Ipipe.dll.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified.

    I suggest you read up on CB Global variables in hope you try to make your code compile for someone other than you.
    Right now the code does NOT compile for me even after I give what are likely good values for the CB custom variables that you never define in the CB projects in any place I can find.

    Edit: I could NOT even guess a good value for the CB custom variable "LIB"; so telling me the value of that would help me try to help you.
    I suggest you read the information on where you found this code in case it gives fixes or other information.

    Tim S.
    Last edited by stahta01; 01-28-2015 at 01:40 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  10. #25
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Okay plenty of faults on my part for sure but I'll go over your issues that I see then try and sort out the settings from my end to be more team (couldn't think of the right word) friendly
    1. There's no manifest to be included
    2. Looks like you're using VS2010, since I'm using C99 I think you'll need to upgrade to VS2013 to get the version of VC this project needs
    3. LIB is supposed to be a common directory for compiling libraries e.g. "C:\Program Files (x86)\Compiled Libs\", in my case it's just "c:\p\lib\"
    4. Doesn't look like you have IUP installed from that log, the GUI runs on that so if you really gonna try to compile it then best sort that out, CB will need an environment variable for that too
    Let me know of any other troubles you have so I can sort it out my end and create a suitable readme for environment specific stuff

    Edit: Just noticed my own log spitting the manifest stuff as well, I've added /MANIFEST:NO to linker settings but no luck in stopping the msg, anyone know how to stop it trying to run non-existent manifest?
    Last edited by awsdert; 01-28-2015 at 02:09 PM.

  11. #26
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    The only thing I can think of is these lines in regards to my access violation, am I right or just barking up the wrong tree?
    Code:
    op = _O_RDWR | ((saveFile == 1) ? _O_CREAT : 0) | ( (i >= guiMenu_Hacks) ? _O_TEXT : _O_BINARY );
    ipFdOpen ( &fd, path, op, IP_D_RW, IP_A_RW );
    FILE *file  = ipFdOpenFile ( fd, "r+" );

  12. #27
    Registered User
    Join Date
    May 2009
    Posts
    3,825
    Line 224 in file guiMenu.c

    appMethods.OnLoad ( fd );

    You are using the one parameter version of OnLoad later on the code wants the two parameter version of OnLoad.

    Code:
    typedef void  (*_HACK_COM_FILE_FUNC)( FILE *file, char const *dataDir );
    Code:
    void  ARMAX_RAW_EXP armaxRawHack_OnLoad( FILE *file, char const *dataDir )
    I would guess this is causing the error; but, you should be getting a compiler warning if you are using a decent compiler. But, "your" code is very hard to read and follow. I think you need to learn how to turn up the Compiler warning and you NEED to read the warnings!!!

    Tim S.
    Last edited by stahta01; 01-28-2015 at 02:36 PM.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

  13. #28
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    I found the cause I think, some kinda issue when retrieving selected section number, keep getting 0 and that is causing the file to be loaded as binary instead of text. Since I'm having a break from programming I'm just leaving a FIXME comment there but at least I know part of the cause now, thank you to those who actually made an effort to look through the code.

    Edit: stahta thank you for pointing out that little issue there, not causing me issues right now as the code calls fine but I will sort that one out at some point (prob as soon as I get back to programming).
    Last edited by awsdert; 01-28-2015 at 03:04 PM.

  14. #29
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    887
    Okay done a work-around for the that bug but still getting the access violation, got some things to do atm so if anyone want's to try locating the problem line it will be in one of the 4 functions I mentioned in the first post, they're small so you won't be looking through hundreds of lines, the value of op in guiOpen() is 0x4002(_O_TEXT|_O_RW) when I open the file if that is any help. Also uploaded the changed code with some preliminary settings for GCC, I'll try making them better when I get back but for now you'll have to make do or wait (please post your problems if you do try to compile).

  15. #30
    Registered User
    Join Date
    May 2009
    Posts
    3,825
    Quote Originally Posted by awsdert View Post
    Okay done a work-around for the that bug but still getting the access violation, got some things to do atm so if anyone want's to try locating the problem line it will be in one of the 4 functions I mentioned in the first post, they're small so you won't be looking through hundreds of lines, the value of op in guiOpen() is 0x4002(_O_TEXT|_O_RW) when I open the file if that is any help. Also uploaded the changed code with some preliminary settings for GCC, I'll try making them better when I get back but for now you'll have to make do or wait (please post your problems if you do try to compile).
    I already told you where it is.

    Tim S.
    "...a computer is a stupid machine with the ability to do incredibly smart things, while computer programmers are smart people with the ability to do incredibly stupid things. They are,in short, a perfect match.." Bill Bryson

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Access violation in C++
    By Sjvlsdsd in forum C++ Programming
    Replies: 3
    Last Post: 07-22-2011, 03:33 AM
  2. Access violation??
    By ozumsafa in forum C Programming
    Replies: 13
    Last Post: 09-18-2007, 10:11 AM
  3. Why am I having an access violation?
    By ldb88 in forum C++ Programming
    Replies: 12
    Last Post: 06-12-2007, 12:27 PM
  4. Access Violation!!
    By Yoshi in forum C++ Programming
    Replies: 4
    Last Post: 09-11-2002, 01:22 PM

Tags for this Thread