Juan Lang : crypt32:
Add base message type and use it to implement CryptMsgDuplicate and
CryptMsgClose .
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jun 29 08:14:37 CDT 2007
Module: wine
Branch: master
Commit: b790a09efbd02369b2e3bf0db8a946a15e0a502c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b790a09efbd02369b2e3bf0db8a946a15e0a502c
Author: Juan Lang <juan.lang at gmail.com>
Date: Thu Jun 28 16:45:29 2007 -0700
crypt32: Add base message type and use it to implement CryptMsgDuplicate and CryptMsgClose.
---
dlls/crypt32/msg.c | 42 ++++++++++++++++++++++++++++++++++++++++--
1 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/dlls/crypt32/msg.c b/dlls/crypt32/msg.c
index a25affa..f806838 100644
--- a/dlls/crypt32/msg.c
+++ b/dlls/crypt32/msg.c
@@ -24,6 +24,24 @@
WINE_DEFAULT_DEBUG_CHANNEL(crypt);
+/* Called when a message's ref count reaches zero. Free any message-specific
+ * data here.
+ */
+typedef void (*CryptMsgCloseFunc)(HCRYPTMSG msg);
+
+typedef struct _CryptMsgBase
+{
+ LONG ref;
+ DWORD open_flags;
+ CryptMsgCloseFunc close;
+} CryptMsgBase;
+
+static inline void CryptMsgBase_Init(CryptMsgBase *msg, DWORD dwFlags)
+{
+ msg->ref = 1;
+ msg->open_flags = dwFlags;
+}
+
static inline const char *MSG_TYPE_STR(DWORD type)
{
switch (type)
@@ -89,13 +107,33 @@ HCRYPTMSG WINAPI CryptMsgOpenToDecode(DWORD dwMsgEncodingType, DWORD dwFlags,
HCRYPTMSG WINAPI CryptMsgDuplicate(HCRYPTMSG hCryptMsg)
{
- FIXME("(%p): stub\n", hCryptMsg);
+ TRACE("(%p)\n", hCryptMsg);
+
+ if (hCryptMsg)
+ {
+ CryptMsgBase *msg = (CryptMsgBase *)hCryptMsg;
+
+ InterlockedIncrement(&msg->ref);
+ }
return hCryptMsg;
}
BOOL WINAPI CryptMsgClose(HCRYPTMSG hCryptMsg)
{
- FIXME("(%p): stub\n", hCryptMsg);
+ TRACE("(%p)\n", hCryptMsg);
+
+ if (hCryptMsg)
+ {
+ CryptMsgBase *msg = (CryptMsgBase *)hCryptMsg;
+
+ if (InterlockedDecrement(&msg->ref) == 0)
+ {
+ TRACE("freeing %p\n", msg);
+ if (msg->close)
+ msg->close(msg);
+ CryptMemFree(msg);
+ }
+ }
return TRUE;
}
More information about the wine-cvs
mailing list