|
I just tried this:
long long unsigned int llui;
unsigned int ui;
unsigned long ul;
cout << "long long unsigned int: " << sizeof(llui) << endl;
cout << " unsigned int: " << sizeof(ui) << endl;
cout << " unsigned long: " << sizeof(ul) << endl;
resulting in:
long long unsigned int: 8
unsigned int: 4
unsigned long: 4
It appears that the compiler accepts all specifications and creates the largest item. The results are the same whether unsigned or not.
Veni, vidi, abiit domum
|
|
|
|
|
Why do you think it is a nonsense?
long is a shortcut for long int , (like short for short int ).
unsigned is a legal attribute and foo is a noble choice for a variable name.
You may also find it here: "Data Type Ranges" at MSDN[^].
Veni, vidi, vici.
|
|
|
|
|
Because the "unsigned" should be the first specification. We do not write "int unsigned", so why is "long unsigned int" OK?
|
|
|
|
|
Vaclav_Sal wrote: We do not write "int unsigned", so why is "long unsigned int" OK?
We do, actually (at least we can do) (MSDN[^]):
The optional keywords signed and unsigned can precede or follow any of the integral types, except enum, and can also be used alone as type specifiers, in which case they are understood as signed int and unsigned int, respectively. When used alone, the keyword int is assumed to be signed. When used alone, the keywords long and short are understood as long int and short int.
Veni, vidi, vici.
|
|
|
|
|
Hello everybody, I'm new in this forum. I don't know where to place this thread, because it's about VB6 and C, but I think the problem is in the C code so here I am. I'm working with C with no special focus, so the solution can be in C++ too
Well, this is the problem. I have a VB6 program that simply calls a function when the Command1 is pressed. This one:
Public Function SampleSub(ByVal x As Integer, ByVal y As Integer) As Boolean
MsgBox "Hello world!"
SampleSub = True
End Function
I'm trying to call it from C like this:
#include "main.h"
typedef BOOL (__stdcall *SampleSubPtr)(WORD, WORD);
static SampleSubPtr SampleSub;
DLL_EXPORT BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
BOOL ret;
if (fdwReason == DLL_PROCESS_ATTACH)
{
SampleSub = (SampleSubPtr)(0x00401B90);
if (SampleSub == NULL)
MessageBox(0, "SampleSub is NULL.", "M", 0);
ret = SampleSub(5, 5);
}
return TRUE;
}
0x00401B90 is the pointer to the VB6 function. Then I place this DLL into the VB6 program memory space and the function is called. But it simply doesn't work. Debugging this with OllyDbg gives me this error when calling the function:
Access violation when reading [00000076]
I'm 100% sure that the function is at the address 0x00401B90 . VB6 uses __stdcall and I use __stdcall from C. VB6 uses 16-bit integers and I use 16-bit integers (WORD ) from C.
I can't solve this. Any ideas?
Thanks in advance! ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
Is the SampleSub() function in a DLL?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Hello. Thanks for the answer. No, the SampleSub() function is inside a VB6 program, an executable. Then I build a C DLL with the code above and inject it on the VB6 process. Sorry if I don't explain that very well.
Thanks again. ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
How are you determining the address of the VB6 function?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi, thanks for your answer. I'm using:
AddressOf SampleSub
Also OllyDbg gives me that address.
|
|
|
|
|
I would experiment with calling other VB6 functions to see if they give the same result. Especially try calling a function that takes no parameters to see if the problem might be the parameter passing.
Have you ever had success calling a VB6 function from C?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
I'm afraid I don't know what it could be. However, I had always believed that it was not possible to arbitrarily call into a VB6 executable.
I was under the impression that the old VB worked on a, sort of, virtual execution scheme, and the VB program was under the control of a supervisor thread.
I wish I could be more helpful!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Ok thank you very much, I'll keep trying and tell you if I could make the trick. If anybody have any idea please tell me!!
Thanks again! ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
|
Hi Randor, thank you very much for your reply. I'm actually just using a VB6 "function" with no return value and that takes no parameters. This one:
Public Sub SampleSub()
MsgBox "Hello world!"
End Sub
With the typedef void (__stdcall *SampleSubPtr)(void); prototype. What should I use instead of void ? I think it will be better to start calling a simple function with no parameters, that's why I delete the old function that returns a VB boolean and takes two Integers as it params. I checked out the link your provided but that's for a Variant type in VB6, do you mean I should use VARIANT in C++ for any VB6 type?
I was thinking... I always get the Access violation when reading... error, do you think that a type incompatibility can cause this?
What would you do in my place? This problem is driving me crazy!
Thanks again! ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
hi all,
please guide me and provide me a right direction.
currently I m using office automation and random password generation for this but is to time taking and slow process.
please help me to start for ms office file password recovery type application?
thanks in advance.
|
|
|
|
|
Le@rner wrote: please guide me and provide me a right direction. Learn how to do basic research[^].
Veni, vidi, abiit domum
|
|
|
|
|
I already do this this search list all recovery application.
not about the how to implement of code for this..
|
|
|
|
|
Then I guess you need to try contacting one of the authors of those packages.
Veni, vidi, abiit domum
|
|
|
|
|
really why those authors disclose their logics..
it means codeproject not help me for this...
|
|
|
|
|
Le@rner wrote: it means codeproject not help me for this... No, it means we don't have the answer.
Veni, vidi, abiit domum
|
|
|
|
|
can u please suggest me any other option or way to move on.
|
|
|
|
|
The only thing I can suggest is more Googling, and maybe some initiative. You also need to consider why passwords exist; if it was easy to crack them then there would be no reason to use them in the first place.
Veni, vidi, abiit domum
|
|
|
|
|
hi all,
is there any option to know the office file is password protected or not?
thanks in advance.
|
|
|
|
|
Try opening it?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|