sizeof

Windows NtQueryInformationProcess()

跟風遠走 提交于 2019-12-04 14:17:39
{   https://www.orcode.com/article/Processes_20126324.html } { 或代码 文章 编程通用 线程,进程及IPC 与NtQueryInformationProcess获取进程信息 {A} {S0}简介 本文将展示一种方法来读取一个过程的下列项目,主要是使用{A2}进程ID父ID关联掩码退出代码状态命令行过程过程映像文件的路径终端服务会话ID标志,如果目前正在调试过程地址进程环境块(PEB) 这个信息是一个变量声明为一个结构,smPROCESSINFO返回。这种结构是在NtProcessInfo.h定义: typedef struct _smPROCESSINFO { DWORD dwPID; DWORD dwParentPID; DWORD dwSessionID; DWORD dwPEBBaseAddress; DWORD dwAffinityMask; LONG dwBasePriority; LONG dwExitStatus; BYTE cBeingDebugged; TCHAR szImgPath[MAX_UNICODE_PATH]; TCHAR szCmdLine[MAX_UNICODE_PATH]; } smPROCESSINFO; 虽然有Windows API的检索上述值,本文将展示如何获得这些值

Marshal.SizeOf error in computing size

别说谁变了你拦得住时间么 提交于 2019-12-04 13:59:08
i have a structure public struct SERVER_USB_DEVICE { USB_HWID usbHWID; byte status; bool bExcludeDevice; bool bSharedManually; ulong ulDeviceId; ulong ulClientAddr; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string usbDeviceDescr; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string locationInfo; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] string nickName; } i am getting following error System.ArgumentException was unhandled Message="Type 'SERVER_USB_DEVICE' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed." at

概率专题·期望

浪尽此生 提交于 2019-12-04 13:57:19
uva 11021 Tribbles UVA 11722 Joining with Friend UVA 11427 Expect the Expected UVA 11762 Race to 1 UVA 10491 So you want to be a 2n-aire UVA 11346 Probability UVA 11637 Garbage Remembering Exam UVA 11605 Lights inside a 3d Grid UVA 10491 Cows and Cars UVA 1413 Game UVA 1498 Activation uva 11021 Tribbles k只麻球,每活一天就会死亡,但第二天可能会生一些麻球,具体说来,生i个麻球的概率为pi ,求m天后所有麻球都死亡的概率 f i = p 0 + p 1 f i − 1 + p 2 f i − 2 2 + . . . + p n − 1 f i − 1 n − 1 //--> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<functional> #include<iostream> #include<cmath> #include<cctype> #include

Difference of sizeof between char* x and char x[]

南楼画角 提交于 2019-12-04 13:50:06
I know some difference between char* and char[]. char x[] = "xxxx" Is an array of chars; char *y = "xxxx" is a pointer to the literal (const) string; And x[4]=='\0' , and *(y+4) == '\0' too. So why sizeof(x)==5 and sizeof(y)==4 ? The sizeof an array type is the size the array takes up. Same as sizeof("xxxx") . The sizeof a pointer type is the size the pointer itself takes up. Same as sizeof(char*) . pizza char x[] = "xxxx" is an array of size 5 containing x x x x and \0. char *y = "xxxx" is a pointer to a string. It's length is 4 bytes, because that is the length of the pointer, not the string

基于linux或windows平台上的c/s简单通信

血红的双手。 提交于 2019-12-04 11:55:14
linux: tcpclient.cpp 1 #include<iostream> 2 #include<unistd.h> 3 #include<sys/types.h> 4 #include<sys/socket.h> 5 #include<netdb.h> 6 #include<arpa/inet.h> 7 #include<cstring> 8 #include<sstream> 9 10 using namespace std; 11 12 #define BUFSIZE 512 13 14 // #define SERVERIP "192.168.41.32" 15 // #define SERVERPORT 4140 16 17 /*error report*/ 18 static void bail(const char *on_what){ 19 fputs(strerror(errno), stderr); 20 fputs(": ", stderr); 21 fputs(on_what, stderr); 22 fputc('\n', stderr); 23 exit(1); 24 } 25 26 void getarg(int argc,char* argv[],const char** SERVERIP,int* SERVERPORT) 27 { 28

How to calculate total size of NSDictionary object?

…衆ロ難τιáo~ 提交于 2019-12-04 11:44:32
问题 How to calculate total size of NSDictionary object? i have 3000 StudentClass objects in NSDictionary with different keys. And i want to calculate total size of dictionary in KB. I used malloc_size() but it always return 24 ( NSDictionary contain either 1 object or 3000 object) sizeof() also returns always same. 回答1: You could try to get all the keys of the Dictionary in an array and then iterate the array to find the size, it might give you the total size of the keys inside the dictionary.

C语言的数组和指针的区别

五迷三道 提交于 2019-12-04 10:35:17
1.看到这个题目大家应该知道了,数组和指针它俩不是一回事儿,它俩是有区别的!    我原来看数组的时候,一直都是用数组名表示数组内容的首地址,但是当我认真在网上看了数组和指针之后,发现数组和指针不等价! 举个例子,相信大家见过这种写法: int arr[] = { 1,2,3,4,5}; int *b = arr;   我们一般的认识是 arr是一个指针,指向数组的首地址,然后它把这个地址的值赋给了指针变量b。   但是这种理解是有一点的不准确,严格来说应该是 arr被转换为了一个指针。 再举个例子: #include <stdio.h> #include <string.h> int main(){ int a[6] = {1,2,3,4,5,6}; int *b = a; int len_a = sizeof(a) / sizeof(int); int len_b = sizeof(b) / sizeof(int); printf("len_a = %d\n",len_a); printf("len_b = %d",len_b); return 0; }   如果,咱们说如果哦,如果数组和指针等价,那么这两个结果应该是一样的,但是我们来看一下运行结果:   这特么是什么玩意,这个 2 是哪来的。    我们来看一下C语言中文网上的描述:   数组是一系列数据的集合

Why do C++ classes without member variables occupy space?

限于喜欢 提交于 2019-12-04 10:09:33
问题 I found that both MSVC and GCC compilers allocate at least one byte per each class instance even if the class is a predicate with no member variables (or with just static member variables). The following code illustrates the point. #include <iostream> class A { public: bool operator()(int x) const { return x>0; } }; class B { public: static int v; static bool check(int x) { return x>0; } }; int B::v = 0; void test() { A a; B b; std::cout << "sizeof(A)=" << sizeof(A) << "\n" << "sizeof(a)=" <<

C++之数据类型--整形&sizeof关键字

空扰寡人 提交于 2019-12-04 09:20:49
数据类型: C++规定在创建一个变量或者常量时,必须要指定出相应的数据类型,否则无法给变量分配内存 整型 **作用**:整型变量表示的是==整数类型==的数据 C++中能够表示整型的类型有以下几种方式,**区别在于所占内存空间不同**: short、int、long、long long int 最常用 sizeof关键字 **作用:**利用sizeof关键字可以== 统计数据类型所占内存大小 == **语法:** sizeof( 数据类型 / 变量) > **整型结论**:short < int <= long <= long long 来源: https://www.cnblogs.com/RevelationTruth/p/11852402.html

size of array of pointers

假装没事ソ 提交于 2019-12-04 09:01:36
问题 i have a doubt regarding sizeof operator Code 1: int main() { int p[10]; printf("%d",sizeof(p)); //output -- 40 return 0; } Code 2: int main() { int *p[10]; printf("%d",sizeof(*p)); //output -- 4 return 0; } in the first code p points to an array of ints. in the second code p points to an array of pointers. i am not able to understand why the first code o/p is 40 but 2nd code o/p is 4 thought both points to an array of the same size ? 回答1: The output of the following program will give you