FAQ
Hey

Can anybody tell me what i'm doing wrong here?
I'm trying to invoke a WinApi method *CryptProtectData* (
http://msdn.microsoft.com/en-us/library/windows/desktop/aa380261(v=vs.85).aspx
)

Code:
http://pastebin.com/s2cdeinK

The output of the bytes returned is always sequential (see link)

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Brainman at Mar 4, 2013 at 8:41 am
    Check that CryptProtectData returned successfully. Also, you must release output buffer with LocalFree as per api.

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Doe at Mar 5, 2013 at 5:19 am
    An obscure error is returned by WinApi when invoking the *ProtectEncryptData
    *:

    *"The operation completed successfully."*

    The same error gets returned, when i call WinApi *LocalFree* on the byte
    array pointer.
    New version:
    http://pastebin.com/KF9yb5uh

    On Monday, March 4, 2013 10:41:30 AM UTC+2, brainman wrote:

    Check that CryptProtectData returned successfully. Also, you must release
    output buffer with LocalFree as per api.

    Alex
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brainman at Mar 5, 2013 at 6:44 am
    I changed your program http://play.golang.org/p/fD7mx2k4Yc to fix some
    small errors. But I get same result as you are. I have never used

    CryptProtectData before, so I do not know what our mistake is. Perhaps you
    should ask a windows expert. Sorry.

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Doe at Mar 6, 2013 at 3:25 am
    Makes me thing this is Golang specific, invoking the method (and the
    equivalent decrypt method) from VC++ worked flawlessly ..
    On Tuesday, March 5, 2013 8:44:45 AM UTC+2, brainman wrote:

    I changed your program http://play.golang.org/p/fD7mx2k4Yc to fix some
    small errors. But I get same result as you are. I have never used

    CryptProtectData before, so I do not know what our mistake is. Perhaps you
    should ask a windows expert. Sorry.

    Alex
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brainman at Mar 6, 2013 at 3:38 am
    It is sure possible something to do with Go. Send me your non-Go program
    to compare. I will investigate when I have time. Thank you.

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Doe at Mar 6, 2013 at 5:28 am
    Thank you for taking the time.
    Here is the snippet: http://pastebin.com/gLyHrrP0
    On Wednesday, March 6, 2013 5:38:34 AM UTC+2, brainman wrote:

    It is sure possible something to do with Go. Send me your non-Go program
    to compare. I will investigate when I have time. Thank you.

    Alex
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brainman at Mar 6, 2013 at 6:26 am
    Here is the snippet: http://pastebin.com/gLyHrrP0
    Sorry, but do I compile that?

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Doe at Mar 6, 2013 at 7:30 am
    You'll need Microsoft's C++ compiler with all the variables set up.
    I'm linking You the VS2012 project (The executable is in the /Debug folder).

    https://mega.co.nz/#!dV8GgCbA!aIQx2030h3lz_0AZQewbhjw24bMMyeoxXXHG60J4hIM
    On Wednesday, March 6, 2013 8:26:18 AM UTC+2, brainman wrote:

    Here is the snippet: http://pastebin.com/gLyHrrP0
    Sorry, but do I compile that?

    Alex
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Brainman at Mar 7, 2013 at 1:34 am
    John,

    Our programs have a bug. This "*p++" does not do what you think it does. Go
    does not have pointer arithmetic, and I should have picked that up quickly.
    But, I guess, I have been doing too much C lately :-).

    Here http://play.golang.org/p/fknP9AuLU- is working version.

    Alex

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • John Doe at Mar 7, 2013 at 9:31 am
    Awesome, thank you again.

    Cheers
    J.
    On Thursday, March 7, 2013 3:34:03 AM UTC+2, brainman wrote:

    John,

    Our programs have a bug. This "*p++" does not do what you think it does.
    Go does not have pointer arithmetic, and I should have picked that up
    quickly. But, I guess, I have been doing too much C lately :-).

    Here http://play.golang.org/p/fknP9AuLU- is working version.

    Alex
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • George McBay at Mar 6, 2013 at 7:49 pm

    On Monday, March 4, 2013 5:51:38 PM UTC-8, John Doe wrote:
    An obscure error is returned by WinApi when invoking the *
    ProtectEncryptData*:

    *"The operation completed successfully."*
    IIRC this is what you're supposed to see on success. The Win32 API calls
    through Proc/Call pull the err value from GetLastError/FormatMessage, which
    if the call worked as expected will result in the "error" message you see (*"The
    operation completed successfully."). *

    You should be looking at the r1, r2 results from the call to Call and
    analyzing them based on whatever call it is you're making to determine if
    there is actually any problem you should worry about since all of these API
    calls use old-school C-style return overloading to signal errors.

    I'm not sure if the non-nil err result in this situation is intentional or
    a bug, it does feel inconsistent with normal Go error handling.

    The same error gets returned, when i call WinApi *LocalFree* on the byte
    array pointer.
    New version:
    http://pastebin.com/KF9yb5uh

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Stephen Gutekanst at Mar 6, 2013 at 5:10 am
    I just tried brainman's code and it ran fine without receiving that error.

    Windows 7 64 bit
    go version devel +e59c2b6934af Thu Jan 10 17:04:55 2013 -0800 windows/amd64

    - Stephen
    On Sunday, March 3, 2013 8:06:09 PM UTC-7, John Doe wrote:

    Hey

    Can anybody tell me what i'm doing wrong here?
    I'm trying to invoke a WinApi method *CryptProtectData* (
    http://msdn.microsoft.com/en-us/library/windows/desktop/aa380261(v=vs.85).aspx
    )

    Code:
    http://pastebin.com/s2cdeinK

    The output of the bytes returned is always sequential (see link)
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 4, '13 at 4:43a
activeMar 7, '13 at 9:31a
posts13
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase