Comments (10)
Hey @hpoul,
I think you will find @timsneath's answer in #64 (comment) helpful on the autogeneration / hand coding front.
Do you have an idea of which specific API calls you want to make?
from win32.
@domesticmouse thanks for your fast reply, i think right now it's CredWrite, CredRead, CredDelete. I don't have experience with win32 APIs (yet), but those seem to be the closest to keychain read/write/delete :)
not sure if it's better to have a generic ffi bridge, or just use the specific C functions in my library (which is how i've implemented it for linux right now), but if it's easier to build on this package, it would be great ;-)
from win32.
Yeah, easy enough to add those functions, and they seem useful to others also. I'll put a quick pull request together.
As far as the latter question is concerned, you're obviously welcome to do what works best for you. But three reasons why you might consider a direct dependency on win32:
- With Dart tree shaking, you're not paying any additional 'tax' for the parts of win32 you're not using; only those typedefs that you actually use are compiled into your plugin;
- Obviously any improvements made to the Win32 package come for free (e.g. Dart finalizer support, or improvements to struct layout, when they arrive)
- If you ever choose to expose any of the credentials outside of your own package, it might be helpful if the Structs etc. are in a common package.
from win32.
cool thanks, that would be great.
To be honest my question was actually if it would be easier for me to work out how to add those APIs to win32
and make a PR vs. just doing it in my own plugin. If I just have to use the package, I'll certainly go for it 😅️
from win32.
You are very welcome to do so, if you want to get familiar with these APIs. A couple of tips:
- Use the Unicode ('W') variants of these APIs, rather than the ANSI ('A') variants, for example: https://docs.microsoft.com/en-us/windows/win32/api/wincred/nf-wincred-credwritew
- If you choose to do this work, the cred APIs go in advapi32.dart, the structs go in structs.dart and then the typedefs themselves go in typedefs.dart. The registry key read/write examples in
advapi32.dart
are a good pattern to build off. - We'll want a sample (
example
folder) and some tests.
If you don't feel comfortable with doing this work, let me know; happy to investigate it at some point.
from win32.
@timsneath Can we promote your comment to a section in either the README? Seems like a useful getting started guide.
from win32.
Done: https://github.com/timsneath/win32/blob/master/CONTRIBUTING.md
from win32.
Thanks for the hints.. I've started adding the functions/structs and CredWrite
seems to work as I can see the written credential in the Credential Manager, but CredRead
returns success without filling my credential struct.
Do you have any idea what I could be doing wrong? I allocate a Pointer and pass it into the function, do I need to do something else to pass it by reference?
https://github.com/authpass/win32/blob/wincred/example/credentials.dart#L35-L43
final cred = CREDENTIAL.allocate();
final result = CredRead(
TEXT(credentialName), CRED_TYPE_GENERIC, 0, cred.addressOf);
if (result != TRUE) {
final errorCode = GetLastError();
print('Error ($result): $errorCode');
return;
}
print('Success. size: ${cred.CredentialBlobSize}');
outputs:
Success. size: 0
(Even though I've written 10 bytes, which I can see in the Credential Manager)
from win32.
never mind, I somehow missed that it was PCREDENTIAL
not CREDENTIAL
. 🤦️ ie. I had to use Pointer<Pointer<CREDENTIAL>>
from win32.
Ah yes -- they're sneaky with that. The second *
is masked in the typedef
, so PCREDENTIAL *x
is equivalent to CREDENTIAL **x
. I spent days blocked on a similar issue when I built out the COM support, so the fact that you'd figured it out before I'd even looked at the code is something you can feel good about :)
from win32.
Related Issues (20)
- Error when build iOS HOT 6
- Migrate away from `elementAt` when Dart 3.3 is out. HOT 3
- Add support for Extensible Storage Engine Functions
- ReadPrinter does not work any suggestion or example code please share
- ReadPrinter does not work any suggestion or example code please share HOT 7
- ☂️ Project the entire Win32 API
- Create wrappers for `VARIANT` and `PROPVARIANT` structures HOT 1
- Abstract away reserved parameters in Win32 functions and COM methods
- Mark optional parameters in Win32 functions and COM methods as nullable
- Generate documentation for APIs
- Detect System state hibernate sleep awake HOT 1
- ShowCursor should use BOOL bShow and pass it in as a parameter. HOT 2
- Flutter Pen Interaction Issues on Windows Platforms
- how to use win32 plugin to get audio sampling rate list HOT 1
- run Web Error: Dart library 'dart:ffi' is not available on this platform
- Windows Defender Trojan Warning with v5.4.0 HOT 7
- Compared to Microsoft's official PROPVARIANT structure, the Win32 library's PROPVARIANT class lacks union content. How should I call blob related? HOT 1
- add socket, recv, bind, listen, select, setsockopt, sendto, WSAStartup (winsock.h) functions HOT 1
- Error: The specified language version is too high. The highest supported language version is 3.3 HOT 2
- Dependency error: imported when compiling to Wasm. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from win32.