Volume serial ID different in C++ and CLEO

m1zg4rd_PL

Well-known member
Joined
Jul 19, 2013
Messages
222
Reaction score
0
Why CLEO snippet return different number than C++ implementation of getting Volume Serial ID?

Code:
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>

#include <windows.h>

using namespace std;

int main()
{
	printf("getting volume info");

	CHAR szVolumeNameBuffer[12]; //this will have the name of your drive
	DWORD dwVolumeSerialNumber; //this will have the serial number of your drive
	DWORD dwMaximumComponentLength; //this is the max length in between each \ in a path
	DWORD dwFileSystemFlags; //this will return flags about the drive's file system
	CHAR szFileSystemNameBuffer[10]; //this will contain the type of file system (ex: NTFS)

	GetVolumeInformationA((LPCSTR)"C:\\", (LPSTR)szVolumeNameBuffer, 12, &dwVolumeSerialNumber, &dwMaximumComponentLength, &dwFileSystemFlags, (LPSTR)szFileSystemNameBuffer, 10);

	ofstream myfile;
	myfile.open ("example.txt");
	myfile << dwVolumeSerialNumber;
	myfile.close();

    return 0;
}

It return 1217173053

Code:
{$CLEO .cs}
thread "get_serial"
wait 3000

:get_serial
wait 10
if
  0AA2: 1@ = load_library "kernel32.dll"
then
  if
    0AA4: 2@ = get_proc_address "GetVolumeInformationA" library 1@
  then
    0AC7: 0@ = var 0@v offset
    0AA5: call 2@ num_params 8 pop 0 0 0 0 0 0@ 0 0 0
    0AF1: write_int 0@ to_ini_file "CLEO\TESTSERIAL.INI" section "MAIN" key "SERIAL"
  end
end
0AA3: free_library 1@
004E: end_thread

It return -1767286668

What is the difference in that numbers? Integer variable is out of range?

EDIT: Ok, It's out of range error, Integer bigger than 2147483647 changes to -2147483648 + value that is out of range, so the real number readed by CLEO is 2527680628, but still it's not equal to value from C++ program (1217173053)  :table_flip:

EDIT2: On the other computer, the problem don't appear, value readed by program is equal to value from cs file: 1991520658, because It's smaller than range limit: 2147483647.
 

T3KTONIT

Well-known member
Joined
Sep 2, 2013
Messages
308
Reaction score
5
Hmmm i don't think calling functions using CLEO is fully functional.

maybe the calling conventions are messed up, try calling another function that is not a WINAPI(_stdcall) function. and see if it returns the right value..


PS: i have never used the call opcode in cleo but... did you even pass it the parameters???
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
173
m1zg4rd link said:
[quote author=T3K link=topic=8405.msg48518#msg48518 date=1405660603]
Hmmm i don't think calling functions using CLEO is fully functional.

This snippet in CLEO is from Opcode.ExE http://ugbase.eu/snippets/get-users-serial-id/ so it should work properly.
[/quote]
For him it didnt work properly either, it has something todo with the return of some Computers (since the digits can be longer or shorter).
Also on C++ you call GetVolumeInformation on C:, on this MSDN says following:
A pointer to a string that contains the root directory of the volume to be described.
If this parameter is NULL, the root of the current directory is used. A trailing backslash is required. For example, you specify \\MyServer\MyShare as "\\MyServer\MyShare\", or the C drive as "C:\".

(what should not matter for the moment).
Also, I dont know how CLEO allocates the memory did you tried to allocate the memory manually and writing to it?
 

m1zg4rd_PL

Well-known member
Joined
Jul 19, 2013
Messages
222
Reaction score
0
0x688 link said:
If this parameter is NULL, the root of the current directory is used. A trailing backslash is required. For example, you specify \\MyServer\MyShare as "\\MyServer\MyShare\", or the C drive as "C:\".[/b]

I changed last parameter (I know in C++ drive letter is first parameter, but in CLEO they are reversed) to drive letter like this:

Code:
0AA5: call 2@ num_params 8 pop 0 0 0 0 0 0@ 0 0 "C:"

Script now returns 49960876.
 

0x_

Wtf I'm not new....
Staff member
Administrator
Joined
Feb 18, 2013
Messages
1,123
Reaction score
173
Still not the return you want?
If not, then try to manually allocate memory could be some cleo limit
 
Top