Failure while accessing Bcd using wmic - wmic

I am getting an error when I try to access the EnumerateObjects method of the BcdStore class using wmic.
I initially ran the GetSystemDisk method to see that I can access the BcdStore (see below). This worked fine.
______________ cmd window output begins __________________
C:>wmic /namespace:\root\wmi class BcdStore call GetSystemDisk
Executing (BcdStore)->GetSystemDisk()
Method execution successful.
Out Parameters:
instance of __PARAMETERS
{
Disk = "\\Device\\Harddisk0\\DR0";
ReturnValue = TRUE;
};
______________ cmd window output ends __________________
Then I ran the EnumerateObjects method, but got a failure, please see below. The different versions are just different variations of how to pass the arguments to the method, But this didn't work.
______________ cmd window output begins __________________
C:>wmic /namespace:\root\wmi class BcdStore call EnumerateObjects 10200003
Executing (BcdStore)->EnumerateObjects()
ERROR:
Description = Invalid method Parameter(s)
C:>wmic /namespace:\root\wmi class BcdStore call EnumerateObjects Type=10200003
Executing (BcdStore)->EnumerateObjects()
ERROR:
Description = Invalid method Parameter(s)
C:>wmic /namespace:\root\wmi class BcdStore call EnumerateObjects Type="H10200003"
ERROR:
Description = Type mismatch.
C:>wmic /namespace:\root\wmi class BcdStore call EnumerateObjects 0x10200003
ERROR:
Description = Type mismatch.
______________ cmd window output ends __________________
Any help would be appreciated.

This is not an answer because I'am not sure to really understand what you want to do, but it can be an explanation of why what you do does not work.
The following works because GetSystemDisk is a static method of the class BcdStore :
wmic /namespace:\root\wmi class BcdStore call GetSystemDisk
As you can see in the method qualifier of WMI Cim studio :
But EnumerateObjects is an instance method of the class BcdStore, so you can't call it from the class itself, you must call it from an instance. WMI Object Browser show no instance on my W2K8R2 for BcdStore class.

Related

Uninstantiable; Callable when using Callable variables from a trait declaration

With this code, I'm trying to add a "logging" trait to a subroutine:
my &loggr = -> $event {
state %store;
%store{ DateTime.new( now ) } = $event;
}
multi sub trait_mod:<is>(Sub $s, :$logger){
loggr( $s.name );
}
multi sub add( Int $a, Int $b) is logger {
$a + $b;
}
say add(1,2);
However, I get the error:
===SORRY!=== Error while compiling /home/jmerelo/Code/perl6/my-perl6-examples/is-logger-fail.p6
Cannot invoke this object (REPR: Uninstantiable; Callable)
at /home/jmerelo/Code/perl6/my-perl6-examples/is-logger-fail.p6:14
(line 14 would be the line where add is declared). Declaring loggr directly as a sub yields no error. Why am I getting this Uninstantiable error here?
Why am I getting this Uninstantiable error here?
When used after a my declaration, = (or :=) invokes assignment (or binding) at run-time. A trait applied to a compile-time sub declaration runs at compile-time, which comes first. So your trait calls loggr before it's initialized.
To fix that, you need to shift the variable initialization to compile-time, eg:
BEGIN &loggr = ...
or
constant &loggr = ...
While the error message reads like a low-level error, and it would be nice if it specifically mentioned loggr (but perhaps doesn't because it's low-level), it will hopefully make more sense now:
===SORRY!=== Error while compiling ...
Cannot invoke this object (REPR: Uninstantiable; Callable)
Your code has asked to call loggr at compile-time. But while it does have the appropriate Callable type, it hasn't yet been initialized, so is uninstantiable at the time it is being asked to invoke it.

Parameter specified as non-null is null

I have a function inside of a larger project that is called on startup via another function. Here's the code for it:
val infoDoc = File("res/info.txt")
private fun readInfo(): MutableList<Reminder> {
val reminders = mutableListOf<Reminder>()
infoDoc.forEachLine {
//...
}
return reminders
}
However, when I attempt to run it, I get this error:
java.lang.ExceptionInInitializerError
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.io.FilesKt__FileReadWriteKt.forEachLine, parameter $receiver
at kotlin.io.FilesKt__FileReadWriteKt.forEachLine(FileReadWrite.kt)
at kotlin.io.FilesKt__FileReadWriteKt.forEachLine$default(FileReadWrite.kt:154)
at main.IoKt.readInfo(io.kt:22)
at main.IoKt.read(io.kt:8)
at main.AppKt.<clinit>(app.kt:23)
Exception in thread "main"
Note that Reminder is a custom class, and that infoDoc is declared in app.kt. I can provide any other code that is required.
Edit: There are checks in place to make sure that info.txt exists, and is readable/writable.
The exception happens because infoDoc is not initialized yet. Initializers in Kotlin are executed from top to bottom, so it looks like the initializer of a property declared above infoDoc in app.kt is calling the readInfo function.
To fix the problem, move the declaration of infoDoc above the place where readInfo is called.
Check if info.txt exists, or try the absolute file path.

Object argument to mock EXPECT_CALL

I have a simple mock class:
class MockCanInterface : public lib::CanInterface {
public:
MockCanInterface() : CanInterface({"mock"}) {}
MOCK_METHOD1(Write, bool(const lib::CanFrame& frame));
MOCK_METHOD1(Read, bool(lib::CanFrame* frame));
};
In the test code I want to pass an object to the Write method. Is there a way to do this with .With clause? It works with passing argument directly, but now with .With. The code compiles, but fails during execution - the size of the object is correct, but the data isn't.
This works:
EXPECT_CALL(can_, Write(expected_command_))
.WillOnce(Return(true));
This doesn't:
EXPECT_CALL(can_, Write(_))
.With(Args<0>(expected_command_))
.WillOnce(Return(true));
I admit that there may be something missing in the way the code sets the expected object.
I think the point is: The method Write() required a CanFrame argument passed by reference.
I suggest to use the Actions provided by GMock:
SetArgReferee - reference or value
SetArgPointee - pointer
You can find examples and much more here
However this solution works for me, I hope for you too ;)
EXPECT_CALL(can_, Write(_))
.WillOnce(SetArgReferee<0>(expected_command_));
or with the return value:
EXPECT_CALL(can_, Write(_))
.WillOnce(DoAll(SetArgReferee<0>(expected_command_), Return(true)));

Create Method via GDSL script that has a delegating closure parameter

Using the (scarcely documented) gdsl scripts of Intellij, one can add dynamic methods to a class:
contributor(context(ctype: "my.Type")) {
method name: "doIt", params: [body: {}], type: void
}
One can also configure the delegation of a closure:
contributor(context(scope: closureScope())) {
def call = enclosingCall("doIt")
if (call) {
def method = call.bind()
def clazz = method?.containingClass
if (clazz?.qualName == 'my.Type') {
delegatesTo(findClass('my.Inner'))
}
}
}
Which, when doIt is a method that is defined in the code (not dynamically added), also works as designed.
However, when using the closureScope with the previously created method, the containing class method is always null, meaning that I can not safely delegate inside the closure to the addressed my.Inner class.
What I want is adding a dynamic method equivalent to:
void doIt(#DelegatesTo(my.Inner) Closure)...
I.e. I want the method to be available in code completion (this works), and inside the so created closure, I want correct code completion when addressing methods of my.Inner.
So far, I tried various approaches:
include the #DelegatesTo annotation in the param definition
try more esoteric approaches in finding the owner of the closure, which fails because the GrMethodCall simply has no parent
unconditionally delegating all closures named doIt to my.Inner which works, but is no viable solution since I do have multiple doIt methods (on different classes) delegating to different targets.
So, how can I make IDEA behave as expected and delegate to the correct target?
Edit to make it clearer:
Given the following classes:
package my
class Type {
void doIt(Closure) {}
}
class Inner {
void inInner() {}
}
and the following gdsl:
contributor(context(scope: closureScope())) {
def call = enclosingCall("doIt")
if (call) {
def method = call.bind()
def clazz = method?.containingClass
println clazz?.qualName
if (clazz?.qualName == 'my.Type') {
delegatesTo(findClass('my.Inner'))
}
}
}
when I start typing in a new script:
new Type().doIt {
inInner()
}
When inside the closure, I get the following:
code completion for inInner
inInner is shown as valid
The console output when started with idea.bat from commandline shows the line my.Type (from the println)
Ctrl-B on inInner correctly links to source code.
(The same behaviour can be reached without the gdsl when annotation the Closure Parameter in the doIt method with #DelegatesTo(Inner))
However, I do not want to manually include the doIt method in the source of Type, it is generated by an AST Transformation, so my source file now looks like this:
package my
class Type {
}
class Inner {
void inInner() {}
}
I can tell IntelliJ about the new method using the following gdsl snippet
contributor(context(ctype: "my.Type")) {
method name: "doIt", params: [body: {}], type: void
}
Now the IDE correctly recognizes the doIt method with a closure parameter. However, inside the Closure, the following happens:
sometimes code completion shows inInner, sometimes after changing something, it does not (when using the original code to fix a type, it was shown, but later declared "unresolved", after going through the code changes of this edited example, it is not shown anymore...)
Even when shown, inInner is shown with "cannot resolve symbol" decoration
the console shows null as clazz, i.e. the method is found, but not linked to an owner ASTNode
Ctrl-B does not link to the corresponding method in Inner
So what I want is the same behaviour for an injected doIt method (via Gdsl) as with a method included in the source, i.e. I want the gdsl to inject a doIt method with a delegating closure (to Inner) into the type class.
This worked for me adding the ctype to scope insted of finding the class type from the method
contributor(context(scope: closureScope(), ctype: 'my.Type')) {
def call = enclosingCall("doIt")
if (call) {
delegatesTo(findClass('my.Inner'))
}
}

Cannot get lambda code sample to compile

I want to experiment with a simple bit of code found here:
http://msdn.microsoft.com/en-au/library/ff664617%28v=pandp.50%29.aspx
But I cannot get it to compile, I must be doing something wrong. About a third of the way down the page it gives a code sample like this:
'Usage exManager.Process(Function() method-name(param1, param2), _
"Exception Policy Name")
But if I enter the following code:
Dim exManager As ExceptionManager
exManager = EnterpriseLibraryContainer.Current.GetInstance(Of ExceptionManager)()
exManager.Process(Function() TestSub(), "Exception Policy Name")
I get an error on the third line that says:
Overload resolution failed because no accessible 'Process' can
be called with these arguments:
'Public Overridable Function Process(Of TResult)(action As System.Func(Of TResult), policyName As String) As TResult': Cannot
refer to an instance member of a class from within a shared method or
shared member initializer without an explicit instance of the class.
'Public Overridable Function Process(Of TResult)(action As System.Func(Of TResult), policyName As String) As TResult': Data
type(s) of the type parameter(s) cannot be inferred from these
arguments. Specifying the data type(s) explicitly might correct this
error.
etc.
Even if I try to modify the lambda like this:
exManager.Process(Function() Dim A As Integer=6, "Exception Policy Name")
I get a similar error.
Any comments would be appreciated.
UPDATE:
Note I am compiling for .NET Framework 4 Client Profile
You are using the Process(Of TResult) overload when you call exManager.Process(Function() TestSub(), "Exception Policy Name").
The method is generic and expects and type argument (TResult), which in a lot of cases can be inferred by the compiler. Now the exception tells you that, in your case, the compiler can infer TResult.
I guess your TestSub is really a Sub and therefore has no return value which the compiler could use to infer TResult.
So use the non-generic Process method by either using Sub instead of Function
exManager.Process(Sub() TestSub(), "Exception Policy Name")
or simply use AddressOf:
exManager.Process(AddressOf TestSub, "Exception Policy Name")