Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0

    SetFilePointerEx and its LARGE_INTEGER type


    I am trying to set the file pointer at the beggining in the file. So I do this.

    SetFilePointerEx(hFile, 0, NULL,(DWORD) 0);

    But the DDK2003 builder (I thinks it is C#) says that it can't convert from INT to LARGE_INTEGER at parameter 2 (C2440).

    then did a explicit cast, the same result.

    SetFilePointerEx(hFile,(LARGE_INTEGER) 0, NULL,(DWORD) 0);

    What is the correct way to use the function or to initialize a LARGE_INTEGER variable with the value ZERO?.

    LARGE_INTEGER li = 0 ; (don't works). The same.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    What is the correct way to use the function or to initialize a LARGE_INTEGER variable with the value ZERO?.

    LARGE_INTEGER li = 0 ; (don't works). The same.
    The LARGE_INTEGER structure is used to represent a 64-bit signed integer value. LowPart and HighPart is 32-bit, LowPart is low-order 32 bits and HighPart is high-order 32 bits. The value of LARGE_INTEGER is HighPart*2^31 + LowPart.


    Code:
    #include <windows.h>
    #include <stdio.h>
    
    int main(void)
    {
    LARGE_INTEGER lInt;
    int i = 0;
    lInt.QuadPart = i;
    return 0;
    }
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    66 view, zero answers?, hehe that speak a lot about this forum.

    anyway was: LARGE_INTEGER is more like a struct with a union, so was needed to use its member Li.QuadPart = 0;, offcourse before posting here I did some research but didn't find it within 30min.

    I am not a native programmer of C, but my commercial software has several components writen in C, one of them is a print monitor driver, the old model (NT 4.0 architecture), is not compatible with 64bits because, all Wins 64 excluded the old nt4.0 model. :)

    The first attempt was to compile my old driver in 64bits, sucess in the compilation, but win64 expected a new set of functions, structures instances, etc.

    So, I installed a copy of DDK 2003, use the build enviroment for 64bits, and start with the print monitor example included, strip down all its features that I wasn't needing. Compile it, tested it, installed it, it is all ok.

    Now, I was compiling the old driver with minGW stuff C++, so, when I just copy/past the ACTIVE code functions from the old version to the new one the ddk builder thrown a big list of errors.

    The first were like all wcscpy/wcscat/tcscpy/tcscat/strcpy/strcat functions deprecated, WTH?, so a work around was to exclude that error code, not solving the problem itself but just ingoring the deprecations to compile.

    anyway, I thinks the .bmp .zip and .png included source files of those libraries will not compile at all, is a way to tell to the ddk builder that some files are written in c++ and must compile using that language that way? (remember that the rest of the source is C#).

    EDIT: no, I am more confused: I was thinking that the ddk2003 builder is compiling in C#, but it didn't accept a simple class declaration like in C#, but also it didn't accept the original class declaration that was in C++.


    So, why the hell it is not accepting them.

    originally I had:

    class IfStream
    {
    public:
    IfStream( const char* fileName );
    int get();
    BOOL read( char* buff, int len );
    ~IfStream();
    private:
    HANDLE hFile;
    };

    compiled Ok, with mingw

    Bit it simple returns errors in the ddk builder, C2061, syntaxis error identifier 'class'.

    So, ok, then change it to what I just learn to be C#.

    public class IfStream
    {
    public IfStream( const char* fileName );
    public int get();
    public BOOL read( char* buff, int len );
    public ~IfStream();
    private HANDLE hFile;
    };

    Getting the same thing, so, return to the basics, what is the builder compiling maybe just C?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    Microsoft Windows Driver Development Kit (DDK) for Microsoft Windows Server 2003 has been superseded by the Windows Driver Kit Thus, is there a compelling reason why you're using DDK2003?

    EDIT: no, I am more confused: I was thinking that the ddk2003 builder is compiling in C#, but it didn't accept a simple class declaration like in C#, but also it didn't accept the original class declaration that was in C++.
    The DDK or more accurately, the Windows Driver Kit (WDK) works primarily on the kernel level. Thus, it uses C (and C++) not C# which is a high level language.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    the localmonitor example in ddk 2003 is clean and understable for me , quite near the same as my old driver version. The builder is accepting just plain c. No class . No "new" statements. No "string" type. So yesterday start converting all of them
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    I already has the printer monitor working, but by now it outputs in .bmp file format

    I needs to find out a .PNG library that is compatible with just PLAIN C.

    I needs a library that, passing a PathFileName + an instance BITMAPINFO struct, and that it generates the .png file.

    there is some open source free of bugs .png library for PLAIN C?
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    Originally Posted by flyguille
    I already has the printer monitor working, but by now it outputs in .bmp file format

    I needs to find out a .PNG library that is compatible with just PLAIN C.

    I needs a library that, passing a PathFileName + an instance BITMAPINFO struct, and that it generates the .png file.

    there is some open source free of bugs .png library for PLAIN C?
    ImageMagik C API may be a viable option.
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    seem easy but i don't want that big overhead , one of the problem whit my old driver is that it save 98MB bmp file then uses a internal lib to pick up and convert that
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    I figure out that my old driver has ZIP/PNG plain C libraries, so I can reuse them.

    In my old driver compiled with mingw, I had a lot of:

    .obj/pngtrans.o: png/pngtrans.c
    $(CC) -c png/pngtrans.c -o .obj/pngtrans.o $(CFLAGS)

    in its MAKEFILE

    but the builder uses a file named "source" that has:

    Code:
    !IF 0
    
    Copyright (c) 1989-2003  Microsoft Corporation
    
    Module Name:
    
        sources.
    
    Abstract:
    
        This file specifies the target component being built and the list of
        sources files needed to build that component.  Also specifies optional
        compiler switches and libraries that are unique for the component being
        built.
    
    !ENDIF
    
    !IFNDEF MSC_WARNING_LEVEL
    MSC_WARNING_LEVEL=/W3
    !ENDIF
    MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX
    
    BUILD_PRODUCES=PrintscanPrintSpoolerMonitorsLocal
    
    C_DEFINES=-DUNICODE -DNO_STRICT -D_SPL_CLUST 
    
    TARGETNAME=flulpypt64
    TARGETTYPE=DYNLINK
    TARGETPATH=obj
    DLLENTRY=_DllMainCRTStartup
    DLLDEF=localmon.def
    DLLORDER=localmon.prf
    TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib     \
               $(SDK_LIB_PATH)\advapi32.lib     \
               $(SDK_LIB_PATH)\user32.lib       \
               $(SDK_LIB_PATH)\ws2_32.lib       \
               $(SDK_LIB_PATH)\spoolss.lib
    
    
    USE_MSVCRT=1
    
    
    SOURCES=localmon.rc  \
            localmon.c   \
            winspool.c   \
            util.c       \
            config.c     \
            xcv.c
    
    
    
    PRECOMPILED_INCLUDE=precomp.h
    PRECOMPILED_PCH=precomp.pch
    PRECOMPILED_OBJ=precomp.obj
    quite different way to work.-

    Anyway, as I am not experienced in the C language and its tools, I did a foolish thing, like include:

    Code:
    #include "png/pngerror.c"
    #include "png/pnggccrd.c"
    #include "png/pngget.c"
    #include "png/pngmem.c"
    #include "png/pngpread.c"
    #include "png/pngread.c"
    #include "png/pngrio.c"
    jejeje, trown a lot of undeclared indentified obvious because the compiler is taking each file as a individual module. So, undoing that.



    So, sure is a dumb newbie question for any in this forum, but I needs some help, I readed more tutorials of C programming in these two weeks than in years, asking in the forum is like my last resource to find out something. I come from the VB world :D, having 20 years since I sell my first profitable app, but programmed in assembler (z80 family) and a lot of times directly in code machine (a lot of hex numbers) since 8yo (MSX family computers (very easy if you has the opcode tables and none compiler in hand (pre-Internet era) ;D, and what was the first thing I did? a text-line IDE plus compiler, jumping to assembler coding with that :D).

    So, the question is how to include correctly the all the source library in that "source" named file that the builder uses.
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    Originally Posted by flyguille
    I figure out that my old driver has ZIP/PNG plain C libraries, so I can reuse them.

    In my old driver compiled with mingw, I had a lot of:

    .obj/pngtrans.o: png/pngtrans.c
    $(CC) -c png/pngtrans.c -o .obj/pngtrans.o $(CFLAGS)

    in its MAKEFILE

    but the builder uses a file named "source" that has:

    Code:
    !IF 0
    
    Copyright (c) 1989-2003  Microsoft Corporation
    
    Module Name:
    
        sources.
    
    Abstract:
    
        This file specifies the target component being built and the list of
        sources files needed to build that component.  Also specifies optional
        compiler switches and libraries that are unique for the component being
        built.
    
    !ENDIF
    
    !IFNDEF MSC_WARNING_LEVEL
    MSC_WARNING_LEVEL=/W3
    !ENDIF
    MSC_WARNING_LEVEL=$(MSC_WARNING_LEVEL) /WX
    
    BUILD_PRODUCES=PrintscanPrintSpoolerMonitorsLocal
    
    C_DEFINES=-DUNICODE -DNO_STRICT -D_SPL_CLUST 
    
    TARGETNAME=flulpypt64
    TARGETTYPE=DYNLINK
    TARGETPATH=obj
    DLLENTRY=_DllMainCRTStartup
    DLLDEF=localmon.def
    DLLORDER=localmon.prf
    TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib     \
               $(SDK_LIB_PATH)\advapi32.lib     \
               $(SDK_LIB_PATH)\user32.lib       \
               $(SDK_LIB_PATH)\ws2_32.lib       \
               $(SDK_LIB_PATH)\spoolss.lib
    
    
    USE_MSVCRT=1
    
    
    SOURCES=localmon.rc  \
            localmon.c   \
            winspool.c   \
            util.c       \
            config.c     \
            xcv.c
    
    
    
    PRECOMPILED_INCLUDE=precomp.h
    PRECOMPILED_PCH=precomp.pch
    PRECOMPILED_OBJ=precomp.obj
    quite different way to work.-

    Anyway, as I am not experienced in the C language and its tools, I did a foolish thing, like include:

    Code:
    #include "png/pngerror.c"
    #include "png/pnggccrd.c"
    #include "png/pngget.c"
    #include "png/pngmem.c"
    #include "png/pngpread.c"
    #include "png/pngread.c"
    #include "png/pngrio.c"
    jejeje, trown a lot of undeclared indentified obvious because the compiler is taking each file as a individual module. So, undoing that.



    So, sure is a dumb newbie question for any in this forum, but I needs some help, I readed more tutorials of C programming in these two weeks than in years, asking in the forum is like my last resource to find out something. I come from the VB world :D, having 20 years since I sell my first profitable app, but programmed in assembler (z80 family) and a lot of times directly in code machine (a lot of hex numbers) since 8yo (MSX family computers (very easy if you has the opcode tables and none compiler in hand (pre-Internet era) ;D, and what was the first thing I did? a text-line IDE plus compiler, jumping to assembler coding with that :D).

    So, the question is how to include correctly the all the source library in that "source" named file that the builder uses.
    I continue without ideas, hoy to install a library in the ddk 2003 enviroment of the builder.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    187
    Rep Power
    83
    So, the question is how to include correctly the all the source library in that "source" named file that the builder uses.
    I'm not sure I understand this question. But anyway, you would used the SOURCES directive to include all your source files to be compiled:

    Code:
    SOURCES= \
    png/pngerror.c \
    png/pnggccrd.c \
    png/pngget.c \
    png/pngmem.c \
    png/pngpread.c \
    png/pngread.c \
    png/pngrio.c
    Use the TARGETLIBS directive in order to allow the builder to find your specific lib files
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    my first try was that but the builder didn't accept it like not acepting any path specification. Then undo that and wrote #include directives for all those files in the main proyect source .c file, with worst results
  24. #13
  25. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    I tried again:

    BUILD: d:\winddk\3790~1.183\src\print\monitors\localmon: Ignoring invalid direct
    ory prefix in SOURCES= entry: png\png.c

    I tried to use \ or /, throwing the same error.

    Code:
    SOURCES=localmon.rc  \
            localmon.c   \
            winspool.c   \
            util.c       \
            config.c     \
            xcv.c \
    png\png.c \
    png\pngerror.c \
    png/pnggccrd.c \
    png/pngget.c \
    png/pngmem.c \
    png/pngpread.c \
    png/pngread.c \
    png/pngrio.c \
    png/pngrtran.c \
    png/pngrutil.c \
    png/pngset.c \
    png/pngtrans.c \
    png/pngvcrd.c \
    png/pngwio.c \
    png/pngwrite.c \
    png/pngwtran.c \
    png/pngwutil.c \
    zip/adler32.c \
    zip/compress.c \
    zip/crc32.c \
    zip/deflate.c \
    zip/gzio.c \
    zip/infback.c \
    zip/inffast.c \
    zip/inflate.c \
    zip/inftrees.c \
    zip/trees.c \
    zip/uncompr.c \
    zip/zutil.c
    that is the problem.

    Also somebody say, use TARGETLIB, but that is not for precompiled version like .lib / .o files?, I needs to compile it first to get those kind of files.

    Is hard to find something about the "source" file, because its name is soooo common in english language and in programming that is a ocean of results, I tried several convinations, and that is why I am asking here.
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    just move all files to the main directory as a workaround (happily no same name overwrites).

    now, jumping in other problems.

    now it throw a lot of "unexpected end of file while looking for precompiled header directive". What I understand, is each .c file must have a .h file? there is none, only one single png.h. Looking for solutions in some places says there must be a #include "stdafx.h" at the beggining of each file, I did that, and the errors continue.
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    21
    Rep Power
    0
    Originally Posted by flyguille
    just move all files to the main directory as a workaround (happily no same name overwrites).

    now, jumping in other problems.

    now it throw a lot of "unexpected end of file while looking for precompiled header directive". What I understand, is each .c file must have a .h file? there is none, only one single png.h. Looking for solutions in some places says there must be a #include "stdafx.h" at the beggining of each file, I did that, and the errors continue.
    I thinks the said errors are not preventing to compile it, there is others error.

    "macro redefinition"

    the error points to constructions like this.

    this one is from CRC32.c (zlib) file.

    Code:
    #ifdef BYFOUR
    #  define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
                    (((w)&0xff00)<<8)+(((w)&0xff)<<24))
       local unsigned long crc32_little OF((unsigned long,
                            const unsigned char FAR *, unsigned));
       local unsigned long crc32_big OF((unsigned long,
                            const unsigned char FAR *, unsigned));
    #  define TBLS 8
    #else
    #  define TBLS 1
    #endif /* BYFOUR */
    the builder is claiming that TBLS is declared twice BUT IT IS INSIDE of an #ifdef construction, I don't understand why it is claiming that error, the precompiler should only take one part of the #ifdef , no both.

    on other hand it is part of the zlib, it is already tested that compiles ok, with mingw, but in this BUILD -c of DDK 2003 , it seems don't understand #ifdef constructions, HOW CAN BE?.

    AFTER DOING A LOT OF WORKAROUND, like writing // on one side of all the #ifdef construction, now only left the C1010s errors, and that are the only ones.

    "unexpected end of file while looking for precompiled header directive"

    TIRED of adapting things, how remove them?.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo