#1 Burning Software

It is currently Thu Dec 19, 2024 8:07 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: C# wrapper for UDF api
PostPosted: Thu Jan 25, 2007 11:34 pm 
Offline

Joined: Thu Jan 25, 2007 11:16 pm
Posts: 44
Hi,
I'm trying to import some StarBurn api to build (and burn) an UDF image, but I got the following error from VS2005:

Quote:
A call to PInvoke function 'StarBurnWrapper!StarBurnWrapper.Dll::StarBurn_UDF_CreateEx' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.


My imports are the the following:

Code:
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct UDF_CONTROL_BLOCK
    {
        public int Head;
        public int SystemStructures;
        public int Tail;
        public int Body;
    }

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern int StarBurn_UDF_GetNodeObject(int parent);

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern EXCEPTION_NUMBER StarBurn_UDF_Add(StringBuilder ExceptionText, int ExceptionTextSize,
            ref int SystemError, StringBuilder DirectoryOrFileAbsolutePathAndName,
            StringBuilder DirectoryOrFileNewName, int parent, ref int newChild);

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(int UDFRoot, int ISO9660UDFBridgeRootVideo,
            int ISO9660UDFBridgeRootAudio, ref UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
            StringBuilder ExceptionText, int ExceptionTextSize,
            ref int SystemError, StringBuilder VolumeLabel, StringBuilder PublisherPreparerName,
            StringBuilder ApplicationName, long year, long month, long day, long hour, long minutes,
            long seconds, long milliseconds);


The problem raises calling StarBurn_UDF_CreateEx in this piece of code:

Code:
                int root = 0;
                int child = 0;
                StringBuilder absPath = new StringBuilder("c:\\burn\\eclipse.zip");
                StringBuilder newPath = new StringBuilder("eclipse.zip");
                ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, null, null, 0, ref root);
                ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, absPath, newPath, root, ref child);

                StringBuilder vLabel = new StringBuilder("TEST", 10);
                StringBuilder pubName = new StringBuilder("Test", 10);
                StringBuilder AppName = new StringBuilder("wrapper", 10);
                //UDF_Control_Block = new UDF_CONTROL_BLOCK();
                int node = Dll.StarBurn_UDF_GetNodeObject(root);

                UDF_Control_Block.Body = 0;
                UDF_Control_Block.Head = 0;
                UDF_Control_Block.SystemStructures = 0;
                UDF_Control_Block.Tail = 0;

                int video = 0;
                int audio = 0;
                ErrorCode = Dll.StarBurn_UDF_CreateEx(node, video, audio, ref UDF_Control_Block,
                    ExceptionText, 1024, ref SystemError, vLabel, pubName, AppName,
                    2007, 1, 26, 23, 14, 12, 2);


thanks in advance,
Massimo.


Top
 Profile  
 
 Post subject: Re: C# wrapper for UDF api
PostPosted: Fri Jan 26, 2007 5:12 pm 
Offline

Joined: Fri Jan 26, 2007 4:31 pm
Posts: 452
Hi,

In C/C++
LONG 32-bit signed integer.

In C#
long Signed 64-bit integer

Therefore we must use 32-bit type (like int) for parameters :
year, month, day, hour, minutes, seconds, milliseconds.

DllImport declaration of StarBurn_UDF_CreateEx() must be something like that:

Code:
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
      public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(
         uint UDFRoot,
         uint ISO9660UDFBridgeRootVideo,
         uint ISO9660UDFBridgeRootAudio,
         out UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
         IntPtr ExceptionText,
         int ExceptionTextSize,
         out uint SystemError,
         [MarshalAs(UnmanagedType.LPStr)]
         String VolumeLabel,
         [MarshalAs(UnmanagedType.LPStr)]
         String PublisherPreparerName,
         [MarshalAs(UnmanagedType.LPStr)]
         String MyApplicationName,
                  int year,
                  int month,
                  int day,
                  int hour,
                  int minutes,
                  int seconds,
                  int milliseconds);


mbat wrote:
Hi,
I'm trying to import some StarBurn api to build (and burn) an UDF image, but I got the following error from VS2005:

Quote:
A call to PInvoke function 'StarBurnWrapper!StarBurnWrapper.Dll::StarBurn_UDF_CreateEx' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.


My imports are the the following:

Code:
    [StructLayout(LayoutKind.Sequential, Pack = 1)]
    public struct UDF_CONTROL_BLOCK
    {
        public int Head;
        public int SystemStructures;
        public int Tail;
        public int Body;
    }

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern int StarBurn_UDF_GetNodeObject(int parent);

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern EXCEPTION_NUMBER StarBurn_UDF_Add(StringBuilder ExceptionText, int ExceptionTextSize,
            ref int SystemError, StringBuilder DirectoryOrFileAbsolutePathAndName,
            StringBuilder DirectoryOrFileNewName, int parent, ref int newChild);

        [DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
        public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(int UDFRoot, int ISO9660UDFBridgeRootVideo,
            int ISO9660UDFBridgeRootAudio, ref UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
            StringBuilder ExceptionText, int ExceptionTextSize,
            ref int SystemError, StringBuilder VolumeLabel, StringBuilder PublisherPreparerName,
            StringBuilder ApplicationName, long year, long month, long day, long hour, long minutes,
            long seconds, long milliseconds);


The problem raises calling StarBurn_UDF_CreateEx in this piece of code:

Code:
                int root = 0;
                int child = 0;
                StringBuilder absPath = new StringBuilder("c:\\burn\\eclipse.zip");
                StringBuilder newPath = new StringBuilder("eclipse.zip");
                ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, null, null, 0, ref root);
                ErrorCode = Dll.StarBurn_UDF_Add(ExceptionText, 1024, ref SystemError, absPath, newPath, root, ref child);

                StringBuilder vLabel = new StringBuilder("TEST", 10);
                StringBuilder pubName = new StringBuilder("Test", 10);
                StringBuilder AppName = new StringBuilder("wrapper", 10);
                //UDF_Control_Block = new UDF_CONTROL_BLOCK();
                int node = Dll.StarBurn_UDF_GetNodeObject(root);

                UDF_Control_Block.Body = 0;
                UDF_Control_Block.Head = 0;
                UDF_Control_Block.SystemStructures = 0;
                UDF_Control_Block.Tail = 0;

                int video = 0;
                int audio = 0;
                ErrorCode = Dll.StarBurn_UDF_CreateEx(node, video, audio, ref UDF_Control_Block,
                    ExceptionText, 1024, ref SystemError, vLabel, pubName, AppName,
                    2007, 1, 26, 23, 14, 12, 2);


thanks in advance,
Massimo.


Top
 Profile  
 
 Post subject: Re: C# wrapper for UDF api
PostPosted: Mon Jan 29, 2007 4:52 pm 
Offline

Joined: Thu Jan 25, 2007 11:16 pm
Posts: 44
Thanks a lot andrey! It worked!
The following dllimport works well too:

Code:
[DllImport("StarBurn.dll", CharSet = CharSet.Ansi)]
public static extern EXCEPTION_NUMBER StarBurn_UDF_CreateEx(
  int UDFRoot,
  int ISO9660UDFBridgeRootVideo,
  int ISO9660UDFBridgeRootAudio,
  ref UDF_CONTROL_BLOCK PUDF_CONTROL_BLOCK,
  StringBuilder ExceptionText, int ExceptionTextSize,
  ref int SystemError,
  StringBuilder VolumeLabel,
  StringBuilder PublisherPreparerName,
  StringBuilder ApplicationName,
  int year,
  int month,
  int day,
  int hour,
  int minutes,
  int seconds,
  int milliseconds
);


Massimo.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 29, 2007 9:41 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
Excellent! :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 29 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group