473,946 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PInvoke and Unmanaged DLL calls

Has anyone made use of PKWare's PKCDL.DLL for the Implode and Explode
functions?

I have been able to successfully define everything correctly and even
get the invoked function (Explode) to run properly. This means data is
being exploded properly, confirmed with CRC values and reviewing the
actual data.

However just before the unmanaged function exits, I get a null exception
error. I am using:

ReadHandler rh = new ReadHandler(thi s.ReadData);
WriteHandler wh = new WriteHandler(th is.WriteData);

IntPtr buffer = Marshal.AllocHG lobal(bufferSiz e)
try {
object data = this;

// Invoke DLL here...
PkCdl.Explode(r h, wh, buffer, ref data);

} finally {
Marshal.FreeHGl obal(buffer);
}

to allocate the needed buffer for the DLL. In the corresponding
ReadData/WriteData callback methods, I use the Marshal.Copy() methods to
move data in/out of managed memory.

Now somewhere along the way an the exception happens inside the
try..finally (shown above).

If this rings a bell with anyone, I will gladly supply complete sample
code and would be more than interested in hearing your thoughts.
Thanks,
Joe Martin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05
11 4669
Is intptr buffer= statement getting any reference ?

with regards,
J.V.Ravichandra n
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandra n+J.V.&cob=aspn etpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID= P3966388&BN=999 &PN=2
- Or, just search on "J.V.Ravichandr an"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #11
We are getting closer....
How are PKCALLBACK and PKCALL defined (typedef PKCALL ....), these are
defining the calling convention used.
And the "void* param" is still a mistery to me, you pass it a ref to managed
instance of a class, but this is something that the function is not
expecting for sure.
Worse, it's a reference pointer so the caller can change the reference at
will brrrr....
I suggest you to look at a C sample using that function, and see what get's
passed as param here
Willy.

"Joe Martin" <an*******@devd ex.com> wrote in message
news:uD******** ******@TK2MSFTN GP11.phx.gbl...


Sure, here you go:
typedef unsigned int(PKCALLBACK * PKReadBuf)(void * buf, unsigned int
size, void* param)

Read buffer call back function definition.
Parameters:
buf Pointer the buffer to fill with data
size The amount of data to read
param User specified call back pointer.

Returns:
The actual amount of data read, must be less than or equal to size.

typedef void(PKCALLBACK * PKWriteBuf)(con st void* buf, unsigned int
size, void* param)

Write buffer call back function definition.
Parameters:
buf Pointer to the buffer containing the data to write
size The size of the buffer
param User specified call back pointer.


//----------------------------------

PKCDL_DECL unsigned int PKCALL pkexplode (
PKReadBuf read_buf,
PKWriteBuf write_buf,
void * work_buf,
void * param
)

Function to decompress data using the DCL implode algorithm.
Parameters:
read_buf Pointer to read buffer function.
write_buf Pointer to the write buffer function.
work_buf Pointer to the working buffer.

Returns:
Returns the error code for the function.
See also:
ERROR_CODES for possible return values

//----------------------------
Hope this helps...
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
370
by: Muthiah Samy | last post by:
Hi All, I am trying to call COM Component in .NET using PInvoke. In the following scenario, ( I am getting an exception called SEH - External component has thrown an exception) UnManaged Code ---------------
2
445
by: RobJUK66 | last post by:
have a 3rd party .Net dll that wraps a set of further unmanaged dll's. The ..Net DLL basically uses pinvoke to wrap the calls. The low level dlls provide an API to talk to a complex device which appears as a USB hub (with a scanner, flash drive and some other bits and pieces). Using a VB.Net windows app, we call the main unmanaged API function (lets call it doStuff() ) and then call messagebox.show to pop up a modal results dialog. This...
2
3001
by: Jeff Lederer | last post by:
I have created a simple test C# console program that calls an unmanaged C subroutine in a DLL where one of the arguments is a callback to the C# code. I noticed that when the callback has no paramaters, it works fine. But when there are parameters, I get the exception: "Runtime failure check #0: The value of ESP not properly saved..." Here are the facts: The delegate declaration: >>> public delegate int querydlg(IntPtr pEnv, string...
3
3480
by: Brett Robichaud | last post by:
I have created a simple background thread to make one pinvoke call into a DLL I've created. My Winforms app spawns the thread in the form load event then go about it's business. The problem is that my form appears to be blocked while the background thread is running. I am very familir with threads in unmanaged code but am just getting into them in C#. Are there issues I need to be aware of with regards to threading a simple pinvoke...
1
1874
by: cppdev | last post by:
Hello, After reading a few articles, http://blogs.gotdotnet.com/cbrumme/PermaLink.aspx/e55664b4-6471-48b9-b360-f0fa27ab6cc0 http://blogs.gotdotnet.com/anathan/commentview.aspx/8ec0b7b2-6290-4500-a8c7-1b6c677214cb i have the following question: __gc class C {
4
1681
by: yaron | last post by:
Hi, I want to use my unmanaged c++ class library from a c# client. my unmanaged c++ class library use polymorpism, is this polymorphism also exported to my c# client via PInvoke ? thanks.
3
16067
by: msnews.microsoft.com | last post by:
Hi i am using User32.dll in Visual stdio 2005. public static extern long SetActiveWindow(long hwnd); public static extern long keybd_event(byte bVk, byte bScan, long dwFlags,
8
6672
by: Rajesh Soni | last post by:
Hi! I'm getting a PInvoke error while trying to execute the following code... declaration: Structure POINTAPI Dim x As IntPtr
14
3821
by: Mohamed Mansour | last post by:
Hey there, this will be somewhat a long post, but any response is appreciated! I have done many PInvoke in the past from C++ to C#, but I did PInvoke within C# not C++/CLI. Can someone explain more why C++/CLI would be better to PInvoke than doing the PInvoke in C#? Because, usually in C# as you already know we use DLLImport and extern
0
9981
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10686
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7423
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6111
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.