Можно ли подсмотреть
Стоит ли сдавать?
Легко ли найти дампы на них?
Сильно ли сложно их сдать?
Как проходит сам экзамен?
Короче, основные принципы...
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
struct Node* next;
int value;
} Node;
typedef struct List {
Node* head;
Node* list[10];
} List;
void newNode(List* change_list, int value) {
int size = sizeof(change_list)/sizeof(*change_list);
if (size == 0) {
Node* new_node = (Node*)malloc(sizeof(Node));
new_node->next = NULL; // здесь
new_node->value = value; // и здесь вываливается ошибка
change_list->list[size] = new_node;
change_list->head = change_list->list[0];
}
}
int main() {
List* new_list = (List*)malloc(sizeof(List));
newNode(new_list, 5);
printf("%d", new_list->list[0]->value);
}
extern "C" __declspec(dllexport) int* CallNewProccess()
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
if(!CreateProcess(NULL, const_cast<WCHAR*>(L"cmd"), NULL, NULL,
FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi))
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return 0;
}
return pi.hProcess;
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
class WinApiClass
{
[DllImport("DLL4.dll")]
[DllImport("kernel32.dll", SetLastError=true)]
static extern bool CloseHandle(IntPtr hObject);
public static extern IntPtr CallNewProccess();
}
static void Main(string[] args)
{
IntPtr hndl = 0;
try
{
hndl = WinApiClass.CallNewProccess();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
if( hndl != 0 )
{
CloseHandle(hndl);
}
Console.WriteLine("Press any key to continue...");
Console.ReadKey(true);
}
int main()
{
//...
thread first (...);
first.join();
return 0;
}