#1 Burning Software

It is currently Thu Dec 19, 2024 9:10 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: StarBurn_ISO9660JolietFileTree_Add crashes
PostPosted: Thu Mar 01, 2007 3:04 pm 
Offline

Joined: Wed Feb 28, 2007 12:27 pm
Posts: 3
Hi,
I am writing my first DVD burning app with the SDK in VB.NET but am getting the error below whenever I call library routine
StarBurn_ISO9660JolietFileTree_Add

Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

The full code is below and the video files are in a sub-dir c:\avi which is set as ISO Root. Can you help me please - I'm not a low level or C# programmer and am totally stumped

Thanks

Public Sub BuildImage()

Dim Excp As EXCEPTION_NUMBER
Dim ISOFileTree As Integer
Dim FileTree As FILE_TREE
Dim isoLevel2 As Boolean
Dim isoLevels As Integer
Dim imageSize As Long
Dim remainingBytes As Long
Dim currentwriteSize As Integer
Dim imageSizeLowPart As Integer
Dim imageSizeHighPart As Integer
Dim Buffer() As Byte
Dim dirs As String()
Dim files As String()
Dim dir As String
Dim file As String

Try
If isoLevel < 2 Then isoLevel2 = False Else isoLevel2 = True

If isoIncludeJoliet Then
FileTree = FILE_TREE.FILE_TREE_JOLIET
Else
FileTree = FILE_TREE.FILE_TREE_ISO9660
End If

Try
dirs = Directory.GetDirectories(isoRoot)
files = Directory.GetFiles(isoRoot)

Catch ex As Exception
MsgBox("Invalid Root Directory")
Excp = -1
End Try

If Not dirs Is Nothing And Not files Is Nothing Then
Try
Excp = StarBurn_ISO9660JolietFileTree_Create(ISOFileTree, pExceptionText, ExceptionTextSize, SystemError, _
ISOCallBack, IntPtr.Zero, True, False, isoLevel2, FileTree)
If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
ExceptionText = Marshal.PtrToStringAnsi(pExceptionText)
MsgBox(ExceptionText, MsgBoxStyle.Exclamation)
Exit Try
End If

' Get the tree root

Excp = StarBurn_ISO9660JolietFileTree_GetRoot(ISOFileTree)
If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
ExceptionText = Marshal.PtrToStringAnsi(pExceptionText)
MsgBox(ExceptionText, MsgBoxStyle.Exclamation)
Exit Try
End If

' Directory first

For Each dir In dirs
Excp = StarBurn_ISO9660JolietFileTree_Add(ISOFileTree, pExceptionText, ExceptionTextSize, SystemError, _
dir, Nothing, FILE_TIME.FILE_TIME_CREATION, 0, 0)

If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
ExceptionText = Marshal.PtrToStringAnsi(pExceptionText)
MsgBox(ExceptionText, MsgBoxStyle.Exclamation)
Exit Try
End If

Next

' Then the files

For Each file In files
Excp = StarBurn_ISO9660JolietFileTree_Add(ISOFileTree, pExceptionText, ExceptionTextSize, SystemError, _
file, Nothing, FILE_TIME.FILE_TIME_CREATION, 0, 0)
If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
ExceptionText = Marshal.PtrToStringAnsi(pExceptionText)
MsgBox(ExceptionText, MsgBoxStyle.Exclamation)
Exit Try
End If
Next

isoLevels = StarBurn_ISO9660JolietFileTree_GetLevel(ISOFileTree)
Excp = StarBurn_ISO9660JolietFileTree_BuildImage(ISOFileTree, pExceptionText, ExceptionTextSize, SystemError, _
0, isoLevels, False, isoVolume, isoPublisher, isoApplication)

If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
ExceptionText = Marshal.PtrToStringAnsi(pExceptionText)
MsgBox(ExceptionText, MsgBoxStyle.Exclamation)
Exit Try
End If

imageSizeLowPart = StarBurn_ISO9660JolietFileTree_GetSizeInUCHARs(ISOFileTree, imageSizeHighPart)
imageSize = imageSizeHighPart * &H100000000 + imageSizeLowPart
remainingBytes = imageSize

' Write binary file to disk

Dim fs As New FileStream(FileName, FileMode.Create)
Dim w As New BinaryWriter(fs)
While remainingBytes > 0
If remainingBytes > ImageBufferSize Then
currentwriteSize = ImageBufferSize
Else
currentwriteSize = remainingBytes
End If
ReDim Buffer(currentwriteSize - 1)
Excp = StarBurn_ISO9660JolietFileTree_Read(ISOFileTree, pExceptionText, ExceptionTextSize, SystemError, _
currentwriteSize, Buffer)
w.Write(Buffer)
remainingBytes = remainingBytes - currentwriteSize
End While
w.Close()
fs.Close()

Catch e As IOException
Excp = -1
MsgBox("Error writing file " & FileName)
Catch ex As Exception
Excp = -1
MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
End Try
End If

If Not ISOCallBack Is Nothing Then
If Excp <> EXCEPTION_NUMBER.EN_SUCCESS Then
'ISOCallBack(CALLBACK_NUMBER.CN_PROCESS_COMPLETE_ERROR, Context, IntPtr.Zero, IntPtr.Zero)
Else
'ISOCallBack(CALLBACK_NUMBER.CN_PROCESS_COMPLETE_SUCCESFULLY, Context, IntPtr.Zero, IntPtr.Zero)
End If
End If
Catch ex As System.Exception
MsgBox("Error " & ex.Message & " occurred while building the ISO file")
End Try

End Sub


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 01, 2007 7:39 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
Looks like you have API calls parameters declared wrong... Please send us complete source code project to support@rocketdivision.com so we could fix it. Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 12:19 am 
Offline

Joined: Wed Feb 28, 2007 12:27 pm
Posts: 3
Thanks Anton, just sent it, hope you can help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 02, 2007 12:42 am 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
Got the stuff. Fowarded to VB guys. Will let you know ASAP (I think on this weekend). Thanks!

dsimpson wrote:
Thanks Anton, just sent it, hope you can help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 03, 2007 10:17 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
The problem is - you're passing bad callback pointer. What you really need to do:

1) Declare callback function like this:

Private
Shared Sub DummyCallBack(ByVal Number As Recorder.CALLBACK_NUMBER, ByVal Context As IntPtr, ByVal Special1 As IntPtr, ByVal Special2 As IntPtr)

End Sub

2) Create delegate and initialize propery ISO_Callback with it. Like this:

Public
Class Form1
...
Private _CurrentRecorder As Recorder
Dim Cbk As Recorder.CallbackDelegate
...

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs ) Handles Button1.Click

' * Create and Initialize recorder ...*
...
' * Set new delegate ... *
_CurrentRecorder.ISO_Callback = New Recorder.CallbackDelegate(AddressOf DummyCallBack)
...
End Sub

Everything should work fine (as it does in your fixed sample).

Let us know if you'd need anything else.


Top
 Profile  
 
 Post subject: Fantastic..
PostPosted: Mon Mar 05, 2007 12:48 pm 
Offline

Joined: Wed Feb 28, 2007 12:27 pm
Posts: 3
Works a treat, thank you, all I was missing was actually the function def for DummyCallBack in my form.

Great work


Top
 Profile  
 
 Post subject: Re: Fantastic..
PostPosted: Mon Mar 05, 2007 2:21 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
Nice to know you're OK. Thanks for letting us know :)

dsimpson wrote:
Works a treat, thank you, all I was missing was actually the function def for DummyCallBack in my form.

Great work


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 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